summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-05-12 23:44:15 +0000
committerphk <phk@FreeBSD.org>2002-05-12 23:44:15 +0000
commitd4023f2e24f76a780fa8dc8a8102a24bc61db723 (patch)
treeddf4e8af9db2f764e32a42f67fac111c0999753b /sbin
parente76663bf875c4d4b218d6483379d4a4133ca13ee (diff)
downloadFreeBSD-src-d4023f2e24f76a780fa8dc8a8102a24bc61db723.zip
FreeBSD-src-d4023f2e24f76a780fa8dc8a8102a24bc61db723.tar.gz
UFS2 preparation commit:
Remove support for converting old FFS formats to newer. Submitted by: mckusick Sponspored by: DARPA & NAI Labs.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/dir.c67
-rw-r--r--sbin/fsck_ffs/fsck.h3
-rw-r--r--sbin/fsck_ffs/fsutil.c4
-rw-r--r--sbin/fsck_ffs/inode.c3
-rw-r--r--sbin/fsck_ffs/pass1.c27
-rw-r--r--sbin/fsck_ffs/pass2.c51
-rw-r--r--sbin/fsck_ffs/pass5.c13
-rw-r--r--sbin/fsck_ffs/setup.c80
8 files changed, 27 insertions, 221 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 84c8f02..9a3eee4 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -130,29 +130,8 @@ dirscan(struct inodesc *idesc)
if (dsize > sizeof(dbuf))
dsize = sizeof(dbuf);
memmove(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);
memmove(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
(size_t)dsize);
@@ -244,19 +223,9 @@ dircheck(struct inodesc *idesc, struct direct *dp)
goto bad;
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 ||
namlen > MAXNAMLEN ||
@@ -393,27 +362,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 = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
+ dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
dirp->d_namlen = newent.d_namlen;
memmove(dirp->d_name, idesc->id_name, (size_t)newent.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);
}
@@ -425,10 +376,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 = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
+ dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
return (ALTERED|STOP);
}
@@ -669,10 +617,7 @@ allocdir(ino_t parent, ino_t request, int mode)
struct dirtemplate *dirp;
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 f220026..e94a6b7 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -211,9 +211,6 @@ int bkgrdflag; /* use a snapshot to run on an active system */
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 */
int bkgrdcheck; /* determine if background check is possible */
char usedsoftdep; /* just fix soft dependency inconsistencies */
char preen; /* just fix normal inconsistencies */
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 9f4607f..bf6c7fe 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -520,8 +520,8 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
void
catch(int sig)
{
- if (!doinglevel2)
- ckfini(0);
+
+ ckfini(0);
exit(12);
}
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index a30591b..0050ae1 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -633,8 +633,7 @@ allocino(ino_t request, int type)
dp->di_blocks = btodb(sblock.fs_fsize);
n_files++;
inodirty();
- if (newinofmt)
- inoinfo(ino)->ino_type = IFTODT(type);
+ inoinfo(ino)->ino_type = IFTODT(type);
return (ino);
}
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index e3fd6ea..ef31787 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -243,24 +243,6 @@ checkinode(ino_t inumber, struct inodesc *idesc)
if (mode == IFBLK || mode == IFCHR)
ndb++;
if (mode == IFLNK) {
- if (doinglevel2 &&
- dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN &&
- dp->di_blocks != 0) {
- symbuf = alloca(secsize);
- if (bread(fsreadfd, symbuf,
- fsbtodb(&sblock, dp->di_db[0]),
- (long)secsize) != 0)
- errx(EEXIT, "cannot read symlink");
- if (debug) {
- symbuf[dp->di_size] = 0;
- printf("convert symlink %lu(%s) of size %ld\n",
- (u_long)inumber, symbuf, (long)dp->di_size);
- }
- dp = ginode(inumber);
- memmove(dp->di_shortlink, symbuf, (long)dp->di_size);
- dp->di_blocks = 0;
- inodirty();
- }
/*
* Fake ndb value so direct/indirect block checks below
* will detect any garbage after symlink string.
@@ -319,15 +301,6 @@ checkinode(ino_t inumber, struct inodesc *idesc)
} else
inoinfo(inumber)->ino_state = FSTATE;
inoinfo(inumber)->ino_type = IFTODT(mode);
- if (doinglevel2 &&
- (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) {
- dp = ginode(inumber);
- dp->di_uid = dp->di_ouid;
- dp->di_ouid = -1;
- dp->di_gid = dp->di_ogid;
- dp->di_ogid = -1;
- inodirty();
- }
badblk = dupblk = 0;
idesc->id_number = inumber;
if (dp->di_flags & SF_SNAPSHOT)
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 838dcb7..2347f76 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -118,10 +118,8 @@ pass2(void)
inoinfo(ROOTINO)->ino_state);
}
inoinfo(ROOTINO)->ino_state = DFOUND;
- if (newinofmt) {
- inoinfo(WINO)->ino_state = FSTATE;
- inoinfo(WINO)->ino_type = DT_WHT;
- }
+ inoinfo(WINO)->ino_state = FSTATE;
+ inoinfo(WINO)->ino_type = DT_WHT;
/*
* Sort the directory list into disk block order.
*/
@@ -232,13 +230,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 = inoinfo(dirp->d_ino)->ino_type;
- ret |= ALTERED;
- }
- /*
* check for "."
*/
if (idesc->id_entryno != 0)
@@ -250,7 +241,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)
@@ -260,21 +251,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)strcpy(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",
@@ -303,21 +282,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)strcpy(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);
@@ -333,7 +300,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)
@@ -391,8 +358,7 @@ chk2:
if (dirp->d_ino > maxino) {
fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
n = reply("REMOVE");
- } else if (newinofmt &&
- ((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
+ } else if (((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
(dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
dirp->d_ino = WINO;
@@ -461,8 +427,7 @@ again:
/* fall through */
case FSTATE:
- if (newinofmt &&
- dirp->d_type != inoinfo(dirp->d_ino)->ino_type) {
+ if (dirp->d_type != inoinfo(dirp->d_ino)->ino_type) {
fileerror(idesc->id_number, dirp->d_ino,
"BAD TYPE VALUE");
dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 1d73dc8..f2ab2a8 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -60,7 +60,7 @@ pass5(void)
struct fs *fs = &sblock;
struct cg *cg = &cgrp;
ufs_daddr_t dbase, dmax, d;
- int i, j, excessdirs;
+ int i, j, excessdirs, rewritecg = 0;
struct csum *cs;
struct csum cstotal;
struct inodesc idesc[3];
@@ -77,7 +77,7 @@ pass5(void)
pwarn("DELETING CLUSTERING MAPS\n");
if (preen || reply("DELETE CLUSTERING MAPS")) {
fs->fs_contigsumsize = 0;
- doinglevel1 = 1;
+ rewritecg = 1;
sbdirty();
}
}
@@ -104,7 +104,7 @@ pass5(void)
doit);
fs->fs_cgsize =
fragroundup(fs, CGSIZE(fs));
- doinglevel1 = 1;
+ rewritecg = 1;
sbdirty();
}
}
@@ -161,11 +161,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));
j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
for (i = fs->fs_size; i < j; i++)
@@ -309,7 +306,7 @@ pass5(void)
memmove(cs, &newcg->cg_cs, sizeof *cs);
sbdirty();
}
- if (doinglevel1) {
+ if (rewritecg) {
memmove(cg, newcg, (size_t)fs->fs_cgsize);
cgdirty();
continue;
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 9364ce3..107ded2 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -210,81 +210,11 @@ setup(char *dev)
sbdirty();
}
}
- if (sblock.fs_interleave < 1 ||
- sblock.fs_interleave > sblock.fs_nsect) {
- pfatal("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK",
- sblock.fs_interleave);
- sblock.fs_interleave = 1;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_npsect < sblock.fs_nsect ||
- sblock.fs_npsect > sblock.fs_nsect*2) {
- pfatal("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK",
- sblock.fs_npsect);
- sblock.fs_npsect = sblock.fs_nsect;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_inodefmt >= FS_44INODEFMT) {
- newinofmt = 1;
- } else {
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- /* This should match the kernel limit in ffs_oldfscompat(). */
- sblock.fs_maxfilesize = (u_int64_t)1 << 39;
- newinofmt = 0;
- }
- /*
- * Convert to new inode format.
- */
- if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) {
- 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;
- sizepb = sblock.fs_bsize;
- sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1;
- for (i = 0; i < NIADDR; i++) {
- sizepb *= NINDIR(&sblock);
- sblock.fs_maxfilesize += sizepb;
- }
- sblock.fs_maxsymlinklen = MAXSYMLINKLEN;
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- sbdirty();
- dirty(&asblk);
- }
- /*
- * Convert to new cylinder group format.
- */
- if (cvtlevel >= 1 && sblock.fs_postblformat == FS_42POSTBLFMT) {
- 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_opostbl[0][0]) -
- (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);
+ 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 2002 with the command ``fsck -c 2''\n");
+ exit(EEXIT);
}
if (asblk.b_dirty && !bflag) {
memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize);
OpenPOWER on IntegriCloud