Skip to content

Commit

Permalink
utimensat: AT_EMPTY_PATH support
Browse files Browse the repository at this point in the history
This makes it possible to use utimensat on an O_PATH file (including
symlinks).

It supersedes the nonstandard utimensat(fd, NULL, ...) form.

Cc: linux-api@vger.kernel.org
Cc: linux-man@vger.kernel.org
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Miklos Szeredi committed May 14, 2020
1 parent 9470451 commit 44a3b87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/utimes.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,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);
Expand All @@ -117,6 +117,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)
Expand Down

0 comments on commit 44a3b87

Please sign in to comment.