summaryrefslogtreecommitdiffstats
path: root/sbin/fsdb
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2006-04-21 20:33:16 +0000
committermaxim <maxim@FreeBSD.org>2006-04-21 20:33:16 +0000
commit9f0fef2ee11028561e0199425e62c036a72300b7 (patch)
treef0c4d3039e1e8f8159eb571a5479be984ebc0479 /sbin/fsdb
parent782918fd852836566f16c74c69a96f9d7020e38b (diff)
downloadFreeBSD-src-9f0fef2ee11028561e0199425e62c036a72300b7.zip
FreeBSD-src-9f0fef2ee11028561e0199425e62c036a72300b7.tar.gz
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
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 d9828bd..21a0ae5 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 a739c47..abe1f47 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 b000619..474ac82 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);
OpenPOWER on IntegriCloud