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:
committed by
waddlesplash
parent
560f1681fa
commit
e08f7fd12b
@@ -6202,10 +6202,13 @@ common_fcntl(int fd, int op, size_t argument, bool kernel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case F_SETFL:
|
case F_SETFL:
|
||||||
|
{
|
||||||
// Set file descriptor open mode
|
// Set file descriptor open mode
|
||||||
|
|
||||||
// we only accept changes to O_APPEND and O_NONBLOCK
|
// we only accept changes to certain flags
|
||||||
argument &= O_APPEND | O_NONBLOCK;
|
const int32 modifiableFlags = O_APPEND | O_NONBLOCK;
|
||||||
|
argument &= modifiableFlags;
|
||||||
|
|
||||||
if (descriptor->ops->fd_set_flags != NULL) {
|
if (descriptor->ops->fd_set_flags != NULL) {
|
||||||
status = descriptor->ops->fd_set_flags(descriptor.Get(), argument);
|
status = descriptor->ops->fd_set_flags(descriptor.Get(), argument);
|
||||||
} else if (vnode != NULL && HAS_FS_CALL(vnode, set_flags)) {
|
} 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) {
|
if (status == B_OK) {
|
||||||
// update this descriptor's open_mode field
|
// update this descriptor's open_mode field
|
||||||
descriptor->open_mode = (descriptor->open_mode
|
descriptor->open_mode = (descriptor->open_mode
|
||||||
& ~(O_APPEND | O_NONBLOCK)) | argument;
|
& ~modifiableFlags) | argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case F_GETFL:
|
case F_GETFL:
|
||||||
// Get file descriptor open mode
|
// Get file descriptor open mode
|
||||||
|
|||||||
Reference in New Issue
Block a user