Volume-centric VFS implementation
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m41s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m41s
This commit is contained in:
27
ce/ce.c
27
ce/ce.c
@@ -2,6 +2,7 @@
|
|||||||
#include <liballoc.h>
|
#include <liballoc.h>
|
||||||
#include <list.h>
|
#include <list.h>
|
||||||
#include <minmax.h>
|
#include <minmax.h>
|
||||||
|
#include <path.h>
|
||||||
#include <printf.h>
|
#include <printf.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -68,36 +69,42 @@ static void cmd_cat (struct list_node_link* tokens) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct desc desc;
|
struct desc desc;
|
||||||
|
char volume[VOLUME_MAX];
|
||||||
|
const char* path;
|
||||||
|
int ret;
|
||||||
|
|
||||||
struct list_node_link *token_link, *token_tmp_link;
|
struct list_node_link *token_link, *token_tmp_link;
|
||||||
list_foreach (tokens, token_link, token_tmp_link) {
|
list_foreach (tokens, token_link, token_tmp_link) {
|
||||||
struct token* token = list_entry (token_link, struct token, tokens_link);
|
struct token* token = list_entry (token_link, struct token, tokens_link);
|
||||||
|
|
||||||
int handle = open (token->buffer);
|
if (!path_parse (token->buffer, volume, &path)) {
|
||||||
|
printf ("ERROR bad path '%s'\n", token->buffer);
|
||||||
if (handle < 0) {
|
|
||||||
printf ("ERROR opening %s: %s\n", token->buffer, str_status[-handle]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe (handle, &desc);
|
if ((ret = volume_open (volume)) < 0) {
|
||||||
|
printf ("ERROR could not open volume '%s': %s\n", volume, str_status[-ret]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe (path, &desc);
|
||||||
|
|
||||||
if (desc.type != FS_FILE)
|
if (desc.type != FS_FILE)
|
||||||
goto close1;
|
goto close;
|
||||||
|
|
||||||
char* buffer = malloc (desc.size + 1);
|
char* buffer = malloc (desc.size + 1);
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
goto close1;
|
goto close;
|
||||||
|
|
||||||
memset (buffer, 0, desc.size + 1);
|
memset (buffer, 0, desc.size + 1);
|
||||||
read (handle, 0, (uint8_t*)buffer, desc.size);
|
read (path, 0, (uint8_t*)buffer, desc.size);
|
||||||
printf ("%s\n", buffer);
|
printf ("%s\n", buffer);
|
||||||
|
|
||||||
close1:
|
close:
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
free (buffer);
|
free (buffer);
|
||||||
close (handle);
|
volume_close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef _M_PATH_H
|
#ifndef _M_PATH_H
|
||||||
#define _M_PATH_H
|
#define _M_PATH_H
|
||||||
|
|
||||||
#define MAX_PATH 1024
|
#define PATH_MAX 1024
|
||||||
|
#define VOLUME_MAX 256
|
||||||
|
|
||||||
#endif // _M_PATH_H
|
#endif // _M_PATH_H
|
||||||
@@ -15,5 +15,6 @@
|
|||||||
#define ST_BAD_PATH 11
|
#define ST_BAD_PATH 11
|
||||||
#define ST_EXEC_ERROR 12
|
#define ST_EXEC_ERROR 12
|
||||||
#define ST_MOUNT_ERROR 13
|
#define ST_MOUNT_ERROR 13
|
||||||
|
#define ST_TRY_AGAIN 14
|
||||||
|
|
||||||
#endif // _M_STATUS_H
|
#endif // _M_STATUS_H
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#define SYS_ARGUMENT_PTR 11
|
#define SYS_ARGUMENT_PTR 11
|
||||||
#define SYS_DEVICE_DO 12
|
#define SYS_DEVICE_DO 12
|
||||||
#define SYS_EXEC 13
|
#define SYS_EXEC 13
|
||||||
#define SYS_OPEN 14
|
#define SYS_VOLUME_OPEN 14
|
||||||
#define SYS_CLOSE 15
|
#define SYS_VOLUME_CLOSE 15
|
||||||
#define SYS_READ 16
|
#define SYS_READ 16
|
||||||
#define SYS_DESCRIBE 17
|
#define SYS_DESCRIBE 17
|
||||||
#define SYS_MAIL_SEND 18
|
#define SYS_MAIL_SEND 18
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void receiver (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void app_main (void) {
|
void app_main (void) {
|
||||||
int ce_pid = exec ("ramdisk:/ce");
|
int ce_pid = exec ("ramdisk", "ce");
|
||||||
ce_pgid = get_procgroup (ce_pid);
|
ce_pgid = get_procgroup (ce_pid);
|
||||||
|
|
||||||
process_spawn (&receiver, NULL);
|
process_spawn (&receiver, NULL);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void bootmain (void) {
|
|||||||
|
|
||||||
struct device* ramdisk_device = device_find (RAMDISK_DEVICE);
|
struct device* ramdisk_device = device_find (RAMDISK_DEVICE);
|
||||||
struct reschedule_ctx rctx = {.cpu = thiscpu, .reschedule = false};
|
struct reschedule_ctx rctx = {.cpu = thiscpu, .reschedule = false};
|
||||||
int ret = vfs_create_mountpoint ("ramdisk", VFS_TARFS, ramdisk_device, NULL, &rctx);
|
int ret = vfs_create_volume ("ramdisk", VFS_TARFS, ramdisk_device, NULL, &rctx);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
DEBUG ("could not mount ramdisk! (%d)\n", ret);
|
DEBUG ("could not mount ramdisk! (%d)\n", ret);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <amd64/gdt.h>
|
#include <amd64/gdt.h>
|
||||||
#include <amd64/proc.h>
|
#include <amd64/proc.h>
|
||||||
#include <aux/elf.h>
|
#include <aux/elf.h>
|
||||||
|
#include <fs/vfs.h>
|
||||||
#include <libk/align.h>
|
#include <libk/align.h>
|
||||||
#include <libk/list.h>
|
#include <libk/list.h>
|
||||||
#include <libk/rbtree.h>
|
#include <libk/rbtree.h>
|
||||||
@@ -116,6 +117,7 @@ void proc_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
|
|||||||
|
|
||||||
procgroup_detach (proc->procgroup, proc, rctx);
|
procgroup_detach (proc->procgroup, proc, rctx);
|
||||||
|
|
||||||
|
vfs_volume_close (proc, proc->cwv, rctx);
|
||||||
proc_free_pid (proc->pid);
|
proc_free_pid (proc->pid);
|
||||||
/* clean the process */
|
/* clean the process */
|
||||||
free (proc);
|
free (proc);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <amd64/mm.h>
|
#include <amd64/mm.h>
|
||||||
#include <amd64/msr-index.h>
|
#include <amd64/msr-index.h>
|
||||||
#include <amd64/msr.h>
|
#include <amd64/msr.h>
|
||||||
|
#include <fs/vfs.h>
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
#include <libk/string.h>
|
#include <libk/string.h>
|
||||||
#include <limine/requests.h>
|
#include <limine/requests.h>
|
||||||
@@ -99,7 +100,9 @@ static void smp_bootstrap (struct limine_mp_info* mp_info) {
|
|||||||
|
|
||||||
atomic_fetch_sub (&cpu_counter, 1);
|
atomic_fetch_sub (&cpu_counter, 1);
|
||||||
|
|
||||||
struct proc* spin_proc = proc_from_file (NULL, "ramdisk", "/spin");
|
struct reschedule_ctx rctx = {.cpu = NULL, .reschedule = false};
|
||||||
|
|
||||||
|
struct proc* spin_proc = proc_from_file (VFS_KERNEL, "ramdisk", "/spin", &rctx);
|
||||||
proc_register (spin_proc, thiscpu, NULL);
|
proc_register (spin_proc, thiscpu, NULL);
|
||||||
|
|
||||||
spin_lock (&spin_proc->cpu->lock);
|
spin_lock (&spin_proc->cpu->lock);
|
||||||
|
|||||||
@@ -1,64 +1,6 @@
|
|||||||
#include <fs/vfs.h>
|
#include <fs/vfs.h>
|
||||||
#include <libk/fieldsizeof.h>
|
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
|
#include <path_defs.h>
|
||||||
bool path_validate_char (char ch) {
|
|
||||||
return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
|
||||||
(ch == '_') || (ch == '-') || (ch == '/') || (ch == '.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path_validate (const char* path) {
|
|
||||||
if (path == NULL || *path == '\0')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const char* ptr = path;
|
|
||||||
|
|
||||||
if (*ptr != '/')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
while (*ptr != '\0') {
|
|
||||||
if (*ptr == '/' && *(ptr + 1) == '/')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!path_validate_char (*ptr))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptr > path + 1 && *(ptr - 1) == '/')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path_parse (const char* source, char* mountpoint, const char** path) {
|
|
||||||
if (source == NULL || mountpoint == NULL || path == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
while (source[i] != ':' && source[i] != '\0') {
|
|
||||||
if (i >= (fieldsizeof (struct vfs_mountpoint, key) - 1))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
mountpoint[i] = source[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source[i] != ':' || i == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
mountpoint[i] = '\0';
|
|
||||||
|
|
||||||
const char* internal_path = &source[i + 1];
|
|
||||||
|
|
||||||
if (!path_validate (internal_path))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*path = internal_path;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* path_basename (const char* path) {
|
const char* path_basename (const char* path) {
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
|
|||||||
@@ -3,11 +3,8 @@
|
|||||||
|
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
|
|
||||||
/* Path scheme: MOUNTPOINT:/path/to/file.txt */
|
/* Path scheme: VOLUME:/path/to/file.txt */
|
||||||
|
|
||||||
bool path_validate_char (char ch);
|
|
||||||
bool path_validate (const char* path);
|
|
||||||
bool path_parse (const char* source, char* mountpoint, const char** path);
|
|
||||||
const char* path_basename (const char* path);
|
const char* path_basename (const char* path);
|
||||||
|
|
||||||
#endif // _KERNEL_FS_PATH_H
|
#endif // _KERNEL_FS_PATH_H
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <libk/string.h>
|
#include <libk/string.h>
|
||||||
#include <limine/requests.h>
|
#include <limine/requests.h>
|
||||||
#include <mm/liballoc.h>
|
#include <mm/liballoc.h>
|
||||||
#include <path.h>
|
#include <path_defs.h>
|
||||||
#include <status.h>
|
#include <status.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <xdrv_device.h>
|
#include <xdrv_device.h>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
static struct tar_file* tar_get_file (struct tarfs* tarfs, const char* filename) {
|
static struct tar_file* tar_get_file (struct tarfs* tarfs, const char* filename) {
|
||||||
for (size_t i = 0; i < TARFS_FILES_MAX; i++) {
|
for (size_t i = 0; i < TARFS_FILES_MAX; i++) {
|
||||||
if ((tarfs->tarfs_files[i].header != NULL) &&
|
if ((tarfs->tarfs_files[i].header != NULL) &&
|
||||||
(strncmp (tarfs->tarfs_files[i].header->filename, filename, MAX_PATH) == 0))
|
(strncmp (tarfs->tarfs_files[i].header->filename, filename, PATH_MAX) == 0))
|
||||||
return &tarfs->tarfs_files[i];
|
return &tarfs->tarfs_files[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -54,8 +54,7 @@ static size_t tar_parse (struct tarfs* tarfs, uint8_t* addr) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
int tarfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||||
struct reschedule_ctx* rctx) {
|
|
||||||
struct tarfs* tarfs = malloc (sizeof (*tarfs));
|
struct tarfs* tarfs = malloc (sizeof (*tarfs));
|
||||||
|
|
||||||
if (tarfs == NULL)
|
if (tarfs == NULL)
|
||||||
@@ -63,9 +62,9 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
|||||||
|
|
||||||
memset (tarfs, 0, sizeof (*tarfs));
|
memset (tarfs, 0, sizeof (*tarfs));
|
||||||
|
|
||||||
mountpoint->udata = tarfs;
|
volume->udata = tarfs;
|
||||||
|
|
||||||
struct device* back_device = mountpoint->back_device;
|
struct device* back_device = volume->back_device;
|
||||||
size_t total_size, sector_size;
|
size_t total_size, sector_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
|||||||
ret = back_device->ops[XDRV_GET_SIZE](back_device, proc, rctx, &total_size, NULL, NULL, NULL);
|
ret = back_device->ops[XDRV_GET_SIZE](back_device, proc, rctx, &total_size, NULL, NULL, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
spin_unlock (&back_device->lock);
|
spin_unlock (&back_device->lock);
|
||||||
free (mountpoint->udata);
|
free (volume->udata);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
|||||||
NULL);
|
NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
spin_unlock (&back_device->lock);
|
spin_unlock (&back_device->lock);
|
||||||
free (mountpoint->udata);
|
free (volume->udata);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
|||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
spin_unlock (&back_device->lock);
|
spin_unlock (&back_device->lock);
|
||||||
free (mountpoint->udata);
|
free (volume->udata);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,15 +113,15 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tarfs_describe (struct vfs_mountpoint* mountpoint, const char* path, struct desc* desc) {
|
int tarfs_describe (struct vfs_volume* volume, const char* path, struct desc* desc) {
|
||||||
(void)mountpoint;
|
(void)volume;
|
||||||
|
|
||||||
const char* filename = path_basename (path);
|
const char* filename = path_basename (path);
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return -ST_BAD_PATH;
|
return -ST_BAD_PATH;
|
||||||
|
|
||||||
struct tar_file* file = tar_get_file ((struct tarfs*)mountpoint->udata, filename);
|
struct tar_file* file = tar_get_file ((struct tarfs*)volume->udata, filename);
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
@@ -133,16 +132,16 @@ int tarfs_describe (struct vfs_mountpoint* mountpoint, const char* path, struct
|
|||||||
return ST_OK;
|
return ST_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tarfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, size_t off,
|
int tarfs_read (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
(void)mountpoint;
|
(void)volume;
|
||||||
|
|
||||||
const char* filename = path_basename (path);
|
const char* filename = path_basename (path);
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return -ST_BAD_PATH;
|
return -ST_BAD_PATH;
|
||||||
|
|
||||||
struct tar_file* file = tar_get_file ((struct tarfs*)mountpoint->udata, filename);
|
struct tar_file* file = tar_get_file ((struct tarfs*)volume->udata, filename);
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ struct tarfs {
|
|||||||
uint8_t* buffer;
|
uint8_t* buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vfs_mountpoint;
|
struct vfs_volume;
|
||||||
|
|
||||||
int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc, struct reschedule_ctx* rctx);
|
int tarfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
int tarfs_describe (struct vfs_mountpoint* mountpoint, const char* path, struct desc* desc);
|
int tarfs_describe (struct vfs_volume* volume, const char* path, struct desc* desc);
|
||||||
|
|
||||||
int tarfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, size_t off,
|
int tarfs_read (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
#endif // _KERNEL_FS_TARFS_H
|
#endif // _KERNEL_FS_TARFS_H
|
||||||
|
|||||||
246
kernel/fs/vfs.c
246
kernel/fs/vfs.c
@@ -10,216 +10,182 @@
|
|||||||
#include <mm/liballoc.h>
|
#include <mm/liballoc.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
#include <proc/procgroup.h>
|
#include <proc/procgroup.h>
|
||||||
|
#include <proc/reschedule.h>
|
||||||
|
#include <proc/suspension_q.h>
|
||||||
#include <status.h>
|
#include <status.h>
|
||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
|
|
||||||
static struct vfs_mount_table mount_table;
|
static struct vfs_volume_table volume_table;
|
||||||
|
|
||||||
static struct vfs_mountpoint* vfs_find_mountpoint (const char* mountpoint) {
|
static struct vfs_volume* vfs_find_volume (const char* volume) {
|
||||||
struct hash_node_link* found_link = NULL;
|
struct hash_node_link* found_link = NULL;
|
||||||
size_t mountpoint_len = strlen (mountpoint);
|
size_t volume_len = strlen (volume);
|
||||||
uint32_t hash = hash_fnv32 (mountpoint, strlen (mountpoint));
|
uint32_t hash = hash_fnv32 (volume, strlen (volume));
|
||||||
|
|
||||||
spin_lock (&mount_table.lock);
|
spin_lock (&volume_table.lock);
|
||||||
hash_find (&mount_table, mountpoint, mountpoint_len, hash,
|
hash_find (&volume_table, volume, volume_len, hash, lengthof (volume_table.volume_buckets),
|
||||||
lengthof (mount_table.mountpoint_buckets), mountpoint_buckets, struct vfs_mountpoint,
|
volume_buckets, struct vfs_volume, volume_table_link, key, found_link);
|
||||||
mount_table_link, key, found_link);
|
spin_unlock (&volume_table.lock);
|
||||||
spin_unlock (&mount_table.lock);
|
|
||||||
|
|
||||||
if (found_link == NULL)
|
if (found_link == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return hash_entry (found_link, struct vfs_mountpoint, mount_table_link);
|
return hash_entry (found_link, struct vfs_volume, volume_table_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_create_mountpoint (const char* key, int fs_type, struct device* back_device,
|
int vfs_create_volume (const char* key, int fs_type, struct device* back_device, struct proc* proc,
|
||||||
struct proc* proc, struct reschedule_ctx* rctx) {
|
struct reschedule_ctx* rctx) {
|
||||||
if (strlen_null (key) > fieldsizeof (struct vfs_mountpoint, key))
|
if (strlen_null (key) > VOLUME_MAX)
|
||||||
return -ST_OOB_ERROR;
|
return -ST_OOB_ERROR;
|
||||||
|
|
||||||
struct vfs_mountpoint* mountpoint = malloc (sizeof (*mountpoint));
|
struct vfs_volume* volume = malloc (sizeof (*volume));
|
||||||
|
|
||||||
if (mountpoint == NULL)
|
if (volume == NULL)
|
||||||
return -ST_OOM_ERROR;
|
return -ST_OOM_ERROR;
|
||||||
|
|
||||||
memset (mountpoint, 0, sizeof (*mountpoint));
|
memset (volume, 0, sizeof (*volume));
|
||||||
|
|
||||||
memcpy (mountpoint->key, key, strlen_null (key));
|
memcpy (volume->key, key, strlen_null (key));
|
||||||
mountpoint->fs_type = fs_type;
|
volume->fs_type = fs_type;
|
||||||
mountpoint->back_device = back_device;
|
volume->back_device = back_device;
|
||||||
|
volume->lock = SPIN_LOCK_INIT;
|
||||||
|
|
||||||
switch (mountpoint->fs_type) {
|
switch (volume->fs_type) {
|
||||||
case VFS_TARFS: {
|
case VFS_TARFS: {
|
||||||
mountpoint->driver_ops.mount = &tarfs_mount;
|
volume->driver_ops.mount = &tarfs_mount;
|
||||||
mountpoint->driver_ops.describe = &tarfs_describe;
|
volume->driver_ops.describe = &tarfs_describe;
|
||||||
mountpoint->driver_ops.read = &tarfs_read;
|
volume->driver_ops.read = &tarfs_read;
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
free (mountpoint);
|
free (volume);
|
||||||
return -ST_MOUNT_ERROR;
|
return -ST_MOUNT_ERROR;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = mountpoint->driver_ops.mount (mountpoint, proc, rctx);
|
int ret = volume->driver_ops.mount (volume, proc, rctx);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
free (mountpoint);
|
free (volume);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mp_hash = hash_fnv32 (mountpoint->key, strlen (mountpoint->key));
|
uint32_t mp_hash = hash_fnv32 (volume->key, strlen (volume->key));
|
||||||
|
|
||||||
spin_lock (&mount_table.lock);
|
spin_lock (&volume_table.lock);
|
||||||
|
|
||||||
hash_insert (&mount_table, &mountpoint->mount_table_link, mp_hash,
|
hash_insert (&volume_table, &volume->volume_table_link, mp_hash,
|
||||||
lengthof (mount_table.mountpoint_buckets), mountpoint_buckets);
|
lengthof (volume_table.volume_buckets), volume_buckets);
|
||||||
|
|
||||||
spin_unlock (&mount_table.lock);
|
spin_unlock (&volume_table.lock);
|
||||||
|
|
||||||
return ST_OK;
|
return ST_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_open (struct procgroup* procgroup, const char* mountpoint, const char* path) {
|
int vfs_volume_open (struct proc* proc, const char* volume_name, struct reschedule_ctx* rctx) {
|
||||||
struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint);
|
struct vfs_volume* volume = vfs_find_volume (volume_name);
|
||||||
|
|
||||||
if (vmp == NULL)
|
if (volume == NULL)
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
|
|
||||||
struct vfs_handle* handle = malloc (sizeof (*handle));
|
spin_lock (&volume->lock);
|
||||||
|
|
||||||
if (handle == NULL)
|
if (!volume->locked) {
|
||||||
return -ST_OOM_ERROR;
|
volume->locked = true;
|
||||||
|
volume->owner = proc;
|
||||||
memset (handle, 0, sizeof (*handle));
|
spin_unlock (&volume->lock);
|
||||||
handle->mountpoint = vmp;
|
return ST_OK;
|
||||||
handle->ownerpg = procgroup;
|
} else {
|
||||||
strncpy (handle->path, path, sizeof (handle->path));
|
if (proc == VFS_KERNEL) {
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
spin_lock (&procgroup->lock);
|
return -ST_TRY_AGAIN;
|
||||||
|
} else {
|
||||||
int id = handle->id = id_alloc (&procgroup->vfs_handle_id_alloc);
|
proc_sq_suspend (proc, &volume->sq, &volume->lock, rctx);
|
||||||
|
return ST_OK;
|
||||||
if (id < 0) {
|
}
|
||||||
free (handle);
|
}
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
return -ST_OOM_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rbtree_insert (struct vfs_handle, &procgroup->vfs_handle_tree, &handle->handle_tree_link,
|
int vfs_volume_close (struct proc* proc, const char* volume_name, struct reschedule_ctx* rctx) {
|
||||||
handle_tree_link, id);
|
struct vfs_volume* volume = vfs_find_volume (volume_name);
|
||||||
|
|
||||||
spin_unlock (&procgroup->lock);
|
if (volume == NULL)
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_close (struct procgroup* procgroup, int id) {
|
|
||||||
struct vfs_handle* handle = NULL;
|
|
||||||
|
|
||||||
spin_lock (&procgroup->lock);
|
|
||||||
|
|
||||||
rbtree_find (struct vfs_handle, &procgroup->vfs_handle_tree, id, handle, handle_tree_link, id);
|
|
||||||
|
|
||||||
if (handle == NULL) {
|
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
|
|
||||||
|
spin_lock (&volume->lock);
|
||||||
|
|
||||||
|
if (volume->locked && volume->owner != proc) {
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
|
return -ST_PERMISSION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock (&handle->lock);
|
spin_lock (&volume->sq.lock);
|
||||||
|
|
||||||
rbtree_delete (&procgroup->vfs_handle_tree, &handle->handle_tree_link);
|
struct list_node_link* node = volume->sq.proc_list;
|
||||||
|
|
||||||
id_free (&procgroup->vfs_handle_id_alloc, handle->id);
|
if (node) {
|
||||||
|
struct proc_sq_entry* sq_entry = list_entry (node, struct proc_sq_entry, sq_link);
|
||||||
|
struct proc* resumed_proc = sq_entry->proc;
|
||||||
|
|
||||||
spin_unlock (&handle->lock);
|
volume->owner = proc;
|
||||||
spin_unlock (&procgroup->lock);
|
volume->locked = true;
|
||||||
|
|
||||||
free (handle);
|
spin_unlock (&volume->sq.lock);
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
|
|
||||||
|
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||||
|
return ST_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
volume->locked = false;
|
||||||
|
volume->owner = NULL;
|
||||||
|
|
||||||
|
spin_unlock (&volume->sq.lock);
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
|
|
||||||
return ST_OK;
|
return ST_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_describe (struct procgroup* procgroup, int id, struct desc* desc) {
|
int vfs_read (struct proc* proc, const char* volume_name, const char* path, uint8_t* buffer,
|
||||||
struct vfs_handle* handle = NULL;
|
size_t off, size_t size, struct reschedule_ctx* rctx) {
|
||||||
|
struct vfs_volume* volume = vfs_find_volume (volume_name);
|
||||||
|
|
||||||
spin_lock (&procgroup->lock);
|
if (volume == NULL)
|
||||||
|
|
||||||
rbtree_find (struct vfs_handle, &procgroup->vfs_handle_tree, id, handle, handle_tree_link, id);
|
|
||||||
|
|
||||||
if (handle == NULL) {
|
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
return -ST_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
|
|
||||||
spin_lock (&handle->lock);
|
|
||||||
int ret = handle->mountpoint->driver_ops.describe (handle->mountpoint, handle->path, desc);
|
|
||||||
spin_unlock (&handle->lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_read (struct procgroup* procgroup, int id, uint8_t* buffer, size_t off, size_t size) {
|
|
||||||
struct vfs_handle* handle = NULL;
|
|
||||||
|
|
||||||
spin_lock (&procgroup->lock);
|
|
||||||
|
|
||||||
rbtree_find (struct vfs_handle, &procgroup->vfs_handle_tree, id, handle, handle_tree_link, id);
|
|
||||||
|
|
||||||
if (handle == NULL) {
|
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
return -ST_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock (&procgroup->lock);
|
|
||||||
|
|
||||||
spin_lock (&handle->lock);
|
|
||||||
int ret =
|
|
||||||
handle->mountpoint->driver_ops.read (handle->mountpoint, handle->path, buffer, off, size);
|
|
||||||
spin_unlock (&handle->lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_kernel_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off,
|
|
||||||
size_t size) {
|
|
||||||
struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint);
|
|
||||||
|
|
||||||
if (vmp == NULL)
|
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
|
|
||||||
return vmp->driver_ops.read (vmp, path, buffer, off, size);
|
spin_lock (&volume->lock);
|
||||||
|
|
||||||
|
if (volume->locked && volume->owner != proc) {
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
|
return -ST_PERMISSION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_kernel_describe (const char* mountpoint, const char* path, struct desc* desc) {
|
spin_unlock (&volume->lock);
|
||||||
struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint);
|
|
||||||
|
|
||||||
if (vmp == NULL)
|
return volume->driver_ops.read (volume, path, buffer, off, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfs_describe (struct proc* proc, const char* volume_name, const char* path, struct desc* desc,
|
||||||
|
struct reschedule_ctx* rctx) {
|
||||||
|
struct vfs_volume* volume = vfs_find_volume (volume_name);
|
||||||
|
|
||||||
|
if (volume == NULL)
|
||||||
return -ST_NOT_FOUND;
|
return -ST_NOT_FOUND;
|
||||||
|
|
||||||
return vmp->driver_ops.describe (vmp, path, desc);
|
spin_lock (&volume->lock);
|
||||||
|
|
||||||
|
if (volume->locked && volume->owner != proc) {
|
||||||
|
spin_unlock (&volume->lock);
|
||||||
|
return -ST_PERMISSION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vfs_procgroup_cleanup (struct procgroup* procgroup) {
|
spin_unlock (&volume->lock);
|
||||||
struct vfs_handle* handle;
|
|
||||||
|
|
||||||
struct rb_node_link* node;
|
return volume->driver_ops.describe (volume, path, desc);
|
||||||
rbtree_first (&procgroup->vfs_handle_tree, node);
|
|
||||||
|
|
||||||
while (node != NULL) {
|
|
||||||
struct rb_node_link* next;
|
|
||||||
rbtree_next (node, next);
|
|
||||||
handle = rbtree_entry (node, struct vfs_handle, handle_tree_link);
|
|
||||||
node = next;
|
|
||||||
|
|
||||||
vfs_close (procgroup, handle->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vfs_init (void) {
|
void vfs_init (void) {
|
||||||
memset (&mount_table, 0, sizeof (mount_table));
|
memset (&volume_table, 0, sizeof (volume_table));
|
||||||
|
|
||||||
mount_table.lock = SPIN_LOCK_INIT;
|
volume_table.lock = SPIN_LOCK_INIT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,64 +7,56 @@
|
|||||||
#include <libk/list.h>
|
#include <libk/list.h>
|
||||||
#include <libk/rbtree.h>
|
#include <libk/rbtree.h>
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
#include <path.h>
|
#include <path_defs.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
#include <proc/procgroup.h>
|
#include <proc/procgroup.h>
|
||||||
#include <proc/reschedule.h>
|
#include <proc/reschedule.h>
|
||||||
|
#include <proc/suspension_q.h>
|
||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
|
|
||||||
|
#define VFS_KERNEL ((struct proc*)0x123)
|
||||||
|
|
||||||
#define VFS_TARFS 0
|
#define VFS_TARFS 0
|
||||||
|
|
||||||
struct vfs_mountpoint;
|
struct vfs_volume;
|
||||||
|
|
||||||
struct vfs_handle {
|
struct vfs_volume {
|
||||||
int id;
|
char key[VOLUME_MAX];
|
||||||
struct vfs_mountpoint* mountpoint;
|
struct hash_node_link volume_table_link;
|
||||||
char path[MAX_PATH];
|
|
||||||
struct procgroup* ownerpg;
|
|
||||||
struct rb_node_link handle_tree_link;
|
|
||||||
spin_lock_t lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vfs_mountpoint {
|
|
||||||
char key[0x100];
|
|
||||||
struct hash_node_link mount_table_link;
|
|
||||||
int fs_type;
|
int fs_type;
|
||||||
|
spin_lock_t lock;
|
||||||
|
struct proc* owner;
|
||||||
|
bool locked;
|
||||||
|
struct proc_suspension_q sq;
|
||||||
struct {
|
struct {
|
||||||
int (*mount) (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
int (*mount) (struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx);
|
||||||
struct reschedule_ctx* rctx);
|
|
||||||
|
|
||||||
int (*describe) (struct vfs_mountpoint* mountpoint, const char* path, struct desc* desc);
|
int (*describe) (struct vfs_volume* volume, const char* path, struct desc* desc);
|
||||||
|
|
||||||
int (*read) (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, size_t off,
|
int (*read) (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||||
size_t size);
|
size_t size);
|
||||||
} driver_ops;
|
} driver_ops;
|
||||||
struct device* back_device;
|
struct device* back_device;
|
||||||
void* udata
|
void* udata
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vfs_mount_table {
|
struct vfs_volume_table {
|
||||||
struct hash_node_link* mountpoint_buckets[1024];
|
struct hash_node_link* volume_buckets[1024];
|
||||||
spin_lock_t lock;
|
spin_lock_t lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vfs_create_mountpoint (const char* key, int fs_type, struct device* back_device,
|
int vfs_create_volume (const char* key, int fs_type, struct device* back_device, struct proc* proc,
|
||||||
struct proc* proc, struct reschedule_ctx* rctx);
|
struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
int vfs_describe (struct procgroup* procgroup, int id, struct desc* desc);
|
int vfs_volume_open (struct proc* proc, const char* volume, struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
int vfs_read (struct procgroup* procgroup, int id, uint8_t* buffer, size_t off, size_t size);
|
int vfs_volume_close (struct proc* proc, const char* volume, struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
int vfs_close (struct procgroup* procgroup, int id);
|
int vfs_read (struct proc* proc, const char* volume, const char* path, uint8_t* buffer, size_t off,
|
||||||
|
size_t size, struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
int vfs_open (struct procgroup* procgroup, const char* mountpoint, const char* path);
|
int vfs_describe (struct proc* proc, const char* volume, const char* path, struct desc* desc,
|
||||||
|
struct reschedule_ctx* rctx);
|
||||||
int vfs_kernel_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off,
|
|
||||||
size_t size);
|
|
||||||
|
|
||||||
int vfs_kernel_describe (const char* mountpoint, const char* path, struct desc* desc);
|
|
||||||
|
|
||||||
void vfs_procgroup_cleanup (struct procgroup* procgroup);
|
|
||||||
|
|
||||||
void vfs_init (void);
|
void vfs_init (void);
|
||||||
|
|
||||||
|
|||||||
@@ -57,3 +57,11 @@ int strncmp (const char* s1, const char* s2, size_t n) {
|
|||||||
return (*(unsigned char*)s1 - *(unsigned char*)s2);
|
return (*(unsigned char*)s1 - *(unsigned char*)s2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strcmp (const char* s1, const char* s2) {
|
||||||
|
while (*s1 && (*s1 == *s2)) {
|
||||||
|
s1++;
|
||||||
|
s2++;
|
||||||
|
}
|
||||||
|
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ void strncpy (char* dst, const char* src, size_t n);
|
|||||||
size_t strlen (const char* str);
|
size_t strlen (const char* str);
|
||||||
int memcmp (const void* s1, const void* s2, size_t n);
|
int memcmp (const void* s1, const void* s2, size_t n);
|
||||||
int strncmp (const char* s1, const char* s2, size_t n);
|
int strncmp (const char* s1, const char* s2, size_t n);
|
||||||
|
int strcmp (const char* s1, const char* s2);
|
||||||
|
|
||||||
#define strlen_null(x) (strlen ((x)) + 1)
|
#define strlen_null(x) (strlen ((x)) + 1)
|
||||||
|
|
||||||
|
|||||||
@@ -115,66 +115,47 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) {
|
|||||||
return aux;
|
return aux;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct proc* proc_from_file (struct procgroup* procgroup, const char* mountpoint,
|
struct proc* proc_from_file (struct proc* proc1, const char* volume, const char* path,
|
||||||
const char* path) {
|
struct reschedule_ctx* rctx) {
|
||||||
struct desc desc;
|
struct desc desc;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (procgroup == NULL) {
|
for (;;) {
|
||||||
if (vfs_kernel_describe (mountpoint, path, &desc) < 0)
|
ret = vfs_volume_open (proc1, volume, rctx);
|
||||||
return NULL;
|
|
||||||
|
if (ret < 0) {
|
||||||
if (desc.type != FS_FILE)
|
if (ret == -ST_TRY_AGAIN)
|
||||||
return NULL;
|
continue;
|
||||||
|
else
|
||||||
uint8_t* temp_buffer = malloc (desc.size);
|
|
||||||
|
|
||||||
if (temp_buffer == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (vfs_kernel_read (mountpoint, path, temp_buffer, 0, desc.size) < 0) {
|
|
||||||
free (temp_buffer);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proc_check_elf (temp_buffer)) {
|
if ((ret = vfs_describe (proc1, volume, path, &desc, rctx)) < 0) {
|
||||||
free (temp_buffer);
|
vfs_volume_close (proc1, volume, rctx);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct proc* proc = proc_from_elf (temp_buffer);
|
|
||||||
|
|
||||||
free (temp_buffer);
|
|
||||||
return proc;
|
|
||||||
} else {
|
|
||||||
int handle = vfs_open (procgroup, mountpoint, path);
|
|
||||||
|
|
||||||
if (handle < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (vfs_describe (procgroup, handle, &desc) != ST_OK) {
|
|
||||||
vfs_close (procgroup, handle);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc.type != FS_FILE) {
|
if (desc.type != FS_FILE) {
|
||||||
vfs_close (procgroup, handle);
|
vfs_volume_close (proc1, volume, rctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* temp_buffer = malloc (desc.size);
|
uint8_t* temp_buffer = malloc (desc.size);
|
||||||
|
|
||||||
if (temp_buffer == NULL) {
|
if (temp_buffer == NULL) {
|
||||||
vfs_close (procgroup, handle);
|
vfs_volume_close (proc1, volume, rctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vfs_read (procgroup, handle, temp_buffer, 0, desc.size) != ST_OK) {
|
if ((ret = vfs_read (proc1, volume, path, temp_buffer, 0, desc.size, rctx)) < 0) {
|
||||||
free (temp_buffer);
|
free (temp_buffer);
|
||||||
vfs_close (procgroup, handle);
|
vfs_volume_close (proc1, volume, rctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs_close (procgroup, handle);
|
vfs_volume_close (proc1, volume, rctx);
|
||||||
|
|
||||||
if (!proc_check_elf (temp_buffer)) {
|
if (!proc_check_elf (temp_buffer)) {
|
||||||
free (temp_buffer);
|
free (temp_buffer);
|
||||||
@@ -186,7 +167,6 @@ struct proc* proc_from_file (struct procgroup* procgroup, const char* mountpoint
|
|||||||
free (temp_buffer);
|
free (temp_buffer);
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct proc* proc_find_pid (int pid) {
|
struct proc* proc_find_pid (int pid) {
|
||||||
struct proc* proc = NULL;
|
struct proc* proc = NULL;
|
||||||
@@ -358,10 +338,12 @@ void proc_init (void) {
|
|||||||
irq_attach (&proc_irq_sched, NULL, CPU_REQUEST_SCHED);
|
irq_attach (&proc_irq_sched, NULL, CPU_REQUEST_SCHED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct proc* spin_proc = proc_from_file (NULL, "ramdisk", "/spin");
|
struct reschedule_ctx rctx = {.cpu = NULL, .reschedule = false};
|
||||||
|
|
||||||
|
struct proc* spin_proc = proc_from_file (VFS_KERNEL, "ramdisk", "/spin", &rctx);
|
||||||
proc_register (spin_proc, thiscpu, NULL);
|
proc_register (spin_proc, thiscpu, NULL);
|
||||||
|
|
||||||
struct proc* init = proc_from_file (NULL, "ramdisk", "/init");
|
struct proc* init = proc_from_file (VFS_KERNEL, "ramdisk", "/init", &rctx);
|
||||||
init->procgroup->capabilities |= (PROC_CAP_TERMINAL | PROC_CAP_KB);
|
init->procgroup->capabilities |= (PROC_CAP_TERMINAL | PROC_CAP_KB);
|
||||||
proc_register (init, thiscpu, NULL);
|
proc_register (init, thiscpu, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <libk/list.h>
|
#include <libk/list.h>
|
||||||
#include <libk/rbtree.h>
|
#include <libk/rbtree.h>
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
|
#include <path_defs.h>
|
||||||
#include <proc/procgroup.h>
|
#include <proc/procgroup.h>
|
||||||
#include <proc/resource.h>
|
#include <proc/resource.h>
|
||||||
#include <proc/suspension_q.h>
|
#include <proc/suspension_q.h>
|
||||||
@@ -45,6 +46,7 @@ struct proc {
|
|||||||
uintptr_t uvaddr_argument;
|
uintptr_t uvaddr_argument;
|
||||||
void* mail_recv_buffer;
|
void* mail_recv_buffer;
|
||||||
size_t mail_recv_size;
|
size_t mail_recv_size;
|
||||||
|
char cwv[VOLUME_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
void proc_sched (void);
|
void proc_sched (void);
|
||||||
@@ -57,7 +59,8 @@ void proc_register (struct proc* proc, struct cpu* register_cpu, struct reschedu
|
|||||||
|
|
||||||
struct proc* proc_find_pid (int pid);
|
struct proc* proc_find_pid (int pid);
|
||||||
|
|
||||||
struct proc* proc_from_file (struct procgroup* procgroup, const char* mountpoint, const char* path);
|
struct proc* proc_from_file (struct proc* proc1, const char* volume, const char* path,
|
||||||
|
struct reschedule_ctx* rctx);
|
||||||
|
|
||||||
void proc_free_pid (int pid);
|
void proc_free_pid (int pid);
|
||||||
|
|
||||||
|
|||||||
@@ -151,13 +151,7 @@ struct procgroup* procgroup_create (void) {
|
|||||||
|
|
||||||
memset (procgroup, 0, sizeof (*procgroup));
|
memset (procgroup, 0, sizeof (*procgroup));
|
||||||
|
|
||||||
if (!id_alloc_init (&procgroup->vfs_handle_id_alloc, PROCGROUP_VFS_HANDLES_MAX)) {
|
|
||||||
free (procgroup);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!id_alloc_init (&procgroup->rid_alloc, PROCGROUP_RESOURCES_MAX)) {
|
if (!id_alloc_init (&procgroup->rid_alloc, PROCGROUP_RESOURCES_MAX)) {
|
||||||
id_alloc_fini (&procgroup->vfs_handle_id_alloc);
|
|
||||||
free (procgroup);
|
free (procgroup);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -166,7 +160,6 @@ struct procgroup* procgroup_create (void) {
|
|||||||
|
|
||||||
if (procgroup->pgid < 0) {
|
if (procgroup->pgid < 0) {
|
||||||
id_alloc_fini (&procgroup->rid_alloc);
|
id_alloc_fini (&procgroup->rid_alloc);
|
||||||
id_alloc_fini (&procgroup->vfs_handle_id_alloc);
|
|
||||||
free (procgroup);
|
free (procgroup);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -178,7 +171,6 @@ struct procgroup* procgroup_create (void) {
|
|||||||
|
|
||||||
if (proc_create_resource_mail (procgroup) == NULL) {
|
if (proc_create_resource_mail (procgroup) == NULL) {
|
||||||
id_alloc_fini (&procgroup->rid_alloc);
|
id_alloc_fini (&procgroup->rid_alloc);
|
||||||
id_alloc_fini (&procgroup->vfs_handle_id_alloc);
|
|
||||||
free (procgroup);
|
free (procgroup);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -237,9 +229,6 @@ static void procgroup_delete (struct procgroup* procgroup, struct reschedule_ctx
|
|||||||
proc_delete_resource (procgroup, resource, rctx);
|
proc_delete_resource (procgroup, resource, rctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlock VFS owned mountpoints */
|
|
||||||
vfs_procgroup_cleanup (procgroup);
|
|
||||||
|
|
||||||
/* delete mappings */
|
/* delete mappings */
|
||||||
struct list_node_link *mapping_link, *mapping_link_tmp;
|
struct list_node_link *mapping_link, *mapping_link_tmp;
|
||||||
list_foreach (procgroup->mappings, mapping_link, mapping_link_tmp) {
|
list_foreach (procgroup->mappings, mapping_link, mapping_link_tmp) {
|
||||||
@@ -254,7 +243,6 @@ static void procgroup_delete (struct procgroup* procgroup, struct reschedule_ctx
|
|||||||
|
|
||||||
free (procgroup->tls.tls_tmpl);
|
free (procgroup->tls.tls_tmpl);
|
||||||
|
|
||||||
id_alloc_fini (&procgroup->vfs_handle_id_alloc);
|
|
||||||
id_alloc_fini (&procgroup->rid_alloc);
|
id_alloc_fini (&procgroup->rid_alloc);
|
||||||
id_free (&pgid_alloc, procgroup->pgid);
|
id_free (&pgid_alloc, procgroup->pgid);
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ struct procgroup {
|
|||||||
uintptr_t map_base;
|
uintptr_t map_base;
|
||||||
struct procgroup_tls tls;
|
struct procgroup_tls tls;
|
||||||
uint64_t capabilities;
|
uint64_t capabilities;
|
||||||
struct rb_node_link* vfs_handle_tree;
|
|
||||||
struct id_alloc vfs_handle_id_alloc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct procgroup* procgroup_create (void);
|
struct procgroup* procgroup_create (void);
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
#include <fs/vfs.h>
|
#include <fs/vfs.h>
|
||||||
#include <libk/assert.h>
|
#include <libk/assert.h>
|
||||||
#include <libk/fieldlengthof.h>
|
#include <libk/fieldlengthof.h>
|
||||||
#include <libk/fieldsizeof.h>
|
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
|
#include <libk/string.h>
|
||||||
#include <limine/requests.h>
|
#include <limine/requests.h>
|
||||||
#include <mm/pmm.h>
|
#include <mm/pmm.h>
|
||||||
|
#include <path_defs.h>
|
||||||
#include <proc/mail.h>
|
#include <proc/mail.h>
|
||||||
#include <proc/mutex.h>
|
#include <proc/mutex.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
@@ -260,9 +261,10 @@ DEFINE_SYSCALL (sys_device_do) {
|
|||||||
return SYSRESULT (ret);
|
return SYSRESULT (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int exec (char* path) */
|
/* int exec (char* volume, char* path) */
|
||||||
DEFINE_SYSCALL (sys_exec) {
|
DEFINE_SYSCALL (sys_exec) {
|
||||||
uintptr_t uvaddr_path = a1;
|
uintptr_t uvaddr_volume = a1;
|
||||||
|
uintptr_t uvaddr_path = a2;
|
||||||
|
|
||||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
|
|
||||||
@@ -277,13 +279,16 @@ DEFINE_SYSCALL (sys_exec) {
|
|||||||
|
|
||||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||||
|
|
||||||
char mountpoint[fieldsizeof (struct vfs_mountpoint, key)];
|
spin_lock (&proc->procgroup->lock);
|
||||||
const char* subpath = NULL;
|
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_volume);
|
||||||
|
spin_unlock (&proc->procgroup->lock);
|
||||||
|
|
||||||
if (!path_parse (path, mountpoint, &subpath))
|
if (out_paddr == 0)
|
||||||
return SYSRESULT (-ST_BAD_PATH);
|
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||||
|
|
||||||
struct proc* new = proc_from_file (proc->procgroup, mountpoint, subpath);
|
const char* volume = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||||
|
|
||||||
|
struct proc* new = proc_from_file (proc, volume, path, rctx);
|
||||||
|
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
return SYSRESULT (-ST_EXEC_ERROR);
|
return SYSRESULT (-ST_EXEC_ERROR);
|
||||||
@@ -296,9 +301,56 @@ DEFINE_SYSCALL (sys_exec) {
|
|||||||
return SYSRESULT (pid);
|
return SYSRESULT (pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int open (char* path) */
|
/* int volume_open (char* volume) */
|
||||||
DEFINE_SYSCALL (sys_open) {
|
DEFINE_SYSCALL (sys_volume_open) {
|
||||||
|
uintptr_t uvaddr_volume = a1;
|
||||||
|
|
||||||
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
|
|
||||||
|
uintptr_t out_paddr;
|
||||||
|
|
||||||
|
spin_lock (&proc->procgroup->lock);
|
||||||
|
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_volume);
|
||||||
|
spin_unlock (&proc->procgroup->lock);
|
||||||
|
|
||||||
|
if (out_paddr == 0)
|
||||||
|
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||||
|
|
||||||
|
const char* volume = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||||
|
|
||||||
|
int ret = vfs_volume_open (proc, volume, rctx);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return SYSRESULT (ret);
|
||||||
|
|
||||||
|
spin_lock (&proc->lock);
|
||||||
|
strncpy (proc->cwv, volume, VOLUME_MAX);
|
||||||
|
spin_unlock (&proc->lock);
|
||||||
|
|
||||||
|
return SYSRESULT (ST_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* int volume_close (void) */
|
||||||
|
DEFINE_SYSCALL (sys_volume_close) {
|
||||||
|
spin_lock (&proc->lock);
|
||||||
|
|
||||||
|
int ret = vfs_volume_close (proc, proc->cwv, rctx);
|
||||||
|
|
||||||
|
if (ret == ST_OK) {
|
||||||
|
memset (proc->cwv, 0, sizeof (proc->cwv));
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_unlock (&proc->lock);
|
||||||
|
|
||||||
|
return SYSRESULT (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* int read (char* path, size_t off, uint8_t* buffer, size_t size) */
|
||||||
|
DEFINE_SYSCALL (sys_read) {
|
||||||
uintptr_t uvaddr_path = a1;
|
uintptr_t uvaddr_path = a1;
|
||||||
|
size_t off = (size_t)a2;
|
||||||
|
uintptr_t uvaddr_buffer = a3;
|
||||||
|
size_t size = (size_t)a4;
|
||||||
|
|
||||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
|
|
||||||
@@ -313,48 +365,46 @@ DEFINE_SYSCALL (sys_open) {
|
|||||||
|
|
||||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||||
|
|
||||||
char mountpoint[fieldsizeof (struct vfs_mountpoint, key)];
|
|
||||||
const char* subpath = NULL;
|
|
||||||
|
|
||||||
if (!path_parse (path, mountpoint, &subpath))
|
|
||||||
return SYSRESULT (-ST_BAD_PATH);
|
|
||||||
|
|
||||||
return SYSRESULT (vfs_open (proc->procgroup, mountpoint, subpath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* int close (int handle) */
|
|
||||||
DEFINE_SYSCALL (sys_close) {
|
|
||||||
int handle = (int)a1;
|
|
||||||
|
|
||||||
return SYSRESULT (vfs_close (proc->procgroup, handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* int read (int handle, size_t off, uint8_t* buffer, size_t size) */
|
|
||||||
DEFINE_SYSCALL (sys_read) {
|
|
||||||
int handle = (int)a1;
|
|
||||||
size_t off = (size_t)a2;
|
|
||||||
uintptr_t uvaddr_buffer = a3;
|
|
||||||
size_t size = (size_t)a4;
|
|
||||||
|
|
||||||
uint8_t* buffer = sys_get_user_buffer (proc, uvaddr_buffer, size);
|
uint8_t* buffer = sys_get_user_buffer (proc, uvaddr_buffer, size);
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||||
|
|
||||||
return SYSRESULT (vfs_read (proc->procgroup, handle, buffer, off, size));
|
spin_lock (&proc->lock);
|
||||||
|
int ret = vfs_read (proc, proc->cwv, path, buffer, off, size, rctx);
|
||||||
|
spin_unlock (&proc->lock);
|
||||||
|
|
||||||
|
return SYSRESULT (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int describe (int handle, struct desc* desc) */
|
/* int describe (char* path, struct desc* desc) */
|
||||||
DEFINE_SYSCALL (sys_describe) {
|
DEFINE_SYSCALL (sys_describe) {
|
||||||
int handle = (int)a1;
|
uintptr_t uvaddr_path = a1;
|
||||||
uintptr_t uvaddr_desc = a2;
|
uintptr_t uvaddr_desc = a2;
|
||||||
|
|
||||||
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
|
|
||||||
|
uintptr_t out_paddr;
|
||||||
|
|
||||||
|
spin_lock (&proc->procgroup->lock);
|
||||||
|
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||||
|
spin_unlock (&proc->procgroup->lock);
|
||||||
|
|
||||||
|
if (out_paddr == 0)
|
||||||
|
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||||
|
|
||||||
|
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||||
|
|
||||||
struct desc* desc = sys_get_user_buffer (proc, uvaddr_desc, sizeof (struct desc));
|
struct desc* desc = sys_get_user_buffer (proc, uvaddr_desc, sizeof (struct desc));
|
||||||
|
|
||||||
if (desc == NULL)
|
if (desc == NULL)
|
||||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||||
|
|
||||||
return SYSRESULT (vfs_describe (proc->procgroup, handle, desc));
|
spin_lock (&proc->lock);
|
||||||
|
int ret = vfs_describe (proc, proc->cwv, path, desc, rctx);
|
||||||
|
spin_unlock (&proc->lock);
|
||||||
|
|
||||||
|
return SYSRESULT (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int get_procgroup (int pid) */
|
/* int get_procgroup (int pid) */
|
||||||
@@ -386,8 +436,8 @@ static syscall_handler_func_t handler_table[] = {
|
|||||||
[SYS_MUTEX_UNLOCK] = &sys_mutex_unlock,
|
[SYS_MUTEX_UNLOCK] = &sys_mutex_unlock,
|
||||||
[SYS_DEVICE_DO] = &sys_device_do,
|
[SYS_DEVICE_DO] = &sys_device_do,
|
||||||
[SYS_EXEC] = &sys_exec,
|
[SYS_EXEC] = &sys_exec,
|
||||||
[SYS_OPEN] = &sys_open,
|
[SYS_VOLUME_OPEN] = &sys_volume_open,
|
||||||
[SYS_CLOSE] = &sys_close,
|
[SYS_VOLUME_CLOSE] = &sys_volume_close,
|
||||||
[SYS_READ] = &sys_read,
|
[SYS_READ] = &sys_read,
|
||||||
[SYS_DESCRIBE] = &sys_describe,
|
[SYS_DESCRIBE] = &sys_describe,
|
||||||
[SYS_MAIL_SEND] = &sys_mail_send,
|
[SYS_MAIL_SEND] = &sys_mail_send,
|
||||||
|
|||||||
81
libaux/path.c
Normal file
81
libaux/path.c
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#include <path.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
bool path_validate_char (char ch) {
|
||||||
|
return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
||||||
|
(ch == '_') || (ch == '-') || (ch == '/') || (ch == '.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool path_validate (const char* path) {
|
||||||
|
if (path == NULL || *path == '\0')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const char* ptr = path;
|
||||||
|
|
||||||
|
if (*ptr != '/')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*ptr != '\0') {
|
||||||
|
if (*ptr == '/' && *(ptr + 1) == '/')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!path_validate_char (*ptr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr > path + 1 && *(ptr - 1) == '/')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool path_parse (const char* source, char* volume, const char** path) {
|
||||||
|
if (source == NULL || volume == NULL || path == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
while (source[i] != ':' && source[i] != '\0') {
|
||||||
|
if (i >= (VOLUME_MAX - 1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
volume[i] = source[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source[i] != ':' || i == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
volume[i] = '\0';
|
||||||
|
|
||||||
|
const char* internal_path = &source[i + 1];
|
||||||
|
|
||||||
|
if (!path_validate (internal_path))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*path = internal_path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* path_basename (const char* path) {
|
||||||
|
if (path == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
const char* last_slash = NULL;
|
||||||
|
const char* ptr = path;
|
||||||
|
|
||||||
|
while (*ptr != '\0') {
|
||||||
|
if (*ptr == '/')
|
||||||
|
last_slash = ptr;
|
||||||
|
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_slash == NULL)
|
||||||
|
return path;
|
||||||
|
|
||||||
|
return last_slash + 1;
|
||||||
|
}
|
||||||
12
libaux/path.h
Normal file
12
libaux/path.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef _LIBAUX_PATH_H
|
||||||
|
#define _LIBAUX_PATH_H
|
||||||
|
|
||||||
|
#include <path_defs.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool path_validate_char (char ch);
|
||||||
|
bool path_validate (const char* path);
|
||||||
|
bool path_parse (const char* source, char* volume, const char** path);
|
||||||
|
const char* path_basename (const char* path);
|
||||||
|
|
||||||
|
#endif // _LIBAUX_PATH_H
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
c += printf.c
|
c += printf.c \
|
||||||
|
path.c
|
||||||
|
|
||||||
o += printf.o
|
o += printf.o \
|
||||||
|
path.o
|
||||||
|
|||||||
@@ -39,18 +39,18 @@ int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4) {
|
|||||||
return (int)do_syscall (SYS_DEVICE_DO, device_id, cmd, a1, a2, a3, a4);
|
return (int)do_syscall (SYS_DEVICE_DO, device_id, cmd, a1, a2, a3, a4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int exec (const char* path) { return (int)do_syscall (SYS_EXEC, path); }
|
int exec (const char* volume, const char* path) { return (int)do_syscall (SYS_EXEC, volume, path); }
|
||||||
|
|
||||||
int open (const char* path) { return (int)do_syscall (SYS_OPEN, path); }
|
int volume_open (const char* volume) { return (int)do_syscall (SYS_VOLUME_OPEN, volume); }
|
||||||
|
|
||||||
int close (int handle) { return (int)do_syscall (SYS_CLOSE, handle); }
|
int volume_close (void) { return (int)do_syscall (SYS_VOLUME_CLOSE, 0); }
|
||||||
|
|
||||||
int read (int handle, size_t off, uint8_t* buffer, size_t size) {
|
int read (const char* path, size_t off, uint8_t* buffer, size_t size) {
|
||||||
return (int)do_syscall (SYS_READ, handle, off, buffer, size);
|
return (int)do_syscall (SYS_READ, path, off, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int describe (int handle, struct desc* desc) {
|
int describe (const char* path, struct desc* desc) {
|
||||||
return (int)do_syscall (SYS_DESCRIBE, handle, desc);
|
return (int)do_syscall (SYS_DESCRIBE, path, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mail_send (int pgid, void* mesg, size_t mesg_size) {
|
int mail_send (int pgid, void* mesg, size_t mesg_size) {
|
||||||
|
|||||||
@@ -51,19 +51,19 @@ void* argument_ptr (void);
|
|||||||
int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4);
|
int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4);
|
||||||
|
|
||||||
/* Run external ELF program */
|
/* Run external ELF program */
|
||||||
int exec (const char* path);
|
int exec (const char* volume, const char* path);
|
||||||
|
|
||||||
/* Open a file */
|
/* Open a file */
|
||||||
int open (const char* path);
|
int volume_open (const char* volume);
|
||||||
|
|
||||||
/* Close a file */
|
/* Close a file */
|
||||||
int close (int handle);
|
int volume_close (void);
|
||||||
|
|
||||||
/* Read a file */
|
/* Read a file */
|
||||||
int read (int handle, size_t off, uint8_t* buffer, size_t size);
|
int read (const char* path, size_t off, uint8_t* buffer, size_t size);
|
||||||
|
|
||||||
/* describe a file */
|
/* describe a file */
|
||||||
int describe (int handle, struct desc* desc);
|
int describe (const char* path, struct desc* desc);
|
||||||
|
|
||||||
/* send a message to a procgroup's mail */
|
/* send a message to a procgroup's mail */
|
||||||
int mail_send (int pgid, void* mesg, size_t mesg_size);
|
int mail_send (int pgid, void* mesg, size_t mesg_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user