mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibCore: Add helpers to create block and character device files
This commit is contained in:
parent
39c93f63c8
commit
41db527369
2 changed files with 19 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
# include <LibSystem/syscall.h>
|
# include <LibSystem/syscall.h>
|
||||||
# include <serenity.h>
|
# include <serenity.h>
|
||||||
# include <sys/ptrace.h>
|
# include <sys/ptrace.h>
|
||||||
|
# include <sys/sysmacros.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AK_OS_LINUX) && !defined(MFD_CLOEXEC)
|
#if defined(AK_OS_LINUX) && !defined(MFD_CLOEXEC)
|
||||||
|
@ -445,6 +447,18 @@ ErrorOr<int> fcntl(int fd, int command, ...)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AK_OS_SERENITY
|
||||||
|
ErrorOr<void> create_block_device(StringView name, mode_t mode, unsigned major, unsigned minor)
|
||||||
|
{
|
||||||
|
return Core::System::mknod(name, mode | S_IFBLK, makedev(major, minor));
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> create_char_device(StringView name, mode_t mode, unsigned major, unsigned minor)
|
||||||
|
{
|
||||||
|
return Core::System::mknod(name, mode | S_IFCHR, makedev(major, minor));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ErrorOr<void*> mmap(void* address, size_t size, int protection, int flags, int fd, off_t offset, [[maybe_unused]] size_t alignment, [[maybe_unused]] StringView name)
|
ErrorOr<void*> mmap(void* address, size_t size, int protection, int flags, int fd, off_t offset, [[maybe_unused]] size_t alignment, [[maybe_unused]] StringView name)
|
||||||
{
|
{
|
||||||
#ifdef AK_OS_SERENITY
|
#ifdef AK_OS_SERENITY
|
||||||
|
|
|
@ -237,6 +237,11 @@ ErrorOr<void> access(StringView pathname, int mode, int flags = 0);
|
||||||
ErrorOr<DeprecatedString> readlink(StringView pathname);
|
ErrorOr<DeprecatedString> readlink(StringView pathname);
|
||||||
ErrorOr<int> poll(Span<struct pollfd>, int timeout);
|
ErrorOr<int> poll(Span<struct pollfd>, int timeout);
|
||||||
|
|
||||||
|
#ifdef AK_OS_SERENITY
|
||||||
|
ErrorOr<void> create_block_device(StringView name, mode_t mode, unsigned major, unsigned minor);
|
||||||
|
ErrorOr<void> create_char_device(StringView name, mode_t mode, unsigned major, unsigned minor);
|
||||||
|
#endif
|
||||||
|
|
||||||
class AddressInfoVector {
|
class AddressInfoVector {
|
||||||
AK_MAKE_NONCOPYABLE(AddressInfoVector);
|
AK_MAKE_NONCOPYABLE(AddressInfoVector);
|
||||||
AK_MAKE_DEFAULT_MOVABLE(AddressInfoVector);
|
AK_MAKE_DEFAULT_MOVABLE(AddressInfoVector);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue