mount: consolidate permission checks

... and ask for global CAP_SYS_ADMIN only for superblock-level remounts

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
new helper: file_inode(file)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
propagate error from get_empty_filp() to its callers

Based on parts from Anatol's patch (the rest is the next commit).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs: Preserve error code in get_empty_filp(), part 2

Allocating a file structure in function get_empty_filp() might fail because
of several reasons:
 - not enough memory for file structures
 - operation is not allowed
 - user is over its limit

Currently the function returns NULL in all cases and we loose the exact
reason of the error. All callers of get_empty_filp() assume that the function
can fail with ENFILE only.

Return error through pointer. Change all callers to preserve this error code.

[AV: cleaned up a bit, carved the get_empty_filp() part out into a separate commit
(things remaining here deal with alloc_file()), removed pipe(2) behaviour change]

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Reviewed-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
clean shmem_file_setup() a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
vfs: remove d_path_with_unreachable

The last caller was removed >2 years ago in commit 7b2a69ba7.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
link_path_walk(): move assignments to nd->last/nd->last_type up

... and clean the main loop a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
get rid of name and type arguments of walk_component()

... always can be found in nameidata now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lookup_fast: get rid of name argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lookup_slow: get rid of name argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
constify __d_lookup() arguments

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
constify d_lookup() arguments

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs: Fix possible use-after-free with AIO

Running AIO is pinning inode in memory using file reference. Once AIO
is completed using aio_complete(), file reference is put and inode can
be freed from memory. So we have to be sure that calling aio_complete()
is the last thing we do with the inode.

CC: Christoph Hellwig <hch@infradead.org>
CC: Jens Axboe <axboe@kernel.dk>
CC: Jeff Moyer <jmoyer@redhat.com>
CC: stable@vger.kernel.org
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
__d_materialise_unique() is too generic

Its first argument is always non-root, while the second one is
always root.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
xenfs: switch to pure simple_fill_super()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
hostfs: directory methods have no business in non-directory inode_operations

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
spufs_mkdir(): don't d_add() on negative parent

NOTE: this really needs testing - I could've easily fucked up
refcounting in there.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
oprofilefs: add missing ->i_mutex locking in object creation

Right now it's safe only during initial mount *and* functions are asking
to be abused for dynamic adding of objects.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
shmem_setup_file(): use d_alloc_pseudo() instead of d_alloc()

Note that provided ->d_dname() reproduces what we used to get for
those guys in e.g. /proc/self/maps; it might be a good idea to change
that to something less ugly, but for now let's keep the existing
user-visible behaviour

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
hugetlb_file_setup(): use d_alloc_pseudo()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>