Skip to content

Commit 971703f

Browse files
jwrdegoedegregkh
authored andcommitted
vboxsf: Honor excl flag to the dir-inode create op
commit cc3ddee upstream Honor the excl flag to the dir-inode create op, instead of behaving as if it is always set. Note the old behavior still worked most of the time since a non-exclusive open only calls the create op, if there is a race and the file is created between the dentry lookup and the calling of the create call. While at it change the type of the is_dir parameter to the vboxsf_dir_create() helper from an int to a bool, to be consistent with the use of bool for the excl parameter. 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 96b2232 commit 971703f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fs/vboxsf/dir.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,20 @@ 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, int is_dir)
256+
umode_t mode, bool is_dir, bool excl)
257257
{
258258
struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent);
259259
struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
260260
struct shfl_createparms params = {};
261261
int err;
262262

263263
params.handle = SHFL_HANDLE_NIL;
264-
params.create_flags = SHFL_CF_ACT_CREATE_IF_NEW |
265-
SHFL_CF_ACT_FAIL_IF_EXISTS |
266-
SHFL_CF_ACCESS_READWRITE |
267-
(is_dir ? SHFL_CF_DIRECTORY : 0);
264+
params.create_flags = SHFL_CF_ACT_CREATE_IF_NEW | SHFL_CF_ACCESS_READWRITE;
265+
if (is_dir)
266+
params.create_flags |= SHFL_CF_DIRECTORY;
267+
if (excl)
268+
params.create_flags |= SHFL_CF_ACT_FAIL_IF_EXISTS;
269+
268270
params.info.attr.mode = (mode & 0777) |
269271
(is_dir ? SHFL_TYPE_DIRECTORY : SHFL_TYPE_FILE);
270272
params.info.attr.additional = SHFLFSOBJATTRADD_NOTHING;
@@ -291,13 +293,13 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
291293
static int vboxsf_dir_mkfile(struct inode *parent, struct dentry *dentry,
292294
umode_t mode, bool excl)
293295
{
294-
return vboxsf_dir_create(parent, dentry, mode, 0);
296+
return vboxsf_dir_create(parent, dentry, mode, false, excl);
295297
}
296298

297299
static int vboxsf_dir_mkdir(struct inode *parent, struct dentry *dentry,
298300
umode_t mode)
299301
{
300-
return vboxsf_dir_create(parent, dentry, mode, 1);
302+
return vboxsf_dir_create(parent, dentry, mode, true, true);
301303
}
302304

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

0 commit comments

Comments
 (0)