Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-block.git] / fs / namei.c
index 29b044022e9c6642209f3fdb67c7fa8829c5ba04..921ae32dbc8053813e70b2a6454bf7dc4f85306a 100644 (file)
@@ -1110,21 +1110,9 @@ static int follow_automount(struct path *path, struct nameidata *nd,
         * of the daemon to instantiate them before they can be used.
         */
        if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
-                          LOOKUP_OPEN | LOOKUP_CREATE |
-                          LOOKUP_AUTOMOUNT))) {
-               /* Positive dentry that isn't meant to trigger an
-                * automount, EISDIR will allow it to be used,
-                * otherwise there's no mount here "now" so return
-                * ENOENT.
-                */
-               if (path->dentry->d_inode)
-                       return -EISDIR;
-               else
-                       return -ENOENT;
-       }
-
-       if (path->dentry->d_sb->s_user_ns != &init_user_ns)
-               return -EACCES;
+                          LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) &&
+           path->dentry->d_inode)
+               return -EISDIR;
 
        nd->total_link_count++;
        if (nd->total_link_count >= 40)
@@ -2888,6 +2876,27 @@ int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 }
 EXPORT_SYMBOL(vfs_create);
 
+int vfs_mkobj(struct dentry *dentry, umode_t mode,
+               int (*f)(struct dentry *, umode_t, void *),
+               void *arg)
+{
+       struct inode *dir = dentry->d_parent->d_inode;
+       int error = may_create(dir, dentry);
+       if (error)
+               return error;
+
+       mode &= S_IALLUGO;
+       mode |= S_IFREG;
+       error = security_inode_create(dir, dentry, mode);
+       if (error)
+               return error;
+       error = f(dentry, mode, arg);
+       if (!error)
+               fsnotify_create(dir, dentry);
+       return error;
+}
+EXPORT_SYMBOL(vfs_mkobj);
+
 bool may_open_dev(const struct path *path)
 {
        return !(path->mnt->mnt_flags & MNT_NODEV) &&