本文共 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/