diff options
author | Kirk McKusick <mckusick@FreeBSD.org> | 2023-04-18 05:42:32 +0000 |
---|---|---|
committer | Kirk McKusick <mckusick@FreeBSD.org> | 2023-04-18 23:13:26 +0000 |
commit | 7636973c68f15419a71bc8e4253b2fbae3258025 (patch) | |
tree | fb3a1d1a1b3c3b95a800f9849c2ef943d6e5f3a1 /sbin/fsdb/fsdb.c | |
parent | 238271f4a66bd06b8b9a232a82f3ee0882e4cbb9 (diff) | |
download | src-7636973c68f15419a71bc8e4253b2fbae3258025.tar.gz src-7636973c68f15419a71bc8e4253b2fbae3258025.zip |
Add `chdb' command to fsdb(8) to set direct block numbers.
Add the ability to set direct blocks numbers in inodes so that manual
corrections can be made. No checking of the values is attempted so
accidental or deliberate bad values can be set.
Submitted by: Chuck Silvers
MFC after: 1 week
Diffstat (limited to 'sbin/fsdb/fsdb.c')
-rw-r--r-- | sbin/fsdb/fsdb.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index a7d3a439b6b3..887a77dbb8cb 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -161,6 +161,7 @@ CMDFUNC(chatime); /* Change atime */ CMDFUNC(chinum); /* Change inode # of dirent */ CMDFUNC(chname); /* Change dirname of dirent */ CMDFUNC(chsize); /* Change size */ +CMDFUNC(chdb); /* Change direct block pointer */ struct cmdtable cmds[] = { { "help", "Print out help", 1, 1, FL_RO, helpfn }, @@ -195,6 +196,7 @@ struct cmdtable cmds[] = { { "mtime", "Change mtime of current inode to MTIME", 2, 2, FL_WR, chmtime }, { "ctime", "Change ctime of current inode to CTIME", 2, 2, FL_WR, chctime }, { "atime", "Change atime of current inode to ATIME", 2, 2, FL_WR, chatime }, + { "chdb", "Change db pointer N of current inode to BLKNO", 3, 3, FL_WR, chdb }, { "quit", "Exit", 1, 1, FL_RO, quit }, { "q", "Exit", 1, 1, FL_RO, quit }, { "exit", "Exit", 1, 1, FL_RO, quit }, @@ -1046,6 +1048,36 @@ CMDFUNCSTART(chsize) return rval; } +CMDFUNC(chdb) +{ + unsigned int idx; + daddr_t bno; + char *cp; + + if (!checkactive()) + return 1; + + idx = strtoull(argv[1], &cp, 0); + if (cp == argv[1] || *cp != '\0') { + warnx("bad pointer idx `%s'", argv[1]); + return 1; + } + bno = strtoll(argv[2], &cp, 0); + if (cp == argv[2] || *cp != '\0') { + warnx("bad block number `%s'", argv[2]); + return 1; + } + if (idx >= UFS_NDADDR) { + warnx("pointer index %d is out of range", idx); + return 1; + } + + DIP_SET(curinode, di_db[idx], bno); + inodirty(&curip); + printactive(0); + return 0; +} + CMDFUNCSTART(linkcount) { int rval = 1; |