博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
inode更新mtime和ctime
阅读量:4153 次
发布时间:2019-05-25

本文共 1570 字,大约阅读时间需要 5 分钟。

/**
 *	file_update_time-- update mtime and ctime time *	@file: file accessed * *	Update the mtime and ctime members of an inode and mark the inode *	for writeback.  Note that this function is meant exclusively for *	usage in the file write path of filesystems, and filesystems may *	choose to explicitly ignore update via this function with the *	S_NOCMTIME inode flag, e.g. for network filesystem where these *	timestamps are handled by the server.  This can return an error for *	file systems who need to allocate space in order to update an inode. */int file_update_time(struct file *file){	struct inode *inode = file_inode(file);	struct timespec now;	int sync_it = 0;	int ret;	/* First try to exhaust all avenues to not sync */	if (IS_NOCMTIME(inode))		return 0;	now = current_time(inode);	if (!timespec_equal(&inode->i_mtime, &now))		sync_it = S_MTIME;	if (!timespec_equal(&inode->i_ctime, &now))		sync_it |= S_CTIME;	if (IS_I_VERSION(inode))		sync_it |= S_VERSION;	if (!sync_it)		return 0;	/* Finally allowed to write? Takes lock. */	if (__mnt_want_write_file(file))		return 0;	ret = update_time(inode, &now, sync_it);	__mnt_drop_write_file(file);	return ret;}
 
/* * This does the actual work of updating an inodes time or version.  Must have * had called mnt_want_write() before calling this. */static int update_time(struct inode *inode, struct timespec *time, int flags){	int (*update_time)(struct inode *, struct timespec *, int);	update_time = inode->i_op->update_time ? inode->i_op->update_time :		generic_update_time;	return update_time(inode, time, flags);}

转载地址:http://jwhti.baihongyu.com/

你可能感兴趣的文章
Mac升级10.15 Catalina,根目录无权限 完美解决办法!
查看>>
SublimeText3 常用快捷键!for mac 清晰明了!
查看>>
Iterm2 使用技巧 快捷键(mac os)
查看>>
Freemarker 语法入门
查看>>
nginx 的mac的配置参数说明-非常详细!
查看>>
mac 下安装 nginx 及配置
查看>>
iTerm 2 && Oh My Zsh【DIY教程—亲身体验过程】完美替代教程汇总!
查看>>
Mac OS X下Maven的安装与配置
查看>>
使用esotericsoftware高速缓存(ASM)的BeanUtils.copyProperties!高性能!
查看>>
InnoDB中一棵B+树可以存放多少行数据?
查看>>
Java序列化和反序列化为什么要实现Serializable接口?
查看>>
为什么 Java 的 main 方法必须是 public static void?
查看>>
你的Redis为什么变慢了?常见延迟问题定位与分析
查看>>
面试命中率90%的点 —— MySQL锁
查看>>
数组的拷贝及效率
查看>>
Struts1和Struts2的区别和对比(完整版)
查看>>
intellij idea 13&14 插件推荐及快速上手建议 (已更新!)
查看>>
intellij idea 热部署 jrebel 详细配置
查看>>
idea jrebel 热部署快捷配置(简装版)
查看>>
mysql性能优化-慢查询分析、优化索引和配置
查看>>