The patch titled Create fs/utimes.c has been added to the -mm tree. Its filename is create-fs-utimesc.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: Create fs/utimes.c From: Alexey Dobriyan <adobriyan@xxxxxxxxx> * fs/open.c is getting bit crowdy * preparation to lutimes(2) Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- fs/Makefile | 2 fs/open.c | 134 --------------------------------------- fs/utimes.c | 137 ++++++++++++++++++++++++++++++++++++++++ include/linux/namei.h | 1 include/linux/utime.h | 2 5 files changed, 141 insertions(+), 135 deletions(-) diff -puN fs/Makefile~create-fs-utimesc fs/Makefile --- a/fs/Makefile~create-fs-utimesc +++ a/fs/Makefile @@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table. ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ - pnode.o drop_caches.o splice.o sync.o + pnode.o drop_caches.o splice.o sync.o utimes.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o diff -puN fs/open.c~create-fs-utimesc fs/open.c --- a/fs/open.c~create-fs-utimesc +++ a/fs/open.c @@ -6,7 +6,6 @@ #include <linux/string.h> #include <linux/mm.h> -#include <linux/utime.h> #include <linux/file.h> #include <linux/smp_lock.h> #include <linux/quotaops.h> @@ -29,8 +28,6 @@ #include <linux/rcupdate.h> #include <linux/audit.h> -#include <asm/unistd.h> - int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) { int retval = -ENODEV; @@ -353,137 +350,6 @@ asmlinkage long sys_ftruncate64(unsigned } #endif -#ifdef __ARCH_WANT_SYS_UTIME - -/* - * sys_utime() can be implemented in user-level using sys_utimes(). - * Is this for backwards compatibility? If so, why not move it - * into the appropriate arch directory (for those architectures that - * need it). - */ - -/* If times==NULL, set access and modification to current time, - * must be owner or have write permission. - * Else, update from *times, must be owner or super user. - */ -asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times) -{ - int error; - struct nameidata nd; - struct inode * inode; - struct iattr newattrs; - - error = user_path_walk(filename, &nd); - if (error) - goto out; - inode = nd.dentry->d_inode; - - error = -EROFS; - if (IS_RDONLY(inode)) - goto dput_and_out; - - /* Don't worry, the checks are done in inode_change_ok() */ - newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; - if (times) { - error = -EPERM; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - goto dput_and_out; - - error = get_user(newattrs.ia_atime.tv_sec, ×->actime); - newattrs.ia_atime.tv_nsec = 0; - if (!error) - error = get_user(newattrs.ia_mtime.tv_sec, ×->modtime); - newattrs.ia_mtime.tv_nsec = 0; - if (error) - goto dput_and_out; - - newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; - } else { - error = -EACCES; - if (IS_IMMUTABLE(inode)) - goto dput_and_out; - - if (current->fsuid != inode->i_uid && - (error = vfs_permission(&nd, MAY_WRITE)) != 0) - goto dput_and_out; - } - mutex_lock(&inode->i_mutex); - error = notify_change(nd.dentry, &newattrs); - mutex_unlock(&inode->i_mutex); -dput_and_out: - path_release(&nd); -out: - return error; -} - -#endif - -/* If times==NULL, set access and modification to current time, - * must be owner or have write permission. - * Else, update from *times, must be owner or super user. - */ -long do_utimes(int dfd, char __user *filename, struct timeval *times) -{ - int error; - struct nameidata nd; - struct inode * inode; - struct iattr newattrs; - - error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); - - if (error) - goto out; - inode = nd.dentry->d_inode; - - error = -EROFS; - if (IS_RDONLY(inode)) - goto dput_and_out; - - /* Don't worry, the checks are done in inode_change_ok() */ - newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; - if (times) { - error = -EPERM; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - goto dput_and_out; - - newattrs.ia_atime.tv_sec = times[0].tv_sec; - newattrs.ia_atime.tv_nsec = times[0].tv_usec * 1000; - newattrs.ia_mtime.tv_sec = times[1].tv_sec; - newattrs.ia_mtime.tv_nsec = times[1].tv_usec * 1000; - newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; - } else { - error = -EACCES; - if (IS_IMMUTABLE(inode)) - goto dput_and_out; - - if (current->fsuid != inode->i_uid && - (error = vfs_permission(&nd, MAY_WRITE)) != 0) - goto dput_and_out; - } - mutex_lock(&inode->i_mutex); - error = notify_change(nd.dentry, &newattrs); - mutex_unlock(&inode->i_mutex); -dput_and_out: - path_release(&nd); -out: - return error; -} - -asmlinkage long sys_futimesat(int dfd, char __user *filename, struct timeval __user *utimes) -{ - struct timeval times[2]; - - if (utimes && copy_from_user(×, utimes, sizeof(times))) - return -EFAULT; - return do_utimes(dfd, filename, utimes ? times : NULL); -} - -asmlinkage long sys_utimes(char __user *filename, struct timeval __user *utimes) -{ - return sys_futimesat(AT_FDCWD, filename, utimes); -} - - /* * access() needs to use the real uid/gid, not the effective uid/gid. * We do this by temporarily clearing all FS-related capabilities and diff -puN /dev/null fs/utimes.c --- /dev/null +++ a/fs/utimes.c @@ -0,0 +1,137 @@ +#include <linux/compiler.h> +#include <linux/fs.h> +#include <linux/linkage.h> +#include <linux/namei.h> +#include <linux/utime.h> +#include <asm/uaccess.h> +#include <asm/unistd.h> + +#ifdef __ARCH_WANT_SYS_UTIME + +/* + * sys_utime() can be implemented in user-level using sys_utimes(). + * Is this for backwards compatibility? If so, why not move it + * into the appropriate arch directory (for those architectures that + * need it). + */ + +/* If times==NULL, set access and modification to current time, + * must be owner or have write permission. + * Else, update from *times, must be owner or super user. + */ +asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times) +{ + int error; + struct nameidata nd; + struct inode * inode; + struct iattr newattrs; + + error = user_path_walk(filename, &nd); + if (error) + goto out; + inode = nd.dentry->d_inode; + + error = -EROFS; + if (IS_RDONLY(inode)) + goto dput_and_out; + + /* Don't worry, the checks are done in inode_change_ok() */ + newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; + if (times) { + error = -EPERM; + if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) + goto dput_and_out; + + error = get_user(newattrs.ia_atime.tv_sec, ×->actime); + newattrs.ia_atime.tv_nsec = 0; + if (!error) + error = get_user(newattrs.ia_mtime.tv_sec, ×->modtime); + newattrs.ia_mtime.tv_nsec = 0; + if (error) + goto dput_and_out; + + newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; + } else { + error = -EACCES; + if (IS_IMMUTABLE(inode)) + goto dput_and_out; + + if (current->fsuid != inode->i_uid && + (error = vfs_permission(&nd, MAY_WRITE)) != 0) + goto dput_and_out; + } + mutex_lock(&inode->i_mutex); + error = notify_change(nd.dentry, &newattrs); + mutex_unlock(&inode->i_mutex); +dput_and_out: + path_release(&nd); +out: + return error; +} + +#endif + +/* If times==NULL, set access and modification to current time, + * must be owner or have write permission. + * Else, update from *times, must be owner or super user. + */ +long do_utimes(int dfd, char __user *filename, struct timeval *times) +{ + int error; + struct nameidata nd; + struct inode * inode; + struct iattr newattrs; + + error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); + + if (error) + goto out; + inode = nd.dentry->d_inode; + + error = -EROFS; + if (IS_RDONLY(inode)) + goto dput_and_out; + + /* Don't worry, the checks are done in inode_change_ok() */ + newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; + if (times) { + error = -EPERM; + if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) + goto dput_and_out; + + newattrs.ia_atime.tv_sec = times[0].tv_sec; + newattrs.ia_atime.tv_nsec = times[0].tv_usec * 1000; + newattrs.ia_mtime.tv_sec = times[1].tv_sec; + newattrs.ia_mtime.tv_nsec = times[1].tv_usec * 1000; + newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; + } else { + error = -EACCES; + if (IS_IMMUTABLE(inode)) + goto dput_and_out; + + if (current->fsuid != inode->i_uid && + (error = vfs_permission(&nd, MAY_WRITE)) != 0) + goto dput_and_out; + } + mutex_lock(&inode->i_mutex); + error = notify_change(nd.dentry, &newattrs); + mutex_unlock(&inode->i_mutex); +dput_and_out: + path_release(&nd); +out: + return error; +} + +asmlinkage long sys_futimesat(int dfd, char __user *filename, struct timeval __user *utimes) +{ + struct timeval times[2]; + + if (utimes && copy_from_user(×, utimes, sizeof(times))) + return -EFAULT; + return do_utimes(dfd, filename, utimes ? times : NULL); +} + +asmlinkage long sys_utimes(char __user *filename, struct timeval __user *utimes) +{ + return sys_futimesat(AT_FDCWD, filename, utimes); +} diff -puN include/linux/namei.h~create-fs-utimesc include/linux/namei.h --- a/include/linux/namei.h~create-fs-utimesc +++ a/include/linux/namei.h @@ -1,6 +1,7 @@ #ifndef _LINUX_NAMEI_H #define _LINUX_NAMEI_H +#include <linux/dcache.h> #include <linux/linkage.h> struct vfsmount; diff -puN include/linux/utime.h~create-fs-utimesc include/linux/utime.h --- a/include/linux/utime.h~create-fs-utimesc +++ a/include/linux/utime.h @@ -1,6 +1,8 @@ #ifndef _LINUX_UTIME_H #define _LINUX_UTIME_H +#include <linux/types.h> + struct utimbuf { time_t actime; time_t modtime; _ Patches currently in -mm which might be from adobriyan@xxxxxxxxx are optical-proc-ide-media.patch sh-fix-fpn_start-typo.patch asus_acpi-fix-proc-files-parsing.patch asus_acpi-dont-printk-on-writing-garbage-to-proc-files.patch git-alsa.patch git-agpgart.patch git-dvb.patch config_pm=n-slim-drivers-ieee1394-ohci1394c.patch git-libata-all.patch git-net.patch config_pm=n-slim-drivers-pcmcia.patch i82092-wire-up-errors-from-pci_register_driver.patch config_pm=n-slim-drivers-serial-8250_pcic.patch megaraid-fix-warnings-when-config_proc_fs=n.patch git-xfs.patch headers_check-improve-include-regexp.patch headers_check-clarify-error-message.patch task_struct-ifdef-missedem-v-ipc.patch ifdef-blktrace-debugging-fields.patch tty_ioc-keep-davej-sane.patch ifdef-quota_read-quota_write.patch reiserfs-ifdef-xattr_sem.patch reiserfs-ifdef-acl-stuff-from-inode.patch fsh-ifdef-security-fields.patch config_pm=n-slim-drivers-parport-parport_serialc.patch config_pm=n-slim-sound-oss-tridentc.patch config_pm=n-slim-sound-oss-cs46xxc.patch windfarm_smu_satc-simplify-around-i2c_add_driver.patch cramfs-rewrite-init_cramfs_fs.patch freevxfs-fix-leak-on-error-path.patch cramfs-make-cramfs_uncompress_exit-return-void.patch 9p-fix-leak-on-error-path.patch ban-register_filesystemnull.patch jbd-use-build_bug_on-in-journal-init.patch really-ignore-kmem_cache_destroy-return-value.patch make-kmem_cache_destroy-return-void.patch documentation-submittingdrivers-minor-update.patch kmemdup-introduce.patch kmemdup-some-users.patch create-fs-utimesc.patch remove-null-check-in-register_nls.patch make-kmem_cache_destroy-return-void-ecryptfs.patch config_pm=n-slim-drivers-ide-pci-sc1200c.patch documentation-ioctl-messtxt-start-tree-wide-ioctl-registry.patch ioctl-messtxt-xfs-typos.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html