diff --git a/src/kernel/apps/rld/rldelf.c b/src/kernel/apps/rld/rldelf.c index 43f04d2b9f..2c4904ca28 100644 --- a/src/kernel/apps/rld/rldelf.c +++ b/src/kernel/apps/rld/rldelf.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/src/kernel/core/arch/x86/arch_cpu.c b/src/kernel/core/arch/x86/arch_cpu.c index 089b2bab33..9ad5a359aa 100755 --- a/src/kernel/core/arch/x86/arch_cpu.c +++ b/src/kernel/core/arch/x86/arch_cpu.c @@ -9,6 +9,7 @@ #include #include #include +#include #include diff --git a/src/kernel/core/arch/x86/arch_int.c b/src/kernel/core/arch/x86/arch_int.c index b6b268dce8..d1ba319fee 100755 --- a/src/kernel/core/arch/x86/arch_int.c +++ b/src/kernel/core/arch/x86/arch_int.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/kernel/core/arch/x86/arch_vm.c b/src/kernel/core/arch/x86/arch_vm.c index 29e384e767..deaf004f91 100755 --- a/src/kernel/core/arch/x86/arch_vm.c +++ b/src/kernel/core/arch/x86/arch_vm.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/src/kernel/core/arch/x86/arch_vm_translation_map.c b/src/kernel/core/arch/x86/arch_vm_translation_map.c index 52a35e49ee..f1f917d26b 100755 --- a/src/kernel/core/arch/x86/arch_vm_translation_map.c +++ b/src/kernel/core/arch/x86/arch_vm_translation_map.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/src/kernel/core/cbuf.c b/src/kernel/core/cbuf.c index 0abaac033f..61606972e8 100644 --- a/src/kernel/core/cbuf.c +++ b/src/kernel/core/cbuf.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/kernel/core/elf.c b/src/kernel/core/elf.c index 6bfec1a312..78357decd9 100644 --- a/src/kernel/core/elf.c +++ b/src/kernel/core/elf.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/src/kernel/core/fd.c b/src/kernel/core/fd.c index 17e07f40ba..1c259ad31a 100644 --- a/src/kernel/core/fd.c +++ b/src/kernel/core/fd.c @@ -61,7 +61,7 @@ new_fd(struct io_context *ioctx, struct file_descriptor *f) } } if (fd < 0) { - fd = ERR_NO_MORE_HANDLES; + fd = EMFILE; goto err; } diff --git a/src/kernel/core/fs/bootfs.c b/src/kernel/core/fs/bootfs.c index 19a21d973b..23d26a4943 100755 --- a/src/kernel/core/fs/bootfs.c +++ b/src/kernel/core/fs/bootfs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -138,7 +139,7 @@ bootfs_delete_vnode(struct bootfs *fs, struct bootfs_vnode *v, bool force_delete // cant delete it if it's in a directory or is a directory // and has children if(!force_delete && ((v->stream.type == STREAM_TYPE_DIR && v->stream.u.dir.dir_head != NULL) || v->dir_next != NULL)) { - return ERR_NOT_ALLOWED; + return EPERM; } // remove it from the global hash table @@ -218,7 +219,7 @@ static int bootfs_insert_in_dir(struct bootfs_vnode *dir, struct bootfs_vnode *v) { if(dir->stream.type != STREAM_TYPE_DIR) - return ERR_INVALID_ARGS; + return EINVAL; v->dir_next = dir->stream.u.dir.dir_head; dir->stream.u.dir.dir_head = v; @@ -355,7 +356,7 @@ bootfs_create_vnode_tree(struct bootfs *fs, struct bootfs_vnode *root) new_vnode = bootfs_create_vnode(fs, leaf); if(new_vnode == NULL) - return ERR_NO_MEMORY; + return ENOMEM; // set up the new node new_vnode->stream.type = STREAM_TYPE_FILE; @@ -390,7 +391,7 @@ bootfs_mount(fs_cookie *_fs, fs_id id, const char *device, void *args, vnode_id fs = kmalloc(sizeof(struct bootfs)); if(fs == NULL) { - err = ERR_NO_MEMORY; + err = ENOMEM; goto err; } @@ -405,14 +406,14 @@ bootfs_mount(fs_cookie *_fs, fs_id id, const char *device, void *args, vnode_id fs->vnode_list_hash = hash_init(BOOTFS_HASH_SIZE, (addr)&v->all_next - (addr)v, &bootfs_vnode_compare_func, &bootfs_vnode_hash_func); if(fs->vnode_list_hash == NULL) { - err = ERR_NO_MEMORY; + err = ENOMEM; goto err2; } // create a vnode v = bootfs_create_vnode(fs, ""); if(v == NULL) { - err = ERR_NO_MEMORY; + err = ENOMEM; goto err3; } @@ -494,7 +495,7 @@ bootfs_lookup(fs_cookie _fs, fs_vnode _dir, const char *name, vnode_id *id) TRACE(("bootfs_lookup: entry dir 0x%x, name '%s'\n", dir, name)); if (dir->stream.type != STREAM_TYPE_DIR) - return ERR_VFS_NOT_DIR; + return ENOTDIR; mutex_lock(&fs->lock); @@ -605,7 +606,7 @@ bootfs_open(fs_cookie _fs, fs_vnode _v, file_cookie *_cookie, stream_type st, in cookie = kmalloc(sizeof(struct bootfs_cookie)); if (cookie == NULL) { - err = ERR_NO_MEMORY; + err = ENOMEM; goto err; } @@ -783,12 +784,12 @@ bootfs_seek(fs_cookie _fs, fs_vnode _v, file_cookie _cookie, off_t pos, int st) cookie->u.file.pos = pos + cookie->s->u.file.len; break; default: - err = ERR_INVALID_ARGS; + err = EINVAL; } break; default: - err = ERR_INVALID_ARGS; + err = EINVAL; } mutex_unlock(&fs->lock); @@ -819,7 +820,7 @@ bootfs_read_dir(fs_cookie _fs, fs_vnode _vnode, file_cookie _cookie, struct dire dirent->d_reclen = strlen(cookie->u.dir.ptr->name); if (sizeof(struct dirent) + dirent->d_reclen + 1 > bufferSize) { - status = ERR_VFS_INSUFFICIENT_BUF; + status = ENOBUFS; goto err; } @@ -912,28 +913,28 @@ bootfs_writepage(fs_cookie _fs, fs_vnode _v, iovecs *vecs, off_t pos) TRACE(("bootfs_writepage: vnode 0x%x, vecs 0x%x, pos 0x%x 0x%x\n", v, vecs, pos)); - return ERR_NOT_ALLOWED; + return EPERM; } static int bootfs_create(fs_cookie _fs, fs_vnode _dir, const char *name, stream_type st, void *create_args, vnode_id *new_vnid) { - return ERR_VFS_READONLY_FS; + return EROFS; } static int bootfs_unlink(fs_cookie _fs, fs_vnode _dir, const char *name) { - return ERR_VFS_READONLY_FS; + return EROFS; } static int bootfs_rename(fs_cookie _fs, fs_vnode _olddir, const char *oldname, fs_vnode _newdir, const char *newname) { - return ERR_VFS_READONLY_FS; + return EROFS; } @@ -985,7 +986,7 @@ bootfs_wstat(fs_cookie _fs, fs_vnode _v, struct stat *stat, int stat_mask) TRACE(("bootfs_wstat: vnode 0x%x (0x%x 0x%x), stat 0x%x\n", v, v->id, stat)); // cannot change anything - return ERR_VFS_READONLY_FS; + return EROFS; } diff --git a/src/kernel/core/fs/devfs.c b/src/kernel/core/fs/devfs.c index 7c58ebb69c..16fdd4719f 100755 --- a/src/kernel/core/fs/devfs.c +++ b/src/kernel/core/fs/devfs.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/src/kernel/core/fs/rootfs.c b/src/kernel/core/fs/rootfs.c index 6bd6505bbd..ca6c42f789 100755 --- a/src/kernel/core/fs/rootfs.c +++ b/src/kernel/core/fs/rootfs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/kernel/core/fs/vfs.c b/src/kernel/core/fs/vfs.c index 2d211d1cfb..ff393c9340 100755 --- a/src/kernel/core/fs/vfs.c +++ b/src/kernel/core/fs/vfs.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/kernel/core/khash.c b/src/kernel/core/khash.c index 61028e0e58..48a2e02451 100644 --- a/src/kernel/core/khash.c +++ b/src/kernel/core/khash.c @@ -106,7 +106,7 @@ int hash_remove(void *_hash_table, void *e) } } - return ERR_GENERAL; + return B_ERROR; } void *hash_find(void *_hash_table, void *e) diff --git a/src/kernel/core/lock.c b/src/kernel/core/lock.c index 698a513b37..6c20be3733 100644 --- a/src/kernel/core/lock.c +++ b/src/kernel/core/lock.c @@ -26,7 +26,7 @@ int recursive_lock_get_recursion(recursive_lock *lock) int recursive_lock_create(recursive_lock *lock) { if(lock == NULL) - return ERR_INVALID_ARGS; + return EINVAL; lock->holder = -1; lock->recursion = 0; lock->sem = create_sem(1, "recursive_lock_sem"); @@ -80,7 +80,7 @@ int mutex_init(mutex *m, const char *in_name) const char *name; if(m == NULL) - return ERR_INVALID_ARGS; + return EINVAL; if(in_name == NULL) name = "mutex_sem"; diff --git a/src/kernel/core/module.c b/src/kernel/core/module.c index f58d358a70..10e0869961 100644 --- a/src/kernel/core/module.c +++ b/src/kernel/core/module.c @@ -5,10 +5,6 @@ ** Distributed under the terms of the NewOS License. */ -// TODO: -// - "offsetof" macro is missing -// -> move it to a public place - #include #include #include @@ -533,21 +529,21 @@ static inline int init_module(module *module) case MOD_INIT: SHOW_ERROR( 0, "circular reference to %s\n", module->name ); - res = ERR_GENERAL; + res = B_ERROR; break; case MOD_UNINIT: SHOW_ERROR( 0, "tried to load module %s which is currently unloading\n", module->name ); - res = ERR_GENERAL; + res = B_ERROR; break; case MOD_ERROR: SHOW_INFO( 0, "cannot load module %s because its earlier unloading failed\n", module->name ); - res = ERR_GENERAL; + res = B_ERROR; break; default: - res = ERR_GENERAL; + res = B_ERROR; } return res; @@ -563,11 +559,11 @@ static inline int uninit_module(module *module) case MOD_INIT: panic( "Trying to unload module %s which is initializing\n", module->name ); - return ERR_GENERAL; + return B_ERROR; case MOD_UNINIT: panic( "Trying to unload module %s which is un-initializing\n", module->name ); - return ERR_GENERAL; + return B_ERROR; case MOD_RDY: { @@ -592,7 +588,7 @@ static inline int uninit_module(module *module) // fall through default: - return ERR_GENERAL; + return B_ERROR; } } @@ -640,12 +636,12 @@ static inline int module_create_dir_iterator( module_iterator *iter, int file, c dir = (struct module_dir_iterator *)kmalloc( sizeof( *dir )); if (dir == NULL ) - return ERR_NO_MEMORY; + return ENOMEM; dir->name = (char *)kstrdup( name ); if (dir->name == NULL ) { kfree( dir ); - return ERR_NO_MEMORY; + return ENOMEM; } dir->file = file; @@ -830,7 +826,7 @@ static inline int module_enter_base_path(module_iterator *iter) if (iter->base_path_id >= (int)num_module_paths ) { SHOW_FLOW0( 3, "no locations left\n" ); - return ERR_NOT_FOUND; + return ENOENT; } SHOW_FLOW(3, "trying base path (%s)\n", module_paths[iter->base_path_id]); diff --git a/src/kernel/core/port.c b/src/kernel/core/port.c index d005095abd..7fcc28c4ba 100644 --- a/src/kernel/core/port.c +++ b/src/kernel/core/port.c @@ -13,7 +13,7 @@ #include #include #include - +#include #include #include diff --git a/src/kernel/core/sem.c b/src/kernel/core/sem.c index f5326595a7..b03362716a 100644 --- a/src/kernel/core/sem.c +++ b/src/kernel/core/sem.c @@ -15,6 +15,7 @@ #include #include #include +#include #include diff --git a/src/kernel/core/syscalls.c b/src/kernel/core/syscalls.c index c71e173411..c53840e7a3 100644 --- a/src/kernel/core/syscalls.c +++ b/src/kernel/core/syscalls.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -19,9 +18,10 @@ #include #include #include -#include #include #include +#include +#include #define INT32TOINT64(x, y) ((int64)(x) | ((int64)(y) << 32)) diff --git a/src/kernel/core/sysctl.c b/src/kernel/core/sysctl.c index eaeb0ecbb5..9eec39d9c6 100644 --- a/src/kernel/core/sysctl.c +++ b/src/kernel/core/sysctl.c @@ -5,9 +5,10 @@ #include #include #include -#include #include +#include + /* Not sure where to put this definition yet (sys/param.h?), * so just add it here * XXX - horrible hack! diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index 8f9c1d5d56..a93e935c3f 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -32,6 +32,7 @@ #include #include #include +#include struct proc_key { proc_id id; diff --git a/src/kernel/core/vm/vm.c b/src/kernel/core/vm/vm.c index fa8b79ca19..91298b5406 100755 --- a/src/kernel/core/vm/vm.c +++ b/src/kernel/core/vm/vm.c @@ -3,6 +3,7 @@ ** Distributed under the terms of the NewOS License. */ #include +#include #include #include #include diff --git a/src/kernel/core/vm/vm_store_anonymous_noswap.c b/src/kernel/core/vm/vm_store_anonymous_noswap.c index eb33076f39..88cc3da61f 100755 --- a/src/kernel/core/vm/vm_store_anonymous_noswap.c +++ b/src/kernel/core/vm/vm_store_anonymous_noswap.c @@ -8,6 +8,7 @@ #include #include #include +#include static void anonymous_destroy(struct vm_store *store) { diff --git a/src/kernel/core/vm/vm_store_device.c b/src/kernel/core/vm/vm_store_device.c index 94f66efc36..9f48ff87ad 100755 --- a/src/kernel/core/vm/vm_store_device.c +++ b/src/kernel/core/vm/vm_store_device.c @@ -9,6 +9,7 @@ #include #include #include +#include struct device_store_data { addr base_addr; diff --git a/src/kernel/core/vm/vm_store_null.c b/src/kernel/core/vm/vm_store_null.c index 61009bfe38..efe9e751f6 100755 --- a/src/kernel/core/vm/vm_store_null.c +++ b/src/kernel/core/vm/vm_store_null.c @@ -10,6 +10,7 @@ #include #include #include +#include static void null_destroy(struct vm_store *store) {