aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsdb
diff options
context:
space:
mode:
authorMaxim Konovalov <maxim@FreeBSD.org>2006-04-21 20:33:16 +0000
committerMaxim Konovalov <maxim@FreeBSD.org>2006-04-21 20:33:16 +0000
commit1bc508492ad9623be86882686ec91494bc56d674 (patch)
treef0c4d3039e1e8f8159eb571a5479be984ebc0479 /sbin/fsdb
parent1def0ca64d4f9b641fb4c9f25f8f4df9bb1d4847 (diff)
downloadsrc-1bc508492ad9623be86882686ec91494bc56d674.tar.gz
src-1bc508492ad9623be86882686ec91494bc56d674.zip
o Do recrack(arguments) for commands which actually take NAME as
arguments so we do not coredump at "help foo", "back bar" and such. o Be consistent and print argc - 1 as a command arguments number in all cases. PR: bin/37096 Submitted by: Joshua Goodall MFC after: 1 month
Notes
Notes: svn path=/head/; revision=157950
Diffstat (limited to 'sbin/fsdb')
-rw-r--r--sbin/fsdb/fsdb.c19
-rw-r--r--sbin/fsdb/fsdb.h1
-rw-r--r--sbin/fsdb/fsdbutil.c2
3 files changed, 12 insertions, 10 deletions
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c
index d9828bdbf4ea..21a0ae511287 100644
--- a/sbin/fsdb/fsdb.c
+++ b/sbin/fsdb/fsdb.c
@@ -151,8 +151,8 @@ struct cmdtable cmds[] = {
{ "?", "Print out help", 1, 1, FL_RO, helpfn },
{ "inode", "Set active inode to INUM", 2, 2, FL_RO, focus },
{ "clri", "Clear inode INUM", 2, 2, FL_WR, zapi },
- { "lookup", "Set active inode by looking up NAME", 2, 2, FL_RO, focusname },
- { "cd", "Set active inode by looking up NAME", 2, 2, FL_RO, focusname },
+ { "lookup", "Set active inode by looking up NAME", 2, 2, FL_RO | FL_ST, focusname },
+ { "cd", "Set active inode by looking up NAME", 2, 2, FL_RO | FL_ST, focusname },
{ "back", "Go to previous active inode", 1, 1, FL_RO, back },
{ "active", "Print active inode", 1, 1, FL_RO, active },
{ "print", "Print active inode", 1, 1, FL_RO, active },
@@ -161,11 +161,11 @@ struct cmdtable cmds[] = {
{ "downlink", "Decrement link count", 1, 1, FL_WR, downlink },
{ "linkcount", "Set link count to COUNT", 2, 2, FL_WR, linkcount },
{ "ls", "List current inode as directory", 1, 1, FL_RO, ls },
- { "rm", "Remove NAME from current inode directory", 2, 2, FL_WR, rm },
- { "del", "Remove NAME from current inode directory", 2, 2, FL_WR, rm },
- { "ln", "Hardlink INO into current inode directory as NAME", 3, 3, FL_WR, ln },
+ { "rm", "Remove NAME from current inode directory", 2, 2, FL_WR | FL_ST, rm },
+ { "del", "Remove NAME from current inode directory", 2, 2, FL_WR | FL_ST, rm },
+ { "ln", "Hardlink INO into current inode directory as NAME", 3, 3, FL_WR | FL_ST, ln },
{ "chinum", "Change dir entry number INDEX to INUM", 3, 3, FL_WR, chinum },
- { "chname", "Change dir entry number INDEX to NAME", 3, 3, FL_WR, chname },
+ { "chname", "Change dir entry number INDEX to NAME", 3, 3, FL_WR | FL_ST, chname },
{ "chtype", "Change type of current inode to TYPE", 2, 2, FL_WR, newtype },
{ "chmod", "Change mode of current inode to MODE", 2, 2, FL_WR, chmode },
{ "chlen", "Change length of current inode to LENGTH", 2, 2, FL_WR, chlen },
@@ -188,11 +188,11 @@ helpfn(int argc, char *argv[])
struct cmdtable *cmdtp;
printf("Commands are:\n%-10s %5s %5s %s\n",
- "command", "min argc", "max argc", "what");
+ "command", "min args", "max args", "what");
for (cmdtp = cmds; cmdtp->cmd; cmdtp++)
printf("%-10s %5u %5u %s\n",
- cmdtp->cmd, cmdtp->minargc, cmdtp->maxargc, cmdtp->helptxt);
+ cmdtp->cmd, cmdtp->minargc-1, cmdtp->maxargc-1, cmdtp->helptxt);
return 0;
}
@@ -255,7 +255,8 @@ cmdloop(void)
else if (cmd_argc >= cmdp->minargc &&
cmd_argc <= cmdp->maxargc)
rval = (*cmdp->handler)(cmd_argc, cmd_argv);
- else if (cmd_argc >= cmdp->minargc) {
+ else if (cmd_argc >= cmdp->minargc &&
+ (cmdp->flags & FL_ST) == FL_ST) {
strcpy(line, elline);
cmd_argv = recrack(line, &cmd_argc, cmdp->maxargc);
rval = (*cmdp->handler)(cmd_argc, cmd_argv);
diff --git a/sbin/fsdb/fsdb.h b/sbin/fsdb/fsdb.h
index a739c47f1a0a..abe1f4760ccb 100644
--- a/sbin/fsdb/fsdb.h
+++ b/sbin/fsdb/fsdb.h
@@ -48,6 +48,7 @@ struct cmdtable {
unsigned int flags;
#define FL_RO 0x0000 /* for symmetry */
#define FL_WR 0x0001 /* wants to write */
+#define FL_ST 0x0002 /* resplit final string if argc > maxargc */
int (*handler)(int argc, char *argv[]);
};
extern union dinode *curinode;
diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c
index b00061941e00..474ac82f1b9a 100644
--- a/sbin/fsdb/fsdbutil.c
+++ b/sbin/fsdb/fsdbutil.c
@@ -98,7 +98,7 @@ argcount(struct cmdtable *cmdp, int argc, char *argv[])
{
if (cmdp->minargc == cmdp->maxargc)
warnx("command `%s' takes %u arguments, got %u", cmdp->cmd,
- cmdp->minargc-1, argc);
+ cmdp->minargc-1, argc-1);
else
warnx("command `%s' takes from %u to %u arguments",
cmdp->cmd, cmdp->minargc-1, cmdp->maxargc-1);