]> www.infradead.org Git - users/jedix/linux-maple.git/commit
readlinkat: ensure we return ENOENT for the empty pathname for normal lookups
authorAndy Whitcroft <apw@canonical.com>
Wed, 2 Nov 2011 08:44:39 +0000 (09:44 +0100)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Thu, 8 Dec 2011 19:18:00 +0000 (11:18 -0800)
commitc647d117abcf742296ee49e37a1f6380b9ed362e
treef113cb94840432873f439880e4b5fca5817ecb2d
parent5608a20e67a7f3fe34f389778a54533b54d8a0ec
readlinkat: ensure we return ENOENT for the empty pathname for normal lookups

commit 1fa1e7f615f4d3ae436fa319af6e4eebdd4026a8 upstream.

Since the commit below which added O_PATH support to the *at() calls, the
error return for readlink/readlinkat for the empty pathname has switched
from ENOENT to EINVAL:

  commit 65cfc6722361570bfe255698d9cd4dccaf47570d
  Author: Al Viro <viro@zeniv.linux.org.uk>
  Date:   Sun Mar 13 15:56:26 2011 -0400

    readlinkat(), fchownat() and fstatat() with empty relative pathnames

This is both unexpected for userspace and makes readlink/readlinkat
inconsistant with all other interfaces; and inconsistant with our stated
return for these pathnames.

As the readlinkat call does not have a flags parameter we cannot use the
AT_EMPTY_PATH approach used in the other calls.  Therefore expose whether
the original path is infact entry via a new user_path_at_empty() path
lookup function.  Use this to determine whether to default to EINVAL or
ENOENT for failures.

Addresses http://bugs.launchpad.net/bugs/817187

[akpm@linux-foundation.org: remove unused getname_flags()]
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/namei.c
fs/stat.c
include/linux/namei.h