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

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

更新文件的访问时间:
/** *	touch_atime	-	update the access time *	@path: the &struct path to update *	@inode: inode to update * *	Update the accessed time on an inode and mark it for writeback. *	This function automatically handles read only file systems and media, *	as well as the "noatime" flag and inode specific "noatime" markers. */bool __atime_needs_update(const struct path *path, struct inode *inode,			  bool rcu){	struct vfsmount *mnt = path->mnt;	struct timespec now;	if (inode->i_flags & S_NOATIME)		return false;	/* Atime updates will likely cause i_uid and i_gid to be written	 * back improprely if their true value is unknown to the vfs.	 */	if (HAS_UNMAPPED_ID(inode))		return false;	if (IS_NOATIME(inode))		return false;	if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))		return false;	if (mnt->mnt_flags & MNT_NOATIME)		return false;	if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))		return false;	now = current_time(inode);	if (!relatime_need_update(path, inode, now, rcu))		return false;	if (timespec_equal(&inode->i_atime, &now))		return false;	return true;}
 
void touch_atime(const struct path *path){	struct vfsmount *mnt = path->mnt;	struct inode *inode = d_inode(path->dentry);	struct timespec now;	if (!__atime_needs_update(path, inode, false))		return;	if (!sb_start_write_trylock(inode->i_sb))		return;	if (__mnt_want_write(mnt) != 0)		goto skip_update;	/*	 * File systems can error out when updating inodes if they need to	 * allocate new space to modify an inode (such is the case for	 * Btrfs), but since we touch atime while walking down the path we	 * really don't care if we failed to update the atime of the file,	 * so just ignore the return value.	 * We may also fail on filesystems that have the ability to make parts	 * of the fs read only, e.g. subvolumes in Btrfs.	 */	now = current_time(inode);	update_time(inode, &now, S_ATIME);	__mnt_drop_write(mnt);skip_update:	sb_end_write(inode->i_sb);}EXPORT_SYMBOL(touch_atime);

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

你可能感兴趣的文章
配置文件的重要性------轻化操作
查看>>
又是缓存惹的祸!!!
查看>>
为什么要实现程序指令和程序数据的分离?
查看>>
我对C++ string和length方法的一个长期误解------从protobuf序列化说起(没处理好会引起数据丢失、反序列化失败哦!)
查看>>
一起来看看protobuf中容易引起bug的一个细节
查看>>
无protobuf协议情况下的反序列化------貌似无解, 其实有解!
查看>>
make -n(仅列出命令, 但不会执行)用于调试makefile
查看>>
makefile中“-“符号的使用
查看>>
go语言如何从终端逐行读取数据?------用bufio包
查看>>
go的值类型和引用类型------重要的概念
查看>>
求二叉树中结点的最大值(所有结点的值都是正整数)
查看>>
用go的flag包来解析命令行参数
查看>>
来玩下go的http get
查看>>
队列和栈的本质区别
查看>>
matlab中inline的用法
查看>>
如何用matlab求函数的最值?
查看>>
Git从入门到放弃
查看>>
java8采用stream对集合的常用操作
查看>>
EasySwift/YXJOnePixelLine 极其方便的画出真正的一个像素的线
查看>>
Ubuntu系统上安装Nginx服务器的简单方法
查看>>