Date: Sat, 29 Apr 2023 18:08:02 GMT From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 146ba7a1d60c - stable/13 - Add `chdb' command to fsdb(8) to set direct block numbers. Message-ID: <202304291808.33TI82JA003236@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=146ba7a1d60c7ab8959d41ccfdd2543cc5d18b34 commit 146ba7a1d60c7ab8959d41ccfdd2543cc5d18b34 Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2023-04-18 05:42:32 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> CommitDate: 2023-04-29 18:04:53 +0000 Add `chdb' command to fsdb(8) to set direct block numbers. (cherry picked from commit 7636973c68f15419a71bc8e4253b2fbae3258025) --- sbin/fsdb/fsdb.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index 4d66194bf86d..f907ea160a16 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304291808.33TI82JA003236>