summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-23 06:53:01 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-23 06:57:00 +0100
commit8bb18fdc565f4fe133f80e64101fb0d663e27bf2 (patch)
tree44a16f30690aa7bad64afb79f44ac04d440a256f
parent69a3aecf6b0e5f1d1a52e7adc6ed2b98cb3b0abe (diff)
downloadserenity-8bb18fdc565f4fe133f80e64101fb0d663e27bf2.zip
Kernel: Get rid of Unix namespace.
This is no longer needed as the Kernel can stand on its own legs now and there won't be any conflict with host system data types.
-rw-r--r--Kernel/Ext2FileSystem.cpp20
-rw-r--r--Kernel/Ext2FileSystem.h14
-rw-r--r--Kernel/FileDescriptor.cpp8
-rw-r--r--Kernel/FileDescriptor.h6
-rw-r--r--Kernel/FileSystem.cpp8
-rw-r--r--Kernel/FileSystem.h14
-rw-r--r--Kernel/InodeMetadata.h42
-rw-r--r--Kernel/Limits.h2
-rw-r--r--Kernel/Makefile2
-rw-r--r--Kernel/MemoryManager.h2
-rw-r--r--Kernel/Process.cpp28
-rw-r--r--Kernel/Process.h16
-rw-r--r--Kernel/SyntheticFileSystem.cpp16
-rw-r--r--Kernel/SyntheticFileSystem.h14
-rw-r--r--Kernel/Syscall.cpp14
-rw-r--r--Kernel/TTY.cpp18
-rw-r--r--Kernel/TTY.h5
-rw-r--r--Kernel/UnixTypes.h9
-rw-r--r--Kernel/kprintf.cpp2
-rw-r--r--LibC/stdarg.h5
-rw-r--r--LibC/sys/select.cpp4
21 files changed, 124 insertions, 125 deletions
diff --git a/Kernel/Ext2FileSystem.cpp b/Kernel/Ext2FileSystem.cpp
index 505fdcc794..4318fe268f 100644
--- a/Kernel/Ext2FileSystem.cpp
+++ b/Kernel/Ext2FileSystem.cpp
@@ -399,7 +399,7 @@ RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
return new_inode;
}
-ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*)
+ssize_t Ext2FSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileDescriptor*)
{
ASSERT(offset >= 0);
if (m_raw_inode.i_size == 0)
@@ -409,7 +409,7 @@ ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
// This avoids wasting an entire block on short links. (Most links are short.)
static const unsigned max_inline_symlink_length = 60;
if (is_symlink() && size() < max_inline_symlink_length) {
- ssize_t nread = min((Unix::off_t)size() - offset, static_cast<Unix::off_t>(count));
+ ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
memcpy(buffer, m_raw_inode.i_block + offset, nread);
return nread;
}
@@ -436,7 +436,7 @@ ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
dword offset_into_first_block = offset % block_size;
ssize_t nread = 0;
- size_t remaining_count = min((Unix::off_t)count, (Unix::off_t)size() - offset);
+ size_t remaining_count = min((off_t)count, (off_t)size() - offset);
byte* out = buffer;
#ifdef EXT2_DEBUG
@@ -462,7 +462,7 @@ ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
return nread;
}
-ssize_t Ext2FSInode::write_bytes(Unix::off_t offset, size_t count, const byte* data, FileDescriptor*)
+ssize_t Ext2FSInode::write_bytes(off_t offset, size_t count, const byte* data, FileDescriptor*)
{
LOCKER(m_lock);
@@ -496,7 +496,7 @@ ssize_t Ext2FSInode::write_bytes(Unix::off_t offset, size_t count, const byte* d
dword offset_into_first_block = offset % block_size;
ssize_t nwritten = 0;
- size_t remaining_count = min((Unix::off_t)count, (Unix::off_t)new_size - offset);
+ size_t remaining_count = min((off_t)count, (off_t)new_size - offset);
const byte* in = data;
#ifdef EXT2_DEBUG
@@ -1006,7 +1006,7 @@ bool Ext2FS::set_block_allocation_state(GroupIndex group, BlockIndex bi, bool ne
return true;
}
-RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, Unix::mode_t mode, int& error)
+RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error)
{
ASSERT(parent_id.fsid() == fsid());
@@ -1047,7 +1047,7 @@ RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const Strin
return inode;
}
-RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, Unix::mode_t mode, unsigned size, int& error)
+RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, unsigned size, int& error)
{
ASSERT(parent_id.fsid() == fsid());
auto parent_inode = get_inode(parent_id);
@@ -1217,7 +1217,7 @@ void Ext2FSInode::one_retain_left()
// FIXME: I would like to not live forever, but uncached Ext2FS is fucking painful right now.
}
-int Ext2FSInode::set_atime(Unix::time_t t)
+int Ext2FSInode::set_atime(time_t t)
{
if (fs().is_readonly())
return -EROFS;
@@ -1226,7 +1226,7 @@ int Ext2FSInode::set_atime(Unix::time_t t)
return 0;
}
-int Ext2FSInode::set_ctime(Unix::time_t t)
+int Ext2FSInode::set_ctime(time_t t)
{
if (fs().is_readonly())
return -EROFS;
@@ -1235,7 +1235,7 @@ int Ext2FSInode::set_ctime(Unix::time_t t)
return 0;
}
-int Ext2FSInode::set_mtime(Unix::time_t t)
+int Ext2FSInode::set_mtime(time_t t)
{
if (fs().is_readonly())
return -EROFS;
diff --git a/Kernel/Ext2FileSystem.h b/Kernel/Ext2FileSystem.h
index eea6b17608..9cd09354ed 100644
--- a/Kernel/Ext2FileSystem.h
+++ b/Kernel/Ext2FileSystem.h
@@ -25,19 +25,19 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(Unix::off_t, size_t, byte* buffer, FileDescriptor*) override;
+ virtual ssize_t read_bytes(off_t, size_t, byte* buffer, FileDescriptor*) override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
virtual InodeIdentifier lookup(const String& name) override;
virtual String reverse_lookup(InodeIdentifier) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(Unix::off_t, size_t, const byte* data, FileDescriptor*) override;
+ virtual ssize_t write_bytes(off_t, size_t, const byte* data, FileDescriptor*) override;
virtual bool add_child(InodeIdentifier child_id, const String& name, byte file_type, int& error) override;
virtual bool remove_child(const String& name, int& error) override;
virtual RetainPtr<Inode> parent() const override;
- virtual int set_atime(Unix::time_t) override;
- virtual int set_ctime(Unix::time_t) override;
- virtual int set_mtime(Unix::time_t) override;
+ virtual int set_atime(time_t) override;
+ virtual int set_ctime(time_t) override;
+ virtual int set_mtime(time_t) override;
virtual int increment_link_count() override;
virtual int decrement_link_count() override;
@@ -82,8 +82,8 @@ private:
virtual const char* class_name() const override;
virtual InodeIdentifier root_inode() const override;
- virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size, int& error) override;
- virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t, int& error) override;
+ virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) override;
+ virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override;
unsigned allocate_inode(unsigned preferredGroup, unsigned expectedSize);
diff --git a/Kernel/FileDescriptor.cpp b/Kernel/FileDescriptor.cpp
index 9668af33fa..bb7a6f4bcc 100644
--- a/Kernel/FileDescriptor.cpp
+++ b/Kernel/FileDescriptor.cpp
@@ -66,14 +66,14 @@ RetainPtr<FileDescriptor> FileDescriptor::clone()
return descriptor;
}
-bool additionWouldOverflow(Unix::off_t a, Unix::off_t b)
+bool additionWouldOverflow(off_t a, off_t b)
{
ASSERT(a > 0);
uint64_t ua = a;
return (ua + b) > maxFileOffset;
}
-int FileDescriptor::stat(Unix::stat* buffer)
+int FileDescriptor::fstat(stat* buffer)
{
ASSERT(!is_fifo());
if (!m_inode && !m_device)
@@ -99,7 +99,7 @@ int FileDescriptor::stat(Unix::stat* buffer)
return 0;
}
-Unix::off_t FileDescriptor::seek(Unix::off_t offset, int whence)
+off_t FileDescriptor::seek(off_t offset, int whence)
{
ASSERT(!is_fifo());
if (!m_inode && !m_device)
@@ -114,7 +114,7 @@ Unix::off_t FileDescriptor::seek(Unix::off_t offset, int whence)
if (metadata.isSocket() || metadata.isFIFO())
return -ESPIPE;
- Unix::off_t newOffset;
+ off_t newOffset;
switch (whence) {
case SEEK_SET:
diff --git a/Kernel/FileDescriptor.h b/Kernel/FileDescriptor.h
index 65d3c05a97..77477d2423 100644
--- a/Kernel/FileDescriptor.h
+++ b/Kernel/FileDescriptor.h
@@ -23,10 +23,10 @@ public:
int close();
- Unix::off_t seek(Unix::off_t, int whence);
+ off_t seek(off_t, int whence);
ssize_t read(Process&, byte*, size_t);
ssize_t write(Process&, const byte* data, size_t);
- int stat(Unix::stat*);
+ int fstat(stat*);
bool can_read(Process&);
bool can_write(Process&);
@@ -77,7 +77,7 @@ private:
RetainPtr<Inode> m_inode;
RetainPtr<CharacterDevice> m_device;
- Unix::off_t m_current_offset { 0 };
+ off_t m_current_offset { 0 };
ByteBuffer m_generator_cache;
diff --git a/Kernel/FileSystem.cpp b/Kernel/FileSystem.cpp
index 61d336a215..983f203742 100644
--- a/Kernel/FileSystem.cpp
+++ b/Kernel/FileSystem.cpp
@@ -56,7 +56,7 @@ ByteBuffer Inode::read_entire(FileDescriptor* descriptor)
ssize_t nread;
byte buffer[4096];
byte* out = contents.pointer();
- Unix::off_t offset = 0;
+ off_t offset = 0;
for (;;) {
nread = read_bytes(offset, sizeof(buffer), buffer, descriptor);
ASSERT(nread <= (ssize_t)sizeof(buffer));
@@ -112,17 +112,17 @@ void Inode::will_be_destroyed()
flush_metadata();
}
-int Inode::set_atime(Unix::time_t)
+int Inode::set_atime(time_t)
{
return -ENOTIMPL;
}
-int Inode::set_ctime(Unix::time_t)
+int Inode::set_ctime(time_t)
{
return -ENOTIMPL;
}
-int Inode::set_mtime(Unix::time_t)
+int Inode::set_mtime(time_t)
{
return -ENOTIMPL;
}
diff --git a/Kernel/FileSystem.h b/Kernel/FileSystem.h
index e58d4dd135..99154d4b73 100644
--- a/Kernel/FileSystem.h
+++ b/Kernel/FileSystem.h
@@ -45,8 +45,8 @@ public:
byte fileType { 0 };
};
- virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size, int& error) = 0;
- virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t, int& error) = 0;
+ virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) = 0;
+ virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0;
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const = 0;
@@ -80,20 +80,20 @@ public:
ByteBuffer read_entire(FileDescriptor* = nullptr);
- virtual ssize_t read_bytes(Unix::off_t, size_t, byte* buffer, FileDescriptor*) = 0;
+ virtual ssize_t read_bytes(off_t, size_t, byte* buffer, FileDescriptor*) = 0;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) = 0;
virtual InodeIdentifier lookup(const String& name) = 0;
virtual String reverse_lookup(InodeIdentifier) = 0;
- virtual ssize_t write_bytes(Unix::off_t, size_t, const byte* data, FileDescriptor*) = 0;
+ virtual ssize_t write_bytes(off_t, size_t, const byte* data, FileDescriptor*) = 0;
virtual bool add_child(InodeIdentifier child_id, const String& name, byte file_type, int& error) = 0;
virtual bool remove_child(const String& name, int& error) = 0;
virtual RetainPtr<Inode> parent() const = 0;
bool is_metadata_dirty() const { return m_metadata_dirty; }
- virtual int set_atime(Unix::time_t);
- virtual int set_ctime(Unix::time_t);
- virtual int set_mtime(Unix::time_t);
+ virtual int set_atime(time_t);
+ virtual int set_ctime(time_t);
+ virtual int set_mtime(time_t);
virtual int increment_link_count();
virtual int decrement_link_count();
diff --git a/Kernel/InodeMetadata.h b/Kernel/InodeMetadata.h
index edce447306..a515c48ace 100644
--- a/Kernel/InodeMetadata.h
+++ b/Kernel/InodeMetadata.h
@@ -4,16 +4,16 @@
#include "UnixTypes.h"
#include <AK/HashTable.h>
-inline bool isDirectory(Unix::mode_t mode) { return (mode & 0170000) == 0040000; }
-inline bool isCharacterDevice(Unix::mode_t mode) { return (mode & 0170000) == 0020000; }
-inline bool isBlockDevice(Unix::mode_t mode) { return (mode & 0170000) == 0060000; }
-inline bool isRegularFile(Unix::mode_t mode) { return (mode & 0170000) == 0100000; }
-inline bool isFIFO(Unix::mode_t mode) { return (mode & 0170000) == 0010000; }
-inline bool isSymbolicLink(Unix::mode_t mode) { return (mode & 0170000) == 0120000; }
-inline bool isSocket(Unix::mode_t mode) { return (mode & 0170000) == 0140000; }
-inline bool isSticky(Unix::mode_t mode) { return mode & 01000; }
-inline bool isSetUID(Unix::mode_t mode) { return mode & 04000; }
-inline bool isSetGID(Unix::mode_t mode) { return mode & 02000; }
+inline bool isDirectory(mode_t mode) { return (mode & 0170000) == 0040000; }
+inline bool isCharacterDevice(mode_t mode) { return (mode & 0170000) == 0020000; }
+inline bool isBlockDevice(mode_t mode) { return (mode & 0170000) == 0060000; }
+inline bool isRegularFile(mode_t mode) { return (mode & 0170000) == 0100000; }
+inline bool isFIFO(mode_t mode) { return (mode & 0170000) == 0010000; }
+inline bool isSymbolicLink(mode_t mode) { return (mode & 0170000) == 0120000; }
+inline bool isSocket(mode_t mode) { return (mode & 0170000) == 0140000; }
+inline bool isSticky(mode_t mode) { return mode & 01000; }
+inline bool isSetUID(mode_t mode) { return mode & 04000; }
+inline bool isSetGID(mode_t mode) { return mode & 02000; }
struct InodeMetadata {
bool isValid() const { return inode.is_valid(); }
@@ -39,17 +39,17 @@ struct InodeMetadata {
bool isSetGID() const { return ::isSetGID(mode); }
InodeIdentifier inode;
- Unix::off_t size { 0 };
- Unix::mode_t mode { 0 };
- Unix::uid_t uid { 0 };
- Unix::gid_t gid { 0 };
- Unix::nlink_t linkCount { 0 };
- Unix::time_t atime { 0 };
- Unix::time_t ctime { 0 };
- Unix::time_t mtime { 0 };
- Unix::time_t dtime { 0 };
- Unix::blkcnt_t blockCount { 0 };
- Unix::blksize_t blockSize { 0 };
+ off_t size { 0 };
+ mode_t mode { 0 };
+ uid_t uid { 0 };
+ gid_t gid { 0 };
+ nlink_t linkCount { 0 };
+ time_t atime { 0 };
+ time_t ctime { 0 };
+ time_t mtime { 0 };
+ time_t dtime { 0 };
+ blkcnt_t blockCount { 0 };
+ blksize_t blockSize { 0 };
unsigned majorDevice { 0 };
unsigned minorDevice { 0 };
};
diff --git a/Kernel/Limits.h b/Kernel/Limits.h
index 00d063e7b7..e342507fc9 100644
--- a/Kernel/Limits.h
+++ b/Kernel/Limits.h
@@ -2,7 +2,7 @@
#include "UnixTypes.h"
-inline static const Unix::off_t maxFileOffset = 2147483647;
+inline static const off_t maxFileOffset = 2147483647;
static const size_t GoodBufferSize = 4096;
diff --git a/Kernel/Makefile b/Kernel/Makefile
index 8215dcb8bc..c27dce62b0 100644
--- a/Kernel/Makefile
+++ b/Kernel/Makefile
@@ -75,7 +75,7 @@ KERNEL = kernel
BOOTLOADER = Boot/boot.bin
IMAGE = .floppy-image
ARCH_FLAGS =
-STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib #-nostdinc
+STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc
KERNEL_FLAGS = -ffreestanding -fno-stack-protector -fno-ident -fno-builtin
WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings
FLAVOR_FLAGS = -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic
diff --git a/Kernel/MemoryManager.h b/Kernel/MemoryManager.h
index aa2df1ce80..4aa2741064 100644
--- a/Kernel/MemoryManager.h
+++ b/Kernel/MemoryManager.h
@@ -104,7 +104,7 @@ private:
VMObject(PhysicalAddress, size_t);
String m_name;
bool m_anonymous { false };
- Unix::off_t m_inode_offset { 0 };
+ off_t m_inode_offset { 0 };
size_t m_size { 0 };
RetainPtr<Inode> m_inode;
Vector<RetainPtr<PhysicalPage>> m_physical_pages;
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index fdb1e54745..7b15986166 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -158,7 +158,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
int prot = params->prot;
int flags = params->flags;
int fd = params->fd;
- Unix::off_t offset = params->offset;
+ off_t offset = params->offset;
if (size == 0)
return (void*)-EINVAL;
if ((dword)addr & ~PAGE_MASK || size & ~PAGE_MASK)
@@ -1109,7 +1109,7 @@ int Process::sys$close(int fd)
return rc;
}
-int Process::sys$utime(const char* pathname, const Unix::utimbuf* buf)
+int Process::sys$utime(const char* pathname, const utimbuf* buf)
{
if (!validate_read_str(pathname))
return -EFAULT;
@@ -1123,8 +1123,8 @@ int Process::sys$utime(const char* pathname, const Unix::utimbuf* buf)
auto& inode = *descriptor->inode();
if (inode.fs().is_readonly())
return -EROFS;
- Unix::time_t atime;
- Unix::time_t mtime;
+ time_t atime;
+ time_t mtime;
if (buf) {
atime = buf->actime;
mtime = buf->modtime;
@@ -1190,18 +1190,18 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
return 0;
}
-int Process::sys$fstat(int fd, Unix::stat* statbuf)
+int Process::sys$fstat(int fd, stat* statbuf)
{
if (!validate_write_typed(statbuf))
return -EFAULT;
auto* descriptor = file_descriptor(fd);
if (!descriptor)
return -EBADF;
- descriptor->stat(statbuf);
+ descriptor->fstat(statbuf);
return 0;
}
-int Process::sys$lstat(const char* path, Unix::stat* statbuf)
+int Process::sys$lstat(const char* path, stat* statbuf)
{
if (!validate_write_typed(statbuf))
return -EFAULT;
@@ -1209,11 +1209,11 @@ int Process::sys$lstat(const char* path, Unix::stat* statbuf)
auto descriptor = VFS::the().open(move(path), error, O_NOFOLLOW_NOERROR, 0, cwd_inode()->identifier());
if (!descriptor)
return error;
- descriptor->stat(statbuf);
+ descriptor->fstat(statbuf);
return 0;
}
-int Process::sys$stat(const char* path, Unix::stat* statbuf)
+int Process::sys$stat(const char* path, stat* statbuf)
{
if (!validate_write_typed(statbuf))
return -EFAULT;
@@ -1221,7 +1221,7 @@ int Process::sys$stat(const char* path, Unix::stat* statbuf)
auto descriptor = VFS::the().open(move(path), error, 0, 0, cwd_inode()->identifier());
if (!descriptor)
return error;
- descriptor->stat(statbuf);
+ descriptor->fstat(statbuf);
return 0;
}
@@ -1736,7 +1736,7 @@ int Process::sys$dup2(int old_fd, int new_fd)
return new_fd;
}
-int Process::sys$sigprocmask(int how, const Unix::sigset_t* set, Unix::sigset_t* old_set)
+int Process::sys$sigprocmask(int how, const sigset_t* set, sigset_t* old_set)
{
if (old_set) {
if (!validate_read_typed(old_set))
@@ -1763,7 +1763,7 @@ int Process::sys$sigprocmask(int how, const Unix::sigset_t* set, Unix::sigset_t*
return 0;
}
-int Process::sys$sigpending(Unix::sigset_t* set)
+int Process::sys$sigpending(sigset_t* set)
{
if (!validate_read_typed(set))
return -EFAULT;
@@ -1771,7 +1771,7 @@ int Process::sys$sigpending(Unix::sigset_t* set)
return 0;
}
-int Process::sys$sigaction(int signum, const Unix::sigaction* act, Unix::sigaction* old_act)
+int Process::sys$sigaction(int signum, const sigaction* act, sigaction* old_act)
{
if (signum < 1 || signum >= 32 || signum == SIGKILL || signum == SIGSTOP)
return -EINVAL;
@@ -1836,7 +1836,7 @@ int Process::sys$mkdir(const char* pathname, mode_t mode)
return 0;
}
-Unix::clock_t Process::sys$times(Unix::tms* times)
+clock_t Process::sys$times(tms* times)
{
if (!validate_write_typed(times))
return -EFAULT;
diff --git a/Kernel/Process.h b/Kernel/Process.h
index d58ce0689d..b37fa4562c 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -144,9 +144,9 @@ public:
int sys$close(int fd);
ssize_t sys$read(int fd, void* outbuf, size_t nread);
ssize_t sys$write(int fd, const void*, size_t);
- int sys$fstat(int fd, Unix::stat*);
- int sys$lstat(const char*, Unix::stat*);
- int sys$stat(const char*, Unix::stat*);
+ int sys$fstat(int fd, stat*);
+ int sys$lstat(const char*, stat*);
+ int sys$stat(const char*, stat*);
int sys$lseek(int fd, off_t, int whence);
int sys$kill(pid_t pid, int sig);
int sys$geterror() { return m_error; }
@@ -175,9 +175,9 @@ public:
int sys$getdtablesize();
int sys$dup(int oldfd);
int sys$dup2(int oldfd, int newfd);
- int sys$sigaction(int signum, const Unix::sigaction* act, Unix::sigaction* old_act);
- int sys$sigprocmask(int how, const Unix::sigset_t* set, Unix::sigset_t* old_set);
- int sys$sigpending(Unix::sigset_t*);
+ int sys$sigaction(int signum, const sigaction* act, sigaction* old_act);
+ int sys$sigprocmask(int how, const sigset_t* set, sigset_t* old_set);
+ int sys$sigpending(sigset_t*);
int sys$getgroups(int size, gid_t*);
int sys$setgroups(size_t, const gid_t*);
int sys$pipe(int* pipefd);
@@ -189,8 +189,8 @@ public:
int sys$fcntl(int fd, int cmd, dword extra_arg);
int sys$ioctl(int fd, unsigned request, unsigned arg);
int sys$mkdir(const char* pathname, mode_t mode);
- Unix::clock_t sys$times(Unix::tms*);
- int sys$utime(const char* pathname, const struct Unix::utimbuf*);
+ clock_t sys$times(tms*);
+ int sys$utime(const char* pathname, const struct utimbuf*);
int sys$unlink(const char* pathname);
int gui$create_window(const GUI_WindowParameters*);
diff --git a/Kernel/SyntheticFileSystem.cpp b/Kernel/SyntheticFileSystem.cpp
index c87bf0c8d7..0feb8d022b 100644
--- a/Kernel/SyntheticFileSystem.cpp
+++ b/Kernel/SyntheticFileSystem.cpp
@@ -56,7 +56,7 @@ RetainPtr<SynthFSInode> SynthFS::create_directory(String&& name)
return file;
}
-RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, Unix::mode_t mode)
+RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, mode_t mode)
{
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
file->m_data = contents;
@@ -69,7 +69,7 @@ RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& co
return file;
}
-RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& generator, Unix::mode_t mode)
+RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& generator, mode_t mode)
{
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
file->m_generator = move(generator);
@@ -82,7 +82,7 @@ RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<B
return file;
}
-RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& read_callback, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&& write_callback, Unix::mode_t mode)
+RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& read_callback, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&& write_callback, mode_t mode)
{
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
file->m_generator = move(read_callback);
@@ -150,7 +150,7 @@ InodeIdentifier SynthFS::root_inode() const
return { fsid(), 1 };
}
-RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t mode, unsigned size, int& error)
+RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, unsigned size, int& error)
{
(void) parentInode;
(void) name;
@@ -161,7 +161,7 @@ RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String
return { };
}
-RetainPtr<Inode> SynthFS::create_directory(InodeIdentifier, const String&, Unix::mode_t, int& error)
+RetainPtr<Inode> SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
{
error = -EROFS;
return nullptr;
@@ -200,7 +200,7 @@ InodeMetadata SynthFSInode::metadata() const
return m_metadata;
}
-ssize_t SynthFSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor)
+ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor)
{
#ifdef SYNTHFS_DEBUG
kprintf("SynthFS: read_bytes %u\n", index());
@@ -220,7 +220,7 @@ ssize_t SynthFSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
}
auto* data = generatedData ? &generatedData : &m_data;
- ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
+ ssize_t nread = min(static_cast<off_t>(data->size() - offset), static_cast<off_t>(count));
memcpy(buffer, data->pointer() + offset, nread);
if (nread == 0 && descriptor && descriptor->generator_cache())
descriptor->generator_cache().clear();
@@ -273,7 +273,7 @@ void SynthFSInode::flush_metadata()
{
}
-ssize_t SynthFSInode::write_bytes(Unix::off_t offset, size_t size, const byte* buffer, FileDescriptor*)
+ssize_t SynthFSInode::write_bytes(off_t offset, size_t size, const byte* buffer, FileDescriptor*)
{
if (!m_write_callback)
return -EPERM;
diff --git a/Kernel/SyntheticFileSystem.h b/Kernel/SyntheticFileSystem.h
index a0ad26e87b..b0b5056fe9 100644
--- a/Kernel/SyntheticFileSystem.h
+++ b/Kernel/SyntheticFileSystem.h
@@ -14,8 +14,8 @@ public:
virtual bool initialize() override;
virtual const char* class_name() const override;
virtual InodeIdentifier root_inode() const override;
- virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size, int& error) override;
- virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t, int& error) override;
+ virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) override;
+ virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override;
protected:
@@ -27,9 +27,9 @@ protected:
SynthFS();
RetainPtr<SynthFSInode> create_directory(String&& name);
- RetainPtr<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, Unix::mode_t = 0010644);
- RetainPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, Unix::mode_t = 0100644);
- RetainPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&&, Unix::mode_t = 0100644);
+ RetainPtr<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, mode_t = 0010644);
+ RetainPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, mode_t = 0100644);
+ RetainPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&&, mode_t = 0100644);
InodeIdentifier add_file(RetainPtr<SynthFSInode>&&, InodeIndex parent = RootInodeIndex);
bool remove_file(InodeIndex);
@@ -54,13 +54,13 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(Unix::off_t, size_t, byte* buffer, FileDescriptor*) override;
+ virtual ssize_t read_bytes(off_t, size_t, byte* buffer, FileDescriptor*) override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
virtual InodeIdentifier lookup(const String& name) override;
virtual String reverse_lookup(InodeIdentifier) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(Unix::off_t, size_t, const byte* buffer, FileDescriptor*) override;
+ virtual ssize_t write_bytes(off_t, size_t, const byte* buffer, FileDescriptor*) override;
virtual bool add_child(InodeIdentifier child_id, const String& name, byte file_type, int& error) override;
virtual bool remove_child(const String& name, int& error) override;
virtual RetainPtr<Inode> parent() const override;
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 841ceb0c71..57b98a535d 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -67,9 +67,9 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_get_dir_entries:
return current->sys$get_dir_entries((int)arg1, (void*)arg2, (size_t)arg3);
case Syscall::SC_lstat:
- return current->sys$lstat((const char*)arg1, (Unix::stat*)arg2);
+ return current->sys$lstat((const char*)arg1, (stat*)arg2);
case Syscall::SC_stat:
- return current->sys$stat((const char*)arg1, (Unix::stat*)arg2);
+ return current->sys$stat((const char*)arg1, (stat*)arg2);
case Syscall::SC_getcwd:
return current->sys$getcwd((char*)arg1, (size_t)arg2);
case Syscall::SC_open:
@@ -152,7 +152,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_dup2:
return current->sys$dup2((int)arg1, (int)arg2);
case Syscall::SC_sigaction:
- return current->sys$sigaction((int)arg1, (const Unix::sigaction*)arg2, (Unix::sigaction*)arg3);
+ return current->sys$sigaction((int)arg1, (const sigaction*)arg2, (sigaction*)arg3);
case Syscall::SC_umask:
return current->sys$umask((mode_t)arg1);
case Syscall::SC_getgroups:
@@ -164,7 +164,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
ASSERT_NOT_REACHED();
return 0;
case Syscall::SC_sigprocmask:
- return current->sys$sigprocmask((int)arg1, (const Unix::sigset_t*)arg2, (Unix::sigset_t*)arg3);
+ return current->sys$sigprocmask((int)arg1, (const sigset_t*)arg2, (sigset_t*)arg3);
case Syscall::SC_pipe:
return current->sys$pipe((int*)arg1);
case Syscall::SC_killpg:
@@ -182,13 +182,13 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_ioctl:
return current->sys$ioctl((int)arg1, (unsigned)arg2, (unsigned)arg3);
case Syscall::SC_fstat:
- return current->sys$fstat((int)arg1, (Unix::stat*)arg2);
+ return current->sys$fstat((int)arg1, (stat*)arg2);
case Syscall::SC_mkdir:
return current->sys$mkdir((const char*)arg1, (mode_t)arg2);
case Syscall::SC_times:
- return current->sys$times((Unix::tms*)arg1);
+ return current->sys$times((tms*)arg1);
case Syscall::SC_utime:
- return current->sys$utime((const char*)arg1, (const Unix::utimbuf*)arg2);
+ return current->sys$utime((const char*)arg1, (const utimbuf*)arg2);
case Syscall::SC_sync:
return sync();
case Syscall::SC_unlink:
diff --git a/Kernel/TTY.cpp b/Kernel/TTY.cpp
index 808e2976f0..f5be22e864 100644
--- a/Kernel/TTY.cpp
+++ b/Kernel/TTY.cpp
@@ -82,7 +82,7 @@ void TTY::generate_signal(int signal)
});
}
-void TTY::set_termios(const Unix::termios& t)
+void TTY::set_termios(const termios& t)
{
m_termios = t;
dbgprintf("%s set_termios: ECHO=%u, ISIG=%u, ICANON=%u\n",
@@ -109,8 +109,8 @@ void TTY::set_termios(const Unix::termios& t)
int TTY::ioctl(Process& process, unsigned request, unsigned arg)
{
pid_t pgid;
- Unix::termios* tp;
- Unix::winsize* ws;
+ termios* tp;
+ winsize* ws;
if (process.tty() && process.tty() != this)
return -ENOTTY;
@@ -125,22 +125,22 @@ int TTY::ioctl(Process& process, unsigned request, unsigned arg)
m_pgid = pgid;
return 0;
case TCGETS:
- tp = reinterpret_cast<Unix::termios*>(arg);
- if (!process.validate_write(tp, sizeof(Unix::termios)))
+ tp = reinterpret_cast<termios*>(arg);
+ if (!process.validate_write(tp, sizeof(termios)))
return -EFAULT;
*tp = m_termios;
return 0;
case TCSETS:
case TCSETSF:
case TCSETSW:
- tp = reinterpret_cast<Unix::termios*>(arg);
- if (!process.validate_read(tp, sizeof(Unix::termios)))
+ tp = reinterpret_cast<termios*>(arg);
+ if (!process.validate_read(tp, sizeof(termios)))
return -EFAULT;
set_termios(*tp);
return 0;
case TIOCGWINSZ:
- ws = reinterpret_cast<Unix::winsize*>(arg);
- if (!process.validate_write(ws, sizeof(Unix::winsize)))
+ ws = reinterpret_cast<winsize*>(arg);
+ if (!process.validate_write(ws, sizeof(winsize)))
return -EFAULT;
ws->ws_row = m_rows;
ws->ws_col = m_columns;
diff --git a/Kernel/TTY.h b/Kernel/TTY.h
index 178b474152..686f69dbd7 100644
--- a/Kernel/TTY.h
+++ b/Kernel/TTY.h
@@ -24,8 +24,7 @@ public:
void set_pgid(pid_t pgid) { m_pgid = pgid; }
pid_t pgid() const { return m_pgid; }
- const Unix::termios& termios() const { return m_termios; }
- void set_termios(const Unix::termios&);
+ void set_termios(const termios&);
bool should_generate_signals() const { return m_termios.c_lflag & ISIG; }
bool should_echo_input() const { return m_termios.c_lflag & ECHO; }
bool in_canonical_mode() const { return m_termios.c_lflag & ICANON; }
@@ -47,7 +46,7 @@ private:
DoubleBuffer m_buffer;
pid_t m_pgid { 0 };
- Unix::termios m_termios;
+ termios m_termios;
unsigned short m_rows { 0 };
unsigned short m_columns { 0 };
};
diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h
index 6084a23985..46a4799718 100644
--- a/Kernel/UnixTypes.h
+++ b/Kernel/UnixTypes.h
@@ -1,12 +1,8 @@
#pragma once
-extern "C" {
-
#define FD_SETSIZE 64
struct fd_set { unsigned char bits[FD_SETSIZE / 8]; };
-namespace Unix {
-
#define WNOHANG 1
#define SIG_DFL ((void*)0)
@@ -295,8 +291,3 @@ struct stat {
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
-
-}
-
-}
-
diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp
index a7de0d50dd..bc4da74c4d 100644
--- a/Kernel/kprintf.cpp
+++ b/Kernel/kprintf.cpp
@@ -1,7 +1,7 @@
#include "kprintf.h"
#include "Console.h"
#include "IO.h"
-#include <stdarg.h>
+#include <LibC/stdarg.h>
#include "Process.h"
#include <AK/Types.h>
#include <AK/printf.cpp>
diff --git a/LibC/stdarg.h b/LibC/stdarg.h
index c58efc85fa..366964cb27 100644
--- a/LibC/stdarg.h
+++ b/LibC/stdarg.h
@@ -1,6 +1,11 @@
#pragma once
+#ifdef KERNEL
+#define __BEGIN_DECLS
+#define __END_DECLS
+#else
#include <sys/cdefs.h>
+#endif
__BEGIN_DECLS
diff --git a/LibC/sys/select.cpp b/LibC/sys/select.cpp
index 1c0d7c6aa7..70a46e7850 100644
--- a/LibC/sys/select.cpp
+++ b/LibC/sys/select.cpp
@@ -3,9 +3,13 @@
#include <errno.h>
#include <stdio.h>
+extern "C" {
+
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout)
{
Syscall::SC_select_params params { nfds, readfds, writefds, exceptfds, timeout };
int rc = syscall(SC_select, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
+
+}