Make it possible to build the Kernel on a macOS host.

It still requires an ELF compiler and linker, but at least it builds.
I need to get rid of the "Unix" namespace. This does a lot of that.
This commit is contained in:
Andreas Kling 2018-12-02 23:34:50 +01:00
parent 44036f32bc
commit 85b886c2e0
Notes: sideshowbarker 2024-07-19 16:09:22 +09:00
31 changed files with 88 additions and 94 deletions

View file

@ -49,11 +49,11 @@ public:
m_buffer[m_offset++] = ch;
}
Unix::size_t offset() const { return m_offset; }
size_t offset() const { return m_offset; }
private:
ByteBuffer& m_buffer;
Unix::size_t m_offset { 0 };
size_t m_offset { 0 };
};
}

View file

@ -11,18 +11,23 @@ typedef signed short signed_word;
typedef signed int signed_dword;
typedef signed long long int signed_qword;
typedef dword size_t;
typedef signed_dword ssize_t;
typedef unsigned long size_t;
typedef long ssize_t;
static_assert(sizeof(size_t) == sizeof(dword));
static_assert(sizeof(ssize_t) == sizeof(signed_dword));
typedef signed_dword ptrdiff_t;
typedef byte uint8_t;
typedef word uint16_t;
typedef dword uint32_t;
typedef qword uint64_t;
typedef signed_byte int8_t;
typedef signed_word int16_t;
typedef signed_dword int32_t;
typedef signed_qword int64_t;
#else
#include <stdint.h>

View file

@ -16,8 +16,8 @@ public:
void open(Direction);
void close(Direction);
Unix::ssize_t write(const byte*, Unix::size_t);
Unix::ssize_t read(byte*, Unix::size_t);
ssize_t write(const byte*, size_t);
ssize_t read(byte*, size_t);
bool can_read() const;
bool can_write() const;

View file

@ -141,7 +141,7 @@ public:
void* sys$mmap(const Syscall::SC_mmap_params*);
int sys$munmap(void*, size_t size);
int sys$set_mmap_name(void*, size_t, const char*);
int sys$get_dir_entries(int fd, void*, size_t);
ssize_t sys$get_dir_entries(int fd, void*, size_t);
int sys$getcwd(char*, size_t);
int sys$chdir(const char*);
int sys$sleep(unsigned seconds);

View file

@ -7,7 +7,7 @@ extern "C" {
void memcpy(void*, const void*, dword);
void strcpy(char*, const char*);
int strcmp(char const*, const char*);
dword strlen(const char*);
size_t strlen(const char*);
void *memset(void*, byte, dword);
char *strdup(const char*);
int memcmp(const void*, const void*, size_t);

View file

@ -14,13 +14,13 @@ void DoubleBuffer::flip()
m_read_buffer_index = 0;
}
Unix::ssize_t DoubleBuffer::write(const byte* data, size_t size)
ssize_t DoubleBuffer::write(const byte* data, size_t size)
{
m_write_buffer->append(data, size);
return size;
}
Unix::ssize_t DoubleBuffer::read(byte* data, size_t size)
ssize_t DoubleBuffer::read(byte* data, size_t size)
{
if (m_read_buffer_index >= m_read_buffer->size() && !m_write_buffer->isEmpty())
flip();

View file

@ -13,8 +13,8 @@ public:
{
}
Unix::ssize_t write(const byte*, size_t);
Unix::ssize_t read(byte*, size_t);
ssize_t write(const byte*, size_t);
ssize_t read(byte*, size_t);
bool is_empty() const { return m_read_buffer_index >= m_read_buffer->size() && m_write_buffer->isEmpty(); }

View file

@ -17,16 +17,11 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _ELF_H
#define _ELF_H 1
#include <features.h>
__BEGIN_DECLS
#pragma once
/* Standard ELF types. */
#include <stdint.h>
#include <AK/Types.h>
/* Type for a 16-bit quantity. */
typedef uint16_t Elf32_Half;
@ -2640,6 +2635,3 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_M32R_NUM 256 /* Keep this the last entry. */
__END_DECLS
#endif /* elf.h */

View file

@ -29,8 +29,8 @@ typedef struct
static byte alloc_map[POOL_SIZE / CHUNK_SIZE / 8];
volatile dword sum_alloc = 0;
volatile dword sum_free = POOL_SIZE;
volatile size_t sum_alloc = 0;
volatile size_t sum_free = POOL_SIZE;
volatile size_t kmalloc_sum_eternal = 0;
volatile size_t kmalloc_sum_page_aligned = 0;
@ -193,12 +193,12 @@ void kfree(void *ptr)
#endif
}
void* operator new(unsigned int size)
void* operator new(size_t size)
{
return kmalloc(size);
}
void* operator new[](unsigned int size)
void* operator new[](size_t size)
{
return kmalloc(size);
}

View file

@ -8,10 +8,10 @@ void kfree(void*);
bool is_kmalloc_address(void*);
extern volatile dword sum_alloc;
extern volatile dword sum_free;
extern volatile dword kmalloc_sum_eternal;
extern volatile dword kmalloc_sum_page_aligned;
extern volatile size_t sum_alloc;
extern volatile size_t sum_free;
extern volatile size_t kmalloc_sum_eternal;
extern volatile size_t kmalloc_sum_page_aligned;
inline void* operator new(size_t, void* p) { return p; }
inline void* operator new[](size_t, void* p) { return p; }

View file

@ -17,7 +17,6 @@ typedef dword gid_t;
typedef int pid_t;
typedef dword time_t;
typedef dword suseconds_t;
typedef dword size_t;
struct timeval {
time_t tv_sec;

View file

@ -14,8 +14,8 @@ public:
virtual bool hasDataAvailableForRead() const = 0;
virtual Unix::ssize_t read(byte* buffer, Unix::size_t bufferSize) = 0;
virtual Unix::ssize_t write(const byte* buffer, Unix::size_t bufferSize) = 0;
virtual ssize_t read(byte* buffer, size_t bufferSize) = 0;
virtual ssize_t write(const byte* buffer, size_t bufferSize) = 0;
unsigned major() const { return m_major; }
unsigned minor() const { return m_minor; }

View file

@ -12,7 +12,7 @@ public:
DiskDevice& device() { return *m_device; }
const DiskDevice& device() const { return *m_device; }
unsigned blockSize() const { return m_blockSize; }
size_t blockSize() const { return m_blockSize; }
protected:
explicit DiskBackedFS(RetainPtr<DiskDevice>&&);
@ -27,7 +27,7 @@ protected:
bool writeBlocks(unsigned index, unsigned count, const ByteBuffer&);
private:
unsigned m_blockSize { 0 };
size_t m_blockSize { 0 };
RetainPtr<DiskDevice> m_device;
mutable SpinLock m_blockCacheLock;

View file

@ -325,7 +325,7 @@ RetainPtr<CoreInode> Ext2FS::get_inode(InodeIdentifier inode) const
return new_inode;
}
Unix::ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*)
ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*)
{
ASSERT(offset >= 0);
if (m_raw_inode.i_size == 0)
@ -335,7 +335,7 @@ Unix::ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, Unix::size_t count, by
// 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) {
Unix::ssize_t nread = min((Unix::off_t)size() - offset, static_cast<Unix::off_t>(count));
ssize_t nread = min((Unix::off_t)size() - offset, static_cast<Unix::off_t>(count));
memcpy(buffer, m_raw_inode.i_block + offset, nread);
return nread;
}
@ -361,8 +361,8 @@ Unix::ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, Unix::size_t count, by
dword offset_into_first_block = offset % block_size;
Unix::ssize_t nread = 0;
Unix::size_t remaining_count = min((Unix::off_t)count, (Unix::off_t)size() - offset);
ssize_t nread = 0;
size_t remaining_count = min((Unix::off_t)count, (Unix::off_t)size() - offset);
byte* out = buffer;
#ifdef EXT2_DEBUG
@ -387,7 +387,7 @@ Unix::ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, Unix::size_t count, by
return nread;
}
Unix::ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const
ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*) const
{
ASSERT(offset >= 0);
ASSERT(inode.fsid() == id());
@ -411,7 +411,7 @@ Unix::ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset
// This avoids wasting an entire block on short links. (Most links are short.)
static const unsigned maxInlineSymlinkLength = 60;
if (isSymbolicLink(e2inode->i_mode) && e2inode->i_size < maxInlineSymlinkLength) {
Unix::ssize_t nread = min((Unix::off_t)e2inode->i_size - offset, static_cast<Unix::off_t>(count));
ssize_t nread = min((Unix::off_t)e2inode->i_size - offset, static_cast<Unix::off_t>(count));
memcpy(buffer, e2inode->i_block + offset, nread);
return nread;
}
@ -431,8 +431,8 @@ Unix::ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset
dword offsetIntoFirstBlock = offset % blockSize();
Unix::ssize_t nread = 0;
Unix::size_t remainingCount = min((Unix::off_t)count, (Unix::off_t)e2inode->i_size - offset);
ssize_t nread = 0;
size_t remainingCount = min((Unix::off_t)count, (Unix::off_t)e2inode->i_size - offset);
byte* out = buffer;
#ifdef EXT2_DEBUG
@ -453,7 +453,7 @@ Unix::ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset
else
offsetIntoBlock = 0;
dword numBytesToCopy = min(blockSize() - offsetIntoBlock, remainingCount);
size_t numBytesToCopy = min(blockSize() - offsetIntoBlock, remainingCount);
memcpy(out, block.pointer() + offsetIntoBlock, numBytesToCopy);
remainingCount -= numBytesToCopy;
nread += numBytesToCopy;

View file

@ -22,7 +22,7 @@ public:
private:
// ^CoreInode
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) override;
virtual ssize_t read_bytes(Unix::off_t, size_t, byte* buffer, FileDescriptor*) override;
virtual void populate_metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
virtual InodeIdentifier lookup(const String& name) override;
@ -74,7 +74,7 @@ private:
virtual InodeMetadata inodeMetadata(InodeIdentifier) const override;
virtual bool set_mtime(InodeIdentifier, dword timestamp) override;
virtual InodeIdentifier create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size, int& error) override;
virtual Unix::ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const override;
virtual ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*) const override;
virtual InodeIdentifier create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t, int& error) override;
virtual InodeIdentifier find_parent_of_inode(InodeIdentifier) const override;
virtual RetainPtr<CoreInode> get_inode(InodeIdentifier) const override;

View file

@ -133,7 +133,7 @@ Unix::off_t FileDescriptor::seek(Unix::off_t offset, int whence)
return m_currentOffset;
}
Unix::ssize_t FileDescriptor::read(byte* buffer, Unix::size_t count)
ssize_t FileDescriptor::read(byte* buffer, size_t count)
{
if (is_fifo()) {
ASSERT(fifo_direction() == FIFO::Reader);
@ -143,12 +143,12 @@ Unix::ssize_t FileDescriptor::read(byte* buffer, Unix::size_t count)
// FIXME: What should happen to m_currentOffset?
return m_vnode->characterDevice()->read(buffer, count);
}
Unix::ssize_t nread = m_vnode->fileSystem()->read_inode_bytes(m_vnode->inode, m_currentOffset, count, buffer, this);
ssize_t nread = m_vnode->fileSystem()->read_inode_bytes(m_vnode->inode, m_currentOffset, count, buffer, this);
m_currentOffset += nread;
return nread;
}
Unix::ssize_t FileDescriptor::write(const byte* data, Unix::size_t size)
ssize_t FileDescriptor::write(const byte* data, size_t size)
{
if (is_fifo()) {
ASSERT(fifo_direction() == FIFO::Writer);
@ -189,7 +189,7 @@ ByteBuffer FileDescriptor::readEntireFile()
if (m_vnode->isCharacterDevice()) {
auto buffer = ByteBuffer::createUninitialized(1024);
Unix::ssize_t nread = m_vnode->characterDevice()->read(buffer.pointer(), buffer.size());
ssize_t nread = m_vnode->characterDevice()->read(buffer.pointer(), buffer.size());
buffer.trim(nread);
return buffer;
}
@ -205,7 +205,7 @@ bool FileDescriptor::isDirectory() const
return m_vnode->metadata().isDirectory();
}
ssize_t FileDescriptor::get_dir_entries(byte* buffer, Unix::size_t size)
ssize_t FileDescriptor::get_dir_entries(byte* buffer, size_t size)
{
auto metadata = m_vnode->metadata();
if (!metadata.isValid())

View file

@ -23,14 +23,14 @@ public:
int close();
Unix::off_t seek(Unix::off_t, int whence);
Unix::ssize_t read(byte*, Unix::size_t);
Unix::ssize_t write(const byte* data, Unix::size_t);
ssize_t read(byte*, size_t);
ssize_t write(const byte* data, size_t);
int stat(Unix::stat*);
bool hasDataAvailableForRead();
bool can_write();
ssize_t get_dir_entries(byte* buffer, Unix::size_t);
ssize_t get_dir_entries(byte* buffer, size_t);
ByteBuffer readEntireFile();

View file

@ -44,20 +44,20 @@ ByteBuffer CoreInode::read_entire(FileDescriptor* descriptor)
size_t initial_size = metadata().size ? metadata().size : 4096;
auto contents = ByteBuffer::createUninitialized(initial_size);
Unix::ssize_t nread;
ssize_t nread;
byte buffer[4096];
byte* out = contents.pointer();
Unix::off_t offset = 0;
for (;;) {
nread = read_bytes(offset, sizeof(buffer), buffer, descriptor);
//kprintf("nread: %u, bufsiz: %u, initial_size: %u\n", nread, sizeof(buffer), initial_size);
ASSERT(nread <= (Unix::ssize_t)sizeof(buffer));
ASSERT(nread <= (ssize_t)sizeof(buffer));
if (nread <= 0)
break;
memcpy(out, buffer, nread);
out += nread;
offset += nread;
ASSERT(offset <= (Unix::ssize_t)initial_size); // FIXME: Support dynamically growing the buffer.
ASSERT(offset <= (ssize_t)initial_size); // FIXME: Support dynamically growing the buffer.
}
if (nread < 0) {
kprintf("CoreInode::read_entire: ERROR: %d\n", nread);
@ -82,20 +82,20 @@ ByteBuffer FS::readEntireInode(InodeIdentifier inode, FileDescriptor* handle) co
size_t initialSize = metadata.size ? metadata.size : 4096;
auto contents = ByteBuffer::createUninitialized(initialSize);
Unix::ssize_t nread;
ssize_t nread;
byte buffer[4096];
byte* out = contents.pointer();
Unix::off_t offset = 0;
for (;;) {
nread = read_inode_bytes(inode, offset, sizeof(buffer), buffer, handle);
//kprintf("nread: %u, bufsiz: %u, initialSize: %u\n", nread, sizeof(buffer), initialSize);
ASSERT(nread <= (Unix::ssize_t)sizeof(buffer));
ASSERT(nread <= (ssize_t)sizeof(buffer));
if (nread <= 0)
break;
memcpy(out, buffer, nread);
out += nread;
offset += nread;
ASSERT(offset <= (Unix::ssize_t)initialSize); // FIXME: Support dynamically growing the buffer.
ASSERT(offset <= (ssize_t)initialSize); // FIXME: Support dynamically growing the buffer.
}
if (nread < 0) {
kprintf("[fs] readInode: ERROR: %d\n", nread);
@ -115,7 +115,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
name[name_length] = '\0';
}
FS::DirectoryEntry::DirectoryEntry(const char* n, Unix::size_t nl, InodeIdentifier i, byte ft)
FS::DirectoryEntry::DirectoryEntry(const char* n, size_t nl, InodeIdentifier i, byte ft)
: name_length(nl)
, inode(i)
, fileType(ft)

View file

@ -33,13 +33,13 @@ public:
virtual bool writeInode(InodeIdentifier, const ByteBuffer&) = 0;
virtual InodeMetadata inodeMetadata(InodeIdentifier) const = 0;
virtual Unix::ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const = 0;
virtual ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*) const = 0;
struct DirectoryEntry {
DirectoryEntry(const char* name, InodeIdentifier, byte fileType);
DirectoryEntry(const char* name, Unix::size_t name_length, InodeIdentifier, byte fileType);
DirectoryEntry(const char* name, size_t name_length, InodeIdentifier, byte fileType);
char name[256];
Unix::size_t name_length { 0 };
size_t name_length { 0 };
InodeIdentifier inode;
byte fileType { 0 };
};
@ -80,7 +80,7 @@ public:
ByteBuffer read_entire(FileDescriptor* = nullptr);
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) = 0;
virtual ssize_t read_bytes(Unix::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;

View file

@ -18,14 +18,14 @@ bool FullDevice::hasDataAvailableForRead() const
return true;
}
Unix::ssize_t FullDevice::read(byte* buffer, Unix::size_t bufferSize)
ssize_t FullDevice::read(byte* buffer, size_t bufferSize)
{
Unix::size_t count = min(GoodBufferSize, bufferSize);
size_t count = min(GoodBufferSize, bufferSize);
memset(buffer, 0, count);
return count;
}
Unix::ssize_t FullDevice::write(const byte*, Unix::size_t bufferSize)
ssize_t FullDevice::write(const byte*, size_t bufferSize)
{
if (bufferSize == 0)
return 0;

View file

@ -8,8 +8,8 @@ public:
FullDevice();
virtual ~FullDevice();
virtual Unix::ssize_t read(byte* buffer, Unix::size_t bufferSize) override;
virtual Unix::ssize_t write(const byte* buffer, Unix::size_t bufferSize) override;
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
virtual bool hasDataAvailableForRead() const override;
};

View file

@ -9,6 +9,6 @@ inline static const Unix::off_t maxFileOffset = 2147483647;
inline static const Unix::off_t maxFileOffset = std::numeric_limits<Unix::off_t>::max();
#endif
static const Unix::size_t GoodBufferSize = 4096;
static const size_t GoodBufferSize = 4096;

View file

@ -17,12 +17,12 @@ bool NullDevice::hasDataAvailableForRead() const
return true;
}
Unix::ssize_t NullDevice::read(byte*, Unix::size_t)
ssize_t NullDevice::read(byte*, size_t)
{
return 0;
}
Unix::ssize_t NullDevice::write(const byte*, Unix::size_t bufferSize)
ssize_t NullDevice::write(const byte*, size_t bufferSize)
{
return min(GoodBufferSize, bufferSize);
}

View file

@ -8,8 +8,8 @@ public:
NullDevice();
virtual ~NullDevice() override;
virtual Unix::ssize_t read(byte* buffer, Unix::size_t bufferSize) override;
virtual Unix::ssize_t write(const byte* buffer, Unix::size_t bufferSize) override;
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
virtual bool hasDataAvailableForRead() const override;
};

View file

@ -34,18 +34,18 @@ bool RandomDevice::hasDataAvailableForRead() const
return true;
}
Unix::ssize_t RandomDevice::read(byte* buffer, Unix::size_t bufferSize)
ssize_t RandomDevice::read(byte* buffer, size_t bufferSize)
{
const int range = 'z' - 'a';
Unix::ssize_t nread = min(bufferSize, GoodBufferSize);
for (Unix::ssize_t i = 0; i < nread; ++i) {
ssize_t nread = min(bufferSize, GoodBufferSize);
for (ssize_t i = 0; i < nread; ++i) {
dword r = myrand() % range;
buffer[i] = 'a' + r;
}
return nread;
}
Unix::ssize_t RandomDevice::write(const byte*, Unix::size_t bufferSize)
ssize_t RandomDevice::write(const byte*, size_t bufferSize)
{
// FIXME: Use input for entropy? I guess that could be a neat feature?
return min(GoodBufferSize, bufferSize);

View file

@ -8,8 +8,8 @@ public:
RandomDevice();
virtual ~RandomDevice() override;
virtual Unix::ssize_t read(byte* buffer, Unix::size_t bufferSize) override;
virtual Unix::ssize_t write(const byte* buffer, Unix::size_t bufferSize) override;
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
virtual bool hasDataAvailableForRead() const override;
};

View file

@ -170,7 +170,7 @@ bool SynthFS::writeInode(InodeIdentifier, const ByteBuffer&)
return false;
}
Unix::ssize_t SynthFS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor* handle) const
ssize_t SynthFS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, size_t count, byte* buffer, FileDescriptor* handle) const
{
ASSERT(inode.fsid() == id());
#ifdef SYNTHFS_DEBUG
@ -200,7 +200,7 @@ Unix::ssize_t SynthFS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offse
}
auto* data = generatedData ? &generatedData : &file.m_data;
Unix::ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
memcpy(buffer, data->pointer() + offset, nread);
if (nread == 0 && handle && handle->generatorCache())
handle->generatorCache().clear();
@ -249,7 +249,7 @@ void SynthFSInode::populate_metadata() const
// Already done when SynthFS created the file.
}
Unix::ssize_t SynthFSInode::read_bytes(Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor* descriptor)
ssize_t SynthFSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor)
{
#ifdef SYNTHFS_DEBUG
kprintf("SynthFS: read_bytes %u\n", index());
@ -269,7 +269,7 @@ Unix::ssize_t SynthFSInode::read_bytes(Unix::off_t offset, Unix::size_t count, b
}
auto* data = generatedData ? &generatedData : &m_data;
Unix::ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
memcpy(buffer, data->pointer() + offset, nread);
if (nread == 0 && descriptor && descriptor->generatorCache())
descriptor->generatorCache().clear();

View file

@ -18,7 +18,7 @@ public:
virtual InodeMetadata inodeMetadata(InodeIdentifier) const override;
virtual bool set_mtime(InodeIdentifier, dword timestamp) override;
virtual InodeIdentifier create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size, int& error) override;
virtual Unix::ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const override;
virtual ssize_t read_inode_bytes(InodeIdentifier, Unix::off_t offset, size_t count, byte* buffer, FileDescriptor*) const override;
virtual InodeIdentifier create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t, int& error) override;
virtual InodeIdentifier find_parent_of_inode(InodeIdentifier) const override;
virtual RetainPtr<CoreInode> get_inode(InodeIdentifier) const override;
@ -50,7 +50,7 @@ public:
private:
// ^CoreInode
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) override;
virtual ssize_t read_bytes(Unix::off_t, size_t, byte* buffer, FileDescriptor*) override;
virtual void populate_metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
virtual InodeIdentifier lookup(const String& name) override;

View file

@ -258,8 +258,6 @@ typedef ::time_t time_t;
typedef dword blksize_t;
typedef dword blkcnt_t;
typedef dword size_t;
typedef signed_dword ssize_t;
#define NCCS 32

View file

@ -17,14 +17,14 @@ bool ZeroDevice::hasDataAvailableForRead() const
return true;
}
Unix::ssize_t ZeroDevice::read(byte* buffer, Unix::size_t bufferSize)
ssize_t ZeroDevice::read(byte* buffer, size_t bufferSize)
{
Unix::size_t count = min(GoodBufferSize, bufferSize);
size_t count = min(GoodBufferSize, bufferSize);
memset(buffer, 0, count);
return count;
}
Unix::ssize_t ZeroDevice::write(const byte*, Unix::size_t bufferSize)
ssize_t ZeroDevice::write(const byte*, size_t bufferSize)
{
return min(GoodBufferSize, bufferSize);
}

View file

@ -8,8 +8,8 @@ public:
ZeroDevice();
virtual ~ZeroDevice() override;
virtual Unix::ssize_t read(byte* buffer, Unix::size_t bufferSize) override;
virtual Unix::ssize_t write(const byte* buffer, Unix::size_t bufferSize) override;
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
virtual bool hasDataAvailableForRead() const override;
};