new helper: open_with_fake_path()
[linux-block.git] / fs / open.c
index ee893240d199c22c6ec12d4b2f7c6092c997e8df..dd15711eb6582d123468f68399dd1d94e478a920 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -925,6 +925,24 @@ struct file *dentry_open(const struct path *path, int flags,
 }
 EXPORT_SYMBOL(dentry_open);
 
+struct file *open_with_fake_path(const struct path *path, int flags,
+                               struct inode *inode, const struct cred *cred)
+{
+       struct file *f = alloc_empty_file(flags, cred);
+       if (!IS_ERR(f)) {
+               int error;
+
+               f->f_path = *path;
+               error = do_dentry_open(f, inode, NULL);
+               if (error) {
+                       fput(f);
+                       f = ERR_PTR(error);
+               }
+       }
+       return f;
+}
+EXPORT_SYMBOL(open_with_fake_path);
+
 static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
 {
        int lookup_flags = 0;