-/* $OpenBSD: cmd.c,v 1.137 2021/08/07 13:37:50 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.138 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
int
Xhelp(char *args, struct mbr *mbr)
{
- char help[80];
- char *mbrstr;
- int i;
-
- for (i = 0; cmd_table[i].cmd_name != NULL; i++) {
- strlcpy(help, cmd_table[i].cmd_help, sizeof(help));
- if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
- if (cmd_table[i].cmd_gpt == 0)
- continue;
- mbrstr = strstr(help, "MBR");
- if (mbrstr)
- memcpy(mbrstr, "GPT", 3);
- }
- printf("\t%s\t\t%s\n", cmd_table[i].cmd_name, help);
- }
+ USER_help();
return CMD_CONT;
}
-/* $OpenBSD: cmd.h,v 1.23 2021/07/12 22:18:54 krw Exp $ */
+/* $OpenBSD: cmd.h,v 1.24 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#define CMD_CLEAN 0x0003
#define CMD_DIRTY 0x0004
-struct cmd {
- char *cmd_name;
- int cmd_gpt;
- int (*cmd_fcn)(char *, struct mbr *);
- char *cmd_help;
-};
-extern const struct cmd cmd_table[];
-
int Xreinit(char *, struct mbr *);
int Xdisk(char *, struct mbr *);
int Xmanual(char *, struct mbr *);
-/* $OpenBSD: misc.h,v 1.39 2021/07/12 22:18:54 krw Exp $ */
+/* $OpenBSD: misc.h,v 1.40 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
extern struct unit_type unit_types[];
#define SECTORS 1
+#ifndef nitems
+#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
+#endif
+
/* Prototypes */
int unit_lookup(const char *);
int string_from_line(char *, const size_t);
-/* $OpenBSD: part.c,v 1.102 2021/07/22 13:30:40 krw Exp $ */
+/* $OpenBSD: part.c,v 1.103 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
{ "2e54b353-1271-4842-806f-e436d6af6985" }, /* HiFive BBL */
};
-#ifndef nitems
-#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
-#endif
-
int
PRT_protected_guid(const struct uuid *uuid)
{
-/* $OpenBSD: user.c,v 1.70 2021/08/10 13:48:34 krw Exp $ */
+/* $OpenBSD: user.c,v 1.71 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#include "gpt.h"
#include "disk.h"
+struct cmd {
+ char *cmd_name;
+ int cmd_gpt;
+ int (*cmd_fcn)(char *, struct mbr *);
+ char *cmd_help;
+};
+
const struct cmd cmd_table[] = {
{"help", 1, Xhelp, "Command help list"},
{"manual", 1, Xmanual, "Show entire OpenBSD man page for fdisk"},
{"exit", 1, Xexit, "Exit edit of current MBR, without saving changes"},
{"quit", 1, Xquit, "Quit edit of current MBR, saving current changes"},
{"abort", 1, Xabort, "Abort program without saving current changes"},
- {NULL, 0, NULL, NULL}
};
if (cmd[0] == '\0')
continue;
- for (i = 0; cmd_table[i].cmd_name != NULL; i++)
+ for (i = 0; i < nitems(cmd_table); i++)
if (strstr(cmd_table[i].cmd_name, cmd) == cmd_table[i].cmd_name)
break;
} while (lba_self);
}
+void
+USER_help(void)
+{
+ char help[80];
+ char *mbrstr;
+ int i;
+
+ for (i = 0; i < nitems(cmd_table); i++) {
+ strlcpy(help, cmd_table[i].cmd_help, sizeof(help));
+ if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
+ if (cmd_table[i].cmd_gpt == 0)
+ continue;
+ mbrstr = strstr(help, "MBR");
+ if (mbrstr)
+ memcpy(mbrstr, "GPT", 3);
+ }
+ printf("\t%s\t\t%s\n", cmd_table[i].cmd_name, help);
+ }
+}
+
void
ask_cmd(char **cmd, char **arg)
{
-/* $OpenBSD: user.h,v 1.19 2021/07/13 15:03:34 krw Exp $ */
+/* $OpenBSD: user.h,v 1.20 2021/08/12 12:31:16 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
/* Prototypes */
void USER_edit(const uint64_t, const uint64_t);
void USER_print_disk(const int);
+void USER_help(void);
#endif /* _USER_H */