shell: introduce part create command

This commit is contained in:
S.J.R. van Schaik 2017-03-23 15:20:00 +00:00
parent 886b90f5f3
commit 49c90e70f0
4 changed files with 46 additions and 0 deletions

View file

@ -20,6 +20,7 @@ obj-y += source/bitset.o
obj-y += source/main.o
obj-y += source/shell/cmd.o
obj-y += source/shell/flash.o
obj-y += source/shell/part.o
obj-y += source/core/flash.o

View file

@ -6,5 +6,7 @@ struct cmd {
};
void do_flash_cmd(const char *line);
void do_part_cmd(const char *line);
void cmd_exec(struct cmd *cmds, const char *line);
void cmd_loop(const char *s);

View file

@ -6,6 +6,7 @@
struct cmd main_cmds[] = {
{ "flash", do_flash_cmd },
{ "part", do_part_cmd },
{ NULL, NULL },
};

42
source/shell/part.c Normal file
View file

@ -0,0 +1,42 @@
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <flash.h>
#include <macros.h>
#include <shell.h>
#include <fs/part.h>
static void do_part_create(const char *s);
static struct cmd part_cmds[] = {
{ "create", do_part_create },
{ NULL, NULL },
};
extern struct flash_dev *flash;
static void do_part_create(const char *s)
{
(void)s;
if (!flash) {
fprintf(stderr, "error: no flash device probed.\n");
return;
}
if (part_create(flash) != 0) {
fprintf(stderr, "error: unable to create partition table.\n");
return;
}
}
void do_part_cmd(const char *line)
{
cmd_exec(part_cmds, line);
}