From 4bfc14b6c747019fa6e3eb3ab776cb6626141f62 Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 10 Nov 2024 20:21:33 +0900 Subject: [PATCH] libroot: add posix_devctl() from POSIX.1-2024 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2ae748b2febcdeca0256e9033119dcf9988ccc74 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8556 Reviewed-by: waddlesplash Tested-by: Commit checker robot Reviewed-by: Jérôme Duval --- headers/posix/devctl.h | 22 ++++++++++++++++++++++ src/system/libroot/posix/Jamfile | 1 + src/system/libroot/posix/devctl.c | 23 +++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 headers/posix/devctl.h create mode 100644 src/system/libroot/posix/devctl.c diff --git a/headers/posix/devctl.h b/headers/posix/devctl.h new file mode 100644 index 0000000000..84b8c8ef1d --- /dev/null +++ b/headers/posix/devctl.h @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _DEVCTL_H_ +#define _DEVCTL_H_ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +int posix_devctl(int fd, int cmd, void* __restrict argument, size_t size, int* __restrict result); + +#ifdef __cplusplus +} +#endif + + +#endif // _DEVCTL_H_ diff --git a/src/system/libroot/posix/Jamfile b/src/system/libroot/posix/Jamfile index 68fdf3ef56..6af92bd9fd 100644 --- a/src/system/libroot/posix/Jamfile +++ b/src/system/libroot/posix/Jamfile @@ -29,6 +29,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { MergeObject <$(architecture)>posix_main.o : assert.cpp cat.cpp + devctl.c dlfcn.c dirent.cpp errno.c diff --git a/src/system/libroot/posix/devctl.c b/src/system/libroot/posix/devctl.c new file mode 100644 index 0000000000..8545f404fa --- /dev/null +++ b/src/system/libroot/posix/devctl.c @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +int +posix_devctl(int fd, int cmd, void* __restrict argument, size_t size, int* __restrict result) +{ + int status = _kern_ioctl(fd, cmd, argument, size); + + if (status < B_OK) + return status; + + if (result != NULL) + *result = status; + + return B_OK; +}