From: Andrew Morton <akpm@osdl.org>
To: Alexey Dobriyan <adobriyan@openvz.org>
Cc: devel@openvz.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 1/3] lutimesat: simplify utime(2)
Date: Fri, 26 Jan 2007 12:41:20 -0800 [thread overview]
Message-ID: <20070126124120.f8f78623.akpm@osdl.org> (raw)
In-Reply-To: <20070126112142.GA11128@localhost.sw.ru>
On Fri, 26 Jan 2007 14:21:42 +0300
Alexey Dobriyan <adobriyan@openvz.org> wrote:
> Rewrite via do_utimes() like compat_sys_utime().
>
> Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
> ---
>
> fs/utimes.c | 50 +++++++-------------------------------------------
> 1 file changed, 7 insertions(+), 43 deletions(-)
>
> --- a/fs/utimes.c
> +++ b/fs/utimes.c
> @@ -22,52 +22,16 @@ #ifdef __ARCH_WANT_SYS_UTIME
> */
> asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times)
> {
> - int error;
> - struct nameidata nd;
> - struct inode * inode;
> - struct iattr newattrs;
> + struct timeval tv[2];
>
> - 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;
> + if (get_user(tv[0].tv_sec, ×->actime) ||
> + get_user(tv[1].tv_sec, ×->modtime))
> + return -EFAULT;
> + tv[0].tv_usec = 0;
> + tv[1].tv_usec = 0;
> }
> - 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;
> + return do_utimes(AT_FDCWD, filename, times ? tv : NULL);
> }
>
> #endif
I'm somewhat surprised that this wasn't done earlier. I wonder if there's
some subtle reason why this won't work. How well tested is this?
next prev parent reply other threads:[~2007-01-26 20:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-26 11:21 Alexey Dobriyan
2007-01-26 20:41 ` Andrew Morton [this message]
2007-01-26 23:35 ` Arnd Bergmann
2007-01-28 15:28 ` Alexey Dobriyan
2007-01-28 15:24 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070126124120.f8f78623.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=adobriyan@openvz.org \
--cc=arnd@arndb.de \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome