public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [parch 2/4] vfs: utimensat(): be consistent with utime() for immutable and append-only files
@ 2008-06-03 22:25 Michael Kerrisk
  2008-06-04  4:29 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Kerrisk @ 2008-06-03 22:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: lkml, Christoph Hellwig, Miklos Szeredi, Al Viro, jamie,
	Ulrich Drepper, linux-fsdevel, Subrata Modak

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.

CC: 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>

--- linux-2.6.26-rc4/fs/utimes.c	2008-06-03 22:47:07.000000000 +0200
+++ linux-2.6.26-rc4-utimensat-fix-v4/fs/utimes.c	2008-06-03 22:59:55.000000000 +0200
@@ -102,6 +102,10 @@
 	if (error)
 		goto dput_and_out;

+	if (times && times[0].tv_nsec == UTIME_NOW &&
+		     times[1].tv_nsec == UTIME_NOW)
+		times = NULL;
+
 	/* Don't worry, the checks are done in inode_change_ok() */
 	newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
 	if (times) {



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [parch 2/4] vfs: utimensat(): be consistent with utime() for immutable and append-only files
  2008-06-03 22:25 [parch 2/4] vfs: utimensat(): be consistent with utime() for immutable and append-only files Michael Kerrisk
@ 2008-06-04  4:29 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2008-06-04  4:29 UTC (permalink / raw)
  To: mtk.manpages
  Cc: akpm, linux-kernel, hch, miklos, viro, jamie, drepper,
	linux-fsdevel, subrata

> 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.
> 
> CC: 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>

Acked-by: Miklos Szeredi <mszeredi@suse.cz>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-04  4:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 22:25 [parch 2/4] vfs: utimensat(): be consistent with utime() for immutable and append-only files Michael Kerrisk
2008-06-04  4:29 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox