diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2024-01-09 03:16:01 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2024-01-09 03:16:01 +0000 |
commit | 49761ad4bb9d44ec05c4ca9ac88cfc297c7e48ce (patch) | |
tree | ce66bc938e5e4f7fac1f0e77db057bc5bcfa2a4c /sbin | |
parent | 86838aa7e194992d35ddaeb9f3cd7b3388c5e9b3 (diff) |
Delete support for FFS filesystems before the in-inode symlink
optimization. As observed by ali_farzanrad(at)riseup.net, support
for these was broken in the 5.5 release in early 2014 by the time_t
changes. No one noticed before now, so clearly this isn't something
we need to continue to support; rejecting in ffs_validate() is an
improvement.
Also: simplify DIRSIZ(), drop OLDDIRFMT and NEWDIRFMT, tests of
fs_maxsymlinklen against zero, #ifdef tests of FS_44INODEFMT, and
remove support for newfs -O0, last used in 2016.
ok miod@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dump/main.c | 4 | ||||
-rw-r--r-- | sbin/dump/traverse.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/dir.c | 12 | ||||
-rw-r--r-- | sbin/fsck_ffs/inode.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass2.c | 8 | ||||
-rw-r--r-- | sbin/fsdb/fsdb.c | 4 | ||||
-rw-r--r-- | sbin/newfs/mkfs.c | 30 | ||||
-rw-r--r-- | sbin/newfs/newfs.8 | 9 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 6 | ||||
-rw-r--r-- | sbin/restore/dirs.c | 14 |
11 files changed, 35 insertions, 72 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c index b23c408cd96..a5071abedd3 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.64 2023/12/18 13:23:52 otto Exp $ */ +/* $OpenBSD: main.c,v 1.65 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -455,11 +455,9 @@ main(int argc, char *argv[]) tp_bshift = ffs(TP_BSIZE) - 1; if (TP_BSIZE != (1 << tp_bshift)) quit("TP_BSIZE (%d) is not a power of 2\n", TP_BSIZE); -#ifdef FS_44INODEFMT if (sblock->fs_magic == FS_UFS2_MAGIC || sblock->fs_inodefmt >= FS_44INODEFMT) spcl.c_flags |= DR_NEWINODEFMT; -#endif maxino = (ino_t)sblock->fs_ipg * sblock->fs_ncg; mapsize = roundup(howmany(maxino, NBBY), TP_BSIZE); usedinomap = calloc((unsigned) mapsize, sizeof(char)); diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index 16d783cd750..5d3225d613f 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traverse.c,v 1.40 2023/02/08 08:25:44 tb Exp $ */ +/* $OpenBSD: traverse.c,v 1.41 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */ /*- @@ -547,13 +547,7 @@ dumpino(union dinode *dp, ino_t ino) * Check for short symbolic link. */ if (DIP(dp, di_size) > 0 && -#ifdef FS_44INODEFMT - (DIP(dp, di_size) < sblock->fs_maxsymlinklen || - (sblock->fs_maxsymlinklen == 0 && - DIP(dp, di_blocks) == 0))) { -#else - DIP(dp, di_blocks) == 0) { -#endif + DIP(dp, di_size) < sblock->fs_maxsymlinklen) { void *shortlink; spcl.c_addr[0] = 1; diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index be627ffbec9..150987a22ae 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.33 2023/02/08 08:25:44 tb Exp $ */ +/* $OpenBSD: dir.c,v 1.34 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -52,10 +52,6 @@ struct dirtemplate dirhead = { 0, 12, DT_DIR, 1, ".", 0, DIRBLKSIZ - 12, DT_DIR, 2, ".." }; -struct odirtemplate odirhead = { - 0, 12, 1, ".", - 0, DIRBLKSIZ - 12, 2, ".." -}; static int expanddir(union dinode *, char *); static void freedir(ino_t, ino_t); @@ -210,7 +206,7 @@ dircheck(struct inodesc *idesc, struct direct *dp) return (0); if (dp->d_ino == 0) return (1); - size = DIRSIZ(0, dp); + size = DIRSIZ(dp); namlen = dp->d_namlen; type = dp->d_type; if (dp->d_reclen < size || @@ -292,9 +288,9 @@ mkentry(struct inodesc *idesc) int newlen, oldlen; newent.d_namlen = strlen(idesc->id_name); - newlen = DIRSIZ(0, &newent); + newlen = DIRSIZ(&newent); if (dirp->d_ino != 0) - oldlen = DIRSIZ(0, dirp); + oldlen = DIRSIZ(dirp); else oldlen = 0; if (dirp->d_reclen - oldlen < newlen) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index a1c583e4657..ebda1d4a10d 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.50 2020/07/13 06:52:53 otto Exp $ */ +/* $OpenBSD: inode.c,v 1.51 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */ /* @@ -71,8 +71,7 @@ ckinode(union dinode *dp, struct inodesc *idesc) idesc->id_filesize = DIP(dp, di_size); mode = DIP(dp, di_mode) & IFMT; if (mode == IFBLK || mode == IFCHR || (mode == IFLNK && - (DIP(dp, di_size) < sblock.fs_maxsymlinklen || - (sblock.fs_maxsymlinklen == 0 && DIP(dp, di_blocks) == 0)))) + DIP(dp, di_size) < sblock.fs_maxsymlinklen)) return (KEEPON); if (sblock.fs_magic == FS_UFS1_MAGIC) dino.dp1 = dp->dp1; diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 7da7087be71..edeb370c713 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.47 2020/07/13 06:52:53 otto Exp $ */ +/* $OpenBSD: pass1.c,v 1.48 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */ /* @@ -266,8 +266,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) * Fake ndb value so direct/indirect block checks below * will detect any garbage after symlink string. */ - if (DIP(dp, di_size) < sblock.fs_maxsymlinklen || - (sblock.fs_maxsymlinklen == 0 && DIP(dp, di_blocks) == 0)) { + if (DIP(dp, di_size) < sblock.fs_maxsymlinklen) { if (sblock.fs_magic == FS_UFS1_MAGIC) ndb = howmany(DIP(dp, di_size), sizeof(int32_t)); diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index 0d244c957a0..c048ba86f3b 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.37 2015/01/20 18:22:21 deraadt Exp $ */ +/* $OpenBSD: pass2.c,v 1.38 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */ /* @@ -283,7 +283,7 @@ pass2check(struct inodesc *idesc) proto.d_type = DT_DIR; proto.d_namlen = 1; (void)strlcpy(proto.d_name, ".", sizeof proto.d_name); - entrysize = DIRSIZ(0, &proto); + entrysize = DIRSIZ(&proto); if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) { pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", dirp->d_name); @@ -314,9 +314,9 @@ chk1: proto.d_type = DT_DIR; proto.d_namlen = 2; (void)strlcpy(proto.d_name, "..", sizeof proto.d_name); - entrysize = DIRSIZ(0, &proto); + entrysize = DIRSIZ(&proto); if (idesc->id_entryno == 0) { - n = DIRSIZ(0, dirp); + n = DIRSIZ(dirp); if (dirp->d_reclen < n + entrysize) goto chk2; proto.d_reclen = dirp->d_reclen - n; diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index 2699dd9ae1a..4cd9f65e464 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdb.c,v 1.35 2022/07/22 09:04:44 jsg Exp $ */ +/* $OpenBSD: fsdb.c,v 1.36 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: fsdb.c,v 1.7 1997/01/11 06:50:53 lukem Exp $ */ /*- @@ -601,7 +601,7 @@ chnamefunc(struct inodesc *idesc) if (slotcount++ == desired) { /* will name fit? */ testdir.d_namlen = strlen(idesc->id_name); - if (DIRSIZ(NEWDIRFMT, &testdir) <= dirp->d_reclen) { + if (DIRSIZ(&testdir) <= dirp->d_reclen) { dirp->d_namlen = testdir.d_namlen; strlcpy(dirp->d_name, idesc->id_name, sizeof dirp->d_name); return STOP|ALTERED|FOUND; diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 266ab9538ee..321b83c8557 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.101 2020/06/20 07:49:04 otto Exp $ */ +/* $OpenBSD: mkfs.c,v 1.102 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -279,13 +279,8 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, sblock.fs_sblockloc = SBLOCK_UFS1; sblock.fs_nindir = sblock.fs_bsize / sizeof(int32_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode); - if (Oflag == 0) { - sblock.fs_maxsymlinklen = 0; - sblock.fs_inodefmt = FS_42INODEFMT; - } else { - sblock.fs_maxsymlinklen = MAXSYMLINKLEN_UFS1; - sblock.fs_inodefmt = FS_44INODEFMT; - } + sblock.fs_maxsymlinklen = MAXSYMLINKLEN_UFS1; + sblock.fs_inodefmt = FS_44INODEFMT; sblock.fs_cgoffset = 0; sblock.fs_cgmask = 0xffffffff; sblock.fs_ffs1_size = sblock.fs_size; @@ -778,15 +773,6 @@ struct direct root_dir[] = { { ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, }; -struct odirect { - u_int32_t d_ino; - u_int16_t d_reclen; - u_int16_t d_namlen; - u_char d_name[MAXNAMLEN + 1]; -} oroot_dir[] = { - { ROOTINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, -}; int fsinit1(time_t utime, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid) @@ -814,11 +800,7 @@ fsinit1(time_t utime, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid) node.dp1.di_gid = getegid(); } node.dp1.di_nlink = PREDEFDIR; - if (Oflag == 0) - node.dp1.di_size = makedir((struct direct *)oroot_dir, - PREDEFDIR); - else - node.dp1.di_size = makedir(root_dir, PREDEFDIR); + node.dp1.di_size = makedir(root_dir, PREDEFDIR); node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode); if (node.dp1.di_db[0] == 0) return (1); @@ -919,13 +901,13 @@ makedir(struct direct *protodir, int entries) spcleft = DIRBLKSIZ; for (cp = iobuf, i = 0; i < entries - 1; i++) { - protodir[i].d_reclen = DIRSIZ(0, &protodir[i]); + protodir[i].d_reclen = DIRSIZ(&protodir[i]); memcpy(cp, &protodir[i], protodir[i].d_reclen); cp += protodir[i].d_reclen; spcleft -= protodir[i].d_reclen; } protodir[i].d_reclen = spcleft; - memcpy(cp, &protodir[i], DIRSIZ(0, &protodir[i])); + memcpy(cp, &protodir[i], DIRSIZ(&protodir[i])); return (DIRBLKSIZ); } diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index 2bf932ea0cb..2c509f205bd 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: newfs.8,v 1.79 2022/11/19 08:02:11 sthen Exp $ +.\" $OpenBSD: newfs.8,v 1.80 2024/01/09 03:16:00 guenther Exp $ .\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $ .\" .\" Copyright (c) 1983, 1987, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" @(#)newfs.8 8.3 (Berkeley) 3/27/94 .\" -.Dd $Mdocdate: November 19 2022 $ +.Dd $Mdocdate: January 9 2024 $ .Dt NEWFS 8 .Os .Sh NAME @@ -186,11 +186,6 @@ without really creating the file system. Select the filesystem format: .Pp .Bl -tag -width 3n -offset indent -compact -.It 0 -.Bx 4.3 -format file system. -This option is primarily used to build root file systems that can -be understood by older boot ROMs. .It 1 Fast File System (FFS), the default for .Nm mount_mfs . diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 7ab691d78f0..4e07e6d790e 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.117 2022/12/04 23:50:47 cheloha Exp $ */ +/* $OpenBSD: newfs.c,v 1.118 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -121,7 +121,7 @@ u_short dkcksum(struct disklabel *); int mfs; /* run as the memory based filesystem */ int Nflag; /* run without writing file system */ -int Oflag = 2; /* 0 = 4.3BSD ffs, 1 = 4.4BSD ffs, 2 = ffs2 */ +int Oflag = 2; /* 1 = 4.4BSD ffs, 2 = ffs2 */ daddr_t fssize; /* file system size in 512-byte blocks */ long long sectorsize; /* bytes/sector */ int fsize = 0; /* fragment size */ @@ -211,7 +211,7 @@ main(int argc, char *argv[]) Nflag = 1; break; case 'O': - Oflag = strtonum(optarg, 0, 2, &errstr); + Oflag = strtonum(optarg, 1, 2, &errstr); if (errstr) fatal("%s: invalid ffs version", optarg); oflagset = 1; diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 1a25e7342c1..baebb2c49bc 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirs.c,v 1.42 2019/06/28 13:32:46 deraadt Exp $ */ +/* $OpenBSD: dirs.c,v 1.43 2024/01/09 03:16:00 guenther Exp $ */ /* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */ /* @@ -175,7 +175,7 @@ extractdirs(int genmode) nulldir.d_namlen = 1; nulldir.d_name[0] = '/'; nulldir.d_name[1] = '\0'; - nulldir.d_reclen = DIRSIZ(0, &nulldir); + nulldir.d_reclen = DIRSIZ(&nulldir); for (;;) { curfile.name = "<directory file - name unknown>"; curfile.action = USING; @@ -364,17 +364,17 @@ putdir(char *buf, size_t size) i = DIRBLKSIZ - (loc & (DIRBLKSIZ - 1)); if ((dp->d_reclen & 0x3) != 0 || dp->d_reclen > i || - dp->d_reclen < DIRSIZ(0, dp) || + dp->d_reclen < DIRSIZ(dp) || dp->d_namlen > NAME_MAX) { Vprintf(stdout, "Mangled directory: "); if ((dp->d_reclen & 0x3) != 0) Vprintf(stdout, "reclen not multiple of 4 "); - if (dp->d_reclen < DIRSIZ(0, dp)) + if (dp->d_reclen < DIRSIZ(dp)) Vprintf(stdout, "reclen less than DIRSIZ (%u < %u) ", (unsigned)dp->d_reclen, - (unsigned)DIRSIZ(0, dp)); + (unsigned)DIRSIZ(dp)); if (dp->d_namlen > NAME_MAX) Vprintf(stdout, "reclen name too big (%u > %u) ", @@ -404,7 +404,7 @@ long prev = 0; static void putent(struct direct *dp) { - dp->d_reclen = DIRSIZ(0, dp); + dp->d_reclen = DIRSIZ(dp); if (dirloc + dp->d_reclen > DIRBLKSIZ) { ((struct direct *)(dirbuf + prev))->d_reclen = DIRBLKSIZ - prev; @@ -440,7 +440,7 @@ dcvt(struct odirect *odp, struct direct *ndp) ndp->d_type = DT_UNKNOWN; (void)strncpy(ndp->d_name, odp->d_name, ODIRSIZ); ndp->d_namlen = strlen(ndp->d_name); - ndp->d_reclen = DIRSIZ(0, ndp); + ndp->d_reclen = DIRSIZ(ndp); } /* |