Unify VFS status codes and normal system status codes
All checks were successful
Build documentation / build-and-deploy (push) Successful in 24s

This commit is contained in:
2026-02-12 15:56:37 +01:00
parent fb54483e42
commit f37c34958e
5 changed files with 17 additions and 17 deletions

View File

@@ -10,5 +10,8 @@
#define ST_PERMISSION_ERROR 6 #define ST_PERMISSION_ERROR 6
#define ST_BAD_RESOURCE 7 #define ST_BAD_RESOURCE 7
#define ST_BAD_DEVICE_OP 8 #define ST_BAD_DEVICE_OP 8
#define ST_EXISTS 9
#define ST_OOB_ERROR 10
#define ST_BAD_PATH 11
#endif // _M_STATUS_H #endif // _M_STATUS_H

View File

@@ -5,6 +5,7 @@
#include <libk/string.h> #include <libk/string.h>
#include <limine/requests.h> #include <limine/requests.h>
#include <m/fs_desc_buffer.h> #include <m/fs_desc_buffer.h>
#include <m/status.h>
struct ramdisk_tar_header { struct ramdisk_tar_header {
char filename[100]; char filename[100];
@@ -102,17 +103,17 @@ int ramdiskfs_describe (struct vfs_mountpoint* mountpoint, const char* path,
const char* filename = path_basename (path); const char* filename = path_basename (path);
if (filename == NULL) if (filename == NULL)
return -VFS_BAD_PATH; return -ST_BAD_PATH;
struct ramdisk_tar_file* file = ramdisk_get_file (filename); struct ramdisk_tar_file* file = ramdisk_get_file (filename);
if (file == NULL) if (file == NULL)
return -VFS_NOT_FOUND; return -ST_NOT_FOUND;
desc->size = file->size; desc->size = file->size;
desc->type = FS_FILE; desc->type = FS_FILE;
return VFS_OK; return ST_OK;
} }
int ramdiskfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, int ramdiskfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer,
@@ -122,17 +123,17 @@ int ramdiskfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t
const char* filename = path_basename (path); const char* filename = path_basename (path);
if (filename == NULL) if (filename == NULL)
return -VFS_BAD_PATH; return -ST_BAD_PATH;
struct ramdisk_tar_file* file = ramdisk_get_file (filename); struct ramdisk_tar_file* file = ramdisk_get_file (filename);
if (file == NULL) if (file == NULL)
return -VFS_NOT_FOUND; return -ST_NOT_FOUND;
if (off + size > file->size) if (off + size > file->size)
return -VFS_OOB_ERROR; return -ST_OOB_ERROR;
memcpy (buffer, (void*)((uintptr_t)file->content + off), size); memcpy (buffer, (void*)((uintptr_t)file->content + off), size);
return VFS_OK; return ST_OK;
} }

View File

@@ -5,6 +5,7 @@
#include <libk/lengthof.h> #include <libk/lengthof.h>
#include <libk/std.h> #include <libk/std.h>
#include <libk/string.h> #include <libk/string.h>
#include <m/status.h>
#include <mm/liballoc.h> #include <mm/liballoc.h>
#include <sync/spin_lock.h> #include <sync/spin_lock.h>
#include <sys/debug.h> #include <sys/debug.h>
@@ -78,7 +79,7 @@ int vfs_describe (const char* mountpoint, const char* path, struct fs_desc_buffe
struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint); struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint);
if (vmp == NULL) if (vmp == NULL)
return -VFS_NOT_FOUND; return -ST_NOT_FOUND;
spin_lock (&vmp->lock); spin_lock (&vmp->lock);
@@ -93,7 +94,7 @@ int vfs_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t
struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint); struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint);
if (vmp == NULL) if (vmp == NULL)
return -VFS_NOT_FOUND; return -ST_NOT_FOUND;
spin_lock (&vmp->lock); spin_lock (&vmp->lock);

View File

@@ -7,12 +7,6 @@
#include <m/fs_desc_buffer.h> #include <m/fs_desc_buffer.h>
#include <sync/spin_lock.h> #include <sync/spin_lock.h>
#define VFS_OK 0
#define VFS_EXISTS 1
#define VFS_NOT_FOUND 2
#define VFS_BAD_PATH 3
#define VFS_OOB_ERROR 4
#define VFS_RAMDISKFS 0 #define VFS_RAMDISKFS 0
struct vfs_mountpoint { struct vfs_mountpoint {

View File

@@ -9,6 +9,7 @@
#include <libk/string.h> #include <libk/string.h>
#include <limine/requests.h> #include <limine/requests.h>
#include <m/fs_desc_buffer.h> #include <m/fs_desc_buffer.h>
#include <m/status.h>
#include <mm/liballoc.h> #include <mm/liballoc.h>
#include <mm/pmm.h> #include <mm/pmm.h>
#include <proc/proc.h> #include <proc/proc.h>
@@ -104,7 +105,7 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) {
struct proc* proc_from_file (const char* mountpoint, const char* path) { struct proc* proc_from_file (const char* mountpoint, const char* path) {
struct fs_desc_buffer desc; struct fs_desc_buffer desc;
if (vfs_describe (mountpoint, path, &desc) != VFS_OK) if (vfs_describe (mountpoint, path, &desc) != ST_OK)
return NULL; return NULL;
if (desc.type != FS_FILE) if (desc.type != FS_FILE)
@@ -115,7 +116,7 @@ struct proc* proc_from_file (const char* mountpoint, const char* path) {
if (temp_buffer == NULL) if (temp_buffer == NULL)
return NULL; return NULL;
if (vfs_read (mountpoint, path, temp_buffer, 0, desc.size) != VFS_OK) { if (vfs_read (mountpoint, path, temp_buffer, 0, desc.size) != ST_OK) {
free (temp_buffer); free (temp_buffer);
return NULL; return NULL;
} }