summaryrefslogtreecommitdiffstats
path: root/sbin/fsdb
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>1996-09-26 19:40:04 +0000
committerguido <guido@FreeBSD.org>1996-09-26 19:40:04 +0000
commitce5e7a35c47482f8a47209660ff5a8763349d5ff (patch)
tree6e8d13823eae4affb161f208448a7496af8b8eea /sbin/fsdb
parent5b7e1029fb7af0d235a6e79ba6c8b21f7118b589 (diff)
downloadFreeBSD-src-ce5e7a35c47482f8a47209660ff5a8763349d5ff.zip
FreeBSD-src-ce5e7a35c47482f8a47209660ff5a8763349d5ff.tar.gz
Add chlen command so you can set the size of an inode. This was handy
in order to create sparse directory files that caused a panic of a filesystem where fsck would not find anything. A fix for fsck is in the make but still has to be reviewed by Kirk McKusick.
Diffstat (limited to 'sbin/fsdb')
-rw-r--r--sbin/fsdb/fsdb.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c
index 5d263aa..aba9f1b 100644
--- a/sbin/fsdb/fsdb.c
+++ b/sbin/fsdb/fsdb.c
@@ -130,6 +130,7 @@ CMDFUNC(rm); /* remove name */
CMDFUNC(ln); /* add name */
CMDFUNC(newtype); /* change type */
CMDFUNC(chmode); /* change mode */
+CMDFUNC(chlen); /* change length */
CMDFUNC(chaflags); /* change flags */
CMDFUNC(chgen); /* change generation */
CMDFUNC(chowner); /* change owner */
@@ -162,6 +163,7 @@ struct cmdtable cmds[] = {
{ "chname", "Change dir entry number INDEX to NAME", 3, 3, chname },
{ "chtype", "Change type of current inode to TYPE", 2, 2, newtype },
{ "chmod", "Change mode of current inode to MODE", 2, 2, chmode },
+ { "chlen", "Change length of current inode to LENGTH", 2, 2, chlen },
{ "chown", "Change owner of current inode to OWNER", 2, 2, chowner },
{ "chgrp", "Change group of current inode to GROUP", 2, 2, chgroup },
{ "chflags", "Change flags of current inode to FLAGS", 2, 2, chaflags },
@@ -630,6 +632,27 @@ CMDFUNCSTART(newtype)
return 0;
}
+CMDFUNCSTART(chlen)
+{
+ int rval = 1;
+ long len;
+ char *cp;
+
+ if (!checkactive())
+ return 1;
+
+ len = strtol(argv[1], &cp, 0);
+ if (cp == argv[1] || *cp != '\0' || len < 0) {
+ warnx("bad length `%s'", argv[1]);
+ return 1;
+ }
+
+ curinode->di_size = len;
+ inodirty();
+ printactive();
+ return rval;
+}
+
CMDFUNCSTART(chmode)
{
int rval = 1;
OpenPOWER on IntegriCloud