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:
@@ -8,7 +8,7 @@
|
||||
#include <libk/string.h>
|
||||
#include <limine/requests.h>
|
||||
#include <mm/liballoc.h>
|
||||
#include <path.h>
|
||||
#include <path_defs.h>
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
#include <xdrv_device.h>
|
||||
@@ -16,7 +16,7 @@
|
||||
static struct tar_file* tar_get_file (struct tarfs* tarfs, const char* filename) {
|
||||
for (size_t i = 0; i < TARFS_FILES_MAX; i++) {
|
||||
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 NULL;
|
||||
@@ -54,8 +54,7 @@ static size_t tar_parse (struct tarfs* tarfs, uint8_t* addr) {
|
||||
return i;
|
||||
}
|
||||
|
||||
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) {
|
||||
struct tarfs* tarfs = malloc (sizeof (*tarfs));
|
||||
|
||||
if (tarfs == NULL)
|
||||
@@ -63,9 +62,9 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
|
||||
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;
|
||||
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);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock);
|
||||
free (mountpoint->udata);
|
||||
free (volume->udata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
NULL);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock);
|
||||
free (mountpoint->udata);
|
||||
free (volume->udata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
|
||||
if (buffer == NULL) {
|
||||
spin_unlock (&back_device->lock);
|
||||
free (mountpoint->udata);
|
||||
free (volume->udata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -114,15 +113,15 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tarfs_describe (struct vfs_mountpoint* mountpoint, const char* path, struct desc* desc) {
|
||||
(void)mountpoint;
|
||||
int tarfs_describe (struct vfs_volume* volume, const char* path, struct desc* desc) {
|
||||
(void)volume;
|
||||
|
||||
const char* filename = path_basename (path);
|
||||
|
||||
if (filename == NULL)
|
||||
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)
|
||||
return -ST_NOT_FOUND;
|
||||
@@ -133,16 +132,16 @@ int tarfs_describe (struct vfs_mountpoint* mountpoint, const char* path, struct
|
||||
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) {
|
||||
(void)mountpoint;
|
||||
(void)volume;
|
||||
|
||||
const char* filename = path_basename (path);
|
||||
|
||||
if (filename == NULL)
|
||||
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)
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
Reference in New Issue
Block a user