kernel/vfs: Slight refactor to F_SETFL to reduce duplication.

No functional change intended.

Change-Id: Ida1dd3b1629836d3d48598bb98bc2c56cdcf869f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7696
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-05-28 19:05:22 +00:00
committed by waddlesplash
parent 560f1681fa
commit e08f7fd12b
+7 -3
View File
@@ -6202,10 +6202,13 @@ common_fcntl(int fd, int op, size_t argument, bool kernel)
}
case F_SETFL:
{
// Set file descriptor open mode
// we only accept changes to O_APPEND and O_NONBLOCK
argument &= O_APPEND | O_NONBLOCK;
// we only accept changes to certain flags
const int32 modifiableFlags = O_APPEND | O_NONBLOCK;
argument &= modifiableFlags;
if (descriptor->ops->fd_set_flags != NULL) {
status = descriptor->ops->fd_set_flags(descriptor.Get(), argument);
} else if (vnode != NULL && HAS_FS_CALL(vnode, set_flags)) {
@@ -6217,10 +6220,11 @@ common_fcntl(int fd, int op, size_t argument, bool kernel)
if (status == B_OK) {
// update this descriptor's open_mode field
descriptor->open_mode = (descriptor->open_mode
& ~(O_APPEND | O_NONBLOCK)) | argument;
& ~modifiableFlags) | argument;
}
break;
}
case F_GETFL:
// Get file descriptor open mode