diff options
-rw-r--r-- | sbin/fsck_ffs/dir.c | 69 | ||||
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/inode.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 40 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass2.c | 44 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 15 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 131 | ||||
-rw-r--r-- | sbin/fsck_ffs/utilities.c | 5 |
9 files changed, 75 insertions, 244 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index 39f3406352e..4784b604f0a 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.25 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: dir.c,v 1.26 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -115,29 +115,8 @@ dirscan(struct inodesc *idesc) for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) { dsize = dp->d_reclen; memcpy(dbuf, dp, (size_t)dsize); -# if (BYTE_ORDER == LITTLE_ENDIAN) - if (!newinofmt) { - struct direct *tdp = (struct direct *)dbuf; - u_char tmp; - - tmp = tdp->d_namlen; - tdp->d_namlen = tdp->d_type; - tdp->d_type = tmp; - } -# endif idesc->id_dirp = (struct direct *)dbuf; if ((n = (*idesc->id_func)(idesc)) & ALTERED) { -# if (BYTE_ORDER == LITTLE_ENDIAN) - if (!newinofmt && !doinglevel2) { - struct direct *tdp; - u_char tmp; - - tdp = (struct direct *)dbuf; - tmp = tdp->d_namlen; - tdp->d_namlen = tdp->d_type; - tdp->d_type = tmp; - } -# endif bp = getdirblk(idesc->id_blkno, blksiz); memcpy(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf, (size_t)dsize); @@ -230,19 +209,9 @@ dircheck(struct inodesc *idesc, struct direct *dp) return (0); if (dp->d_ino == 0) return (1); - size = DIRSIZ(!newinofmt, dp); -# if (BYTE_ORDER == LITTLE_ENDIAN) - if (!newinofmt) { - type = dp->d_namlen; - namlen = dp->d_type; - } else { - namlen = dp->d_namlen; - type = dp->d_type; - } -# else - namlen = dp->d_namlen; - type = dp->d_type; -# endif + size = DIRSIZ(0, dp); + namlen = dp->d_namlen; + type = dp->d_type; if (dp->d_reclen < size || idesc->id_filesize < size || type > 15) @@ -334,27 +303,9 @@ mkentry(struct inodesc *idesc) dirp = (struct direct *)(((char *)dirp) + oldlen); dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ dirp->d_reclen = newent.d_reclen; - if (newinofmt) - dirp->d_type = GET_ITYPE(idesc->id_parent); - else - dirp->d_type = 0; + dirp->d_type = GET_ITYPE(idesc->id_parent); dirp->d_namlen = newent.d_namlen; memcpy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1); -# if (BYTE_ORDER == LITTLE_ENDIAN) - /* - * If the entry was split, dirscan() will only reverse the byte - * order of the original entry, and not the new one, before - * writing it back out. So, we reverse the byte order here if - * necessary. - */ - if (oldlen != 0 && !newinofmt && !doinglevel2) { - u_char tmp; - - tmp = dirp->d_namlen; - dirp->d_namlen = dirp->d_type; - dirp->d_type = tmp; - } -# endif return (ALTERED|STOP); } @@ -366,10 +317,7 @@ chgino(struct inodesc *idesc) if (memcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1)) return (KEEPON); dirp->d_ino = idesc->id_parent; - if (newinofmt) - dirp->d_type = GET_ITYPE(idesc->id_parent); - else - dirp->d_type = 0; + dirp->d_type = GET_ITYPE(idesc->id_parent); return (ALTERED|STOP); } @@ -615,10 +563,7 @@ allocdir(ino_t parent, ino_t request, int mode) struct inoinfo *inp; ino = allocino(request, IFDIR|mode); - if (newinofmt) - dirp = &dirhead; - else - dirp = (struct dirtemplate *)&odirhead; + dirp = &dirhead; dirp->dot_ino = ino; dirp->dotdot_ino = parent; dp = ginode(ino); diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 21351b9ba2b..9e86c148367 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.24 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: fsck.h,v 1.25 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */ /* @@ -237,9 +237,6 @@ char yflag; /* assume a yes response */ int bflag; /* location of alternate super block */ int debug; /* output debugging info */ int cvtlevel; /* convert to newer file system format */ -int doinglevel1; /* converting to new cylinder group format */ -int doinglevel2; /* converting to new inode format */ -int newinofmt; /* filesystem has new inode format */ char usedsoftdep; /* just fix soft dependency inconsistencies */ int preen; /* just fix normal inconsistencies */ char resolved; /* cleared if unresolved changes => not clean */ diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 65b2cc48349..afa0df5785c 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.34 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: inode.c,v 1.35 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */ /* @@ -650,8 +650,7 @@ allocino(ino_t request, int type) DIP_SET(dp, di_blocks, btodb(sblock.fs_fsize)); n_files++; inodirty(); - if (newinofmt) - SET_ITYPE(ino, IFTODT(type)); + SET_ITYPE(ino, IFTODT(type)); return (ino); } diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index ff585478f3a..ec2798cebbd 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.37 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: main.c,v 1.38 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -76,6 +76,9 @@ main(int argc, char *argv[]) case 'c': skipclean = 0; cvtlevel = argtoi('c', "conversion level", optarg, 10); + if (cvtlevel < 3) + errexit("cannot do level %d conversion\n", + cvtlevel); break; case 'd': diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 52e2c9af228..dfd37bea54c 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.34 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: pass1.c,v 1.35 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */ /* @@ -259,34 +259,6 @@ checkinode(ino_t inumber, struct inodesc *idesc) ndb++; if (mode == IFLNK) { /* - * Note that the old fastlink format always had di_blocks set - * to 0. Other than that we no longer use the `spare' field - * (which is now the extended uid) for sanity checking, the - * new format is the same as the old. We simply ignore the - * conversion altogether. - mycroft, 19MAY1994 - */ - if (sblock.fs_magic == FS_UFS1_MAGIC && doinglevel2 && - DIP(dp, di_size) > 0 && - DIP(dp, di_size) < MAXSYMLINKLEN_UFS1 && - DIP(dp, di_blocks) != 0) { - symbuf = alloca(secsize); - if (bread(fsreadfd, symbuf, - fsbtodb(&sblock, DIP(dp, di_db[0])), - (long)secsize) != 0) - errexit("cannot read symlink\n"); - if (debug) { - symbuf[DIP(dp, di_size)] = 0; - printf("convert symlink %d(%s) of size %llu\n", - inumber, symbuf, - (unsigned long long)DIP(dp, di_size)); - } - dp = ginode(inumber); - memcpy(dp->dp1.di_shortlink, symbuf, - (long)DIP(dp, di_size)); - DIP_SET(dp, di_blocks, 0); - inodirty(); - } - /* * Fake ndb value so direct/indirect block checks below * will detect any garbage after symlink string. */ @@ -349,16 +321,6 @@ checkinode(ino_t inumber, struct inodesc *idesc) } else SET_ISTATE(inumber, FSTATE); SET_ITYPE(inumber, IFTODT(mode)); - if (sblock.fs_magic == FS_UFS1_MAGIC && doinglevel2 && - (dp->dp1.di_ouid != (u_short)-1 || - dp->dp1.di_ogid != (u_short)-1)) { - dp = ginode(inumber); - DIP_SET(dp, di_uid, dp->dp1.di_ouid); - dp->dp1.di_ouid = -1; - DIP_SET(dp, di_gid, dp->dp1.di_ogid); - dp->dp1.di_ogid = -1; - inodirty(); - } badblk = dupblk = 0; idesc->id_number = inumber; (void)ckinode(dp, idesc); diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index 07261ec59d2..89d98776c2a 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.30 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: pass2.c,v 1.31 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */ /* @@ -259,13 +259,6 @@ pass2check(struct inodesc *idesc) char pathbuf[MAXPATHLEN + 1]; /* - * If converting, set directory entry type. - */ - if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) { - dirp->d_type = GET_ITYPE(dirp->d_ino); - ret |= ALTERED; - } - /* * check for "." */ if (idesc->id_entryno != 0) @@ -277,7 +270,7 @@ pass2check(struct inodesc *idesc) if (reply("FIX") == 1) ret |= ALTERED; } - if (newinofmt && dirp->d_type != DT_DIR) { + if (dirp->d_type != DT_DIR) { direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'"); dirp->d_type = DT_DIR; if (reply("FIX") == 1) @@ -287,21 +280,9 @@ pass2check(struct inodesc *idesc) } direrror(idesc->id_number, "MISSING '.'"); proto.d_ino = idesc->id_number; - if (newinofmt) - proto.d_type = DT_DIR; - else - proto.d_type = 0; + proto.d_type = DT_DIR; proto.d_namlen = 1; (void)strlcpy(proto.d_name, ".", sizeof proto.d_name); -# if BYTE_ORDER == LITTLE_ENDIAN - if (!newinofmt) { - u_char tmp; - - tmp = proto.d_type; - proto.d_type = proto.d_namlen; - proto.d_namlen = tmp; - } -# endif entrysize = DIRSIZ(0, &proto); if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) { pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", @@ -330,21 +311,9 @@ chk1: goto chk2; inp = getinoinfo(idesc->id_number); proto.d_ino = inp->i_parent; - if (newinofmt) - proto.d_type = DT_DIR; - else - proto.d_type = 0; + proto.d_type = DT_DIR; proto.d_namlen = 2; (void)strlcpy(proto.d_name, "..", sizeof proto.d_name); -# if BYTE_ORDER == LITTLE_ENDIAN - if (!newinofmt) { - u_char tmp; - - tmp = proto.d_type; - proto.d_type = proto.d_namlen; - proto.d_namlen = tmp; - } -# endif entrysize = DIRSIZ(0, &proto); if (idesc->id_entryno == 0) { n = DIRSIZ(0, dirp); @@ -360,7 +329,7 @@ chk1: } if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) { inp->i_dotdot = dirp->d_ino; - if (newinofmt && dirp->d_type != DT_DIR) { + if (dirp->d_type != DT_DIR) { direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'"); dirp->d_type = DT_DIR; if (reply("FIX") == 1) @@ -473,8 +442,7 @@ again: /* FALLTHROUGH */ case FSTATE: - if (newinofmt && dirp->d_type != - GET_ITYPE(dirp->d_ino)) { + if (dirp->d_type != GET_ITYPE(dirp->d_ino)) { fileerror(idesc->id_number, dirp->d_ino, "BAD TYPE VALUE"); dirp->d_type = GET_ITYPE(dirp->d_ino); diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index f7a2ffbf3ce..152f0b4017c 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.40 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: pass5.c,v 1.41 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */ /* @@ -65,7 +65,7 @@ pass5(void) struct cg *cg = &cgrp; daddr64_t dbase, dmax; daddr64_t d; - long i, j, k; + long i, j, k, rewritecg = 0; struct csum *cs; struct csum_total cstotal; struct inodesc idesc[3]; @@ -80,7 +80,7 @@ pass5(void) pwarn("DELETING CLUSTERING MAPS\n"); if (preen || reply("DELETE CLUSTERING MAPS")) { fs->fs_contigsumsize = 0; - doinglevel1 = 1; + rewritecg = 1; sbdirty(); } } @@ -107,7 +107,7 @@ pass5(void) doit); fs->fs_cgsize = fragroundup(fs, CGSIZE(fs)); - doinglevel1 = 1; + rewritecg = 1; sbdirty(); } } @@ -164,11 +164,8 @@ pass5(void) fs->fs_postblformat); } memset(&idesc[0], 0, sizeof idesc); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) idesc[i].id_type = ADDR; - if (doinglevel2) - idesc[i].id_fix = FIX; - } memset(&cstotal, 0, sizeof(struct csum_total)); dmax = blknum(fs, fs->fs_size + fs->fs_frag - 1); for (d = fs->fs_size; d < dmax; d++) @@ -320,7 +317,7 @@ pass5(void) memcpy(cs, &newcg->cg_cs, sizeof *cs); sbdirty(); } - if (doinglevel1) { + if (rewritecg) { memcpy(cg, newcg, (size_t)fs->fs_cgsize); cgdirty(); continue; diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 1bcd85aa62a..a275e3919b6 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.47 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: setup.c,v 1.48 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -260,96 +260,57 @@ found: dirty(&asblk); } } - if (sblock.fs_inodefmt >= FS_44INODEFMT) { - if (sblock.fs_maxfilesize != maxfilesize) { - pwarn("INCORRECT MAXFILESIZE=%llu IN SUPERBLOCK", - (unsigned long long)sblock.fs_maxfilesize); - sblock.fs_maxfilesize = maxfilesize; - if (preen) - printf(" (FIXED)\n"); - if (preen || reply("FIX") == 1) { - sbdirty(); - dirty(&asblk); - } - } - maxsymlinklen = sblock.fs_magic == FS_UFS1_MAGIC ? - MAXSYMLINKLEN_UFS1 : MAXSYMLINKLEN_UFS2; - if (sblock.fs_maxsymlinklen != maxsymlinklen) { - pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK", - sblock.fs_maxsymlinklen); - sblock.fs_maxsymlinklen = maxsymlinklen; - if (preen) - printf(" (FIXED)\n"); - if (preen || reply("FIX") == 1) { - sbdirty(); - dirty(&asblk); - } - } - if (sblock.fs_qbmask != ~sblock.fs_bmask) { - pwarn("INCORRECT QBMASK=%lx IN SUPERBLOCK", - (unsigned long)sblock.fs_qbmask); - sblock.fs_qbmask = ~sblock.fs_bmask; - if (preen) - printf(" (FIXED)\n"); - if (preen || reply("FIX") == 1) { - sbdirty(); - dirty(&asblk); - } - } - if (sblock.fs_qfmask != ~sblock.fs_fmask) { - pwarn("INCORRECT QFMASK=%lx IN SUPERBLOCK", - (unsigned long)sblock.fs_qfmask); - sblock.fs_qfmask = ~sblock.fs_fmask; - if (preen) - printf(" (FIXED)\n"); - if (preen || reply("FIX") == 1) { - sbdirty(); - dirty(&asblk); - } + if (sblock.fs_inodefmt < FS_44INODEFMT) { + pwarn("Format of filesystem is too old.\n"); + pwarn("Must update to modern format using a version of fsck\n"); + pfatal("from before release 5.0 with the command ``fsck -c 2''\n"); + exit(8); + } + if (sblock.fs_maxfilesize != maxfilesize) { + pwarn("INCORRECT MAXFILESIZE=%llu IN SUPERBLOCK", + (unsigned long long)sblock.fs_maxfilesize); + sblock.fs_maxfilesize = maxfilesize; + if (preen) + printf(" (FIXED)\n"); + if (preen || reply("FIX") == 1) { + sbdirty(); + dirty(&asblk); } - newinofmt = 1; - } else { - sblock.fs_qbmask = ~sblock.fs_bmask; - sblock.fs_qfmask = ~sblock.fs_fmask; - newinofmt = 0; } - /* - * Convert to new inode format. - */ - if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) { + maxsymlinklen = sblock.fs_magic == FS_UFS1_MAGIC ? + MAXSYMLINKLEN_UFS1 : MAXSYMLINKLEN_UFS2; + if (sblock.fs_maxsymlinklen != maxsymlinklen) { + pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK", + sblock.fs_maxsymlinklen); + sblock.fs_maxsymlinklen = maxsymlinklen; if (preen) - pwarn("CONVERTING TO NEW INODE FORMAT\n"); - else if (!reply("CONVERT TO NEW INODE FORMAT")) - return(0); - doinglevel2++; - sblock.fs_inodefmt = FS_44INODEFMT; - sblock.fs_maxfilesize = maxfilesize; - sblock.fs_maxsymlinklen = MAXSYMLINKLEN_UFS1; + printf(" (FIXED)\n"); + if (preen || reply("FIX") == 1) { + sbdirty(); + dirty(&asblk); + } + } + if (sblock.fs_qbmask != ~sblock.fs_bmask) { + pwarn("INCORRECT QBMASK=%lx IN SUPERBLOCK", + (unsigned long)sblock.fs_qbmask); sblock.fs_qbmask = ~sblock.fs_bmask; - sblock.fs_qfmask = ~sblock.fs_fmask; - sbdirty(); - dirty(&asblk); + if (preen) + printf(" (FIXED)\n"); + if (preen || reply("FIX") == 1) { + sbdirty(); + dirty(&asblk); + } } - /* - * Convert to new cylinder group format. - */ - if (cvtlevel >= 1 && sblock.fs_postblformat == FS_42POSTBLFMT) { + if (sblock.fs_qfmask != ~sblock.fs_fmask) { + pwarn("INCORRECT QFMASK=%lx IN SUPERBLOCK", + (unsigned long)sblock.fs_qfmask); + sblock.fs_qfmask = ~sblock.fs_fmask; if (preen) - pwarn("CONVERTING TO NEW CYLINDER GROUP FORMAT\n"); - else if (!reply("CONVERT TO NEW CYLINDER GROUP FORMAT")) - return(0); - doinglevel1++; - sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT; - sblock.fs_nrpos = 8; - sblock.fs_postbloff = - (char *)(&sblock.fs_maxbsize) - - (char *)(&sblock.fs_firstfield); - sblock.fs_rotbloff = &sblock.fs_space[0] - - (u_char *)(&sblock.fs_firstfield); - sblock.fs_cgsize = - fragroundup(&sblock, CGSIZE(&sblock)); - sbdirty(); - dirty(&asblk); + printf(" (FIXED)\n"); + if (preen || reply("FIX") == 1) { + sbdirty(); + dirty(&asblk); + } } if (sblock.fs_cgsize != fragroundup(&sblock, CGSIZE(&sblock))) { pwarn("INCONSISTENT CGSIZE=%d\n", sblock.fs_cgsize); diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c index 22653cef2f5..07f2bedc847 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.38 2011/04/16 16:37:21 otto Exp $ */ +/* $OpenBSD: utilities.c,v 1.39 2011/04/24 07:07:03 otto Exp $ */ /* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */ /* @@ -511,8 +511,7 @@ getpathname(char *namebuf, size_t namebuflen, ino_t curdir, ino_t ino) void catch(int signo) { - if (!doinglevel2) - ckfini(0); /* XXX signal race */ + ckfini(0); /* XXX signal race */ _exit(12); } |