sdutil FAT formatting, libfat fix memcpy overflow, generate linker .map files for user apps
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m46s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m46s
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <devices.h>
|
||||
#include <fs_types.h>
|
||||
#include <in_input.h>
|
||||
#include <libfat.h>
|
||||
#include <mprintf.h>
|
||||
#include <process_self.h>
|
||||
#include <status.h>
|
||||
@@ -120,6 +122,22 @@ static void list_part_dos (const char* dev_name) {
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
static void format_fat32 (const char* dev_name) {
|
||||
struct fatfs_ctx ctx;
|
||||
|
||||
int r = fat_format_drive (&ctx, dev_name, FS_FAT32);
|
||||
|
||||
mprintf ("\nFormatting done: %s (%d)\n", str_status[r < 0 ? -r : r], r);
|
||||
}
|
||||
|
||||
static void format_fat16 (const char* dev_name) {
|
||||
struct fatfs_ctx ctx;
|
||||
|
||||
int r = fat_format_drive (&ctx, dev_name, FS_FAT16);
|
||||
|
||||
mprintf ("\nFormatting done: %s (%d)\n", str_status[r < 0 ? -r : r], r);
|
||||
}
|
||||
|
||||
void app_main (void) {
|
||||
libprocess_self_init ();
|
||||
|
||||
@@ -142,6 +160,20 @@ void app_main (void) {
|
||||
}
|
||||
|
||||
list_part_dos (devnamebuf);
|
||||
} else if (strcmp (commandbuf, "format_fat32") == 0) {
|
||||
if (env_get (process_get_pgid (), "dev", (void*)devnamebuf, sizeof (devnamebuf)) != ST_OK) {
|
||||
mprintf ("ERROR dev=???. No device name provided for format_fat32\n");
|
||||
return;
|
||||
}
|
||||
|
||||
format_fat32 (devnamebuf);
|
||||
} else if (strcmp (commandbuf, "format_fat16") == 0) {
|
||||
if (env_get (process_get_pgid (), "dev", (void*)devnamebuf, sizeof (devnamebuf)) != ST_OK) {
|
||||
mprintf ("ERROR dev=???. No device name provided for format_fat16\n");
|
||||
return;
|
||||
}
|
||||
|
||||
format_fat16 (devnamebuf);
|
||||
} else {
|
||||
mprintf ("ERROR C=%s. Unknown command\n", commandbuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user