vserver 1.9.5.x5
[linux-2.6.git] / fs / efs / namei.c
index e6c7210..ed4a207 100644 (file)
@@ -75,3 +75,36 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct namei
        return NULL;
 }
 
+struct dentry *efs_get_parent(struct dentry *child)
+{
+       struct dentry *parent;
+       struct inode *inode;
+       efs_ino_t ino;
+       int error;
+
+       lock_kernel();
+
+       error = -ENOENT;
+       ino = efs_find_entry(child->d_inode, "..", 2);
+       if (!ino)
+               goto fail;
+
+       error = -EACCES;
+       inode = iget(child->d_inode->i_sb, ino);
+       if (!inode)
+               goto fail;
+
+       error = -ENOMEM;
+       parent = d_alloc_anon(inode);
+       if (!parent)
+               goto fail_iput;
+
+       unlock_kernel();
+       return parent;
+
+ fail_iput:
+       iput(inode);
+ fail:
+       unlock_kernel();
+       return ERR_PTR(error);
+}