-/* $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 $ */
/*-
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));
-/* $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 $ */
/*-
* 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;
-/* $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 $ */
/*
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);
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 ||
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)
-/* $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 $ */
/*
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;
-/* $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 $ */
/*
* 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));
-/* $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 $ */
/*
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);
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;
-/* $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 $ */
/*-
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;
-/* $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 $ */
/*
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;
{ 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)
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);
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);
}
-.\" $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
.\"
.\" @(#)newfs.8 8.3 (Berkeley) 3/27/94
.\"
-.Dd $Mdocdate: November 19 2022 $
+.Dd $Mdocdate: January 9 2024 $
.Dt NEWFS 8
.Os
.Sh NAME
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 .
-/* $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 $ */
/*
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 */
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;
-/* $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 $ */
/*
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;
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) ",
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;
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);
}
/*
-/* $OpenBSD: ext2fs_dir.h,v 1.11 2014/07/11 07:59:04 pelikan Exp $ */
+/* $OpenBSD: ext2fs_dir.h,v 1.12 2024/01/09 03:16:00 guenther Exp $ */
/* $NetBSD: ext2fs_dir.h,v 1.4 2000/01/28 16:00:23 bouyer Exp $ */
/*
* with null bytes. All names are guaranteed null terminated.
* The maximum length of a name in a directory is EXT2FS_MAXNAMLEN.
*
- * The macro EXT2FS_DIRSIZ(fmt, dp) gives the amount of space required to
+ * The macro EXT2FS_DIRSIZ(dp) gives the amount of space required to
* represent a directory entry. Free space in a directory is represented by
- * entries which have dp->e2d_reclen > DIRSIZ(fmt, dp). All d2fs_bsize bytes
+ * entries which have dp->e2d_reclen > DIRSIZ(dp). All d2fs_bsize bytes
* in a directory block are claimed by the directory entries. This
* usually results in the last entry in a directory having a large
* dp->e2d_reclen. When entries are deleted from a directory, the
-/* $OpenBSD: ffs_inode.c,v 1.81 2021/12/12 09:14:59 visa Exp $ */
+/* $OpenBSD: ffs_inode.c,v 1.82 2024/01/09 03:15:59 guenther Exp $ */
/* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */
/*
return (0);
if (ovp->v_type == VLNK &&
- (DIP(oip, size) < oip->i_ump->um_maxsymlinklen ||
- (oip->i_ump->um_maxsymlinklen == 0 &&
- oip->i_din1->di_blocks == 0))) {
+ DIP(oip, size) < oip->i_ump->um_maxsymlinklen) {
#ifdef DIAGNOSTIC
if (length != 0)
panic("ffs_truncate: partial truncate of symlink");
-/* $OpenBSD: ffs_vfsops.c,v 1.195 2023/07/05 15:13:28 beck Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.196 2024/01/09 03:16:00 guenther Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
return (0); /* Invalid number of fragments */
if (fsp->fs_inodefmt == FS_42INODEFMT)
- fsp->fs_maxsymlinklen = 0;
- else if (fsp->fs_maxsymlinklen < 0)
+ return (0); /* Obsolete format, support broken in 2014 */
+ if (fsp->fs_maxsymlinklen <= 0)
return (0); /* Invalid max size of short symlink */
return (1); /* Super block is okay */
-/* $OpenBSD: ffs_vnops.c,v 1.100 2022/06/26 05:20:43 visa Exp $ */
+/* $OpenBSD: ffs_vnops.c,v 1.101 2024/01/09 03:16:00 guenther Exp $ */
/* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */
/*
panic("ffs_read: mode");
if (vp->v_type == VLNK) {
- if (DIP(ip, size) < ip->i_ump->um_maxsymlinklen ||
- (ip->i_ump->um_maxsymlinklen == 0 && DIP(ip, blocks) == 0))
+ if (DIP(ip, size) < ip->i_ump->um_maxsymlinklen)
panic("ffs_read: short symlink");
} else if (vp->v_type != VREG && vp->v_type != VDIR)
panic("ffs_read: type %d", vp->v_type);
-/* $OpenBSD: dir.h,v 1.12 2019/05/04 15:38:12 deraadt Exp $ */
+/* $OpenBSD: dir.h,v 1.13 2024/01/09 03:15:59 guenther Exp $ */
/* $NetBSD: dir.h,v 1.8 1996/03/09 19:42:41 scottr Exp $ */
/*
* with null bytes. All names are guaranteed null terminated.
* The maximum length of a name in a directory is MAXNAMLEN.
*
- * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent
+ * The macro DIRSIZ(dp) gives the amount of space required to represent
* a directory entry. Free space in a directory is represented by
- * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes
+ * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes
* in a directory block are claimed by the directory entries. This
* usually results in the last entry in a directory having a large
* dp->d_reclen. When entries are deleted from a directory, the
#define DIRECTSIZ(namlen) \
((offsetof(struct direct, d_name) + \
((namlen)+1)*sizeof(((struct direct *)0)->d_name[0]) + 3) & ~3)
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-#define DIRSIZ(oldfmt, dp) \
- ((oldfmt) ? \
- ((sizeof(struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \
- ((sizeof(struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)))
-#else
-#define DIRSIZ(oldfmt, dp) \
+#define DIRSIZ(dp) \
((sizeof(struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
-#endif
-#define OLDDIRFMT 1
-#define NEWDIRFMT 0
/*
* Template for manipulating directories. Should use struct direct's,
u_int8_t dotdot_namlen;
char dotdot_name[4]; /* ditto */
};
-
-/*
- * This is the old format of directories, sanz type element.
- */
-struct odirtemplate {
- u_int32_t dot_ino;
- int16_t dot_reclen;
- u_int16_t dot_namlen;
- char dot_name[4]; /* must be multiple of 4 */
- u_int32_t dotdot_ino;
- int16_t dotdot_reclen;
- u_int16_t dotdot_namlen;
- char dotdot_name[4]; /* ditto */
-};
#endif /* !_DIR_H_ */
-/* $OpenBSD: ufs_dirhash.c,v 1.42 2019/03/15 05:42:38 kevlo Exp $ */
+/* $OpenBSD: ufs_dirhash.c,v 1.43 2024/01/09 03:15:59 guenther Exp $ */
/*
* Copyright (c) 2001, 2002 Ian Dowse. All rights reserved.
*
#define WRAPINCR(val, limit) (((val) + 1 == (limit)) ? 0 : ((val) + 1))
#define WRAPDECR(val, limit) (((val) == 0) ? ((limit) - 1) : ((val) - 1))
-#define OFSFMT(ip) ((ip)->i_ump->um_maxsymlinklen == 0)
#define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n))
int ufs_mindirhashsize;
/* Check if we can/should use dirhash. */
if (ip->i_dirhash == NULL) {
- if (DIP(ip, size) < ufs_mindirhashsize || OFSFMT(ip))
+ if (DIP(ip, size) < ufs_mindirhashsize)
return (-1);
} else {
/* Hash exists, but sysctls could have changed. */
slot = WRAPINCR(slot, dh->dh_hlen);
dh->dh_hused++;
DH_ENTRY(dh, slot) = pos;
- ufsdirhash_adjfree(dh, pos, -DIRSIZ(0, ep));
+ ufsdirhash_adjfree(dh, pos, -DIRSIZ(ep));
}
pos += ep->d_reclen;
}
/* Check for sequential access, and update offset. */
if (dh->dh_seqopt == 0 && dh->dh_seqoff == offset)
dh->dh_seqopt = 1;
- dh->dh_seqoff = offset + DIRSIZ(0, dp);
+ dh->dh_seqoff = offset + DIRSIZ(dp);
*bpp = bp;
*offp = offset;
brelse(bp);
return (-1);
}
- if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp))
+ if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(dp))
break;
i += dp->d_reclen;
dp = (struct direct *)((char *)dp + dp->d_reclen);
while (i < DIRBLKSIZ && freebytes < slotneeded) {
freebytes += dp->d_reclen;
if (dp->d_ino != 0)
- freebytes -= DIRSIZ(0, dp);
+ freebytes -= DIRSIZ(dp);
if (dp->d_reclen == 0) {
brelse(bp);
return (-1);
DH_ENTRY(dh, slot) = offset;
/* Update the per-block summary info. */
- ufsdirhash_adjfree(dh, offset, -DIRSIZ(0, dirp));
+ ufsdirhash_adjfree(dh, offset, -DIRSIZ(dirp));
DIRHASH_UNLOCK(dh);
}
ufsdirhash_delslot(dh, slot);
/* Update the per-block summary info. */
- ufsdirhash_adjfree(dh, offset, DIRSIZ(0, dirp));
+ ufsdirhash_adjfree(dh, offset, DIRSIZ(dirp));
DIRHASH_UNLOCK(dh);
}
/* Check that the entry exists (will panic if it doesn't). */
ufsdirhash_findslot(dh, dp->d_name, dp->d_namlen, offset + i);
- nfree += dp->d_reclen - DIRSIZ(0, dp);
+ nfree += dp->d_reclen - DIRSIZ(dp);
}
if (i != DIRBLKSIZ)
panic("ufsdirhash_checkblock: bad dir end");
-/* $OpenBSD: ufs_lookup.c,v 1.59 2022/01/11 03:13:59 jsg Exp $ */
+/* $OpenBSD: ufs_lookup.c,v 1.60 2024/01/09 03:15:59 guenther Exp $ */
/* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */
/*
int dirchk = 0;
#endif
-#define OFSFMT(ip) ((ip)->i_ump->um_maxsymlinklen == 0)
-
/*
* Convert a component of a pathname into a pointer to a locked inode.
* This is a very central and rather complicated routine.
int size = ep->d_reclen;
if (ep->d_ino != 0)
- size -= DIRSIZ(OFSFMT(dp), ep);
+ size -= DIRSIZ(ep);
if (size > 0) {
if (size >= slotneeded) {
slotstatus = FOUND;
* Check for a name match.
*/
if (ep->d_ino) {
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (OFSFMT(dp))
- namlen = ep->d_type;
- else
- namlen = ep->d_namlen;
-# else
- namlen = ep->d_namlen;
-# endif
+ namlen = ep->d_namlen;
if (namlen == cnp->cn_namelen &&
!memcmp(cnp->cn_nameptr, ep->d_name, namlen)) {
#ifdef UFS_DIRHASH
* Check that directory length properly reflects presence
* of this entry.
*/
- if (dp->i_offset + DIRSIZ(OFSFMT(dp), ep) > DIP(dp, size)) {
+ if (dp->i_offset + DIRSIZ(ep) > DIP(dp, size)) {
ufs_dirbad(dp, dp->i_offset, "i_ffs_size too small");
- DIP_ASSIGN(dp, size, dp->i_offset + DIRSIZ(OFSFMT(dp), ep));
+ DIP_ASSIGN(dp, size, dp->i_offset + DIRSIZ(ep));
dp->i_flag |= IN_CHANGE | IN_UPDATE;
}
brelse(bp);
dp = VTOI(vdp);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (OFSFMT(dp))
- namlen = ep->d_type;
- else
- namlen = ep->d_namlen;
-# else
- namlen = ep->d_namlen;
-# endif
+ namlen = ep->d_namlen;
if ((ep->d_reclen & 0x3) != 0 ||
ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) ||
- ep->d_reclen < DIRSIZ(OFSFMT(dp), ep) || namlen > MAXNAMLEN) {
+ ep->d_reclen < DIRSIZ(ep) || namlen > MAXNAMLEN) {
/*return (1); */
printf("First bad\n");
goto bad;
memset(newdirp->d_name + (cnp->cn_namelen & ~(DIR_ROUNDUP-1)),
0, DIR_ROUNDUP);
memcpy(newdirp->d_name, cnp->cn_nameptr, cnp->cn_namelen);
- if (OFSFMT(ip)) {
- newdirp->d_type = 0;
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- { u_char tmp = newdirp->d_namlen;
- newdirp->d_namlen = newdirp->d_type;
- newdirp->d_type = tmp; }
-# endif
- } else
- newdirp->d_type = IFTODT(DIP(ip, mode));
+ newdirp->d_type = IFTODT(DIP(ip, mode));
}
/*
cr = cnp->cn_cred;
p = cnp->cn_proc;
dp = VTOI(dvp);
- newentrysize = DIRSIZ(OFSFMT(dp), dirp);
+ newentrysize = DIRSIZ(dirp);
if (dp->i_count == 0) {
/*
* dp->i_offset + dp->i_count would yield the space.
*/
ep = (struct direct *)dirbuf;
- dsize = ep->d_ino ? DIRSIZ(OFSFMT(dp), ep) : 0;
+ dsize = ep->d_ino ? DIRSIZ(ep) : 0;
spacefree = ep->d_reclen - dsize;
for (loc = ep->d_reclen; loc < dp->i_count; ) {
nep = (struct direct *)(dirbuf + loc);
dsize = 0;
continue;
}
- dsize = DIRSIZ(OFSFMT(dp), nep);
+ dsize = DIRSIZ(nep);
spacefree += nep->d_reclen - dsize;
#ifdef UFS_DIRHASH
if (dp->i_dirhash != NULL)
if (error)
return (error);
ep->d_ino = newinum;
- if (!OFSFMT(dp))
- ep->d_type = newtype;
+ ep->d_type = newtype;
oip->i_effnlink--;
if (DOINGSOFTDEP(vdp)) {
softdep_change_linkcnt(oip, 0);
if (dp->d_ino == 0)
continue;
/* accept only "." and ".." */
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (OFSFMT(ip))
- namlen = dp->d_type;
- else
- namlen = dp->d_namlen;
-# else
- namlen = dp->d_namlen;
-# endif
+ namlen = dp->d_namlen;
if (namlen > 2)
return (0);
if (dp->d_name[0] != '.')
IO_NODELOCKED, cred, NULL, curproc);
if (error != 0)
break;
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (OFSFMT(VTOI(vp)))
- namlen = dirbuf.dotdot_type;
- else
- namlen = dirbuf.dotdot_namlen;
-# else
- namlen = dirbuf.dotdot_namlen;
-# endif
+ namlen = dirbuf.dotdot_namlen;
if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') {
-/* $OpenBSD: ufs_vnops.c,v 1.158 2023/09/08 20:00:28 mvs Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.159 2024/01/09 03:15:59 guenther Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
/*
* A virgin directory (no blushing please).
*/
-static struct dirtemplate mastertemplate = {
+static const struct dirtemplate mastertemplate = {
0, 12, DT_DIR, 1, ".",
0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
};
-static struct odirtemplate omastertemplate = {
- 0, 12, 1, ".",
- 0, DIRBLKSIZ - 12, 2, ".."
-};
/*
* Update the times in the inode
struct vnode *tvp;
struct buf *bp;
struct direct newdir;
- struct dirtemplate dirtemplate, *dtp;
+ struct dirtemplate dirtemplate;
int error, dmode, blkoff;
#ifdef DIAGNOSTIC
/*
* Initialize directory with "." and ".." from static template.
*/
- if (dp->i_ump->um_maxsymlinklen > 0)
- dtp = &mastertemplate;
- else
- dtp = (struct dirtemplate *)&omastertemplate;
- dirtemplate = *dtp;
+ dirtemplate = mastertemplate;
dirtemplate.dot_ino = ip->i_number;
dirtemplate.dotdot_ino = dp->i_number;
caddr_t diskbuf;
size_t count, entries;
int bufsize, readcnt, error;
-#if (BYTE_ORDER == LITTLE_ENDIAN)
- int ofmt = VTOI(ap->a_vp)->i_ump->um_maxsymlinklen == 0;
-#endif
if (uio->uio_rw != UIO_READ)
return (EINVAL);
off += dp->d_reclen;
u.dn.d_off = off;
u.dn.d_fileno = dp->d_ino;
-#if (BYTE_ORDER == LITTLE_ENDIAN)
- if (ofmt) {
- u.dn.d_type = dp->d_namlen;
- u.dn.d_namlen = dp->d_type;
- } else
-#endif
- {
- u.dn.d_type = dp->d_type;
- u.dn.d_namlen = dp->d_namlen;
- }
+ u.dn.d_type = dp->d_type;
+ u.dn.d_namlen = dp->d_namlen;
memcpy(u.dn.d_name, dp->d_name, u.dn.d_namlen);
memset(u.dn.d_name + u.dn.d_namlen, 0, u.dn.d_reclen
- u.dn.d_namlen - offsetof(struct dirent, d_name));
u_int64_t isize;
isize = DIP(ip, size);
- if (isize < ip->i_ump->um_maxsymlinklen ||
- (ip->i_ump->um_maxsymlinklen == 0 && DIP(ip, blocks) == 0)) {
+ if (isize < ip->i_ump->um_maxsymlinklen)
return (uiomove((char *)SHORTLINK(ip), isize, ap->a_uio));
- }
return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred));
}
-/* $OpenBSD: ffs.c,v 1.38 2023/08/08 04:45:44 guenther Exp $ */
+/* $OpenBSD: ffs.c,v 1.39 2024/01/09 03:16:00 guenther Exp $ */
/* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */
/*
#define ADDDIRENT(e) do { \
tmpdir.d_namlen = strlen((e)); \
- this = DIRSIZ(NEWDIRFMT, &tmpdir); \
- if (this + curdirsize > roundup(curdirsize, DIRBLKSIZ)) \
- curdirsize = roundup(curdirsize, DIRBLKSIZ); \
+ this = DIRSIZ(&tmpdir); \
+ if (this + curdirsize > roundup(curdirsize, DIRBLKSIZ)) \
+ curdirsize = roundup(curdirsize, DIRBLKSIZ); \
curdirsize += this; \
} while (0);
de.d_type = IFTODT(node->type);
de.d_namlen = (uint8_t)strlen(name);
strlcpy(de.d_name, name, sizeof de.d_name);
- de.d_reclen = DIRSIZ(NEWDIRFMT, &de);
+ de.d_reclen = DIRSIZ(&de);
dp = (struct direct *)(dbuf->buf + dbuf->cur);
llen = 0;
if (dp != NULL)
- llen = DIRSIZ(NEWDIRFMT, dp);
+ llen = DIRSIZ(dp);
if (de.d_reclen + dbuf->cur + llen > roundup(dbuf->size, DIRBLKSIZ)) {
newbuf = erealloc(dbuf->buf, dbuf->size + DIRBLKSIZ);