mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
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.
This commit is contained in:
parent
69a3aecf6b
commit
8bb18fdc56
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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*);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef KERNEL
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -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, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue