+out_err:
+ return ERR_PTR(err);
+}
+
+static int fuse_mknod(struct inode *, struct dentry *, umode_t, dev_t);
+static struct file *fuse_atomic_open(struct inode *dir, struct dentry *entry,
+ struct opendata *od, unsigned flags,
+ umode_t mode, bool *created)
+{
+ int err;
+ struct fuse_conn *fc = get_fuse_conn(dir);
+ struct file *file;
+ struct dentry *res = NULL;
+
+ if (d_unhashed(entry)) {
+ res = fuse_lookup(dir, entry, NULL);
+ if (IS_ERR(res))
+ return ERR_CAST(res);
+
+ if (res)
+ entry = res;
+ }
+
+ if (!(flags & O_CREAT) || entry->d_inode)
+ goto no_open;
+
+ /* Only creates */
+ *created = true;
+
+ if (fc->no_create)
+ goto mknod;
+
+ file = fuse_create_open(dir, entry, od, flags, mode);
+ if (PTR_ERR(file) == -ENOSYS) {
+ fc->no_create = 1;
+ goto mknod;
+ }
+out_dput:
+ dput(res);
+ return file;
+
+mknod:
+ err = fuse_mknod(dir, entry, mode, 0);
+ if (err) {
+ file = ERR_PTR(err);
+ goto out_dput;
+ }
+no_open:
+ finish_no_open(od, res);
+ return NULL;