diff options
author | Michael Kerrisk <mtk.manpages@googlemail.com> | 2008-06-10 00:16:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-06-23 08:43:03 -0400 |
commit | 12fd0d3088d27867be68655bcab2b074f2835f60 (patch) | |
tree | 088cf4d5ffc4f4f094b443f1186250403d296132 /fs | |
parent | fe6e9c1f25ac01f848bd084ee0ee62a5a0966ff3 (diff) |
[patch for 2.6.26 2/4] vfs: utimensat(): be consistent with utime() for immutable and append-only files
This patch fixes utimensat() to make its behavior consistent
with that of utime()/utimes() when dealing with files marked
immutable and append-only.
The current utimensat() implementation also returns EPERM if
'times' is non-NULL and the tv_nsec fields are both UTIME_NOW.
For consistency, the
(times != NULL && times[0].tv_nsec == UTIME_NOW &&
times[1].tv_nsec == UTIME_NOW)
case should be treated like the traditional utimes() case where
'times' is NULL. That is, the call should succeed for a file
marked append-only and should give the error EACCES if the file
is marked as immutable.
The simple way to do this is to set 'times' to NULL
if (times[0].tv_nsec == UTIME_NOW && times[1].tv_nsec == UTIME_NOW).
This is also the natural approach, since POSIX.1 semantics consider the
times == {{x, UTIME_NOW}, {y, UTIME_NOW}}
to be exactly equivalent to the case for
times == NULL.
(Thanks to Miklos for pointing this out.)
Patch 3 in this series relies on the simplification provided
by this patch.
Acked-by: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/utimes.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/utimes.c b/fs/utimes.c index af059d5cb485..14d3edbb3d7c 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -102,6 +102,10 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags | |||
102 | if (error) | 102 | if (error) |
103 | goto dput_and_out; | 103 | goto dput_and_out; |
104 | 104 | ||
105 | if (times && times[0].tv_nsec == UTIME_NOW && | ||
106 | times[1].tv_nsec == UTIME_NOW) | ||
107 | times = NULL; | ||
108 | |||
105 | /* Don't worry, the checks are done in inode_change_ok() */ | 109 | /* Don't worry, the checks are done in inode_change_ok() */ |
106 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | 110 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; |
107 | if (times) { | 111 | if (times) { |