mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-07-16 06:08:50 +00:00
fs_ops: refactor setattr
- Only perform one operation per call. - Always fail with EPERM if given unsupported flags.
This commit is contained in:
parent
c23623b5a3
commit
6f2a00dd6f
1 changed files with 5 additions and 7 deletions
12
src/fs_ops.c
12
src/fs_ops.c
|
@ -1073,11 +1073,6 @@ bm_setattr (
|
|||
#define FUSE_SET_ATTR_NAME_(name) FUSE_SET_ATTR_##name
|
||||
#define TO_SET(...) BITWISE_OR(FUSE_SET_ATTR_NAME_, __VA_ARGS__)
|
||||
|
||||
int flags_unsupported = TO_SET(MODE, UID, GID);
|
||||
if (mask & flags_unsupported) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (mask & TO_SET(SIZE)) {
|
||||
debug_assert(!is_tag);
|
||||
|
||||
|
@ -1099,9 +1094,8 @@ bm_setattr (
|
|||
fh->data_len = new_len;
|
||||
xgetrealtime(&fh->mtime);
|
||||
fh->flags |= (FH_FLAG_DIRTY | FH_FLAG_MTIME);
|
||||
}
|
||||
|
||||
if (mask & (TO_SET(ATIME, MTIME))) {
|
||||
} else if (mask & TO_SET(ATIME, MTIME)) {
|
||||
if (ctx.flags.ctime) {
|
||||
mask |= TO_SET(MTIME, MTIME_NOW);
|
||||
}
|
||||
|
@ -1138,6 +1132,10 @@ bm_setattr (
|
|||
if (status < 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
} else {
|
||||
log_printf("unsupported setattr flags: %d", mask);
|
||||
return -EPERM;
|
||||
}
|
||||
#undef TO_SET
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue