From 698a3c0cb73ce81e1ae8d90121b4902f341c15b1 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 6 Jun 2021 20:25:34 +0900 Subject: [PATCH] kernel: change signatures for vfs interfaces to match reality --- base/usr/include/kernel/vfs.h | 50 +++++++++++++------------- kernel/arch/x86_64/ps2hid.c | 2 +- kernel/arch/x86_64/vbox.c | 6 ++-- kernel/arch/x86_64/vmware.c | 2 +- kernel/audio/snd.c | 12 +++---- kernel/net/e1000.c | 6 ++-- kernel/vfs/packetfs.c | 18 +++++----- kernel/vfs/pipe.c | 4 +-- kernel/vfs/portio.c | 4 +-- kernel/vfs/procfs.c | 68 +++++++++++++++++------------------ kernel/vfs/ramdisk.c | 18 +++++----- kernel/vfs/random.c | 2 +- kernel/vfs/tarfs.c | 10 +++--- kernel/vfs/tmpfs.c | 19 +++++----- kernel/vfs/tty.c | 18 +++++----- kernel/vfs/unixpipe.c | 4 +-- kernel/vfs/vfs.c | 50 ++++++++++++-------------- kernel/vfs/zero.c | 8 ++--- kernel/video/lfbvideo.c | 8 ++--- 19 files changed, 153 insertions(+), 156 deletions(-) diff --git a/base/usr/include/kernel/vfs.h b/base/usr/include/kernel/vfs.h index 93b74bf5..41a6e8fb 100644 --- a/base/usr/include/kernel/vfs.h +++ b/base/usr/include/kernel/vfs.h @@ -42,29 +42,29 @@ struct fs_node; -typedef uint64_t (*read_type_t) (struct fs_node *, uint64_t, uint64_t, uint8_t *); -typedef uint64_t (*write_type_t) (struct fs_node *, uint64_t, uint64_t, uint8_t *); +typedef ssize_t (*read_type_t) (struct fs_node *, off_t, size_t, uint8_t *); +typedef ssize_t (*write_type_t) (struct fs_node *, off_t, size_t, uint8_t *); typedef void (*open_type_t) (struct fs_node *, unsigned int flags); typedef void (*close_type_t) (struct fs_node *); -typedef struct dirent *(*readdir_type_t) (struct fs_node *, uint64_t); +typedef struct dirent *(*readdir_type_t) (struct fs_node *, unsigned long); typedef struct fs_node *(*finddir_type_t) (struct fs_node *, char *name); -typedef int (*create_type_t) (struct fs_node *, char *name, uint16_t permission); +typedef int (*create_type_t) (struct fs_node *, char *name, mode_t permission); typedef int (*unlink_type_t) (struct fs_node *, char *name); -typedef int (*mkdir_type_t) (struct fs_node *, char *name, uint16_t permission); -typedef int (*ioctl_type_t) (struct fs_node *, int request, void * argp); +typedef int (*mkdir_type_t) (struct fs_node *, char *name, mode_t permission); +typedef int (*ioctl_type_t) (struct fs_node *, unsigned long request, void * argp); typedef int (*get_size_type_t) (struct fs_node *); -typedef int (*chmod_type_t) (struct fs_node *, int mode); +typedef int (*chmod_type_t) (struct fs_node *, mode_t mode); typedef int (*symlink_type_t) (struct fs_node *, char * name, char * value); -typedef int (*readlink_type_t) (struct fs_node *, char * buf, size_t size); +typedef ssize_t (*readlink_type_t) (struct fs_node *, char * buf, size_t size); typedef int (*selectcheck_type_t) (struct fs_node *); typedef int (*selectwait_type_t) (struct fs_node *, void * process); -typedef int (*chown_type_t) (struct fs_node *, int, int); -typedef void (*truncate_type_t) (struct fs_node *); +typedef int (*chown_type_t) (struct fs_node *, uid_t, gid_t); +typedef int (*truncate_type_t) (struct fs_node *); typedef struct fs_node { char name[256]; /* The filename. */ void * device; /* Device object (optional) */ - uint64_t mask; /* The permissions mask. */ + mode_t mask; /* The permissions mask. */ uid_t uid; /* The owning user. */ uid_t gid; /* The owning group. */ uint64_t flags; /* Flags (node type, etc). */ @@ -74,9 +74,9 @@ typedef struct fs_node { uint64_t open_flags; /* Flags passed to open (read/write/append, etc.) */ /* times */ - uint64_t atime; /* Accessed */ - uint64_t mtime; /* Modified */ - uint64_t ctime; /* Created */ + time_t atime; /* Accessed */ + time_t mtime; /* Modified */ + time_t ctime; /* Created */ /* File operations */ read_type_t read; @@ -116,26 +116,26 @@ extern fs_node_t *fs_root; extern int pty_create(void *size, fs_node_t ** fs_master, fs_node_t ** fs_slave); int has_permission(fs_node_t *node, int permission_bit); -uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); -uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); +ssize_t read_fs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer); +ssize_t write_fs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer); void open_fs(fs_node_t *node, unsigned int flags); void close_fs(fs_node_t *node); -struct dirent *readdir_fs(fs_node_t *node, uint64_t index); +struct dirent *readdir_fs(fs_node_t *node, unsigned long index); fs_node_t *finddir_fs(fs_node_t *node, char *name); -int mkdir_fs(char *name, uint16_t permission); -int create_file_fs(char *name, uint16_t permission); -fs_node_t *kopen(const char *filename, uint64_t flags); +int mkdir_fs(char *name, mode_t permission); +int create_file_fs(char *name, mode_t permission); +fs_node_t *kopen(const char *filename, unsigned int flags); char *canonicalize_path(const char *cwd, const char *input); fs_node_t *clone_fs(fs_node_t * source); -int ioctl_fs(fs_node_t *node, int request, void * argp); -int chmod_fs(fs_node_t *node, int mode); -int chown_fs(fs_node_t *node, int uid, int gid); +int ioctl_fs(fs_node_t *node, unsigned long request, void * argp); +int chmod_fs(fs_node_t *node, mode_t mode); +int chown_fs(fs_node_t *node, uid_t uid, gid_t gid); int unlink_fs(char * name); int symlink_fs(char * value, char * name); -int readlink_fs(fs_node_t * node, char * buf, size_t size); +ssize_t readlink_fs(fs_node_t * node, char * buf, size_t size); int selectcheck_fs(fs_node_t * node); int selectwait_fs(fs_node_t * node, void * process); -void truncate_fs(fs_node_t * node); +int truncate_fs(fs_node_t * node); void vfs_install(void); void * vfs_mount(const char * path, fs_node_t * local_root); diff --git a/kernel/arch/x86_64/ps2hid.c b/kernel/arch/x86_64/ps2hid.c index 9eb531bf..df8ca2e6 100644 --- a/kernel/arch/x86_64/ps2hid.c +++ b/kernel/arch/x86_64/ps2hid.c @@ -223,7 +223,7 @@ static void ps2_mouse_handle(uint8_t data_byte) { } } -static int ioctl_mouse(fs_node_t * node, int request, void * argp) { +static int ioctl_mouse(fs_node_t * node, unsigned long request, void * argp) { if (request == 1) { mouse_cycle = 0; return 0; diff --git a/kernel/arch/x86_64/vbox.c b/kernel/arch/x86_64/vbox.c index 2ddf09c8..b51f357b 100644 --- a/kernel/arch/x86_64/vbox.c +++ b/kernel/arch/x86_64/vbox.c @@ -217,7 +217,7 @@ static void mouse_on_off(unsigned int status) { outportl(vbox_port, vbox_phys_mouse); } -static int ioctl_mouse(fs_node_t * node, int request, void * argp) { +static int ioctl_mouse(fs_node_t * node, unsigned long request, void * argp) { if (request == 1) { /* Disable */ mouse_on_off(VBOX_MOUSE_OFF); @@ -234,7 +234,7 @@ static int ioctl_mouse(fs_node_t * node, int request, void * argp) { return -1; } -uint64_t write_pointer(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_pointer(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { if (!mouse_state) { return -1; } @@ -245,7 +245,7 @@ uint64_t write_pointer(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t return size; } -uint64_t write_rectpipe(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_rectpipe(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { (void)node; (void)offset; diff --git a/kernel/arch/x86_64/vmware.c b/kernel/arch/x86_64/vmware.c index 4b4c7f67..6f8fbf11 100644 --- a/kernel/arch/x86_64/vmware.c +++ b/kernel/arch/x86_64/vmware.c @@ -465,7 +465,7 @@ static void vmware_resize(void * data, char * name) { } } -static int ioctl_mouse(fs_node_t * node, int request, void * argp) { +static int ioctl_mouse(fs_node_t * node, unsigned long request, void * argp) { switch (request) { case 1: /* Disable */ diff --git a/kernel/audio/snd.c b/kernel/audio/snd.c index bb3ee259..4d02e4aa 100644 --- a/kernel/audio/snd.c +++ b/kernel/audio/snd.c @@ -32,12 +32,12 @@ #define SND_BUF_SIZE 0x4000 -static uint64_t snd_dsp_write(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer); -static int snd_dsp_ioctl(fs_node_t * node, int request, void * argp); +static ssize_t snd_dsp_write(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer); +static int snd_dsp_ioctl(fs_node_t * node, unsigned long request, void * argp); static void snd_dsp_open(fs_node_t * node, unsigned int flags); static void snd_dsp_close(fs_node_t * node); -static int snd_mixer_ioctl(fs_node_t * node, int request, void * argp); +static int snd_mixer_ioctl(fs_node_t * node, unsigned long request, void * argp); static void snd_mixer_open(fs_node_t * node, unsigned int flags); static void snd_mixer_close(fs_node_t * node); @@ -105,7 +105,7 @@ snd_unregister_cleanup: return rv; } -static uint64_t snd_dsp_write(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t snd_dsp_write(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { if (!_devices.length) return -1; /* No sink available. */ struct dsp_node * dsp = node->device; @@ -122,7 +122,7 @@ static uint64_t snd_dsp_write(fs_node_t * node, uint64_t offset, uint64_t size, return out; } -static int snd_dsp_ioctl(fs_node_t * node, int request, void * argp) { +static int snd_dsp_ioctl(fs_node_t * node, unsigned long request, void * argp) { /* Potentially use this to set sample rates in the future */ struct dsp_node * dsp = node->device; if (request == 4) { @@ -178,7 +178,7 @@ static snd_device_t * snd_device_by_id(uint32_t device_id) { return out; } -static int snd_mixer_ioctl(fs_node_t * node, int request, void * argp) { +static int snd_mixer_ioctl(fs_node_t * node, unsigned long request, void * argp) { switch (request) { case SND_MIXER_GET_KNOBS: { snd_knob_list_t * list = argp; diff --git a/kernel/net/e1000.c b/kernel/net/e1000.c index 77da4646..17ca5271 100644 --- a/kernel/net/e1000.c +++ b/kernel/net/e1000.c @@ -285,7 +285,7 @@ static void init_tx(struct e1000_nic * device) { read_command(device, E1000_REG_TCTRL)); } -static int ioctl_e1000(fs_node_t * node, int request, void * argp) { +static int ioctl_e1000(fs_node_t * node, unsigned long request, void * argp) { struct e1000_nic * nic = node->device; switch (request) { @@ -310,14 +310,14 @@ static int ioctl_e1000(fs_node_t * node, int request, void * argp) { } } -static uint64_t write_e1000(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_e1000(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { struct e1000_nic * nic = node->device; /* write packet */ send_packet(nic, buffer, size); return size; } -static uint64_t read_e1000(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_e1000(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { if (size != 8092) return 0; struct e1000_nic * nic = node->device; diff --git a/kernel/vfs/packetfs.c b/kernel/vfs/packetfs.c index dabb3907..254ab74e 100644 --- a/kernel/vfs/packetfs.c +++ b/kernel/vfs/packetfs.c @@ -123,7 +123,7 @@ static pex_client_t * create_client(pex_ex_t * p) { return out; } -static uint64_t read_server(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t read_server(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { pex_ex_t * p = (pex_ex_t *)node->device; debug_print(INFO, "[pex] server read(...)"); @@ -141,13 +141,13 @@ static uint64_t read_server(fs_node_t * node, uint64_t offset, uint64_t size, ui } memcpy(buffer, packet, packet->size + sizeof(packet_t)); - uint64_t out = packet->size + sizeof(packet_t); + ssize_t out = packet->size + sizeof(packet_t); free(packet); return out; } -static uint64_t write_server(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t write_server(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { pex_ex_t * p = (pex_ex_t *)node->device; debug_print(INFO, "[pex] server write(...)"); @@ -176,7 +176,7 @@ static uint64_t write_server(fs_node_t * node, uint64_t offset, uint64_t size, u return send_to_client(p, head->target, size - sizeof(header_t), head->data) + sizeof(header_t); } -static int ioctl_server(fs_node_t * node, int request, void * argp) { +static int ioctl_server(fs_node_t * node, unsigned long request, void * argp) { pex_ex_t * p = (pex_ex_t *)node->device; switch (request) { @@ -187,7 +187,7 @@ static int ioctl_server(fs_node_t * node, int request, void * argp) { } } -static uint64_t read_client(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t read_client(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { pex_client_t * c = (pex_client_t *)node->inode; if (c->parent != node->device) { printf("pex: Invalid device endpoint on client read?\n"); @@ -208,7 +208,7 @@ static uint64_t read_client(fs_node_t * node, uint64_t offset, uint64_t size, ui } memcpy(buffer, &packet->data, packet->size); - uint32_t out = packet->size; + ssize_t out = packet->size; debug_print(INFO, "[pex] Client received packet of size %zu", packet->size); if (out == 0) { @@ -219,7 +219,7 @@ static uint64_t read_client(fs_node_t * node, uint64_t offset, uint64_t size, ui return out; } -static uint64_t write_client(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t write_client(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { pex_client_t * c = (pex_client_t *)node->inode; if (c->parent != node->device) { debug_print(WARNING, "[pex] Invalid device endpoint on client write?"); @@ -239,7 +239,7 @@ static uint64_t write_client(fs_node_t * node, uint64_t offset, uint64_t size, u return size; } -static int ioctl_client(fs_node_t * node, int request, void * argp) { +static int ioctl_client(fs_node_t * node, unsigned long request, void * argp) { pex_client_t * c = (pex_client_t *)node->inode; switch (request) { @@ -414,7 +414,7 @@ static fs_node_t * finddir_packetfs(fs_node_t * node, char * name) { return NULL; } -static int create_packetfs(fs_node_t *parent, char *name, uint16_t permission) { +static int create_packetfs(fs_node_t *parent, char *name, mode_t permission) { if (!name) return -EINVAL; pex_t * p = (pex_t *)parent->device; diff --git a/kernel/vfs/pipe.c b/kernel/vfs/pipe.c index 2d2c3e07..636e4bf9 100644 --- a/kernel/vfs/pipe.c +++ b/kernel/vfs/pipe.c @@ -108,7 +108,7 @@ static void pipe_alert_waiters(pipe_device_t * pipe) { spin_unlock(pipe->alert_lock); } -uint64_t read_pipe(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t read_pipe(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { /* Retreive the pipe object associated with this file node */ pipe_device_t * pipe = (pipe_device_t *)node->device; @@ -138,7 +138,7 @@ uint64_t read_pipe(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buf return collected; } -uint64_t write_pipe(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t write_pipe(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { /* Retreive the pipe object associated with this file node */ pipe_device_t * pipe = (pipe_device_t *)node->device; diff --git a/kernel/vfs/portio.c b/kernel/vfs/portio.c index 08393801..950d9168 100644 --- a/kernel/vfs/portio.c +++ b/kernel/vfs/portio.c @@ -15,7 +15,7 @@ #include #include -static uint64_t read_port(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_port(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { switch (size) { case 1: buffer[0] = inportb(offset); @@ -36,7 +36,7 @@ static uint64_t read_port(fs_node_t *node, uint64_t offset, uint64_t size, uint8 return size; } -static uint64_t write_port(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_port(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { switch (size) { case 1: outportb(offset, buffer[0]); diff --git a/kernel/vfs/procfs.c b/kernel/vfs/procfs.c index cbfd2e2f..5e6ff870 100644 --- a/kernel/vfs/procfs.c +++ b/kernel/vfs/procfs.c @@ -56,7 +56,7 @@ static fs_node_t * procfs_generic_create(const char * name, read_type_t read_fun return fnode; } -static uint64_t proc_cmdline_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t proc_cmdline_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; process_t * proc = process_from_pid(node->inode); @@ -69,7 +69,7 @@ static uint64_t proc_cmdline_func(fs_node_t *node, uint64_t offset, uint64_t siz snprintf(buf, 100, "%s", proc->name); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -92,14 +92,14 @@ static uint64_t proc_cmdline_func(fs_node_t *node, uint64_t offset, uint64_t siz } size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); return size; } -static uint64_t proc_status_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t proc_status_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[2048]; process_t * proc = process_from_pid(node->inode); process_t * parent = process_get_parent(proc); @@ -173,7 +173,7 @@ static uint64_t proc_status_func(fs_node_t *node, uint64_t offset, uint64_t size ); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -252,7 +252,7 @@ static fs_node_t * procfs_procdir_create(process_t * process) { return fnode; } -static uint64_t cpuinfo_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t cpuinfo_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[4096]; size_t _bsize = 0; @@ -278,14 +278,14 @@ static uint64_t cpuinfo_func(fs_node_t *node, uint64_t offset, uint64_t size, ui } #endif - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); return size; } -static uint64_t meminfo_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t meminfo_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; size_t total = mmu_total_memory(); size_t free = total - mmu_used_memory(); @@ -298,7 +298,7 @@ static uint64_t meminfo_func(fs_node_t *node, uint64_t offset, uint64_t size, ui , total, free, kheap); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -306,7 +306,7 @@ static uint64_t meminfo_func(fs_node_t *node, uint64_t offset, uint64_t size, ui } #ifdef __x86_64__ -static uint64_t pat_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t pat_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; uint32_t pat_value_low, pat_value_high; @@ -353,7 +353,7 @@ static uint64_t pat_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ ); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -361,27 +361,27 @@ static uint64_t pat_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ } #endif -static uint64_t uptime_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t uptime_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; unsigned long timer_ticks, timer_subticks; relative_time(0,0,&timer_ticks,&timer_subticks); snprintf(buf, 100, "%lu.%06lu\n", timer_ticks, timer_subticks); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); return size; } -static uint64_t cmdline_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t cmdline_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; const char * cmdline = arch_get_cmdline(); snprintf(buf, 1000, "%s\n", cmdline ? cmdline : ""); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -389,7 +389,7 @@ static uint64_t cmdline_func(fs_node_t *node, uint64_t offset, uint64_t size, ui return 0; } -static uint64_t version_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t version_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; char version_number[512]; snprintf(version_number, 510, @@ -407,19 +407,19 @@ static uint64_t version_func(fs_node_t *node, uint64_t offset, uint64_t size, ui __kernel_arch); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); return size; } -static uint64_t compiler_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t compiler_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char buf[1024]; snprintf(buf, 1000, "%s\n", __kernel_compiler_version); size_t _bsize = strlen(buf); - if (offset > _bsize) return 0; + if ((size_t)offset > _bsize) return 0; if (size > _bsize - offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); @@ -455,7 +455,7 @@ static void mount_recurse(char * buf, tree_node_t * node, size_t height) { } } -static uint64_t mounts_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t mounts_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char * buf = malloc(4096); buf[0] = '\0'; @@ -463,7 +463,7 @@ static uint64_t mounts_func(fs_node_t *node, uint64_t offset, uint64_t size, uin mount_recurse(buf, fs_tree->root, 0); size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -474,7 +474,7 @@ static uint64_t mounts_func(fs_node_t *node, uint64_t offset, uint64_t size, uin return size; } -static uint64_t modules_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t modules_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { #if 0 list_t * hash_keys = hashmap_keys(modules_get_list()); char * buf = malloc(hash_keys->length * 512); @@ -506,7 +506,7 @@ static uint64_t modules_func(fs_node_t *node, uint64_t offset, uint64_t size, ui free(hash_keys); size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -521,7 +521,7 @@ static uint64_t modules_func(fs_node_t *node, uint64_t offset, uint64_t size, ui extern hashmap_t * fs_types; /* from kernel/fs/vfs.c */ -static uint64_t filesystems_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t filesystems_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { list_t * hash_keys = hashmap_keys(fs_types); char * buf = malloc(hash_keys->length * 512); unsigned int soffset = 0; @@ -532,7 +532,7 @@ static uint64_t filesystems_func(fs_node_t *node, uint64_t offset, uint64_t size free(hash_keys); size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -543,13 +543,13 @@ static uint64_t filesystems_func(fs_node_t *node, uint64_t offset, uint64_t size return size; } -static uint64_t loader_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t loader_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char * buf = malloc(512); snprintf(buf, 511, "%s\n", arch_get_loader()); size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -563,7 +563,7 @@ static uint64_t loader_func(fs_node_t *node, uint64_t offset, uint64_t size, uin #ifdef __x86_64__ #include #include -static uint64_t irq_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t irq_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char * buf = malloc(4096); unsigned int soffset = 0; @@ -588,7 +588,7 @@ static uint64_t irq_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ soffset += snprintf(&buf[soffset], 100, "imr=0x%04x\n", (inportb(0xA1) << 8) | inportb(0x21)); size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -637,7 +637,7 @@ static void scan_count(uint32_t device, uint16_t vendorid, uint16_t deviceid, vo (*count)++; } -static uint64_t pci_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t pci_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { size_t count = 0; pci_scan(&scan_count, -1, &count); @@ -647,7 +647,7 @@ static uint64_t pci_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ pci_scan(&scan_hit_list, -1, &b); size_t _bsize = b.offset; - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(b.buffer); return 0; } @@ -659,7 +659,7 @@ static uint64_t pci_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ } #endif -static uint64_t smp_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t smp_func(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { char * buf = malloc(4096); unsigned int soffset = 0; @@ -668,7 +668,7 @@ static uint64_t smp_func(fs_node_t *node, uint64_t offset, uint64_t size, uint8_ } size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } @@ -794,7 +794,7 @@ static struct dirent * readdir_procfs_root(fs_node_t *node, uint64_t index) { return out; } -static int readlink_self(fs_node_t * node, char * buf, size_t size) { +static ssize_t readlink_self(fs_node_t * node, char * buf, size_t size) { char tmp[30]; size_t req; snprintf(tmp, 100, "/proc/%d", this_core->current_process->id); diff --git a/kernel/vfs/ramdisk.c b/kernel/vfs/ramdisk.c index bffe7c91..f40f987e 100644 --- a/kernel/vfs/ramdisk.c +++ b/kernel/vfs/ramdisk.c @@ -26,19 +26,19 @@ #include #include -static uint64_t read_ramdisk(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); -static uint64_t write_ramdisk(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer); +static ssize_t read_ramdisk(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer); +static ssize_t write_ramdisk(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer); static void open_ramdisk(fs_node_t *node, unsigned int flags); static void close_ramdisk(fs_node_t *node); -static uint64_t read_ramdisk(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_ramdisk(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { - if (offset > node->length) { + if ((size_t)offset > node->length) { return 0; } - if (offset + size > node->length) { - unsigned int i = node->length - offset; + if ((size_t)offset + size > node->length) { + size_t i = node->length - offset; size = i; } @@ -47,8 +47,8 @@ static uint64_t read_ramdisk(fs_node_t *node, uint64_t offset, uint64_t size, ui return size; } -static uint64_t write_ramdisk(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { - if (offset > node->length) { +static ssize_t write_ramdisk(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { + if ((size_t)offset > node->length) { return 0; } @@ -69,7 +69,7 @@ static void close_ramdisk(fs_node_t * node) { return; } -static int ioctl_ramdisk(fs_node_t * node, int request, void * argp) { +static int ioctl_ramdisk(fs_node_t * node, unsigned long request, void * argp) { switch (request) { case 0x4001: if (this_core->current_process->user != 0) { diff --git a/kernel/vfs/random.c b/kernel/vfs/random.c index 6eaf09a9..782df6a2 100644 --- a/kernel/vfs/random.c +++ b/kernel/vfs/random.c @@ -26,7 +26,7 @@ static uint32_t rand(void) { return w = w ^ (w >> 19) ^ t ^ (t >> 8); } -static uint64_t read_random(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_random(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { size_t s = 0; while (s < size) { buffer[s] = rand() % 0xFF; diff --git a/kernel/vfs/tarfs.c b/kernel/vfs/tarfs.c index d561ab72..affb06a7 100644 --- a/kernel/vfs/tarfs.c +++ b/kernel/vfs/tarfs.c @@ -134,7 +134,7 @@ static int count_slashes(char * string) { return i; } -static struct dirent * readdir_tar_root(fs_node_t *node, uint64_t index) { +static struct dirent * readdir_tar_root(fs_node_t *node, unsigned long index) { if (index == 0) { struct dirent * out = malloc(sizeof(struct dirent)); memset(out, 0x00, sizeof(struct dirent)); @@ -198,13 +198,13 @@ static struct dirent * readdir_tar_root(fs_node_t *node, uint64_t index) { return NULL; } -static uint64_t read_tarfs(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t read_tarfs(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { struct tarfs * self = node->device; struct ustar * file = malloc(sizeof(struct ustar)); ustar_from_offset(self, node->inode, file); size_t file_size = interpret_size(file); - if (offset > file_size) return 0; + if ((size_t)offset > file_size) return 0; if (offset + size > file_size) { size = file_size - offset; } @@ -214,7 +214,7 @@ static uint64_t read_tarfs(fs_node_t * node, uint64_t offset, uint64_t size, uin return read_fs(self->device, offset + node->inode + 512, size, buffer); } -static struct dirent * readdir_tarfs(fs_node_t *node, uint64_t index) { +static struct dirent * readdir_tarfs(fs_node_t *node, unsigned long index) { if (index == 0) { struct dirent * out = malloc(sizeof(struct dirent)); memset(out, 0x00, sizeof(struct dirent)); @@ -338,7 +338,7 @@ static fs_node_t * finddir_tarfs(fs_node_t *node, char *name) { return NULL; } -static int readlink_tarfs(fs_node_t * node, char * buf, size_t size) { +static ssize_t readlink_tarfs(fs_node_t * node, char * buf, size_t size) { struct tarfs * self = node->device; struct ustar * file = malloc(sizeof(struct ustar)); ustar_from_offset(self, node->inode, file); diff --git a/kernel/vfs/tmpfs.c b/kernel/vfs/tmpfs.c index dd591bd5..e0a14cc7 100644 --- a/kernel/vfs/tmpfs.c +++ b/kernel/vfs/tmpfs.c @@ -92,7 +92,7 @@ static int symlink_tmpfs(fs_node_t * parent, char * target, char * name) { return 0; } -static int readlink_tmpfs(fs_node_t * node, char * buf, size_t size) { +static ssize_t readlink_tmpfs(fs_node_t * node, char * buf, size_t size) { struct tmpfs_file * t = (struct tmpfs_file *)(node->device); if (t->type != TMPFS_TYPE_LINK) { printf("tmpfs: not a symlink?\n"); @@ -176,13 +176,13 @@ static char * tmpfs_file_getset_block(struct tmpfs_file * t, size_t blockid, int } -static uint64_t read_tmpfs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_tmpfs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { struct tmpfs_file * t = (struct tmpfs_file *)(node->device); t->atime = now(); uint64_t end; - if (offset + size > t->length) { + if ((size_t)offset + size > t->length) { end = t->length; } else { end = offset + size; @@ -191,7 +191,7 @@ static uint64_t read_tmpfs(fs_node_t *node, uint64_t offset, uint64_t size, uint uint64_t end_block = end / BLOCKSIZE; uint64_t end_size = end - end_block * BLOCKSIZE; uint64_t size_to_read = end - offset; - if (start_block == end_block && offset == end) return 0; + if (start_block == end_block && (size_t)offset == end) return 0; if (start_block == end_block) { void *buf = tmpfs_file_getset_block(t, start_block, 0); memcpy(buffer, (uint8_t *)(((uintptr_t)buf) + ((uintptr_t)offset % BLOCKSIZE)), size_to_read); @@ -220,14 +220,14 @@ static uint64_t read_tmpfs(fs_node_t *node, uint64_t offset, uint64_t size, uint return size_to_read; } -static uint64_t write_tmpfs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_tmpfs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { struct tmpfs_file * t = (struct tmpfs_file *)(node->device); t->atime = now(); t->mtime = t->atime; uint64_t end; - if (offset + size > t->length) { + if ((size_t)offset + size > t->length) { t->length = offset + size; } end = offset + size; @@ -281,7 +281,7 @@ static int chown_tmpfs(fs_node_t * node, int uid, int gid) { return 0; } -static void truncate_tmpfs(fs_node_t * node) { +static int truncate_tmpfs(fs_node_t * node) { struct tmpfs_file * t = (struct tmpfs_file *)(node->device); for (size_t i = 0; i < t->block_count; ++i) { mmu_frame_clear((uintptr_t)t->blocks[i] * 0x1000); @@ -290,6 +290,7 @@ static void truncate_tmpfs(fs_node_t * node) { t->block_count = 0; t->length = 0; t->mtime = node->atime; + return 0; } static void open_tmpfs(fs_node_t * node, unsigned int flags) { @@ -432,7 +433,7 @@ static int unlink_tmpfs(fs_node_t * node, char * name) { return 0; } -static int create_tmpfs(fs_node_t *parent, char *name, uint16_t permission) { +static int create_tmpfs(fs_node_t *parent, char *name, mode_t permission) { if (!name) return -EINVAL; struct tmpfs_dir * d = (struct tmpfs_dir *)parent->device; @@ -459,7 +460,7 @@ static int create_tmpfs(fs_node_t *parent, char *name, uint16_t permission) { return 0; } -static int mkdir_tmpfs(fs_node_t * parent, char * name, uint16_t permission) { +static int mkdir_tmpfs(fs_node_t * parent, char * name, mode_t permission) { if (!name) return -EINVAL; if (!strlen(name)) return -EINVAL; diff --git a/kernel/vfs/tty.c b/kernel/vfs/tty.c index 30a04d1c..d37ce0cc 100644 --- a/kernel/vfs/tty.c +++ b/kernel/vfs/tty.c @@ -261,7 +261,7 @@ static void tty_fill_name(pty_t * pty, char * out) { snprintf((char*)out, 100, "/dev/pts/%zd", pty->name); } -int pty_ioctl(pty_t * pty, int request, void * argp) { +int pty_ioctl(pty_t * pty, unsigned long request, void * argp) { switch (request) { case IOCTLDTYPE: /* @@ -328,13 +328,13 @@ int pty_ioctl(pty_t * pty, int request, void * argp) { } } -uint64_t read_pty_master(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t read_pty_master(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { pty_t * pty = (pty_t *)node->device; /* Standard pipe read */ return ring_buffer_read(pty->out, size, buffer); } -uint64_t write_pty_master(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t write_pty_master(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { pty_t * pty = (pty_t *)node->device; size_t l = 0; @@ -351,7 +351,7 @@ void close_pty_master(fs_node_t * node) { return; } -uint64_t read_pty_slave(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t read_pty_slave(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { pty_t * pty = (pty_t *)node->device; if (pty->tios.c_lflag & ICANON) { @@ -365,7 +365,7 @@ uint64_t read_pty_slave(fs_node_t * node, uint64_t offset, uint64_t size, uint8 } } -uint64_t write_pty_slave(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t write_pty_slave(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { pty_t * pty = (pty_t *)node->device; size_t l = 0; @@ -390,12 +390,12 @@ void close_pty_slave(fs_node_t * node) { * These are separate functions just in case I ever feel the need to do * things differently in the slave or master. */ -int ioctl_pty_master(fs_node_t * node, int request, void * argp) { +int ioctl_pty_master(fs_node_t * node, unsigned long request, void * argp) { pty_t * pty = (pty_t *)node->device; return pty_ioctl(pty, request, argp); } -int ioctl_pty_slave(fs_node_t * node, int request, void * argp) { +int ioctl_pty_slave(fs_node_t * node, unsigned long request, void * argp) { pty_t * pty = (pty_t *)node->device; return pty_ioctl(pty, request, argp); } @@ -502,7 +502,7 @@ static int isatty(fs_node_t * node) { return ioctl_fs(node, IOCTLDTYPE, NULL) == IOCTL_DTYPE_TTY; } -static int readlink_dev_tty(fs_node_t * node, char * buf, size_t size) { +static ssize_t readlink_dev_tty(fs_node_t * node, char * buf, size_t size) { pty_t * pty = NULL; for (unsigned int i = 0; i < ((this_core->current_process->fds->length < 3) ? this_core->current_process->fds->length : 3); ++i) { @@ -552,7 +552,7 @@ static fs_node_t * create_dev_tty(void) { return fnode; } -static struct dirent * readdir_pty(fs_node_t *node, uint64_t index) { +static struct dirent * readdir_pty(fs_node_t *node, unsigned long index) { if (index == 0) { struct dirent * out = malloc(sizeof(struct dirent)); memset(out, 0x00, sizeof(struct dirent)); diff --git a/kernel/vfs/unixpipe.c b/kernel/vfs/unixpipe.c index e4bbc897..4cf13ead 100644 --- a/kernel/vfs/unixpipe.c +++ b/kernel/vfs/unixpipe.c @@ -36,7 +36,7 @@ static void close_complete(struct unix_pipe * self) { ring_buffer_destroy(self->buffer); } -static uint64_t read_unixpipe(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_unixpipe(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { struct unix_pipe * self = node->device; size_t read = 0; @@ -54,7 +54,7 @@ static uint64_t read_unixpipe(fs_node_t * node, uint64_t offset, uint64_t size, return read; } -static uint64_t write_unixpipe(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_unixpipe(fs_node_t * node, off_t offset, size_t size, uint8_t *buffer) { struct unix_pipe * self = node->device; size_t written = 0; diff --git a/kernel/vfs/vfs.c b/kernel/vfs/vfs.c index bc701827..ead92cfb 100644 --- a/kernel/vfs/vfs.c +++ b/kernel/vfs/vfs.c @@ -61,7 +61,7 @@ int has_permission(fs_node_t * node, int permission_bit) { } -static struct dirent * readdir_mapper(fs_node_t *node, uint64_t index) { +static struct dirent * readdir_mapper(fs_node_t *node, unsigned long index) { tree_node_t * d = (tree_node_t *)node->device; if (!d) return NULL; @@ -79,7 +79,7 @@ static struct dirent * readdir_mapper(fs_node_t *node, uint64_t index) { } index -= 2; - unsigned int i = 0; + unsigned long i = 0; foreach(child, d->children) { if (i == index) { /* Recursively print the children */ @@ -145,12 +145,10 @@ int selectwait_fs(fs_node_t * node, void * process) { * @param buffer A buffer to copy of the read data into * @returns Bytes read */ -uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t read_fs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { if (!node) return -ENOENT; - if (node->read) { - uint64_t ret = node->read(node, offset, size, buffer); - return ret; + return node->read(node, offset, size, buffer); } else { return -EINVAL; } @@ -165,12 +163,10 @@ uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffe * @param buffer A buffer to copy from * @returns Bytes written */ -uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +ssize_t write_fs(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { if (!node) return -ENOENT; - if (node->write) { - uint64_t ret = node->write(node, offset, size, buffer); - return ret; + return node->write(node, offset, size, buffer); } else { return -EROFS; } @@ -181,12 +177,14 @@ uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buff * * @param node File to resize */ -void truncate_fs(fs_node_t * node) { - if (!node) return; +int truncate_fs(fs_node_t * node) { + if (!node) return -ENOENT; if (node->truncate) { - node->truncate(node); + return node->truncate(node); } + + return -EINVAL; } //volatile uint8_t tmp_refcount_lock = 0; @@ -254,7 +252,7 @@ void close_fs(fs_node_t *node) { * @param node Node to change permissions for * @param mode New mode bits */ -int chmod_fs(fs_node_t *node, int mode) { +int chmod_fs(fs_node_t *node, mode_t mode) { if (node->chmod) { return node->chmod(node, mode); } @@ -264,7 +262,7 @@ int chmod_fs(fs_node_t *node, int mode) { /** * @brief Change ownership for a file system node. */ -int chown_fs(fs_node_t *node, int uid, int gid) { +int chown_fs(fs_node_t *node, uid_t uid, gid_t gid) { if (node->chown) { return node->chown(node, uid, gid); } @@ -278,14 +276,13 @@ int chown_fs(fs_node_t *node, int uid, int gid) { * @param index Offset to look for * @returns A dirent object. */ -struct dirent *readdir_fs(fs_node_t *node, uint64_t index) { +struct dirent *readdir_fs(fs_node_t *node, unsigned long index) { if (!node) return NULL; if ((node->flags & FS_DIRECTORY) && node->readdir) { - struct dirent *ret = node->readdir(node, index); - return ret; + return node->readdir(node, index); } else { - return (struct dirent *)NULL; + return NULL; } } @@ -300,12 +297,11 @@ fs_node_t *finddir_fs(fs_node_t *node, char *name) { if (!node) return NULL; if ((node->flags & FS_DIRECTORY) && node->finddir) { - fs_node_t *ret = node->finddir(node, name); - return ret; + return node->finddir(node, name); } else { debug_print(WARNING, "Node passed to finddir_fs isn't a directory!"); debug_print(WARNING, "node = %p, name = %s", (void*)node, name); - return (fs_node_t *)NULL; + return NULL; } } @@ -317,7 +313,7 @@ fs_node_t *finddir_fs(fs_node_t *node, char *name) { * @param argp Depends on `request` * @returns Depends on `request` */ -int ioctl_fs(fs_node_t *node, int request, void * argp) { +int ioctl_fs(fs_node_t *node, unsigned long request, void * argp) { if (!node) return -ENOENT; if (node->ioctl) { @@ -335,7 +331,7 @@ int ioctl_fs(fs_node_t *node, int request, void * argp) { * and a file, thus, the use of flag sets should suffice */ -int create_file_fs(char *name, uint16_t permission) { +int create_file_fs(char *name, mode_t permission) { fs_node_t * parent; char *cwd = (char *)(this_core->current_process->wd_name); char *path = canonicalize_path(cwd, name); @@ -434,7 +430,7 @@ int unlink_fs(char * name) { return ret; } -int mkdir_fs(char *name, uint16_t permission) { +int mkdir_fs(char *name, mode_t permission) { fs_node_t * parent; char *cwd = (char *)(this_core->current_process->wd_name); char *path = canonicalize_path(cwd, name); @@ -552,7 +548,7 @@ int symlink_fs(char * target, char * name) { return ret; } -int readlink_fs(fs_node_t *node, char * buf, uint64_t size) { +ssize_t readlink_fs(fs_node_t *node, char * buf, size_t size) { if (!node) return -ENOENT; if (node->readlink) { @@ -1095,7 +1091,7 @@ fs_node_t *kopen_recur(const char *filename, uint64_t flags, uint64_t symlink_de * @param flags Flag bits for read/write mode. * @returns A file system node element that the caller can free. */ -fs_node_t *kopen(const char *filename, uint64_t flags) { +fs_node_t *kopen(const char *filename, unsigned int flags) { debug_print(NOTICE, "kopen(%s)", filename); return kopen_recur(filename, flags, 0, (char *)(this_core->current_process->wd_name)); diff --git a/kernel/vfs/zero.c b/kernel/vfs/zero.c index 9c79958d..4b11714e 100644 --- a/kernel/vfs/zero.c +++ b/kernel/vfs/zero.c @@ -14,11 +14,11 @@ #include #include -static uint64_t read_null(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_null(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { return 0; } -static uint64_t write_null(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_null(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { return 0; } @@ -30,12 +30,12 @@ static void close_null(fs_node_t * node) { return; } -static uint64_t read_zero(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t read_zero(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { memset(buffer, 0x00, size); return 1; } -static uint64_t write_zero(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) { +static ssize_t write_zero(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { return 0; } diff --git a/kernel/video/lfbvideo.c b/kernel/video/lfbvideo.c index 74663c34..003217b2 100644 --- a/kernel/video/lfbvideo.c +++ b/kernel/video/lfbvideo.c @@ -69,7 +69,7 @@ extern void ptr_validate(void * ptr, const char * syscall); * Used by the compositor to get display sizes and by the * resolution changer to initiate modesetting. */ -static int ioctl_vid(fs_node_t * node, int request, void * argp) { +static int ioctl_vid(fs_node_t * node, unsigned long request, void * argp) { switch (request) { case IO_VID_WIDTH: /* Get framebuffer width */ @@ -147,7 +147,7 @@ static fs_node_t * lfb_video_device_create(void /* TODO */) { return fnode; } -static uint64_t framebuffer_func(fs_node_t * node, uint64_t offset, uint64_t size, uint8_t * buffer) { +static ssize_t framebuffer_func(fs_node_t * node, off_t offset, size_t size, uint8_t * buffer) { char * buf = malloc(4096); if (lfb_driver_name) { @@ -169,11 +169,11 @@ static uint64_t framebuffer_func(fs_node_t * node, uint64_t offset, uint64_t siz } size_t _bsize = strlen(buf); - if (offset > _bsize) { + if ((size_t)offset > _bsize) { free(buf); return 0; } - if (size > _bsize - offset) size = _bsize - offset; + if (size > _bsize - (size_t)offset) size = _bsize - offset; memcpy(buffer, buf + offset, size); free(buf);