Compare commits
4 Commits
e61545c4cf
...
858e55118b
| Author | SHA1 | Date | |
|---|---|---|---|
| 858e55118b | |||
| 6313191b9b | |||
| a4c485587e | |||
| 1571469685 |
16
ce/ce.c
16
ce/ce.c
@@ -58,11 +58,15 @@ void cprintf (struct context* context, const char* fmt, ...) {
|
||||
return;
|
||||
}
|
||||
|
||||
vsnprintf (buf, CPRINTF_BUF_MAX, fmt, args);
|
||||
int len = vsnprintf (buf, CPRINTF_BUF_MAX, fmt, args);
|
||||
|
||||
va_end (args);
|
||||
|
||||
strbuf_append_str (&context->strbuf, buf);
|
||||
if (len > 0) {
|
||||
for (int i = 0; i < len; i++)
|
||||
strbuf_append (&context->strbuf, buf[i]);
|
||||
}
|
||||
|
||||
free (buf);
|
||||
}
|
||||
|
||||
@@ -431,10 +435,14 @@ static void ls (struct context* context, const char* path_string) {
|
||||
cprintf (context, "\n");
|
||||
|
||||
for (size_t entry_num = 0; entry_num < entries; entry_num++) {
|
||||
memset (&desc, 0, sizeof (desc));
|
||||
memset (&entry, 0, sizeof (entry));
|
||||
|
||||
read_dir_entry (path, &entry, entry_num);
|
||||
describe (entry.path, &desc);
|
||||
|
||||
cprintf (context, "%-40s%c %-40zu\n", entry.path, (desc.type == FS_DIR ? '*' : ' '), desc.size);
|
||||
cprintf (context, "%c %-40s %-40zu\n", (desc.type == FS_DIR ? 'D' : 'F'), entry.path,
|
||||
desc.size);
|
||||
}
|
||||
|
||||
volume_close ();
|
||||
@@ -489,7 +497,7 @@ static void execute_redir (struct ast_redir* redir, struct context* context) {
|
||||
}
|
||||
|
||||
create_file (path);
|
||||
write_file (path, 0, (uint8_t*)context->strbuf.items, context->strbuf.count);
|
||||
write_file (path, 0, (uint8_t*)context->strbuf.items, context->strbuf.count - 1);
|
||||
|
||||
volume_close ();
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ void bootmain (void) {
|
||||
struct device* ramdisk = device_find ("RD");
|
||||
vfs_create_volume ("RD", VFS_TARFS, ramdisk, false);
|
||||
|
||||
struct device* vdisk = device_find ("VD");
|
||||
device_probe_partitions (vdisk);
|
||||
struct device* temp = device_find ("TEMP");
|
||||
device_probe_partitions (temp);
|
||||
|
||||
struct device* vdp0 = device_find ("VDp0");
|
||||
vfs_create_volume ("VD", VFS_FAT32, vdp0, true);
|
||||
struct device* tempp0 = device_find ("TEMPp0");
|
||||
vfs_create_volume ("TEMP", VFS_FAT32, tempp0, true);
|
||||
|
||||
proc_pid_alloc_init ();
|
||||
procgroup_pgid_alloc_init ();
|
||||
|
||||
@@ -119,7 +119,7 @@ void ramdisk_device_init (void) {
|
||||
device_create ("RD", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init);
|
||||
}
|
||||
|
||||
void vdisk_device_init (void) {
|
||||
void temp_device_init (void) {
|
||||
device_op_func_t ops[] = {
|
||||
[XDRV_GET_SIZE] = &ramdrv_get_size,
|
||||
[XDRV_GET_SECTOR_SIZE] = &ramdrv_get_sector_size,
|
||||
@@ -142,15 +142,15 @@ void vdisk_device_init (void) {
|
||||
mbr.ptes[0].start_lba = 1;
|
||||
mbr.ptes[0].sector_count = div_align_up (init.total_size, init.sector_size) - 1;
|
||||
|
||||
struct device* vdisk =
|
||||
device_create ("VD", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init);
|
||||
struct device* temp =
|
||||
device_create ("TEMP", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init);
|
||||
|
||||
size_t sector = 0;
|
||||
size_t sector_count = 1;
|
||||
|
||||
spin_lock (&vdisk->lock);
|
||||
device_op (vdisk, XDRV_WRITE, NULL, NULL, §or, §or_count, &mbr);
|
||||
spin_unlock (&vdisk->lock);
|
||||
spin_lock (&temp->lock);
|
||||
device_op (temp, XDRV_WRITE, NULL, NULL, §or, §or_count, &mbr);
|
||||
spin_unlock (&temp->lock);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
@@ -167,7 +167,7 @@ void devices_init (void) {
|
||||
|
||||
terminal_device_init ();
|
||||
ramdisk_device_init ();
|
||||
vdisk_device_init ();
|
||||
temp_device_init ();
|
||||
|
||||
#if defined(__x86_64__)
|
||||
ps2kb_device_init ();
|
||||
|
||||
@@ -179,6 +179,9 @@ int fatfs_read_file (struct vfs_volume* volume, const char* path, uint8_t* buffe
|
||||
size_t size) {
|
||||
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+");
|
||||
|
||||
if (file == NULL)
|
||||
@@ -196,6 +199,9 @@ int fatfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buff
|
||||
size_t size) {
|
||||
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+");
|
||||
|
||||
if (file == NULL)
|
||||
@@ -214,6 +220,9 @@ int fatfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct di
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
FL_DIR dir;
|
||||
|
||||
if (!fl_is_dir (fatfs_ctx, path))
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
if (fl_opendir (fatfs_ctx, path, &dir) == NULL)
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user