summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Allow passing O_PATH descriptors via SCM_RIGHTS datagramsAl Viro2011-03-153-2/+4
| | | | | | | | Just need to make sure that AF_UNIX garbage collector won't confuse O_PATHed socket on filesystem for real AF_UNIX opened socket. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* readlinkat(), fchownat() and fstatat() with empty relative pathnamesAl Viro2011-03-152-6/+11
| | | | | | | | | For readlinkat() we simply allow empty pathname; it will fail unless we have dfd equal to O_PATH-opened symlink, so we are outside of POSIX scope here. For fchownat() and fstatat() we allow AT_EMPTY_PATH; let the caller explicitly ask for such behaviour. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Allow O_PATH for symlinksAl Viro2011-03-151-6/+19
| | | | | | | | | | | | | | | | | | | At that point we can't do almost nothing with them. They can be opened with O_PATH, we can manipulate such descriptors with dup(), etc. and we can see them in /proc/*/{fd,fdinfo}/*. We can't (and won't be able to) follow /proc/*/fd/* symlinks for those; there's simply not enough information for pathname resolution to go on from such point - to resolve a symlink we need to know which directory does it live in. We will be able to do useful things with them after the next commit, though - readlinkat() and fchownat() will be possible to use with dfd being an O_PATH-opened symlink and empty relative pathname. Combined with open_by_handle() it'll give us a way to do realink-by-handle and lchown-by-handle without messing with more redundant syscalls. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* New kind of open files - "location only".Al Viro2011-03-157-17/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New flag for open(2) - O_PATH. Semantics: * pathname is resolved, but the file itself is _NOT_ opened as far as filesystem is concerned. * almost all operations on the resulting descriptors shall fail with -EBADF. Exceptions are: 1) operations on descriptors themselves (i.e. close(), dup(), dup2(), dup3(), fcntl(fd, F_DUPFD), fcntl(fd, F_DUPFD_CLOEXEC, ...), fcntl(fd, F_GETFD), fcntl(fd, F_SETFD, ...)) 2) fcntl(fd, F_GETFL), for a common non-destructive way to check if descriptor is open 3) "dfd" arguments of ...at(2) syscalls, i.e. the starting points of pathname resolution * closing such descriptor does *NOT* affect dnotify or posix locks. * permissions are checked as usual along the way to file; no permission checks are applied to the file itself. Of course, giving such thing to syscall will result in permission checks (at the moment it means checking that starting point of ....at() is a directory and caller has exec permissions on it). fget() and fget_light() return NULL on such descriptors; use of fget_raw() and fget_raw_light() is needed to get them. That protects existing code from dealing with those things. There are two things still missing (they come in the next commits): one is handling of symlinks (right now we refuse to open them that way; see the next commit for semantics related to those) and another is descriptor passing via SCM_RIGHTS datagrams. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ext4: Copy fs UUID to superblockAneesh Kumar K.V2011-03-151-0/+2
| | | | | | | | File system UUID is made available to application via /proc/<pid>/mountinfo Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ext3: Copy fs UUID to superblock.Aneesh Kumar K.V2011-03-151-0/+1
| | | | | | | | File system UUID is made available to application via /proc/<pid>/mountinfo Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: Export file system uuid via /proc/<pid>/mountinfoAneesh Kumar K.V2011-03-152-0/+17
| | | | | | | | We add a per superblock uuid field. File systems should update the uuid in the fill_super callback Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* unistd.h: Add new syscalls numbers to asm-genericAneesh Kumar K.V2011-03-151-1/+5
| | | | | Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* x86: Add new syscalls for x86_64Aneesh Kumar K.V2011-03-152-0/+6
| | | | | | | This patch add new syscalls to x86_64 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* x86: Add new syscalls for x86_32Aneesh Kumar K.V2011-03-152-1/+5
| | | | | | | This patch adds new syscalls to x86_32 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fs: Remove i_nlink check from file system link callbackAneesh Kumar K.V2011-03-156-42/+0
| | | | | | | | Now that VFS check for inode->i_nlink == 0 and returns proper error, remove similar check from file system Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fs: Don't allow to create hardlink for deleted fileAneesh Kumar K.V2011-03-151-1/+5
| | | | | | | | | | | Add inode->i_nlink == 0 check in VFS. Some of the file systems do this internally. A followup patch will remove those instance. This is needed to ensure that with link by handle we don't allow to create hardlink of an unlinked file. The check also prevent a race between unlink and link Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: Add open by file handle supportAneesh Kumar K.V2011-03-156-0/+181
| | | | | | | [AV: duplicate of open() guts removed; file_open_root() used instead] Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: Add name to file handle conversion supportAneesh Kumar K.V2011-03-158-2/+139
| | | | | | | | | The syscall also return mount id which can be used to lookup file system specific information such as uuid in /proc/<pid>/mountinfo Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* New AT_... flag: AT_EMPTY_PATHAl Viro2011-03-143-10/+21
| | | | | | | | | | For name_to_handle_at(2) we'll want both ...at()-style syscall that would be usable for non-directory descriptors (with empty relative pathname). Introduce new flag (AT_EMPTY_PATH) to deal with that and corresponding LOOKUP_EMPTY; teach user_path_at() and path_init() to deal with the latter. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* exportfs: Return the minimum required handle sizeAneesh Kumar K.V2011-03-1412-18/+59
| | | | | | | | | | | The exportfs encode handle function should return the minimum required handle size. This helps user to find out the handle size by passing 0 handle size in the first step and then redoing to the call again with the returned handle size value. Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* clean statfs-like syscalls upAl Viro2011-03-145-204/+123
| | | | | | | | | | New helpers: user_statfs() and fd_statfs(), taking userland pathname and descriptor resp. and filling struct kstatfs. Syscalls of statfs family (native, compat and foreign - osf and hpux on alpha and parisc resp.) switched to those. Removes some boilerplate code, simplifies cleanup on errors... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* open-style analog of vfs_path_lookup()Al Viro2011-03-147-84/+77
| | | | | | | | | | | | | new function: file_open_root(dentry, mnt, name, flags) opens the file vfs_path_lookup would arrive to. Note that name can be empty; in that case the usual requirement that dentry should be a directory is lifted. open-coded equivalents switched to it, may_open() got down exactly one caller and became static. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* reduce vfs_path_lookup() to do_path_lookup()Al Viro2011-03-142-52/+44
| | | | | | | | | | | | | | | New lookup flag: LOOKUP_ROOT. nd->root is set (and held) by caller, path_init() starts walking from that place and all pathname resolution machinery never drops nd->root if that flag is set. That turns vfs_path_lookup() into a special case of do_path_lookup() *and* gets us down to 3 callers of link_path_walk(), making it finally feasible to rip the handling of trailing symlink out of link_path_walk(). That will not only simply the living hell out of it, but make life much simpler for unionfs merge. Trailing symlink handling will become iterative, which is a good thing for stack footprint in a lot of situations as well. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* untangle do_lookup()Al Viro2011-03-141-85/+56
| | | | | | | | | | | | | | | | | | | | | | That thing has devolved into rats nest of gotos; sane use of unlikely() gets rid of that horror and gives much more readable structure: * make a fast attempt to find a dentry; false negatives are OK. In RCU mode if everything went fine, we are done, otherwise just drop out of RCU. If we'd done (RCU) ->d_revalidate() and it had not refused outright (i.e. didn't give us -ECHILD), remember its result. * now we are not in RCU mode and hopefully have a dentry. If we do not, lock parent, do full d_lookup() and if that has not found anything, allocate and call ->lookup(). If we'd done that ->lookup(), remember that dentry is good and we don't need to revalidate it. * now we have a dentry. If it has ->d_revalidate() and we can't skip it, call it. * hopefully dentry is good; if not, either fail (in case of error) or try to invalidate it. If d_invalidate() has succeeded, drop it and retry everything as if original attempt had not found a dentry. * now we can finish it up - deal with mountpoint crossing and automount. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* path_openat: clean ELOOP handling a bitAl Viro2011-03-141-8/+6
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* do_last: kill a rudiment of old ->d_revalidate() workaroundAl Viro2011-03-141-5/+0
| | | | | | | | | | | | There used to be time when ->d_revalidate() couldn't return an error. So intents code had lookup_instantiate_filp() stash ERR_PTR(error) in nd->intent.open.filp and had it checked after lookup_hash(), to catch the otherwise silent failures. That had been introduced by commit 4af4c52f34606bdaab6930a845550c6fb02078a4. These days ->d_revalidate() can and does propagate errors back to callers explicitly, so this check isn't needed anymore. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fold __open_namei_create() and open_will_truncate() into do_last()Al Viro2011-03-141-48/+26
| | | | | | ... and clean up a bit more Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* do_last: unify may_open() call and everyting after itAl Viro2011-03-141-37/+22
| | | | | | | | | We have a bunch of diverging codepaths in do_last(); some of them converge, but the case of having to create a new file duplicates large part of common tail of the rest and exits separately. Massage them so that they could be merged. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* move may_open() from __open_name_create() to do_last()Al Viro2011-03-141-5/+7
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* expand finish_open() in its only callerAl Viro2011-03-141-52/+38
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* sanitize pathname component hash calculationAl Viro2011-03-141-23/+19
| | | | | | | | Lift it to lookup_one_len() and link_path_walk() resp. into the same place where we calculated default hash function of the same name. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* kill __lookup_one_len()Al Viro2011-03-141-26/+15
| | | | | | only one caller left Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* switch non-create side of open() to use of do_last()Al Viro2011-03-141-33/+67
| | | | | | | | | | | | | | | | | | | | Instead of path_lookupat() doing trailing symlink resolution, use the same scheme as on the O_CREAT side. Walk with LOOKUP_PARENT, then (in do_last()) look the final component up, then either open it or return error or, if it's a symlink, give the symlink back to path_openat() to be resolved there. The really messy complication here is RCU. We don't want to drop out of RCU mode before the final lookup, since we don't want to bounce parent directory ->d_count without a good reason. Result is _not_ pretty; later in the series we'll clean it up. For now we are roughly back where we'd been before the revert done by Nick's series - top-level logics of path_openat() is cleaned up, do_last() does actual opening, symlink resolution is done uniformly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* get rid of nd->fileAl Viro2011-03-142-9/+7
| | | | | | | Don't stash the struct file * used as starting point of walk in nameidata; pass file ** to path_init() instead. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* get rid of the last LOOKUP_RCU dependencies in link_path_walk()Al Viro2011-03-141-8/+13
| | | | | | | | | | | | New helper: terminate_walk(). An error has happened during pathname resolution and we either drop nd->path or terminate RCU, depending the mode we had been in. After that, nd is essentially empty. Switch link_path_walk() to using that for cleanup. Now the top-level logics in link_path_walk() is back to sanity. RCU dependencies are in the lower-level functions. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* make nameidata_dentry_drop_rcu_maybe() always leave RCU modeAl Viro2011-03-141-5/+11
| | | | | | | | Now we have do_follow_link() guaranteed to leave without dangling RCU and the next step will get LOOKUP_RCU logics completely out of link_path_walk(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* make handle_dots() leave RCU mode on errorAl Viro2011-03-141-11/+12
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* clear RCU on all failure exits from link_path_walk()Al Viro2011-03-141-14/+16
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* pull handling of . and .. into inlined helperAl Viro2011-03-141-14/+16
| | | | | | getting LOOKUP_RCU checks out of link_path_walk()... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* kill out_dput: in link_path_walk()Al Viro2011-03-141-11/+4
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* separate -ESTALE/-ECHILD retries in do_filp_open() from real workAl Viro2011-03-141-29/+20
| | | | | | | | | | | new helper: path_openat(). Does what do_filp_open() does, except that it tries only the walk mode (RCU/normal/force revalidation) it had been told to. Both create and non-create branches are using path_lookupat() now. Fixed the double audit_inode() in non-create branch. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* switch do_filp_open() to struct open_flagsAl Viro2011-03-145-88/+101
| | | | | | | | | take calculation of open_flags by open(2) arguments into new helper in fs/open.c, move filp_open() over there, have it and do_sys_open() use that helper, switch exec.c callers of do_filp_open() to explicit (and constant) struct open_flags. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Collect "operation mode" arguments of do_last() into a structureAl Viro2011-03-141-22/+35
| | | | | | | | | | | | No point messing with passing shitloads of "operation mode" arguments to do_open() one by one, especially since they are not going to change during do_filp_open(). Collect them into a struct, fill it and pass to do_last() by reference. Make sure that lookup intent flags are correctly set and removed - we want them for do_last(), but they make no sense for __do_follow_link(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* clean up the failure exits after __do_follow_link() in do_filp_open()Al Viro2011-03-141-8/+5
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* pull security_inode_follow_link() into __do_follow_link()Al Viro2011-03-141-6/+7
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* pull dropping RCU on success of link_path_walk() into path_lookupat()Al Viro2011-03-141-18/+12
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* untangle the "need_reval_dot" messAl Viro2011-03-142-63/+46
| | | | | | | | | | | | | instead of ad-hackery around need_reval_dot(), do the following: set a flag (LOOKUP_JUMPED) in the beginning of path, on absolute symlink traversal, on ".." and on procfs-style symlinks. Clear on normal components, leave unchanged on ".". Non-nested callers of link_path_walk() call handle_reval_path(), which checks that flag is set and that fs does want the final revalidate thing, then does ->d_revalidate(). In link_path_walk() all the return_reval stuff is gone. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* merge component type recognitionAl Viro2011-03-141-26/+22
| | | | | | no need to do it in three places... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* merge path_init and path_init_rcuAl Viro2011-03-141-83/+35
| | | | | | | | | | Actual dependency on whether we want RCU or not is in 3 small areas (as it ought to be) and everything around those is the same in both versions. Since each function has only one caller and those callers are on two sides of if (flags & LOOKUP_RCU), it's easier and cleaner to merge them and pull the checks inside. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* sanitize path_walk() messAl Viro2011-03-141-92/+56
| | | | | | | | | New helper: path_lookupat(). Basically, what do_path_lookup() boils to modulo -ECHILD/-ESTALE handler. path_walk* family is gone; vfs_path_lookup() is using link_path_walk() directly, do_path_lookup() and do_filp_open() are using path_lookupat(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* take RCU-dependent stuff around exec_permission() into a new helperAl Viro2011-03-141-11/+14
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* kill path_lookup()Al Viro2011-03-146-9/+8
| | | | | | | all remaining callers pass LOOKUP_PARENT to it, so flags argument can die; renamed to kern_path_parent() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fix race in audit_get_nd()Al Viro2011-03-141-53/+32
| | | | | | don't rely on pathname resolution ending up twice at the same point... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* compat breakage in preadv() and pwritev()Al Viro2011-03-131-2/+6
| | | | | | | | | | Fix for a dumb preadv()/pwritev() compat bug - unlike the native variants, compat_... ones forget to check FMODE_P{READ,WRITE}, so e.g. on pipe the native preadv() will fail with -ESPIPE and compat one will act as readv() and succeed. Not critical, but it's a clear bug with trivial fix. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
OpenPOWER on IntegriCloud