Christoph Hellwig
2018-Oct-14 17:21 UTC
[Ocfs2-devel] [PATCH 10/25] vfs: create generic_remap_file_range_touch to update inode metadata
> +/* Update inode timestamps and remove security privileges when remapping. */ > +int generic_remap_file_range_touch(struct file *file, bool is_dedupe) > +{ > + int ret; > + > + /* If can't alter the file contents, we're done. */ > + if (is_dedupe) > + return 0; > + > + /* Update the timestamps, since we can alter file contents. */ > + if (!(file->f_mode & FMODE_NOCMTIME)) { > + ret = file_update_time(file); > + if (ret) > + return ret; > + } > + > + /* > + * Clear the security bits if the process is not being run by root. > + * This keeps people from modifying setuid and setgid binaries. > + */ > + return file_remove_privs(file); > +} > +EXPORT_SYMBOL(generic_remap_file_range_touch);The name seems a little out of touch with what it actually does. Also why a bool argument instead of the more descriptive flags which introduced a few patches ago?
Darrick J. Wong
2018-Oct-15 16:30 UTC
[Ocfs2-devel] [PATCH 10/25] vfs: create generic_remap_file_range_touch to update inode metadata
On Sun, Oct 14, 2018 at 10:21:31AM -0700, Christoph Hellwig wrote:> > +/* Update inode timestamps and remove security privileges when remapping. */ > > +int generic_remap_file_range_touch(struct file *file, bool is_dedupe) > > +{ > > + int ret; > > + > > + /* If can't alter the file contents, we're done. */ > > + if (is_dedupe) > > + return 0; > > + > > + /* Update the timestamps, since we can alter file contents. */ > > + if (!(file->f_mode & FMODE_NOCMTIME)) { > > + ret = file_update_time(file); > > + if (ret) > > + return ret; > > + } > > + > > + /* > > + * Clear the security bits if the process is not being run by root. > > + * This keeps people from modifying setuid and setgid binaries. > > + */ > > + return file_remove_privs(file); > > +} > > +EXPORT_SYMBOL(generic_remap_file_range_touch); > > The name seems a little out of touch with what it actually does.I originally thought "touch" because it updates [cm]time. :) Though looking at the final code, I think this can just be called from the end of generic_remap_file_range_prep, so we can skip the export and all that other stuff.> Also why a bool argument instead of the more descriptive flags which > introduced a few patches ago?Hmm, yes, the remap_flags transition can move up to before this patch. --D