Skip to content

Commit

Permalink
[LibOS] Remove duplicated dent->inode->perm assignment in chmod()
Browse files Browse the repository at this point in the history
The `chmod()` callback is supposed to perform PAL-level (host-level)
file permission change. The description of this callback explicitly
states that "on success, the caller should update `dent->inode->perm`".
Thus, the assignment inside the callback is redundant.

Signed-off-by: Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
  • Loading branch information
dimakuv committed Sep 19, 2023
1 parent 3c10e21 commit 12bd9f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
3 changes: 0 additions & 3 deletions libos/src/fs/chroot/encrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ static int chroot_encrypted_chmod(struct libos_dentry* dent, mode_t perm) {
assert(dent->inode);

char* uri = NULL;
lock(&dent->inode->lock);

int ret = chroot_dentry_uri(dent, dent->inode->type, &uri);
if (ret < 0)
Expand All @@ -362,11 +361,9 @@ static int chroot_encrypted_chmod(struct libos_dentry* dent, mode_t perm) {
ret = pal_to_unix_errno(ret);
goto out;
}
dent->inode->perm = perm;
ret = 0;

out:
unlock(&dent->inode->lock);
free(uri);
return ret;
}
Expand Down
17 changes: 4 additions & 13 deletions libos/src/fs/chroot/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,28 +452,19 @@ static int chroot_chmod(struct libos_dentry* dent, mode_t perm) {

int ret;

lock(&dent->inode->lock);

PAL_HANDLE palhdl;
ret = chroot_temp_open(dent, dent->inode->type, &palhdl);
if (ret < 0)
goto out;
return ret;

mode_t host_perm = HOST_PERM(perm);
PAL_STREAM_ATTR attr = {.share_flags = host_perm};
ret = PalStreamAttributesSetByHandle(palhdl, &attr);
PalObjectClose(palhdl);
if (ret < 0) {
ret = pal_to_unix_errno(ret);
goto out;
}

dent->inode->perm = perm;
ret = 0;
if (ret < 0)
return pal_to_unix_errno(ret);

out:
unlock(&dent->inode->lock);
return ret;
return 0;
}

struct libos_fs_ops chroot_fs_ops = {
Expand Down

0 comments on commit 12bd9f0

Please sign in to comment.