Create libioutil, implement a filewriter
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m21s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m21s
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <path_defs.h>
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
#include <write_file.h>
|
||||
|
||||
static int fat1_diskio_read (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* buffer,
|
||||
uint32_t sector_count) {
|
||||
@@ -196,13 +197,18 @@ int fatfs_read_file (struct vfs_volume* volume, const char* path, uint8_t* buffe
|
||||
}
|
||||
|
||||
int fatfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||
size_t size) {
|
||||
size_t size, uint32_t flags) {
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
|
||||
if (fl_is_dir (fatfs_ctx, path))
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
FL_FILE* file = fl_fopen (fatfs_ctx, path, "wb+");
|
||||
FL_FILE* file;
|
||||
|
||||
if ((flags & WF_APPEND))
|
||||
file = fl_fopen (fatfs_ctx, path, "wb+");
|
||||
else
|
||||
file = fl_fopen (fatfs_ctx, path, "wb");
|
||||
|
||||
if (file == NULL)
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
@@ -22,7 +22,7 @@ int fatfs_read_file (struct vfs_volume* volume, const char* path, uint8_t* buffe
|
||||
size_t size);
|
||||
|
||||
int fatfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||
size_t size);
|
||||
size_t size, uint32_t flags);
|
||||
|
||||
int fatfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct dir_entry* entry,
|
||||
size_t entry_num);
|
||||
|
||||
@@ -199,8 +199,8 @@ int tarfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct di
|
||||
}
|
||||
|
||||
int tarfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||
size_t size) {
|
||||
(void)volume, (void)path, (void)buffer, (void)off, (void)size;
|
||||
size_t size, uint32_t flags) {
|
||||
(void)volume, (void)path, (void)buffer, (void)off, (void)size, (void)flags;
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ int tarfs_read_file (struct vfs_volume* volume, const char* path, uint8_t* buffe
|
||||
size_t size);
|
||||
|
||||
int tarfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||
size_t size);
|
||||
size_t size, uint32_t flags);
|
||||
|
||||
int tarfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct dir_entry* entry,
|
||||
size_t entry_num);
|
||||
|
||||
@@ -206,7 +206,7 @@ int vfs_read_file (struct proc* proc, const char* volume_name, const char* path,
|
||||
}
|
||||
|
||||
int vfs_write_file (struct proc* proc, const char* volume_name, const char* path, uint8_t* buffer,
|
||||
size_t off, size_t size) {
|
||||
size_t off, size_t size, uint32_t flags) {
|
||||
struct vfs_volume* volume = vfs_find_volume (volume_name);
|
||||
|
||||
if (volume == NULL)
|
||||
@@ -221,7 +221,7 @@ int vfs_write_file (struct proc* proc, const char* volume_name, const char* path
|
||||
|
||||
spin_unlock (&volume->lock);
|
||||
|
||||
return volume->driver_ops.write_file (volume, path, buffer, off, size);
|
||||
return volume->driver_ops.write_file (volume, path, buffer, off, size, flags);
|
||||
}
|
||||
|
||||
int vfs_create_file (struct proc* proc, const char* volume_name, const char* path) {
|
||||
|
||||
@@ -42,7 +42,7 @@ struct vfs_volume {
|
||||
size_t size);
|
||||
|
||||
int (*write_file) (struct vfs_volume* volume, const char* path, uint8_t* buffer, size_t off,
|
||||
size_t size);
|
||||
size_t size, uint32_t flags);
|
||||
|
||||
int (*read_dir_entry) (struct vfs_volume* volume, const char* path, struct dir_entry* entry,
|
||||
size_t entry_num);
|
||||
@@ -70,7 +70,7 @@ int vfs_read_file (struct proc* proc, const char* volume, const char* path, uint
|
||||
size_t off, size_t size);
|
||||
|
||||
int vfs_write_file (struct proc* proc, const char* volume, const char* path, uint8_t* buffer,
|
||||
size_t off, size_t size);
|
||||
size_t off, size_t size, uint32_t flags);
|
||||
|
||||
int vfs_describe (struct proc* proc, const char* volume, const char* path, struct desc* desc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user