diff options
-rw-r--r-- | fs/inode.c | 20 | ||||
-rw-r--r-- | fs/read_write.c | 21 | ||||
-rw-r--r-- | include/linux/fs.h | 2 |
3 files changed, 25 insertions, 18 deletions
diff --git a/fs/inode.c b/fs/inode.c index df6542ec3b88..4348cfb14562 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -1899,6 +1899,26 @@ int file_update_time(struct file *file) | |||
1899 | } | 1899 | } |
1900 | EXPORT_SYMBOL(file_update_time); | 1900 | EXPORT_SYMBOL(file_update_time); |
1901 | 1901 | ||
1902 | /* Caller must hold the file's inode lock */ | ||
1903 | int file_modified(struct file *file) | ||
1904 | { | ||
1905 | int err; | ||
1906 | |||
1907 | /* | ||
1908 | * Clear the security bits if the process is not being run by root. | ||
1909 | * This keeps people from modifying setuid and setgid binaries. | ||
1910 | */ | ||
1911 | err = file_remove_privs(file); | ||
1912 | if (err) | ||
1913 | return err; | ||
1914 | |||
1915 | if (unlikely(file->f_mode & FMODE_NOCMTIME)) | ||
1916 | return 0; | ||
1917 | |||
1918 | return file_update_time(file); | ||
1919 | } | ||
1920 | EXPORT_SYMBOL(file_modified); | ||
1921 | |||
1902 | int inode_needs_sync(struct inode *inode) | 1922 | int inode_needs_sync(struct inode *inode) |
1903 | { | 1923 | { |
1904 | if (IS_SYNC(inode)) | 1924 | if (IS_SYNC(inode)) |
diff --git a/fs/read_write.c b/fs/read_write.c index b0fb1176b628..cec7e7b1f693 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -1980,25 +1980,10 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, | |||
1980 | return ret; | 1980 | return ret; |
1981 | 1981 | ||
1982 | /* If can't alter the file contents, we're done. */ | 1982 | /* If can't alter the file contents, we're done. */ |
1983 | if (!(remap_flags & REMAP_FILE_DEDUP)) { | 1983 | if (!(remap_flags & REMAP_FILE_DEDUP)) |
1984 | /* Update the timestamps, since we can alter file contents. */ | 1984 | ret = file_modified(file_out); |
1985 | if (!(file_out->f_mode & FMODE_NOCMTIME)) { | ||
1986 | ret = file_update_time(file_out); | ||
1987 | if (ret) | ||
1988 | return ret; | ||
1989 | } | ||
1990 | 1985 | ||
1991 | /* | 1986 | return ret; |
1992 | * Clear the security bits if the process is not being run by | ||
1993 | * root. This keeps people from modifying setuid and setgid | ||
1994 | * binaries. | ||
1995 | */ | ||
1996 | ret = file_remove_privs(file_out); | ||
1997 | if (ret) | ||
1998 | return ret; | ||
1999 | } | ||
2000 | |||
2001 | return 0; | ||
2002 | } | 1987 | } |
2003 | EXPORT_SYMBOL(generic_remap_file_range_prep); | 1988 | EXPORT_SYMBOL(generic_remap_file_range_prep); |
2004 | 1989 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index e4d382c4342a..79ffa2958bd8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2177,6 +2177,8 @@ static inline void file_accessed(struct file *file) | |||
2177 | touch_atime(&file->f_path); | 2177 | touch_atime(&file->f_path); |
2178 | } | 2178 | } |
2179 | 2179 | ||
2180 | extern int file_modified(struct file *file); | ||
2181 | |||
2180 | int sync_inode(struct inode *inode, struct writeback_control *wbc); | 2182 | int sync_inode(struct inode *inode, struct writeback_control *wbc); |
2181 | int sync_inode_metadata(struct inode *inode, int wait); | 2183 | int sync_inode_metadata(struct inode *inode, int wait); |
2182 | 2184 | ||