Skip to content

Commit bd909fd

Browse files
jwrdegoedegregkh
authored andcommitted
vboxsf: Make vboxsf_dir_create() return the handle for the created file
commit ab0c296 upstream Make vboxsf_dir_create() optionally return the vboxsf-handle for the created file. This is a preparation patch for adding atomic_open support. Fixes: 0fd1695 ("fs: Add VirtualBox guest shared folder (vboxsf) support") Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sudip Mukherjee <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 971703f commit bd909fd

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fs/vboxsf/dir.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int vboxsf_dir_instantiate(struct inode *parent, struct dentry *dentry,
253253
}
254254

255255
static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
256-
umode_t mode, bool is_dir, bool excl)
256+
umode_t mode, bool is_dir, bool excl, u64 *handle_ret)
257257
{
258258
struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent);
259259
struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
@@ -278,28 +278,32 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
278278
if (params.result != SHFL_FILE_CREATED)
279279
return -EPERM;
280280

281-
vboxsf_close(sbi->root, params.handle);
282-
283281
err = vboxsf_dir_instantiate(parent, dentry, &params.info);
284282
if (err)
285-
return err;
283+
goto out;
286284

287285
/* parent directory access/change time changed */
288286
sf_parent_i->force_restat = 1;
289287

290-
return 0;
288+
out:
289+
if (err == 0 && handle_ret)
290+
*handle_ret = params.handle;
291+
else
292+
vboxsf_close(sbi->root, params.handle);
293+
294+
return err;
291295
}
292296

293297
static int vboxsf_dir_mkfile(struct inode *parent, struct dentry *dentry,
294298
umode_t mode, bool excl)
295299
{
296-
return vboxsf_dir_create(parent, dentry, mode, false, excl);
300+
return vboxsf_dir_create(parent, dentry, mode, false, excl, NULL);
297301
}
298302

299303
static int vboxsf_dir_mkdir(struct inode *parent, struct dentry *dentry,
300304
umode_t mode)
301305
{
302-
return vboxsf_dir_create(parent, dentry, mode, true, true);
306+
return vboxsf_dir_create(parent, dentry, mode, true, true, NULL);
303307
}
304308

305309
static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)

0 commit comments

Comments
 (0)