From e42d464b6dff915ff209f5c3300bc82e52eb9f87 Mon Sep 17 00:00:00 2001 From: Vasily Averin Date: Tue, 14 Jul 2015 12:25:02 +0300 Subject: [PATCH rh6] AT_EMPTY_PATH support for fstatat() with empty relative pathnames To: khorenko@virtuozzo.com, vzlin-dev@sw.ru backported part of mainline commit 65cfc6722 ("readlinkat(), fchownat() and fstatat() with empty relative pathnames") related to fstatat "we allow AT_EMPTY_PATH; let the caller explicitly ask for such behaviour." AT_EMPTY_PATH (since Linux 2.6.39) If pathname is an empty string, operate on the file referred to by dirfd (which may have been obtained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory. This change is required to allow systemd v220+ work inside container on RHEL6-based openVZ kernel https://bugzilla.openvz.org/show_bug.cgi?id=3280 Signed-off-by: Vasily Averin --- fs/stat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index c69f8be..1325908 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -79,11 +79,14 @@ int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag) int error = -EINVAL; unsigned int lookup_flags = 0; - if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT)) != 0) + if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | + AT_EMPTY_PATH)) != 0) goto out; if (!(flag & AT_SYMLINK_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; + if (flag & AT_EMPTY_PATH) + lookup_flags |= LOOKUP_EMPTY; retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (error) -- 1.9.1