* [PATCH] utimensat: AT_EMPTY_PATH support
@ 2018-11-07 9:15 Miklos Szeredi
2018-11-07 18:05 ` Vivek Goyal
0 siblings, 1 reply; 2+ messages in thread
From: Miklos Szeredi @ 2018-11-07 9:15 UTC (permalink / raw)
To: Al Viro; +Cc: Vivek Goyal, linux-fsdevel, linux-kernel
This makes it possible to use utimensat on an O_PATH file (including
symlinks).
It supersedes the nonstandard utimensat(fd, NULL, ...) form.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/utimes.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/utimes.c b/fs/utimes.c
index bdcf2daf39c1..f9c7ebad19d7 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -97,13 +97,13 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
goto out;
}
- if (flags & ~AT_SYMLINK_NOFOLLOW)
+ if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
goto out;
if (filename == NULL && dfd != AT_FDCWD) {
struct fd f;
- if (flags & AT_SYMLINK_NOFOLLOW)
+ if (flags)
goto out;
f = fdget(dfd);
@@ -119,6 +119,8 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
if (!(flags & AT_SYMLINK_NOFOLLOW))
lookup_flags |= LOOKUP_FOLLOW;
+ if (flags & AT_EMPTY_PATH)
+ lookup_flags |= LOOKUP_EMPTY;
retry:
error = user_path_at(dfd, filename, lookup_flags, &path);
if (error)
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] utimensat: AT_EMPTY_PATH support
2018-11-07 9:15 [PATCH] utimensat: AT_EMPTY_PATH support Miklos Szeredi
@ 2018-11-07 18:05 ` Vivek Goyal
0 siblings, 0 replies; 2+ messages in thread
From: Vivek Goyal @ 2018-11-07 18:05 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: Al Viro, linux-fsdevel, linux-kernel
On Wed, Nov 07, 2018 at 10:15:52AM +0100, Miklos Szeredi wrote:
> This makes it possible to use utimensat on an O_PATH file (including
> symlinks).
>
> It supersedes the nonstandard utimensat(fd, NULL, ...) form.
>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Thanks for fixing this Miklos. It seems to work for me for following
use case I have where I want to change time on symlink opened with O_PATH.
symfd = open("foo-symlink.txt", O_PATH | O_NOFOLLOW);
utimensat(fd, "", NULL, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
Thanks
Vivek
> ---
> fs/utimes.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/utimes.c b/fs/utimes.c
> index bdcf2daf39c1..f9c7ebad19d7 100644
> --- a/fs/utimes.c
> +++ b/fs/utimes.c
> @@ -97,13 +97,13 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
> goto out;
> }
>
> - if (flags & ~AT_SYMLINK_NOFOLLOW)
> + if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
> goto out;
>
> if (filename == NULL && dfd != AT_FDCWD) {
> struct fd f;
>
> - if (flags & AT_SYMLINK_NOFOLLOW)
> + if (flags)
> goto out;
>
> f = fdget(dfd);
> @@ -119,6 +119,8 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
>
> if (!(flags & AT_SYMLINK_NOFOLLOW))
> lookup_flags |= LOOKUP_FOLLOW;
> + if (flags & AT_EMPTY_PATH)
> + lookup_flags |= LOOKUP_EMPTY;
> retry:
> error = user_path_at(dfd, filename, lookup_flags, &path);
> if (error)
> --
> 2.14.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-07 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 9:15 [PATCH] utimensat: AT_EMPTY_PATH support Miklos Szeredi
2018-11-07 18:05 ` Vivek Goyal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).