summaryrefslogtreecommitdiffstats
path: root/usr.sbin/makefs
diff options
context:
space:
mode:
authornatano <natano@openbsd.org>2016-10-22 16:51:52 +0000
committernatano <natano@openbsd.org>2016-10-22 16:51:52 +0000
commit6c4d9c1ce6f1afdb3609b9be17ab58e6cb11b1b9 (patch)
tree96dae8a5725344a70c039db8a1e376e17a7e2bf2 /usr.sbin/makefs
parentAttach sxitimer(4) using the fdt. (diff)
downloadwireguard-openbsd-6c4d9c1ce6f1afdb3609b9be17ab58e6cb11b1b9.tar.xz
wireguard-openbsd-6c4d9c1ce6f1afdb3609b9be17ab58e6cb11b1b9.zip
Include our own <ufs/ufs/dinode.h>, <ufs/ufs/dir.h> and <ufs/ffs/fs.h>
header files instead of relying on copies of NetBSD's headers. This required some changes in the .c files, due to renamed fields, functions and preprocessor macros. Also pull in our own ffs_tables.c. As a bonus this diff gets rid of layout compatibility issues in the superblock (position of the fs_flags field).
Diffstat (limited to 'usr.sbin/makefs')
-rw-r--r--usr.sbin/makefs/ffs.c98
-rw-r--r--usr.sbin/makefs/ffs.h6
-rw-r--r--usr.sbin/makefs/ffs/dinode.h171
-rw-r--r--usr.sbin/makefs/ffs/dir.h150
-rw-r--r--usr.sbin/makefs/ffs/ffs_alloc.c44
-rw-r--r--usr.sbin/makefs/ffs/ffs_balloc.c80
-rw-r--r--usr.sbin/makefs/ffs/ffs_subr.c14
-rw-r--r--usr.sbin/makefs/ffs/ffs_tables.c12
-rw-r--r--usr.sbin/makefs/ffs/fs.h720
-rw-r--r--usr.sbin/makefs/ffs/mkfs.c205
-rw-r--r--usr.sbin/makefs/ffs/ufs_bmap.c26
11 files changed, 235 insertions, 1291 deletions
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 86267a59ee1..16908119d05 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.c,v 1.11 2016/10/22 10:13:08 natano Exp $ */
+/* $OpenBSD: ffs.c,v 1.12 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */
/*
@@ -78,18 +78,18 @@
#include <string.h>
#include <unistd.h>
-#include "makefs.h"
-#include "ffs.h"
+#include <ufs/ufs/dinode.h>
+#include <ufs/ufs/dir.h>
+#include <ufs/ffs/fs.h>
-#include "ffs/dinode.h"
-#include "ffs/dir.h"
-#include "ffs/fs.h"
#include "ffs/ufs_bswap.h"
-
#include "ffs/ufs_inode.h"
-#include "ffs/newfs_extern.h"
#include "ffs/ffs_extern.h"
+#include "makefs.h"
+#include "ffs.h"
+#include "ffs/newfs_extern.h"
+
#undef DIP
#define DIP(dp, field) \
((ffs_opts->version == 1) ? \
@@ -260,7 +260,7 @@ ffs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
errx(1, "Image file `%s' not created.", image);
TIMER_RESULTS(start, "ffs_create_image");
- fsopts->curinode = UFS_ROOTINO;
+ fsopts->curinode = ROOTINO;
if (debug & DEBUG_FS_MAKEFS)
putchar('\n');
@@ -279,10 +279,10 @@ ffs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
/* update various superblock parameters */
superblock = fsopts->superblock;
superblock->fs_fmod = 0;
- superblock->fs_old_cstotal.cs_ndir = superblock->fs_cstotal.cs_ndir;
- superblock->fs_old_cstotal.cs_nbfree = superblock->fs_cstotal.cs_nbfree;
- superblock->fs_old_cstotal.cs_nifree = superblock->fs_cstotal.cs_nifree;
- superblock->fs_old_cstotal.cs_nffree = superblock->fs_cstotal.cs_nffree;
+ superblock->fs_ffs1_cstotal.cs_ndir = superblock->fs_cstotal.cs_ndir;
+ superblock->fs_ffs1_cstotal.cs_nbfree = superblock->fs_cstotal.cs_nbfree;
+ superblock->fs_ffs1_cstotal.cs_nifree = superblock->fs_cstotal.cs_nifree;
+ superblock->fs_ffs1_cstotal.cs_nffree = superblock->fs_cstotal.cs_nffree;
/* write out superblock; image is now complete */
ffs_write_superblock(fsopts->superblock, fsopts);
@@ -345,7 +345,7 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
/* calculate size of tree */
ffs_size_dir(root, fsopts);
- fsopts->inodes += UFS_ROOTINO; /* include first two inodes */
+ fsopts->inodes += ROOTINO; /* include first two inodes */
if (debug & DEBUG_FS_VALIDATE)
printf("ffs_validate: size of tree: %lld bytes, %lld inodes\n",
@@ -370,13 +370,13 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
fsopts->size += (SBLOCK_UFS1 + SBLOCKSIZE) * ncg;
/* add space needed to store inodes, x3 for blockmaps, etc */
if (ffs_opts->version == 1)
- fsopts->size += ncg * DINODE1_SIZE *
+ fsopts->size += ncg * sizeof(struct ufs1_dinode) *
roundup(fsopts->inodes / ncg,
- ffs_opts->bsize / DINODE1_SIZE);
+ ffs_opts->bsize / sizeof(struct ufs1_dinode));
else
- fsopts->size += ncg * DINODE2_SIZE *
+ fsopts->size += ncg * sizeof(struct ufs2_dinode) *
roundup(fsopts->inodes / ncg,
- ffs_opts->bsize / DINODE2_SIZE);
+ ffs_opts->bsize / sizeof(struct ufs2_dinode));
/* add minfree */
if (ffs_opts->minfree > 0)
@@ -517,11 +517,11 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
(long long)fs->fs_cstotal.cs_ndir);
}
- if ((off_t)(fs->fs_cstotal.cs_nifree + UFS_ROOTINO) < fsopts->inodes) {
+ if ((off_t)(fs->fs_cstotal.cs_nifree + ROOTINO) < fsopts->inodes) {
warnx(
"Image file `%s' has %lld free inodes; %lld are required.",
image,
- (long long)(fs->fs_cstotal.cs_nifree + UFS_ROOTINO),
+ (long long)(fs->fs_cstotal.cs_nifree + ROOTINO),
(long long)fsopts->inodes);
return (-1);
}
@@ -547,12 +547,12 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
#define ADDDIRENT(e) do { \
tmpdir.d_namlen = strlen((e)); \
- this = UFS_DIRSIZ(&tmpdir); \
+ this = DIRSIZ(NEWDIRFMT, &tmpdir); \
if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \
printf("ADDDIRENT: was: %s (%d) this %d cur %d\n", \
e, tmpdir.d_namlen, this, curdirsize); \
- if (this + curdirsize > roundup(curdirsize, UFS_DIRBLKSIZ)) \
- curdirsize = roundup(curdirsize, UFS_DIRBLKSIZ); \
+ if (this + curdirsize > roundup(curdirsize, DIRBLKSIZ)) \
+ curdirsize = roundup(curdirsize, DIRBLKSIZ); \
curdirsize += this; \
if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \
printf("ADDDIRENT: now: %s (%d) this %d cur %d\n", \
@@ -588,8 +588,8 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
slen = strlen(node->symlink) + 1;
if (slen >= (ffs_opts->version == 1 ?
- UFS1_MAXSYMLINKLEN :
- UFS2_MAXSYMLINKLEN))
+ MAXSYMLINKLEN_UFS1 :
+ MAXSYMLINKLEN_UFS2))
ADDSIZE(slen);
}
}
@@ -638,7 +638,7 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
ufs_rw32(cur->inode->st.st_rdev, 0);
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
- if (slen < UFS1_MAXSYMLINKLEN) { /* short link */
+ if (slen < MAXSYMLINKLEN_UFS1) { /* short link */
memcpy(dinp->di_db, cur->symlink, slen);
} else
membuf = cur->symlink;
@@ -682,7 +682,7 @@ ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
ufs_rw64(cur->inode->st.st_rdev, 0);
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
- if (slen < UFS2_MAXSYMLINKLEN) { /* short link */
+ if (slen < MAXSYMLINKLEN_UFS2) { /* short link */
memcpy(dinp->di_db, cur->symlink, slen);
} else
membuf = cur->symlink;
@@ -941,7 +941,7 @@ ffs_dump_dirbuf(dirbuf_t *dbuf, const char *dir)
reclen = ufs_rw16(de->d_reclen, 0);
printf(
" inode %4d %7s offset %4d reclen %3d namlen %3d name %s\n",
- ufs_rw32(de->d_fileno, 0),
+ ufs_rw32(de->d_ino, 0),
inode_type(DTTOIF(de->d_type)), i, reclen,
de->d_namlen, de->d_name);
i += reclen;
@@ -961,35 +961,35 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node)
assert (node != NULL);
/* create direct entry */
(void)memset(&de, 0, sizeof(de));
- de.d_fileno = ufs_rw32(node->inode->ino, 0);
+ de.d_ino = ufs_rw32(node->inode->ino, 0);
de.d_type = IFTODT(node->type);
de.d_namlen = (uint8_t)strlen(name);
strlcpy(de.d_name, name, sizeof de.d_name);
- reclen = UFS_DIRSIZ(&de);
+ reclen = DIRSIZ(NEWDIRFMT, &de);
de.d_reclen = ufs_rw16(reclen, 0);
dp = (struct direct *)(dbuf->buf + dbuf->cur);
llen = 0;
if (dp != NULL)
- llen = UFS_DIRSIZ(dp);
+ llen = DIRSIZ(NEWDIRFMT, dp);
if (debug & DEBUG_FS_MAKE_DIRBUF)
printf(
"ffs_make_dirbuf: dbuf siz %d cur %d lastlen %d\n"
" ino %d type %d reclen %d namlen %d name %.30s\n",
dbuf->size, dbuf->cur, llen,
- ufs_rw32(de.d_fileno, 0), de.d_type, reclen,
+ ufs_rw32(de.d_ino, 0), de.d_type, reclen,
de.d_namlen, de.d_name);
- if (reclen + dbuf->cur + llen > roundup(dbuf->size, UFS_DIRBLKSIZ)) {
+ if (reclen + dbuf->cur + llen > roundup(dbuf->size, DIRBLKSIZ)) {
if (debug & DEBUG_FS_MAKE_DIRBUF)
printf("ffs_make_dirbuf: growing buf to %d\n",
- dbuf->size + UFS_DIRBLKSIZ);
- newbuf = erealloc(dbuf->buf, dbuf->size + UFS_DIRBLKSIZ);
+ dbuf->size + DIRBLKSIZ);
+ newbuf = erealloc(dbuf->buf, dbuf->size + DIRBLKSIZ);
dbuf->buf = newbuf;
- dbuf->size += UFS_DIRBLKSIZ;
- memset(dbuf->buf + dbuf->size - UFS_DIRBLKSIZ, 0, UFS_DIRBLKSIZ);
- dbuf->cur = dbuf->size - UFS_DIRBLKSIZ;
+ dbuf->size += DIRBLKSIZ;
+ memset(dbuf->buf + dbuf->size - DIRBLKSIZ, 0, DIRBLKSIZ);
+ dbuf->cur = dbuf->size - DIRBLKSIZ;
} else if (dp) { /* shrink end of previous */
dp->d_reclen = ufs_rw16(llen,0);
dbuf->cur += llen;
@@ -1028,13 +1028,13 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
printf("ffs_write_inode: din %p ino %u cg %d cgino %d\n",
dp, ino, cg, cgino);
- ffs_rdfs(FFS_FSBTODB(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
+ ffs_rdfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
fsopts);
cgp = (struct cg *)sbbuf;
- if (!cg_chkmagic(cgp, 0))
+ if (!cg_chkmagic(cgp))
errx(1, "ffs_write_inode: cg %d: bad magic number", cg);
- assert (isclr(cg_inosused(cgp, 0), cgino));
+ assert (isclr(cg_inosused(cgp), cgino));
buf = emalloc(fs->fs_bsize);
dp1 = (struct ufs1_dinode *)buf;
@@ -1047,7 +1047,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
errx(1,
"ffs_write_inode: cg %d out of inodes for ino %u",
cg, ino);
- setbit(cg_inosused(cgp, 0), cgino);
+ setbit(cg_inosused(cgp), cgino);
cgp->cg_cs.cs_nifree -= 1;
fs->fs_cstotal.cs_nifree--;
fs->fs_cs(fs, cg).cs_nifree--;
@@ -1062,27 +1062,27 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
*/
initediblk = ufs_rw32(cgp->cg_initediblk, 0);
if (ffs_opts->version == 2 &&
- (uint32_t)(cgino + FFS_INOPB(fs)) > initediblk &&
- initediblk < ufs_rw32(cgp->cg_niblk, 0)) {
+ (uint32_t)(cgino + INOPB(fs)) > initediblk &&
+ initediblk < ufs_rw32(cgp->cg_ffs2_niblk, 0)) {
memset(buf, 0, fs->fs_bsize);
dip = (struct ufs2_dinode *)buf;
- for (i = 0; i < FFS_INOPB(fs); i++) {
+ for (i = 0; i < INOPB(fs); i++) {
dip->di_gen = random() / 2 + 1;
dip++;
}
- ffs_wtfs(FFS_FSBTODB(fs, ino_to_fsba(fs,
+ ffs_wtfs(fsbtodb(fs, ino_to_fsba(fs,
cg * fs->fs_ipg + initediblk)),
fs->fs_bsize, buf, fsopts);
- initediblk += FFS_INOPB(fs);
+ initediblk += INOPB(fs);
cgp->cg_initediblk = ufs_rw32(initediblk, 0);
}
- ffs_wtfs(FFS_FSBTODB(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
+ ffs_wtfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
fsopts);
/* now write inode */
- d = FFS_FSBTODB(fs, ino_to_fsba(fs, ino));
+ d = fsbtodb(fs, ino_to_fsba(fs, ino));
ffs_rdfs(d, fs->fs_bsize, buf, fsopts);
if (ffs_opts->version == 1)
dp1[ino_to_fsbo(fs, ino)] = dp->ffs1_din;
diff --git a/usr.sbin/makefs/ffs.h b/usr.sbin/makefs/ffs.h
index 344dfcfec7a..67b94e7275d 100644
--- a/usr.sbin/makefs/ffs.h
+++ b/usr.sbin/makefs/ffs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.h,v 1.3 2016/10/18 17:23:21 natano Exp $ */
+/* $OpenBSD: ffs.h,v 1.4 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ffs.h,v 1.2 2011/10/09 21:33:43 christos Exp $ */
/*
@@ -39,9 +39,6 @@
#ifndef _FFS_H
#define _FFS_H
-#include "ffs/dinode.h"
-#include "ffs/fs.h"
-
typedef struct {
char label[MAXVOLLEN]; /* volume name/label */
int bsize; /* block size */
@@ -63,7 +60,6 @@ typedef struct {
int version; /* filesystem version (1 = FFS, 2 = UFS2) */
int maxbsize; /* maximum extent size */
int maxblkspercg; /* max # of blocks per cylinder group */
- /* XXX: support `old' file systems ? */
} ffs_opt_t;
#endif /* _FFS_H */
diff --git a/usr.sbin/makefs/ffs/dinode.h b/usr.sbin/makefs/ffs/dinode.h
deleted file mode 100644
index 67116582a87..00000000000
--- a/usr.sbin/makefs/ffs/dinode.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* $OpenBSD: dinode.h,v 1.1 2016/10/18 17:23:21 natano Exp $ */
-/* $NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp $ */
-
-/*
- * Copyright (c) 2002 Networks Associates Technology, Inc.
- * All rights reserved.
- *
- * This software was developed for the FreeBSD Project by Marshall
- * Kirk McKusick and Network Associates Laboratories, the Security
- * Research Division of Network Associates, Inc. under DARPA/SPAWAR
- * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
- * research program
- *
- * Copyright (c) 1982, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)dinode.h 8.9 (Berkeley) 3/29/95
- */
-
-/*
- * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT.
- */
-
-#ifndef _UFS_UFS_DINODE_H_
-#define _UFS_UFS_DINODE_H_
-
-/*
- * The root inode is the root of the file system. Inode 0 can't be used for
- * normal purposes and historically bad blocks were linked to inode 1, thus
- * the root inode is 2. (Inode 1 is no longer used for this purpose, however
- * numerous dump tapes make this assumption, so we are stuck with it).
- */
-#define UFS_ROOTINO ((ino_t)2)
-
-/*
- * The Whiteout inode# is a dummy non-zero inode number which will
- * never be allocated to a real file. It is used as a place holder
- * in the directory entry which has been tagged as a DT_W entry.
- * See the comments about UFS_ROOTINO above.
- */
-#define UFS_WINO ((ino_t)1)
-
-/*
- * A dinode contains all the meta-data associated with a UFS file.
- * This structure defines the on-disk format of a dinode. Since
- * this structure describes an on-disk structure, all its fields
- * are defined by types with precise widths.
- */
-
-#define UFS_NXADDR 2
-#define UFS_NDADDR 12 /* Direct addresses in inode. */
-#define UFS_NIADDR 3 /* Indirect addresses in inode. */
-
-struct ufs1_dinode {
- uint16_t di_mode; /* 0: IFMT, permissions; see below. */
- int16_t di_nlink; /* 2: File link count. */
- uint16_t di_oldids[2]; /* 4: Ffs: old user and group ids. */
- uint64_t di_size; /* 8: File byte count. */
- int32_t di_atime; /* 16: Last access time. */
- int32_t di_atimensec; /* 20: Last access time. */
- int32_t di_mtime; /* 24: Last modified time. */
- int32_t di_mtimensec; /* 28: Last modified time. */
- int32_t di_ctime; /* 32: Last inode change time. */
- int32_t di_ctimensec; /* 36: Last inode change time. */
- int32_t di_db[UFS_NDADDR]; /* 40: Direct disk blocks. */
- int32_t di_ib[UFS_NIADDR]; /* 88: Indirect disk blocks. */
- uint32_t di_flags; /* 100: Status flags (chflags). */
- uint32_t di_blocks; /* 104: Blocks actually held. */
- int32_t di_gen; /* 108: Generation number. */
- uint32_t di_uid; /* 112: File owner. */
- uint32_t di_gid; /* 116: File group. */
- uint64_t di_modrev; /* 120: i_modrev for NFSv4 */
-};
-
-struct ufs2_dinode {
- uint16_t di_mode; /* 0: IFMT, permissions; see below. */
- int16_t di_nlink; /* 2: File link count. */
- uint32_t di_uid; /* 4: File owner. */
- uint32_t di_gid; /* 8: File group. */
- uint32_t di_blksize; /* 12: Inode blocksize. */
- uint64_t di_size; /* 16: File byte count. */
- uint64_t di_blocks; /* 24: Bytes actually held. */
- int64_t di_atime; /* 32: Last access time. */
- int64_t di_mtime; /* 40: Last modified time. */
- int64_t di_ctime; /* 48: Last inode change time. */
- int64_t di_birthtime; /* 56: Inode creation time. */
- int32_t di_mtimensec; /* 64: Last modified time. */
- int32_t di_atimensec; /* 68: Last access time. */
- int32_t di_ctimensec; /* 72: Last inode change time. */
- int32_t di_birthnsec; /* 76: Inode creation time. */
- int32_t di_gen; /* 80: Generation number. */
- uint32_t di_kernflags; /* 84: Kernel flags. */
- uint32_t di_flags; /* 88: Status flags (chflags). */
- int32_t di_extsize; /* 92: External attributes block. */
- int64_t di_extb[UFS_NXADDR];/* 96: External attributes block. */
- int64_t di_db[UFS_NDADDR]; /* 112: Direct disk blocks. */
- int64_t di_ib[UFS_NIADDR]; /* 208: Indirect disk blocks. */
- uint64_t di_modrev; /* 232: i_modrev for NFSv4 */
- int64_t di_spare[2]; /* 240: Reserved; currently unused */
-};
-
-/*
- * The di_db fields may be overlaid with other information for
- * file types that do not have associated disk storage. Block
- * and character devices overlay the first data block with their
- * dev_t value. Short symbolic links place their path in the
- * di_db area.
- */
-#define di_ogid di_oldids[1]
-#define di_ouid di_oldids[0]
-#define di_rdev di_db[0]
-#define UFS1_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(int32_t))
-#define UFS2_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(int64_t))
-
-#define UFS_MAXSYMLINKLEN(ip) \
- ((ip)->i_ump->um_fstype == UFS1) ? \
- UFS1_MAXSYMLINKLEN : UFS2_MAXSYMLINKLEN
-
-/* File permissions. */
-#define IEXEC 0000100 /* Executable. */
-#define IWRITE 0000200 /* Writable. */
-#define IREAD 0000400 /* Readable. */
-#define ISVTX 0001000 /* Sticky bit. */
-#define ISGID 0002000 /* Set-gid. */
-#define ISUID 0004000 /* Set-uid. */
-
-/* File types. */
-#define IFMT 0170000 /* Mask of file type. */
-#define IFIFO 0010000 /* Named pipe (fifo). */
-#define IFCHR 0020000 /* Character device. */
-#define IFDIR 0040000 /* Directory file. */
-#define IFBLK 0060000 /* Block device. */
-#define IFREG 0100000 /* Regular file. */
-#define IFLNK 0120000 /* Symbolic link. */
-#define IFSOCK 0140000 /* UNIX domain socket. */
-#define IFWHT 0160000 /* Whiteout. */
-
-/* Size of the on-disk inode. */
-#define DINODE1_SIZE (sizeof(struct ufs1_dinode)) /* 128 */
-#define DINODE2_SIZE (sizeof(struct ufs2_dinode))
-
-#endif /* !_UFS_UFS_DINODE_H_ */
diff --git a/usr.sbin/makefs/ffs/dir.h b/usr.sbin/makefs/ffs/dir.h
deleted file mode 100644
index 760c915cfc6..00000000000
--- a/usr.sbin/makefs/ffs/dir.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* $OpenBSD: dir.h,v 1.1 2016/10/18 17:23:21 natano Exp $ */
-/* $NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp $ */
-
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)dir.h 8.5 (Berkeley) 4/27/95
- */
-
-#ifndef _UFS_UFS_DIR_H_
-#define _UFS_UFS_DIR_H_
-
-/*
- * Theoretically, directories can be more than 2Gb in length; however, in
- * practice this seems unlikely. So, we define the type doff_t as a 32-bit
- * quantity to keep down the cost of doing lookup on a 32-bit machine.
- */
-#define doff_t int32_t
-#define UFS_MAXDIRSIZE (0x7fffffff)
-
-/*
- * A directory consists of some number of blocks of UFS_DIRBLKSIZ
- * bytes, where UFS_DIRBLKSIZ is chosen such that it can be transferred
- * to disk in a single atomic operation (e.g. 512 bytes on most machines).
- *
- * Each UFS_DIRBLKSIZ byte block contains some number of directory entry
- * structures, which are of variable length. Each directory entry has
- * a struct direct at the front of it, containing its inode number,
- * the length of the entry, and the length of the name contained in
- * the entry. These are followed by the name padded to a 4 byte boundary.
- * All names are guaranteed null terminated.
- * The maximum length of a name in a directory is FFS_MAXNAMLEN.
- *
- * The macro UFS_DIRSIZ(fmt, 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 UFS_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
- * space is returned to the previous entry in the same directory
- * block by increasing its dp->d_reclen. If the first entry of
- * a directory block is free, then its dp->d_ino is set to 0.
- * Entries other than the first in a directory do not normally have
- * dp->d_ino set to 0.
- */
-#undef UFS_DIRBLKSIZ
-#define UFS_DIRBLKSIZ DEV_BSIZE
-#define FFS_MAXNAMLEN 255
-
-#define d_ino d_fileno
-struct direct {
- u_int32_t d_fileno; /* inode number of entry */
- u_int16_t d_reclen; /* length of this record */
- u_int8_t d_type; /* file type, see below */
- u_int8_t d_namlen; /* length of string in d_name */
- char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */
-};
-
-/*
- * File types
- */
-#define DT_UNKNOWN 0
-#define DT_FIFO 1
-#define DT_CHR 2
-#define DT_DIR 4
-#define DT_BLK 6
-#define DT_REG 8
-#define DT_LNK 10
-#define DT_SOCK 12
-#define DT_WHT 14
-
-/*
- * Convert between stat structure types and directory types.
- */
-#define IFTODT(mode) (((mode) & 0170000) >> 12)
-#define DTTOIF(dirtype) ((dirtype) << 12)
-
-/*
- * The UFS_DIRSIZ macro gives the minimum record length which will hold
- * the directory entry. This requires the amount of space in struct direct
- * without the d_name field, plus enough space for the name with a terminating
- * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
- */
-#define UFS_DIRECTSIZ(namlen) \
- ((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3))
-
-#define UFS_DIRSIZ(dp) \
- UFS_DIRECTSIZ((dp)->d_namlen)
-
-/*
- * Template for manipulating directories. Should use struct direct's,
- * but the name field is FFS_MAXNAMLEN - 1, and this just won't do.
- */
-struct dirtemplate {
- u_int32_t dot_ino;
- int16_t dot_reclen;
- u_int8_t dot_type;
- u_int8_t dot_namlen;
- char dot_name[4]; /* must be multiple of 4 */
- u_int32_t dotdot_ino;
- int16_t dotdot_reclen;
- u_int8_t dotdot_type;
- u_int8_t dotdot_namlen;
- char dotdot_name[4]; /* ditto */
-};
-
-/*
- * This is the old format of directories, sans 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 /* !_UFS_UFS_DIR_H_ */
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index 4a6ea51df7c..a6aa425d87d 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_alloc.c,v 1.8 2016/10/18 17:23:21 natano Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.9 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $ */
/* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
@@ -46,11 +46,11 @@
#include <errno.h>
-#include "ffs/dinode.h"
-#include "ffs/ufs_bswap.h"
-#include "ffs/fs.h"
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
#include "ffs/buf.h"
+#include "ffs/ufs_bswap.h"
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
@@ -63,10 +63,6 @@ static daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int,
daddr_t (*)(struct inode *, int, daddr_t, int));
static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
-/* in ffs_tables.c */
-extern const int inside[], around[];
-extern const u_char * const fragtbl[];
-
/*
* Allocate a block in the file system.
*
@@ -95,7 +91,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn __unused, daddr_t bpref, int size,
int cg;
*bnp = 0;
- if (size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
+ if (size > fs->fs_bsize || fragoff(fs, size) != 0) {
errx(EXIT_FAILURE, "%s: bad size: bsize %d size %d", __func__,
fs->fs_bsize, size);
}
@@ -153,7 +149,7 @@ ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap)
fs = ip->i_fs;
if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) {
- if (lbn < UFS_NDADDR + FFS_NINDIR(fs)) {
+ if (lbn < NDADDR + NINDIR(fs)) {
cg = ino_to_cg(fs, ip->i_number);
return (fs->fs_fpg * cg + fs->fs_frag);
}
@@ -192,7 +188,7 @@ ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap)
fs = ip->i_fs;
if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) {
- if (lbn < UFS_NDADDR + FFS_NINDIR(fs)) {
+ if (lbn < NDADDR + NINDIR(fs)) {
cg = ino_to_cg(fs, ip->i_number);
return (fs->fs_fpg * cg + fs->fs_frag);
}
@@ -295,13 +291,13 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
return (0);
- error = bread(ip->i_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
+ error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
(int)fs->fs_cgsize, 0, &bp);
if (error) {
return (0);
}
cgp = (struct cg *)bp->b_data;
- if (!cg_chkmagic(cgp, 0) ||
+ if (!cg_chkmagic(cgp) ||
(cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
brelse(bp, 0);
return (0);
@@ -316,7 +312,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
* allocsiz is the size which will be allocated, hacking
* it down to a smaller size if necessary
*/
- frags = ffs_numfrags(fs, size);
+ frags = numfrags(fs, size);
for (allocsiz = frags; allocsiz < fs->fs_frag; allocsiz++)
if (cgp->cg_frsum[allocsiz] != 0)
break;
@@ -332,7 +328,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
bno = ffs_alloccgblk(ip, bp, bpref);
bpref = dtogd(fs, bno);
for (i = frags; i < fs->fs_frag; i++)
- setbit(cg_blksfree(cgp, 0), bpref + i);
+ setbit(cg_blksfree(cgp), bpref + i);
i = fs->fs_frag - frags;
cgp->cg_cs.cs_nffree += i;
fs->fs_cstotal.cs_nffree += i;
@@ -344,7 +340,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
}
bno = ffs_mapsearch(fs, cgp, bpref, allocsiz);
for (i = 0; i < frags; i++)
- clrbit(cg_blksfree(cgp, 0), bno + i);
+ clrbit(cg_blksfree(cgp), bno + i);
cgp->cg_cs.cs_nffree -= frags;
fs->fs_cstotal.cs_nffree -= frags;
fs->fs_cs(fs, cg).cs_nffree -= frags;
@@ -378,16 +374,16 @@ ffs_alloccgblk(struct inode *ip, struct mkfsbuf *bp, daddr_t bpref)
u_int8_t *blksfree;
cgp = (struct cg *)bp->b_data;
- blksfree = cg_blksfree(cgp, 0);
+ blksfree = cg_blksfree(cgp);
if (bpref == 0 || dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, 0)) {
bpref = ufs_rw32(cgp->cg_rotor, 0);
} else {
- bpref = ffs_blknum(fs, bpref);
+ bpref = blknum(fs, bpref);
bno = dtogd(fs, bpref);
/*
* if the requested block is available, use it
*/
- if (ffs_isblock(fs, blksfree, ffs_fragstoblks(fs, bno)))
+ if (ffs_isblock(fs, blksfree, fragstoblks(fs, bno)))
goto gotit;
}
/*
@@ -398,7 +394,7 @@ ffs_alloccgblk(struct inode *ip, struct mkfsbuf *bp, daddr_t bpref)
return (0);
cgp->cg_rotor = ufs_rw32(bno, 0);
gotit:
- blkno = ffs_fragstoblks(fs, bno);
+ blkno = fragstoblks(fs, bno);
ffs_clrblock(fs, blksfree, (long)blkno);
ffs_clusteracct(fs, cgp, blkno, -1);
cgp->cg_cs.cs_nbfree -= 1;
@@ -445,21 +441,21 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz)
ostart = start;
olen = len;
loc = scanc((u_int)len,
- (const u_char *)&cg_blksfree(cgp, 0)[start],
+ (const u_char *)&cg_blksfree(cgp)[start],
(const u_char *)fragtbl[fs->fs_frag],
(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
if (loc == 0) {
len = start + 1;
start = 0;
loc = scanc((u_int)len,
- (const u_char *)&cg_blksfree(cgp, 0)[0],
+ (const u_char *)&cg_blksfree(cgp)[0],
(const u_char *)fragtbl[fs->fs_frag],
(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
if (loc == 0) {
errx(EXIT_FAILURE, "%s: map corrupted: start %d "
"len %d offset %d %ld", __func__, ostart, olen,
ufs_rw32(cgp->cg_freeoff, 0),
- (long)cg_blksfree(cgp, 0) - (long)cgp);
+ (long)cg_blksfree(cgp) - (long)cgp);
/* NOTREACHED */
}
}
@@ -470,7 +466,7 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz)
* sift through the bits to find the selected frag
*/
for (i = bno + NBBY; bno < i; bno += fs->fs_frag) {
- blk = blkmap(fs, cg_blksfree(cgp, 0), bno);
+ blk = blkmap(fs, cg_blksfree(cgp), bno);
blk <<= 1;
field = around[allocsiz];
subfield = inside[allocsiz];
diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c
index be13c24a3a9..2ed6b74a2ae 100644
--- a/usr.sbin/makefs/ffs/ffs_balloc.c
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_balloc.c,v 1.6 2016/10/18 17:23:21 natano Exp $ */
+/* $OpenBSD: ffs_balloc.c,v 1.7 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ffs_balloc.c,v 1.21 2015/03/29 05:52:59 agc Exp $ */
/* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */
@@ -38,11 +38,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include "ffs/dinode.h"
-#include "ffs/ufs_bswap.h"
-#include "ffs/fs.h"
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
#include "ffs/buf.h"
+#include "ffs/ufs_bswap.h"
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
@@ -74,15 +74,15 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
int32_t nb;
struct mkfsbuf *bp, *nbp;
struct fs *fs = ip->i_fs;
- struct indir indirs[UFS_NIADDR + 2];
+ struct indir indirs[NIADDR + 2];
daddr_t newb, pref;
int32_t *bap;
int osize, nsize, num, i, error;
- int32_t *allocblk, allociblk[UFS_NIADDR + 1];
+ int32_t *allocblk, allociblk[NIADDR + 1];
int32_t *allocib;
- lbn = ffs_lblkno(fs, offset);
- size = ffs_blkoff(fs, offset) + bufsize;
+ lbn = lblkno(fs, offset);
+ size = blkoff(fs, offset) + bufsize;
if (bpp != NULL) {
*bpp = NULL;
}
@@ -97,10 +97,10 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* this fragment has to be extended to be a full block.
*/
- lastlbn = ffs_lblkno(fs, ip->i_ffs1_size);
- if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
+ lastlbn = lblkno(fs, ip->i_ffs1_size);
+ if (lastlbn < NDADDR && lastlbn < lbn) {
nb = lastlbn;
- osize = ffs_blksize(fs, ip, nb);
+ osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
warnx("need to ffs_realloccg; not supported!");
abort();
@@ -108,12 +108,12 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
}
/*
- * The first UFS_NDADDR blocks are direct blocks
+ * The first NDADDR blocks are direct blocks
*/
- if (lbn < UFS_NDADDR) {
+ if (lbn < NDADDR) {
nb = ufs_rw32(ip->i_ffs1_db[lbn], 0);
- if (nb != 0 && ip->i_ffs1_size >= ffs_lblktosize(fs, lbn + 1)) {
+ if (nb != 0 && ip->i_ffs1_size >= lblktosize(fs, lbn + 1)) {
/*
* The block is an already-allocated direct block
@@ -138,8 +138,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* Consider need to reallocate a fragment.
*/
- osize = ffs_fragroundup(fs, ffs_blkoff(fs, ip->i_ffs1_size));
- nsize = ffs_fragroundup(fs, size);
+ osize = fragroundup(fs, blkoff(fs, ip->i_ffs1_size));
+ nsize = fragroundup(fs, size);
if (nsize <= osize) {
/*
@@ -168,8 +168,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* allocate a new block or fragment.
*/
- if (ip->i_ffs1_size < ffs_lblktosize(fs, lbn + 1))
- nsize = ffs_fragroundup(fs, size);
+ if (ip->i_ffs1_size < lblktosize(fs, lbn + 1))
+ nsize = fragroundup(fs, size);
else
nsize = fs->fs_bsize;
error = ffs_alloc(ip, lbn,
@@ -180,7 +180,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
return (error);
if (bpp != NULL) {
bp = getblk(ip->i_devvp, lbn, nsize, 0, 0);
- bp->b_blkno = FFS_FSBTODB(fs, newb);
+ bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
}
@@ -218,7 +218,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
nb = newb;
*allocblk++ = nb;
bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
- bp->b_blkno = FFS_FSBTODB(fs, nb);
+ bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
* Write synchronously so that indirect blocks
@@ -260,7 +260,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
nb = newb;
*allocblk++ = nb;
nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
- nbp->b_blkno = FFS_FSBTODB(fs, nb);
+ nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
* Write synchronously so that indirect blocks
@@ -291,7 +291,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
*allocblk++ = nb;
if (bpp != NULL) {
nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0);
- nbp->b_blkno = FFS_FSBTODB(fs, nb);
+ nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
}
@@ -323,15 +323,15 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
int size;
struct mkfsbuf *bp, *nbp;
struct fs *fs = ip->i_fs;
- struct indir indirs[UFS_NIADDR + 2];
+ struct indir indirs[NIADDR + 2];
daddr_t newb, pref, nb;
int64_t *bap;
int osize, nsize, num, i, error;
- int64_t *allocblk, allociblk[UFS_NIADDR + 1];
+ int64_t *allocblk, allociblk[NIADDR + 1];
int64_t *allocib;
- lbn = ffs_lblkno(fs, offset);
- size = ffs_blkoff(fs, offset) + bufsize;
+ lbn = lblkno(fs, offset);
+ size = blkoff(fs, offset) + bufsize;
if (bpp != NULL) {
*bpp = NULL;
}
@@ -346,10 +346,10 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* this fragment has to be extended to be a full block.
*/
- lastlbn = ffs_lblkno(fs, ip->i_ffs2_size);
- if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
+ lastlbn = lblkno(fs, ip->i_ffs2_size);
+ if (lastlbn < NDADDR && lastlbn < lbn) {
nb = lastlbn;
- osize = ffs_blksize(fs, ip, nb);
+ osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
warnx("need to ffs_realloccg; not supported!");
abort();
@@ -357,12 +357,12 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
}
/*
- * The first UFS_NDADDR blocks are direct blocks
+ * The first NDADDR blocks are direct blocks
*/
- if (lbn < UFS_NDADDR) {
+ if (lbn < NDADDR) {
nb = ufs_rw64(ip->i_ffs2_db[lbn], 0);
- if (nb != 0 && ip->i_ffs2_size >= ffs_lblktosize(fs, lbn + 1)) {
+ if (nb != 0 && ip->i_ffs2_size >= lblktosize(fs, lbn + 1)) {
/*
* The block is an already-allocated direct block
@@ -387,8 +387,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* Consider need to reallocate a fragment.
*/
- osize = ffs_fragroundup(fs, ffs_blkoff(fs, ip->i_ffs2_size));
- nsize = ffs_fragroundup(fs, size);
+ osize = fragroundup(fs, blkoff(fs, ip->i_ffs2_size));
+ nsize = fragroundup(fs, size);
if (nsize <= osize) {
/*
@@ -417,8 +417,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
* allocate a new block or fragment.
*/
- if (ip->i_ffs2_size < ffs_lblktosize(fs, lbn + 1))
- nsize = ffs_fragroundup(fs, size);
+ if (ip->i_ffs2_size < lblktosize(fs, lbn + 1))
+ nsize = fragroundup(fs, size);
else
nsize = fs->fs_bsize;
error = ffs_alloc(ip, lbn,
@@ -429,7 +429,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
return (error);
if (bpp != NULL) {
bp = getblk(ip->i_devvp, lbn, nsize, 0, 0);
- bp->b_blkno = FFS_FSBTODB(fs, newb);
+ bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
}
@@ -467,7 +467,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
nb = newb;
*allocblk++ = nb;
bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
- bp->b_blkno = FFS_FSBTODB(fs, nb);
+ bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
* Write synchronously so that indirect blocks
@@ -509,7 +509,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
nb = newb;
*allocblk++ = nb;
nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
- nbp->b_blkno = FFS_FSBTODB(fs, nb);
+ nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
* Write synchronously so that indirect blocks
@@ -540,7 +540,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp
*allocblk++ = nb;
if (bpp != NULL) {
nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0);
- nbp->b_blkno = FFS_FSBTODB(fs, nb);
+ nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
}
diff --git a/usr.sbin/makefs/ffs/ffs_subr.c b/usr.sbin/makefs/ffs/ffs_subr.c
index 20103af864b..9723e6c4732 100644
--- a/usr.sbin/makefs/ffs/ffs_subr.c
+++ b/usr.sbin/makefs/ffs/ffs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_subr.c,v 1.1 2016/10/18 17:23:21 natano Exp $ */
+/* $OpenBSD: ffs_subr.c,v 1.2 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ffs_subr.c,v 1.49 2016/05/07 11:59:08 maxv Exp $ */
/*
@@ -34,14 +34,10 @@
#include <sys/param.h>
-/* in ffs_tables.c */
-extern const int inside[], around[];
-extern const u_char * const fragtbl[];
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
-#include "ffs/fs.h"
#include "ffs/ufs_bswap.h"
-#include "ffs/dinode.h"
-
#include "ffs/ffs_extern.h"
void panic(const char *, ...)
@@ -147,8 +143,8 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt)
if (fs->fs_contigsumsize <= 0)
return;
- freemapp = cg_clustersfree(cgp, 0);
- sump = cg_clustersum(cgp, 0);
+ freemapp = cg_clustersfree(cgp);
+ sump = cg_clustersum(cgp);
/*
* Allocate or clear the actual block.
*/
diff --git a/usr.sbin/makefs/ffs/ffs_tables.c b/usr.sbin/makefs/ffs/ffs_tables.c
index 2daa2c6537d..077eb900a0e 100644
--- a/usr.sbin/makefs/ffs/ffs_tables.c
+++ b/usr.sbin/makefs/ffs/ffs_tables.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ffs_tables.c,v 1.1 2016/10/18 17:23:21 natano Exp $ */
-/* $NetBSD: ffs_tables.c,v 1.9 2005/12/11 12:25:25 christos Exp $ */
+/* $OpenBSD: ffs_tables.c,v 1.2 2016/10/22 16:51:52 natano Exp $ */
+/* $NetBSD: ffs_tables.c,v 1.2 1994/06/29 06:46:35 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -33,8 +33,7 @@
*/
#include <sys/param.h>
-
-#include "ffs/fs.h"
+#include <ufs/ffs/fs.h>
/*
* Bit patterns for identifying fragments in the block map
@@ -132,6 +131,7 @@ const u_char fragtbl8[256] = {
/*
* The actual fragtbl array.
*/
-const u_char * const fragtbl[MAXFRAG + 1] = {
- 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
+const u_char *fragtbl[MAXFRAG + 1] = {
+ NULL, fragtbl124, fragtbl124, NULL, fragtbl124, NULL, NULL, NULL,
+ fragtbl8,
};
diff --git a/usr.sbin/makefs/ffs/fs.h b/usr.sbin/makefs/ffs/fs.h
deleted file mode 100644
index 0f4223e6f8d..00000000000
--- a/usr.sbin/makefs/ffs/fs.h
+++ /dev/null
@@ -1,720 +0,0 @@
-/* $OpenBSD: fs.h,v 1.1 2016/10/18 17:23:21 natano Exp $ */
-/* $NetBSD: fs.h,v 1.66 2015/02/14 09:06:11 maxv Exp $ */
-
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)fs.h 8.13 (Berkeley) 3/21/95
- */
-
-/*
- * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT.
- */
-
-#ifndef _UFS_FFS_FS_H_
-#define _UFS_FFS_FS_H_
-
-/*
- * Each disk drive contains some number of file systems.
- * A file system consists of a number of cylinder groups.
- * Each cylinder group has inodes and data.
- *
- * A file system is described by its super-block, which in turn
- * describes the cylinder groups. The super-block is critical
- * data and is replicated in each cylinder group to protect against
- * catastrophic loss. This is done at `newfs' time and the critical
- * super-block data does not change, so the copies need not be
- * referenced further unless disaster strikes.
- *
- * For file system fs, the offsets of the various blocks of interest
- * are given in the super block as:
- * [fs->fs_sblkno] Super-block
- * [fs->fs_cblkno] Cylinder group block
- * [fs->fs_iblkno] Inode blocks
- * [fs->fs_dblkno] Data blocks
- * The beginning of cylinder group cg in fs, is given by
- * the ``cgbase(fs, cg)'' macro.
- *
- * Depending on the architecture and the media, the superblock may
- * reside in any one of four places. For tiny media where every block
- * counts, it is placed at the very front of the partition. Historically,
- * UFS1 placed it 8K from the front to leave room for the disk label and
- * a small bootstrap. For UFS2 it got moved to 64K from the front to leave
- * room for the disk label and a bigger bootstrap, and for really piggy
- * systems we check at 256K from the front if the first three fail. In
- * all cases the size of the superblock will be SBLOCKSIZE. All values are
- * given in byte-offset form, so they do not imply a sector size. The
- * SBLOCKSEARCH specifies the order in which the locations should be searched.
- *
- * Unfortunately the UFS2/FFSv2 change was done without adequate consideration
- * of backward compatibility. In particular 'newfs' for a FFSv2 partition
- * must overwrite any old FFSv1 superblock at 8k, and preferably as many
- * of the alternates as it can find - otherwise attempting to mount on a
- * system that only supports FFSv1 is likely to succeed!.
- * For a small FFSv1 filesystem, an old FFSv2 superblock can be left on
- * the disk, and a system that tries to find an FFSv2 filesystem in preference
- * to and FFSv1 one (as NetBSD does) can mount the old FFSv2 filesystem.
- * As a added bonus, the 'first alternate' superblock of a FFSv1 filesystem
- * with 64k blocks is at 64k - just where the code looks first when playing
- * 'hunt the superblock'.
- *
- * The ffsv2 superblock layout (which might contain an ffsv1 filesystem)
- * can be detected by checking for sb->fs_old_flags & FS_FLAGS_UPDATED.
- * This is the default superblock type for NetBSD since ffsv2 support was added.
- */
-#define BBSIZE 8192
-#define BBOFF ((off_t)(0))
-#define BBLOCK ((daddr_t)(0))
-
-#define SBLOCK_FLOPPY 0
-#define SBLOCK_UFS1 8192
-#define SBLOCK_UFS2 65536
-#define SBLOCK_PIGGY 262144
-#define SBLOCKSIZE 8192
-/*
- * NB: Do not, under any circumstances, look for an ffsv1 filesystem at
- * SBLOCK_UFS2. Doing so will find the wrong superblock for filesystems
- * with a 64k block size.
- */
-#define SBLOCKSEARCH \
- { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
-
-/*
- * Max number of fragments per block. This value is NOT tweakable.
- */
-#define MAXFRAG 8
-
-
-
-/*
- * Addresses stored in inodes are capable of addressing fragments
- * of `blocks'. File system blocks of at most size MAXBSIZE can
- * be optionally broken into 2, 4, or 8 pieces, each of which is
- * addressable; these pieces may be DEV_BSIZE, or some multiple of
- * a DEV_BSIZE unit.
- *
- * Large files consist of exclusively large data blocks. To avoid
- * undue wasted disk space, the last data block of a small file may be
- * allocated as only as many fragments of a large block as are
- * necessary. The file system format retains only a single pointer
- * to such a fragment, which is a piece of a single large block that
- * has been divided. The size of such a fragment is determinable from
- * information in the inode, using the ``ffs_blksize(fs, ip, lbn)'' macro.
- *
- * The file system records space availability at the fragment level;
- * to determine block availability, aligned fragments are examined.
- */
-
-/*
- * MINBSIZE is the smallest allowable block size.
- * In order to insure that it is possible to create files of size
- * 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
- * MINBSIZE must be big enough to hold a cylinder group block,
- * thus changes to (struct cg) must keep its size within MINBSIZE.
- * Note that super blocks are always of size SBSIZE,
- * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
- */
-#define MINBSIZE 4096
-
-/*
- * The path name on which the file system is mounted is maintained
- * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
- * the super block for this name.
- */
-#define MAXMNTLEN 468
-
-/*
- * The volume name for this filesystem is maintained in fs_volname.
- * MAXVOLLEN defines the length of the buffer allocated.
- * This space used to be part of of fs_fsmnt.
- */
-#define MAXVOLLEN 32
-
-/*
- * There is a 128-byte region in the superblock reserved for in-core
- * pointers to summary information. Originally this included an array
- * of pointers to blocks of struct csum; now there are just four
- * pointers and the remaining space is padded with fs_ocsp[].
- * NOCSPTRS determines the size of this padding. One pointer (fs_csp)
- * is taken away to point to a contiguous array of struct csum for
- * all cylinder groups; a second (fs_maxcluster) points to an array
- * of cluster sizes that is computed as cylinder groups are inspected;
- * the third (fs_contigdirs) points to an array that tracks the
- * creation of new directories; and the fourth (fs_active) is used
- * by snapshots.
- */
-#define NOCSPTRS ((128 / sizeof(void *)) - 4)
-
-/*
- * A summary of contiguous blocks of various sizes is maintained
- * in each cylinder group. Normally this is set by the initial
- * value of fs_maxcontig. To conserve space, a maximum summary size
- * is set by FS_MAXCONTIG.
- */
-#define FS_MAXCONTIG 16
-
-/*
- * The maximum number of snapshot nodes that can be associated
- * with each filesystem. This limit affects only the number of
- * snapshot files that can be recorded within the superblock so
- * that they can be found when the filesystem is mounted. However,
- * maintaining too many will slow the filesystem performance, so
- * having this limit is a good idea.
- */
-#define FSMAXSNAP 20
-
-/*
- * Used to identify special blocks in snapshots:
- *
- * BLK_NOCOPY - A block that was unallocated at the time the snapshot
- * was taken, hence does not need to be copied when written.
- * BLK_SNAP - A block held by another snapshot that is not needed by this
- * snapshot. When the other snapshot is freed, the BLK_SNAP entries
- * are converted to BLK_NOCOPY. These are needed to allow fsck to
- * identify blocks that are in use by other snapshots (which are
- * expunged from this snapshot).
- */
-#define BLK_NOCOPY ((daddr_t)(1))
-#define BLK_SNAP ((daddr_t)(2))
-
-/*
- * MINFREE gives the minimum acceptable percentage of file system
- * blocks which may be free. If the freelist drops below this level
- * only the superuser may continue to allocate blocks. This may
- * be set to 0 if no reserve of free blocks is deemed necessary,
- * however throughput drops by fifty percent if the file system
- * is run at between 95% and 100% full; thus the minimum default
- * value of fs_minfree is 5%. However, to get good clustering
- * performance, 10% is a better choice. This value is used only
- * when creating a file system and can be overridden from the
- * command line. By default we choose to optimize for time.
- */
-#define MINFREE 5
-#define DEFAULTOPT FS_OPTTIME
-
-/*
- * Grigoriy Orlov <gluk@ptci.ru> has done some extensive work to fine
- * tune the layout preferences for directories within a filesystem.
- * His algorithm can be tuned by adjusting the following parameters
- * which tell the system the average file size and the average number
- * of files per directory. These defaults are well selected for typical
- * filesystems, but may need to be tuned for odd cases like filesystems
- * being used for squid caches or news spools.
- */
-#define AVFILESIZ 16384 /* expected average file size */
-#define AFPDIR 64 /* expected number of files per directory */
-
-/*
- * Per cylinder group information; summarized in blocks allocated
- * from first cylinder group data blocks. These blocks have to be
- * read in from fs_csaddr (size fs_cssize) in addition to the
- * super block.
- */
-struct csum {
- int32_t cs_ndir; /* number of directories */
- int32_t cs_nbfree; /* number of free blocks */
- int32_t cs_nifree; /* number of free inodes */
- int32_t cs_nffree; /* number of free frags */
-};
-
-struct csum_total {
- int64_t cs_ndir; /* number of directories */
- int64_t cs_nbfree; /* number of free blocks */
- int64_t cs_nifree; /* number of free inodes */
- int64_t cs_nffree; /* number of free frags */
- int64_t cs_spare[4]; /* future expansion */
-};
-
-
-/*
- * Super block for an FFS file system in memory.
- */
-struct fs {
- int32_t fs_firstfield; /* historic file system linked list, */
- int32_t fs_unused_1; /* used for incore super blocks */
- int32_t fs_sblkno; /* addr of super-block in filesys */
- int32_t fs_cblkno; /* offset of cyl-block in filesys */
- int32_t fs_iblkno; /* offset of inode-blocks in filesys */
- int32_t fs_dblkno; /* offset of first data after cg */
- int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */
- int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */
- int32_t fs_old_time; /* last time written */
- int32_t fs_old_size; /* number of blocks in fs */
- int32_t fs_old_dsize; /* number of data blocks in fs */
- int32_t fs_ncg; /* number of cylinder groups */
- int32_t fs_bsize; /* size of basic blocks in fs */
- int32_t fs_fsize; /* size of frag blocks in fs */
- int32_t fs_frag; /* number of frags in a block in fs */
-/* these are configuration parameters */
- int32_t fs_minfree; /* minimum percentage of free blocks */
- int32_t fs_old_rotdelay; /* num of ms for optimal next block */
- int32_t fs_old_rps; /* disk revolutions per second */
-/* these fields can be computed from the others */
- int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */
- int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */
- int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */
- int32_t fs_fshift; /* ``numfrags'' calc number of frags */
-/* these are configuration parameters */
- int32_t fs_maxcontig; /* max number of contiguous blks */
- int32_t fs_maxbpg; /* max number of blks per cyl group */
-/* these fields can be computed from the others */
- int32_t fs_fragshift; /* block to frag shift */
- int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
- int32_t fs_sbsize; /* actual size of super block */
- int32_t fs_spare1[2]; /* old fs_csmask */
- /* old fs_csshift */
- int32_t fs_nindir; /* value of FFS_NINDIR */
- int32_t fs_inopb; /* value of FFS_INOPB */
- int32_t fs_old_nspf; /* value of NSPF */
-/* yet another configuration parameter */
- int32_t fs_optim; /* optimization preference, see below */
-/* these fields are derived from the hardware */
- int32_t fs_old_npsect; /* # sectors/track including spares */
- int32_t fs_old_interleave; /* hardware sector interleave */
- int32_t fs_old_trackskew; /* sector 0 skew, per track */
-/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */
- int32_t fs_id[2]; /* unique file system id */
-/* sizes determined by number of cylinder groups and their sizes */
- int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */
- int32_t fs_cssize; /* size of cyl grp summary area */
- int32_t fs_cgsize; /* cylinder group size */
-/* these fields are derived from the hardware */
- int32_t fs_spare2; /* old fs_ntrak */
- int32_t fs_old_nsect; /* sectors per track */
- int32_t fs_old_spc; /* sectors per cylinder */
- int32_t fs_old_ncyl; /* cylinders in file system */
- int32_t fs_old_cpg; /* cylinders per group */
- int32_t fs_ipg; /* inodes per group */
- int32_t fs_fpg; /* blocks per group * fs_frag */
-/* this data must be re-computed after crashes */
- struct csum fs_old_cstotal; /* cylinder summary information */
-/* these fields are cleared at mount time */
- int8_t fs_fmod; /* super block modified flag */
- uint8_t fs_clean; /* file system is clean flag */
- int8_t fs_ronly; /* mounted read-only flag */
- uint8_t fs_old_flags; /* see FS_ flags below */
- u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
- u_char fs_volname[MAXVOLLEN]; /* volume name */
- uint64_t fs_swuid; /* system-wide uid */
- int32_t fs_pad;
-/* these fields retain the current block allocation info */
- int32_t fs_cgrotor; /* last cg searched (UNUSED) */
- void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */
- u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */
- struct csum *fs_csp; /* cg summary info buffer for fs_cs */
- int32_t *fs_maxcluster; /* max cluster in each cyl group */
- u_char *fs_active; /* used by snapshots to track fs */
- int32_t fs_old_cpc; /* cyl per cycle in postbl */
-/* this area is otherwise allocated unless fs_old_flags & FS_FLAGS_UPDATED */
- int32_t fs_maxbsize; /* maximum blocking factor permitted */
- uint8_t fs_journal_version; /* journal format version */
- uint8_t fs_journal_location; /* journal location type */
- uint8_t fs_journal_reserved[2];/* reserved for future use */
- uint32_t fs_journal_flags; /* journal flags */
- uint64_t fs_journallocs[4]; /* location info for journal */
- uint32_t fs_quota_magic; /* see quota2.h */
- uint8_t fs_quota_flags; /* see quota2.h */
- uint8_t fs_quota_reserved[3];
- uint64_t fs_quotafile[2]; /* pointer to quota inodes */
- int64_t fs_sparecon64[9]; /* reserved for future use */
- int64_t fs_sblockloc; /* byte offset of standard superblock */
- struct csum_total fs_cstotal; /* cylinder summary information */
- int64_t fs_time; /* last time written */
- int64_t fs_size; /* number of blocks in fs */
- int64_t fs_dsize; /* number of data blocks in fs */
- int64_t fs_csaddr; /* blk addr of cyl grp summary area */
- int64_t fs_pendingblocks; /* blocks in process of being freed */
- int32_t fs_pendinginodes; /* inodes in process of being freed */
- int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
-/* back to stuff that has been around a while */
- int32_t fs_avgfilesize; /* expected average file size */
- int32_t fs_avgfpdir; /* expected # of files per directory */
- int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */
- int32_t fs_sparecon32[26]; /* reserved for future constants */
- uint32_t fs_flags; /* see FS_ flags below */
-/* back to stuff that has been around a while (again) */
- int32_t fs_contigsumsize; /* size of cluster summary array */
- int32_t fs_maxsymlinklen; /* max length of an internal symlink */
- int32_t fs_old_inodefmt; /* format of on-disk inodes */
- u_int64_t fs_maxfilesize; /* maximum representable file size */
- int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */
- int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */
- int32_t fs_state; /* validate fs_clean field (UNUSED) */
- int32_t fs_old_postblformat; /* format of positional layout tables */
- int32_t fs_old_nrpos; /* number of rotational positions */
- int32_t fs_spare5[2]; /* old fs_postbloff */
- /* old fs_rotbloff */
- int32_t fs_magic; /* magic number */
-};
-
-#define fs_old_postbloff fs_spare5[0]
-#define fs_old_rotbloff fs_spare5[1]
-#define fs_old_postbl_start fs_maxbsize
-#define fs_old_headswitch fs_id[0]
-#define fs_old_trkseek fs_id[1]
-#define fs_old_csmask fs_spare1[0]
-#define fs_old_csshift fs_spare1[1]
-
-#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */
-#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */
-
-#define old_fs_postbl(fs_, cylno, opostblsave) \
- ((((fs_)->fs_old_postblformat == FS_42POSTBLFMT) || \
- ((fs_)->fs_old_postbloff == offsetof(struct fs, fs_old_postbl_start))) \
- ? ((int16_t *)(opostblsave) + (cylno) * (fs_)->fs_old_nrpos) \
- : ((int16_t *)((uint8_t *)(fs_) + \
- (fs_)->fs_old_postbloff) + (cylno) * (fs_)->fs_old_nrpos))
-#define old_fs_rotbl(fs) \
- (((fs)->fs_old_postblformat == FS_42POSTBLFMT) \
- ? ((uint8_t *)(&(fs)->fs_magic+1)) \
- : ((uint8_t *)((uint8_t *)(fs) + (fs)->fs_old_rotbloff)))
-
-/*
- * File system identification
- */
-#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast file system magic number */
-#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast file system magic number */
-#define FS_UFS1_MAGIC_SWAPPED 0x54190100
-#define FS_UFS2_MAGIC_SWAPPED 0x19015419
-#define FS_OKAY 0x7c269d38 /* superblock checksum */
-#define FS_42INODEFMT -1 /* 4.2BSD inode format */
-#define FS_44INODEFMT 2 /* 4.4BSD inode format */
-
-/*
- * File system clean flags
- */
-#define FS_ISCLEAN 0x01
-#define FS_WASCLEAN 0x02
-
-/*
- * Preference for optimization.
- */
-#define FS_OPTTIME 0 /* minimize allocation time */
-#define FS_OPTSPACE 1 /* minimize disk fragmentation */
-
-/*
- * File system flags
- */
-#define FS_UNCLEAN 0x001 /* file system not clean at mount (unused) */
-#define FS_DOSOFTDEP 0x002 /* file system using soft dependencies */
-#define FS_NEEDSFSCK 0x004 /* needs sync fsck (FreeBSD compat, unused) */
-#define FS_SUJ 0x008 /* file system using journaled softupdates */
-#define FS_ACLS 0x010 /* file system has ACLs enabled */
-#define FS_MULTILABEL 0x020 /* file system is MAC multi-label */
-#define FS_GJOURNAL 0x40 /* gjournaled file system */
-#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */
-#define FS_DOWAPBL 0x100 /* Write ahead physical block logging */
-/* FS_NFS4ACLS 0x100 file system has NFSv4 ACLs enabled (FBSD) */
-#define FS_DOQUOTA2 0x200 /* in-filesystem quotas */
-/* FS_INDEXDIRS 0x200 kernel supports indexed directories (FBSD)*/
-#define FS_TRIM 0x400 /* discard deleted blocks in storage layer */
-
-/* File system flags that are ok for NetBSD if set in fs_flags */
-#define FS_KNOWN_FLAGS (FS_DOSOFTDEP | FS_DOWAPBL | FS_DOQUOTA2)
-
-/*
- * Macros to access bits in the fs_active array.
- */
-#define ACTIVECG_SET(fs, cg) \
- do { \
- if ((fs)->fs_active != NULL) \
- setbit((fs)->fs_active, (cg)); \
- } while (/*CONSTCOND*/ 0)
-#define ACTIVECG_CLR(fs, cg) \
- do { \
- if ((fs)->fs_active != NULL) \
- clrbit((fs)->fs_active, (cg)); \
- } while (/*CONSTCOND*/ 0)
-#define ACTIVECG_ISSET(fs, cg) \
- ((fs)->fs_active != NULL && isset((fs)->fs_active, (cg)))
-
-/*
- * The size of a cylinder group is calculated by CGSIZE. The maximum size
- * is limited by the fact that cylinder groups are at most one block.
- * Its size is derived from the size of the maps maintained in the
- * cylinder group and the (struct cg) size.
- */
-#define CGSIZE_IF(fs, ipg, fpg) \
- /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \
- /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \
- /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \
- /* inode map */ howmany((ipg), NBBY) + \
- /* block map */ howmany((fpg), NBBY) +\
- /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \
- /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \
- /* cluster map */ howmany(ffs_fragstoblks(fs, (fpg)), NBBY)))
-
-#define CGSIZE(fs) CGSIZE_IF((fs), (fs)->fs_ipg, (fs)->fs_fpg)
-
-/*
- * The minimal number of cylinder groups that should be created.
- */
-#define MINCYLGRPS 4
-
-
-/*
- * Convert cylinder group to base address of its global summary info.
- */
-#define fs_cs(fs, indx) fs_csp[indx]
-
-/*
- * Cylinder group block for a file system.
- */
-#define CG_MAGIC 0x090255
-struct cg {
- int32_t cg_firstfield; /* historic cyl groups linked list */
- int32_t cg_magic; /* magic number */
- int32_t cg_old_time; /* time last written */
- int32_t cg_cgx; /* we are the cgx'th cylinder group */
- int16_t cg_old_ncyl; /* number of cyl's this cg */
- int16_t cg_old_niblk; /* number of inode blocks this cg */
- int32_t cg_ndblk; /* number of data blocks this cg */
- struct csum cg_cs; /* cylinder summary information */
- int32_t cg_rotor; /* position of last used block */
- int32_t cg_frotor; /* position of last used frag */
- int32_t cg_irotor; /* position of last used inode */
- int32_t cg_frsum[MAXFRAG]; /* counts of available frags */
- int32_t cg_old_btotoff; /* (int32) block totals per cylinder */
- int32_t cg_old_boff; /* (u_int16) free block positions */
- int32_t cg_iusedoff; /* (u_int8) used inode map */
- int32_t cg_freeoff; /* (u_int8) free block map */
- int32_t cg_nextfreeoff; /* (u_int8) next available space */
- int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */
- int32_t cg_clusteroff; /* (u_int8) free cluster map */
- int32_t cg_nclusterblks; /* number of clusters this cg */
- int32_t cg_niblk; /* number of inode blocks this cg */
- int32_t cg_initediblk; /* last initialized inode */
- int32_t cg_sparecon32[3]; /* reserved for future use */
- int64_t cg_time; /* time last written */
- int64_t cg_sparecon64[3]; /* reserved for future use */
- u_int8_t cg_space[1]; /* space for cylinder group maps */
-/* actually longer */
-};
-
-/*
- * The following structure is defined
- * for compatibility with old file systems.
- */
-struct ocg {
- int32_t cg_firstfield; /* historic linked list of cyl groups */
- int32_t cg_unused_1; /* used for incore cyl groups */
- int32_t cg_time; /* time last written */
- int32_t cg_cgx; /* we are the cgx'th cylinder group */
- int16_t cg_ncyl; /* number of cyl's this cg */
- int16_t cg_niblk; /* number of inode blocks this cg */
- int32_t cg_ndblk; /* number of data blocks this cg */
- struct csum cg_cs; /* cylinder summary information */
- int32_t cg_rotor; /* position of last used block */
- int32_t cg_frotor; /* position of last used frag */
- int32_t cg_irotor; /* position of last used inode */
- int32_t cg_frsum[8]; /* counts of available frags */
- int32_t cg_btot[32]; /* block totals per cylinder */
- int16_t cg_b[32][8]; /* positions of free blocks */
- u_int8_t cg_iused[256]; /* used inode map */
- int32_t cg_magic; /* magic number */
- u_int8_t cg_free[1]; /* free block map */
-/* actually longer */
-};
-
-
-/*
- * Macros for access to cylinder group array structures.
- */
-#define old_cg_blktot_old(cgp, ns) \
- (((struct ocg *)(cgp))->cg_btot)
-#define old_cg_blks_old(fs, cgp, cylno, ns) \
- (((struct ocg *)(cgp))->cg_b[cylno])
-
-#define old_cg_blktot_new(cgp, ns) \
- ((int32_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_old_btotoff, (ns))))
-#define old_cg_blks_new(fs, cgp, cylno, ns) \
- ((int16_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_old_boff, (ns))) + (cylno) * (fs)->fs_old_nrpos)
-
-#define old_cg_blktot(cgp, ns) \
- ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
- old_cg_blktot_old(cgp, ns) : old_cg_blktot_new(cgp, ns))
-#define old_cg_blks(fs, cgp, cylno, ns) \
- ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
- old_cg_blks_old(fs, cgp, cylno, ns) : old_cg_blks_new(fs, cgp, cylno, ns))
-
-#define cg_inosused_new(cgp, ns) \
- ((u_int8_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_iusedoff, (ns))))
-#define cg_blksfree_new(cgp, ns) \
- ((u_int8_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_freeoff, (ns))))
-#define cg_chkmagic_new(cgp, ns) \
- (ufs_rw32((cgp)->cg_magic, (ns)) == CG_MAGIC)
-
-#define cg_inosused_old(cgp, ns) \
- (((struct ocg *)(cgp))->cg_iused)
-#define cg_blksfree_old(cgp, ns) \
- (((struct ocg *)(cgp))->cg_free)
-#define cg_chkmagic_old(cgp, ns) \
- (ufs_rw32(((struct ocg *)(cgp))->cg_magic, (ns)) == CG_MAGIC)
-
-#define cg_inosused(cgp, ns) \
- ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
- cg_inosused_old(cgp, ns) : cg_inosused_new(cgp, ns))
-#define cg_blksfree(cgp, ns) \
- ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
- cg_blksfree_old(cgp, ns) : cg_blksfree_new(cgp, ns))
-#define cg_chkmagic(cgp, ns) \
- (cg_chkmagic_new(cgp, ns) || cg_chkmagic_old(cgp, ns))
-
-#define cg_clustersfree(cgp, ns) \
- ((u_int8_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_clusteroff, (ns))))
-#define cg_clustersum(cgp, ns) \
- ((int32_t *)((u_int8_t *)(cgp) + \
- ufs_rw32((cgp)->cg_clustersumoff, (ns))))
-
-
-/*
- * Turn file system block numbers into disk block addresses.
- * This maps file system blocks to device size blocks.
- */
-#define FFS_FSBTODB(fs, b) ((b) << (fs)->fs_fsbtodb)
-#define FFS_DBTOFSB(fs, b) ((b) >> (fs)->fs_fsbtodb)
-
-/*
- * Cylinder group macros to locate things in cylinder groups.
- * They calc file system addresses of cylinder group data structures.
- */
-#define cgbase(fs, c) (((daddr_t)(fs)->fs_fpg) * (c))
-#define cgstart_ufs1(fs, c) \
- (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))
-#define cgstart_ufs2(fs, c) cgbase((fs), (c))
-#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC \
- ? cgstart_ufs2((fs), (c)) : cgstart_ufs1((fs), (c)))
-#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
-#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
-#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
-#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
-
-/*
- * Macros for handling inode numbers:
- * inode number to file system block offset.
- * inode number to cylinder group number.
- * inode number to file system block address.
- */
-#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg)
-#define ino_to_fsba(fs, x) \
- ((daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \
- (ffs_blkstofrags((fs), (((x) % (fs)->fs_ipg) / FFS_INOPB(fs))))))
-#define ino_to_fsbo(fs, x) ((x) % FFS_INOPB(fs))
-
-/*
- * Give cylinder group number for a file system block.
- * Give cylinder group block number for a file system block.
- */
-#define dtog(fs, d) ((d) / (fs)->fs_fpg)
-#define dtogd(fs, d) ((d) % (fs)->fs_fpg)
-
-/*
- * Extract the bits for a block from a map.
- * Compute the cylinder and rotational position of a cyl block addr.
- */
-#define blkmap(fs, map, loc) \
- (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
-#define old_cbtocylno(fs, bno) \
- (FFS_FSBTODB(fs, bno) / (fs)->fs_old_spc)
-#define old_cbtorpos(fs, bno) \
- ((fs)->fs_old_nrpos <= 1 ? 0 : \
- (FFS_FSBTODB(fs, bno) % (fs)->fs_old_spc / (fs)->fs_old_nsect * (fs)->fs_old_trackskew + \
- FFS_FSBTODB(fs, bno) % (fs)->fs_old_spc % (fs)->fs_old_nsect * (fs)->fs_old_interleave) % \
- (fs)->fs_old_nsect * (fs)->fs_old_nrpos / (fs)->fs_old_npsect)
-
-/*
- * The following macros optimize certain frequently calculated
- * quantities by using shifts and masks in place of divisions
- * modulos and multiplications.
- */
-#define ffs_blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
- ((loc) & (fs)->fs_qbmask)
-#define ffs_fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
- ((loc) & (fs)->fs_qfmask)
-#define ffs_lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \
- (((off_t)(frag)) << (fs)->fs_fshift)
-#define ffs_lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \
- ((uint64_t)(((off_t)(blk)) << (fs)->fs_bshift))
-#define ffs_lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
- ((loc) >> (fs)->fs_bshift)
-#define ffs_numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
- ((loc) >> (fs)->fs_fshift)
-#define ffs_blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
- (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask)
-#define ffs_fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
- (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
-#define ffs_fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
- ((frags) >> (fs)->fs_fragshift)
-#define ffs_blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
- ((blks) << (fs)->fs_fragshift)
-#define ffs_fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
- ((fsb) & ((fs)->fs_frag - 1))
-#define ffs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
- ((fsb) &~ ((fs)->fs_frag - 1))
-
-/*
- * Determine the number of available frags given a
- * percentage to hold in reserve.
- */
-#define freespace(fs, percentreserved) \
- (ffs_blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
- (fs)->fs_cstotal.cs_nffree - \
- (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100))
-
-/*
- * Determining the size of a file block in the file system.
- */
-#define ffs_blksize(fs, ip, lbn) \
- (((lbn) >= UFS_NDADDR || (ip)->i_size >= ffs_lblktosize(fs, (lbn) + 1)) \
- ? (fs)->fs_bsize \
- : ((int32_t)ffs_fragroundup(fs, ffs_blkoff(fs, (ip)->i_size))))
-
-#define ffs_sblksize(fs, size, lbn) \
- (((lbn) >= UFS_NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
- ? (fs)->fs_bsize \
- : ((int32_t)ffs_fragroundup(fs, ffs_blkoff(fs, (uint64_t)(size)))))
-
-
-/*
- * Number of inodes in a secondary storage block/fragment.
- */
-#define FFS_INOPB(fs) ((fs)->fs_inopb)
-#define FFS_INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)
-
-/*
- * Number of indirects in a file system block.
- */
-#define FFS_NINDIR(fs) ((fs)->fs_nindir)
-
-
-#endif /* !_UFS_FFS_FS_H_ */
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
index 766e4da17cb..97cbab6d332 100644
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.9 2016/10/22 10:43:08 natano Exp $ */
+/* $OpenBSD: mkfs.c,v 1.10 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: mkfs.c,v 1.34 2016/06/24 19:24:11 christos Exp $ */
/*
@@ -50,15 +50,15 @@
#include <errno.h>
#include <util.h>
-#include "makefs.h"
-#include "ffs.h"
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
-#include "ffs/dinode.h"
#include "ffs/ufs_bswap.h"
-#include "ffs/fs.h"
-
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
+
+#include "makefs.h"
+#include "ffs.h"
#include "ffs/newfs_extern.h"
static void initcg(int, time_t, const fsinfo_t *);
@@ -136,10 +136,10 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
strlcpy((char *)sblock.fs_volname, ffs_opts->label,
sizeof(sblock.fs_volname));
- sblock.fs_old_inodefmt = FS_44INODEFMT;
- sblock.fs_maxsymlinklen = (Oflag == 1 ? UFS1_MAXSYMLINKLEN :
- UFS2_MAXSYMLINKLEN);
- sblock.fs_old_flags = FS_FLAGS_UPDATED;
+ sblock.fs_inodefmt = FS_44INODEFMT;
+ sblock.fs_maxsymlinklen = (Oflag == 1 ? MAXSYMLINKLEN_UFS1 :
+ MAXSYMLINKLEN_UFS2);
+ sblock.fs_ffs1_flags = FS_FLAGS_UPDATED;
sblock.fs_flags = 0;
/*
@@ -226,7 +226,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_bshift++;
for (sblock.fs_fshift = 0, i = sblock.fs_fsize; i > 1; i >>= 1)
sblock.fs_fshift++;
- sblock.fs_frag = ffs_numfrags(&sblock, sblock.fs_bsize);
+ sblock.fs_frag = numfrags(&sblock, sblock.fs_bsize);
for (sblock.fs_fragshift = 0, i = sblock.fs_frag; i > 1; i >>= 1)
sblock.fs_fragshift++;
if (sblock.fs_frag > MAXFRAG) {
@@ -237,28 +237,27 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
exit(21);
}
sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
- sblock.fs_size = fssize = FFS_DBTOFSB(&sblock, fssize);
+ sblock.fs_size = fssize = dbtofsb(&sblock, fssize);
if (Oflag <= 1) {
sblock.fs_magic = FS_UFS1_MAGIC;
sblock.fs_sblockloc = SBLOCK_UFS1;
sblock.fs_nindir = sblock.fs_bsize / sizeof(int32_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
- sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
- sizeof (int32_t));
- sblock.fs_old_inodefmt = FS_44INODEFMT;
- sblock.fs_old_cgoffset = 0;
- sblock.fs_old_cgmask = 0xffffffff;
- sblock.fs_old_size = sblock.fs_size;
- sblock.fs_old_rotdelay = 0;
- sblock.fs_old_rps = 60;
- sblock.fs_old_nspf = sblock.fs_fsize / sectorsize;
- sblock.fs_old_cpg = 1;
- sblock.fs_old_interleave = 1;
- sblock.fs_old_trackskew = 0;
- sblock.fs_old_cpc = 0;
- sblock.fs_old_postblformat = 1;
- sblock.fs_old_nrpos = 1;
+ sblock.fs_maxsymlinklen = (NDADDR + NIADDR) * sizeof (int32_t);
+ sblock.fs_inodefmt = FS_44INODEFMT;
+ sblock.fs_cgoffset = 0;
+ sblock.fs_cgmask = 0xffffffff;
+ sblock.fs_ffs1_size = sblock.fs_size;
+ sblock.fs_rotdelay = 0;
+ sblock.fs_rps = 60;
+ sblock.fs_nspf = sblock.fs_fsize / sectorsize;
+ sblock.fs_cpg = 1;
+ sblock.fs_interleave = 1;
+ sblock.fs_trackskew = 0;
+ sblock.fs_cpc = 0;
+ sblock.fs_postblformat = 1;
+ sblock.fs_nrpos = 1;
} else {
sblock.fs_magic = FS_UFS2_MAGIC;
#if 0 /* XXX makefs is used for small filesystems. */
@@ -268,8 +267,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
#endif
sblock.fs_nindir = sblock.fs_bsize / sizeof(int64_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode);
- sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
- sizeof (int64_t));
+ sblock.fs_maxsymlinklen = (NDADDR + NIADDR) * sizeof (int64_t);
}
sblock.fs_sblkno =
@@ -278,9 +276,9 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_cblkno = (daddr_t)(sblock.fs_sblkno +
roundup(howmany(SBLOCKSIZE, sblock.fs_fsize), sblock.fs_frag));
sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag;
- sblock.fs_maxfilesize = sblock.fs_bsize * UFS_NDADDR - 1;
- for (sizepb = sblock.fs_bsize, i = 0; i < UFS_NIADDR; i++) {
- sizepb *= FFS_NINDIR(&sblock);
+ sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1;
+ for (sizepb = sblock.fs_bsize, i = 0; i < NIADDR; i++) {
+ sizepb *= NINDIR(&sblock);
sblock.fs_maxfilesize += sizepb;
}
@@ -300,23 +298,23 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
*/
origdensity = density;
for (;;) {
- fragsperinode = MAX(ffs_numfrags(&sblock, density), 1);
- minfpg = fragsperinode * FFS_INOPB(&sblock);
+ fragsperinode = MAX(numfrags(&sblock, density), 1);
+ minfpg = fragsperinode * INOPB(&sblock);
if (minfpg > sblock.fs_size)
minfpg = sblock.fs_size;
- sblock.fs_ipg = FFS_INOPB(&sblock);
+ sblock.fs_ipg = INOPB(&sblock);
sblock.fs_fpg = roundup(sblock.fs_iblkno +
- sblock.fs_ipg / FFS_INOPF(&sblock), sblock.fs_frag);
+ sblock.fs_ipg / INOPF(&sblock), sblock.fs_frag);
if (sblock.fs_fpg < minfpg)
sblock.fs_fpg = minfpg;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- FFS_INOPB(&sblock));
+ INOPB(&sblock));
sblock.fs_fpg = roundup(sblock.fs_iblkno +
- sblock.fs_ipg / FFS_INOPF(&sblock), sblock.fs_frag);
+ sblock.fs_ipg / INOPF(&sblock), sblock.fs_frag);
if (sblock.fs_fpg < minfpg)
sblock.fs_fpg = minfpg;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- FFS_INOPB(&sblock));
+ INOPB(&sblock));
if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
break;
density -= sblock.fs_fsize;
@@ -333,7 +331,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
*/
for ( ; sblock.fs_fpg < maxblkspercg; sblock.fs_fpg += sblock.fs_frag) {
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- FFS_INOPB(&sblock));
+ INOPB(&sblock));
if (sblock.fs_size / sblock.fs_fpg < 1)
break;
if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
@@ -342,7 +340,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
break;
sblock.fs_fpg -= sblock.fs_frag;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- FFS_INOPB(&sblock));
+ INOPB(&sblock));
break;
}
/*
@@ -355,7 +353,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
for (;;) {
sblock.fs_ncg = howmany(sblock.fs_size, sblock.fs_fpg);
lastminfpg = roundup(sblock.fs_iblkno +
- sblock.fs_ipg / FFS_INOPF(&sblock), sblock.fs_frag);
+ sblock.fs_ipg / INOPF(&sblock), sblock.fs_frag);
if (sblock.fs_size < lastminfpg) {
printf("Filesystem size %lld < minimum size of %d\n",
(long long)sblock.fs_size, lastminfpg);
@@ -366,18 +364,18 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
break;
sblock.fs_fpg -= sblock.fs_frag;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- FFS_INOPB(&sblock));
+ INOPB(&sblock));
}
if (optimalfpg != sblock.fs_fpg)
printf("Reduced frags per cylinder group from %d to %d %s\n",
optimalfpg, sblock.fs_fpg, "to enlarge last cyl group");
- sblock.fs_cgsize = ffs_fragroundup(&sblock, CGSIZE(&sblock));
- sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / FFS_INOPF(&sblock);
+ sblock.fs_cgsize = fragroundup(&sblock, CGSIZE(&sblock));
+ sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(&sblock);
if (Oflag <= 1) {
- sblock.fs_old_spc = sblock.fs_fpg * sblock.fs_old_nspf;
- sblock.fs_old_nsect = sblock.fs_old_spc;
- sblock.fs_old_npsect = sblock.fs_old_spc;
- sblock.fs_old_ncyl = sblock.fs_ncg;
+ sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
+ sblock.fs_nsect = sblock.fs_spc;
+ sblock.fs_npsect = sblock.fs_spc;
+ sblock.fs_ncyl = sblock.fs_ncg;
}
/*
@@ -385,7 +383,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
*/
sblock.fs_csaddr = cgdmin(&sblock, 0);
sblock.fs_cssize =
- ffs_fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum));
+ fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum));
/*
* Setup memory for temporary in-core cylgroup summaries.
@@ -405,7 +403,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
*lp++ = sblock.fs_contigsumsize;
}
- sblock.fs_sbsize = ffs_fragroundup(&sblock, sizeof(struct fs));
+ sblock.fs_sbsize = fragroundup(&sblock, sizeof(struct fs));
if (sblock.fs_sbsize > SBLOCKSIZE)
sblock.fs_sbsize = SBLOCKSIZE;
sblock.fs_minfree = minfree;
@@ -431,24 +429,24 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_dsize = sblock.fs_size - sblock.fs_sblkno -
sblock.fs_ncg * (sblock.fs_dblkno - sblock.fs_sblkno);
sblock.fs_cstotal.cs_nbfree =
- ffs_fragstoblks(&sblock, sblock.fs_dsize) -
+ fragstoblks(&sblock, sblock.fs_dsize) -
howmany(csfrags, sblock.fs_frag);
sblock.fs_cstotal.cs_nffree =
- ffs_fragnum(&sblock, sblock.fs_size) +
- (ffs_fragnum(&sblock, csfrags) > 0 ?
- sblock.fs_frag - ffs_fragnum(&sblock, csfrags) : 0);
- sblock.fs_cstotal.cs_nifree = sblock.fs_ncg * sblock.fs_ipg - UFS_ROOTINO;
+ fragnum(&sblock, sblock.fs_size) +
+ (fragnum(&sblock, csfrags) > 0 ?
+ sblock.fs_frag - fragnum(&sblock, csfrags) : 0);
+ sblock.fs_cstotal.cs_nifree = sblock.fs_ncg * sblock.fs_ipg - ROOTINO;
sblock.fs_cstotal.cs_ndir = 0;
sblock.fs_dsize -= csfrags;
sblock.fs_time = tstamp;
if (Oflag <= 1) {
- sblock.fs_old_time = tstamp;
- sblock.fs_old_dsize = sblock.fs_dsize;
- sblock.fs_old_csaddr = sblock.fs_csaddr;
- sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
- sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
- sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
- sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
+ sblock.fs_ffs1_time = tstamp;
+ sblock.fs_ffs1_dsize = sblock.fs_dsize;
+ sblock.fs_ffs1_csaddr = sblock.fs_csaddr;
+ sblock.fs_ffs1_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
+ sblock.fs_ffs1_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
+ sblock.fs_ffs1_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
+ sblock.fs_ffs1_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
}
/*
* Dump out summary information about file system.
@@ -457,7 +455,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
printf("%s: %.1fMB (%lld sectors) block size %d, "
"fragment size %d\n",
fsys, (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR,
- (long long)FFS_FSBTODB(&sblock, sblock.fs_size),
+ (long long)fsbtodb(&sblock, sblock.fs_size),
sblock.fs_bsize, sblock.fs_fsize);
printf("\tusing %d cylinder groups of %.2fMB, %d blks, "
"%d inodes.\n",
@@ -471,7 +469,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
* subwindows in sysinst.
*/
printcolwidth = count_digits(
- FFS_FSBTODB(&sblock, cgsblock(&sblock, sblock.fs_ncg -1)));
+ fsbtodb(&sblock, cgsblock(&sblock, sblock.fs_ncg -1)));
nprintcols = 76 / (printcolwidth + 2);
/*
@@ -496,7 +494,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
if (cylno % nprintcols == 0)
printf("\n");
printf(" %*lld,", printcolwidth,
- (long long)FFS_FSBTODB(&sblock, cgsblock(&sblock, cylno)));
+ (long long)fsbtodb(&sblock, cgsblock(&sblock, cylno)));
fflush(stdout);
}
printf("\n");
@@ -507,10 +505,10 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
*/
sblock.fs_time = tstamp;
if (Oflag <= 1) {
- sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
- sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
- sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
- sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
+ sblock.fs_ffs1_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
+ sblock.fs_ffs1_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
+ sblock.fs_ffs1_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
+ sblock.fs_ffs1_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
}
ffs_write_superblock(&sblock, fsopts);
return (&sblock);
@@ -538,7 +536,7 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fsopts)
/* Write out the duplicate super blocks */
for (cylno = 0; cylno < fs->fs_ncg; cylno++)
- ffs_wtfs(FFS_FSBTODB(fs, cgsblock(fs, cylno)),
+ ffs_wtfs(fsbtodb(fs, cgsblock(fs, cylno)),
SBLOCKSIZE, writebuf, fsopts);
/* Write out the cylinder group summaries */
@@ -551,7 +549,7 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fsopts)
if (i + fs->fs_frag > blks)
size = (blks - i) * fs->fs_fsize;
memcpy(wrbuf, space, (u_int)size);
- ffs_wtfs(FFS_FSBTODB(fs, fs->fs_csaddr + i), size, wrbuf, fsopts);
+ ffs_wtfs(fsbtodb(fs, fs->fs_csaddr + i), size, wrbuf, fsopts);
space = (char *)space + size;
}
free(wrbuf);
@@ -583,34 +581,33 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
if (cylno == 0)
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
memset(&acg, 0, sblock.fs_cgsize);
- acg.cg_time = utime;
+ acg.cg_ffs2_time = utime;
acg.cg_magic = CG_MAGIC;
acg.cg_cgx = cylno;
- acg.cg_niblk = sblock.fs_ipg;
- acg.cg_initediblk = sblock.fs_ipg < 2 * FFS_INOPB(&sblock) ?
- sblock.fs_ipg : 2 * FFS_INOPB(&sblock);
+ acg.cg_ffs2_niblk = sblock.fs_ipg;
+ acg.cg_initediblk = sblock.fs_ipg < 2 * INOPB(&sblock) ?
+ sblock.fs_ipg : 2 * INOPB(&sblock);
acg.cg_ndblk = dmax - cbase;
if (sblock.fs_contigsumsize > 0)
acg.cg_nclusterblks = acg.cg_ndblk >> sblock.fs_fragshift;
- start = &acg.cg_space[0] - (u_char *)(&acg.cg_firstfield);
+ start = sizeof(struct cg);
if (Oflag == 2) {
acg.cg_iusedoff = start;
} else {
if (cylno == sblock.fs_ncg - 1)
- acg.cg_old_ncyl = howmany(acg.cg_ndblk,
- sblock.fs_fpg / sblock.fs_old_cpg);
+ acg.cg_ncyl = howmany(acg.cg_ndblk,
+ sblock.fs_fpg / sblock.fs_cpg);
else
- acg.cg_old_ncyl = sblock.fs_old_cpg;
- acg.cg_old_time = acg.cg_time;
- acg.cg_time = 0;
- acg.cg_old_niblk = acg.cg_niblk;
- acg.cg_niblk = 0;
+ acg.cg_ncyl = sblock.fs_cpg;
+ acg.cg_time = acg.cg_ffs2_time;
+ acg.cg_ffs2_time = 0;
+ acg.cg_niblk = acg.cg_ffs2_niblk;
+ acg.cg_ffs2_niblk = 0;
acg.cg_initediblk = 0;
- acg.cg_old_btotoff = start;
- acg.cg_old_boff = acg.cg_old_btotoff +
- sblock.fs_old_cpg * sizeof(int32_t);
- acg.cg_iusedoff = acg.cg_old_boff +
- sblock.fs_old_cpg * sizeof(u_int16_t);
+ acg.cg_btotoff = start;
+ acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(int32_t);
+ acg.cg_iusedoff = acg.cg_boff +
+ sblock.fs_cpg * sizeof(u_int16_t);
}
acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, CHAR_BIT);
if (sblock.fs_contigsumsize <= 0) {
@@ -624,7 +621,7 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
acg.cg_clusteroff = acg.cg_clustersumoff +
(sblock.fs_contigsumsize + 1) * sizeof(int32_t);
acg.cg_nextfreeoff = acg.cg_clusteroff +
- howmany(ffs_fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
+ howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
}
if (acg.cg_nextfreeoff > sblock.fs_cgsize) {
printf("Panic: cylinder group too big\n");
@@ -634,8 +631,8 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
if (cylno == 0) {
size_t r;
- for (r = 0; r < UFS_ROOTINO; r++) {
- setbit(cg_inosused(&acg, 0), r);
+ for (r = 0; r < ROOTINO; r++) {
+ setbit(cg_inosused(&acg), r);
acg.cg_cs.cs_nifree--;
}
}
@@ -645,9 +642,9 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
* for boot and super blocks.
*/
for (d = 0, blkno = 0; d < dlower;) {
- ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno);
+ ffs_setblock(&sblock, cg_blksfree(&acg), blkno);
if (sblock.fs_contigsumsize > 0)
- setbit(cg_clustersfree(&acg, 0), blkno);
+ setbit(cg_clustersfree(&acg), blkno);
acg.cg_cs.cs_nbfree++;
d += sblock.fs_frag;
blkno++;
@@ -656,15 +653,15 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
if ((i = (dupper & (sblock.fs_frag - 1))) != 0) {
acg.cg_frsum[sblock.fs_frag - i]++;
for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) {
- setbit(cg_blksfree(&acg, 0), dupper);
+ setbit(cg_blksfree(&acg), dupper);
acg.cg_cs.cs_nffree++;
}
}
for (d = dupper, blkno = dupper >> sblock.fs_fragshift;
d + sblock.fs_frag <= acg.cg_ndblk; ) {
- ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno);
+ ffs_setblock(&sblock, cg_blksfree(&acg), blkno);
if (sblock.fs_contigsumsize > 0)
- setbit(cg_clustersfree(&acg, 0), blkno);
+ setbit(cg_clustersfree(&acg), blkno);
acg.cg_cs.cs_nbfree++;
d += sblock.fs_frag;
blkno++;
@@ -672,13 +669,13 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
if (d < acg.cg_ndblk) {
acg.cg_frsum[acg.cg_ndblk - d]++;
for (; d < acg.cg_ndblk; d++) {
- setbit(cg_blksfree(&acg, 0), d);
+ setbit(cg_blksfree(&acg), d);
acg.cg_cs.cs_nffree++;
}
}
if (sblock.fs_contigsumsize > 0) {
- int32_t *sump = cg_clustersum(&acg, 0);
- u_char *mapp = cg_clustersfree(&acg, 0);
+ int32_t *sump = cg_clustersum(&acg);
+ u_char *mapp = cg_clustersfree(&acg);
int map = *mapp++;
int bit = 1;
int run = 0;
@@ -725,21 +722,21 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
dp2++;
}
}
- ffs_wtfs(FFS_FSBTODB(&sblock, cgsblock(&sblock, cylno)), iobufsize, iobuf,
+ ffs_wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), iobufsize, iobuf,
fsopts);
/*
* For the old file system, we have to initialize all the inodes.
*/
if (Oflag <= 1) {
for (i = 2 * sblock.fs_frag;
- i < sblock.fs_ipg / FFS_INOPF(&sblock);
+ i < sblock.fs_ipg / INOPF(&sblock);
i += sblock.fs_frag) {
dp1 = (struct ufs1_dinode *)(&iobuf[start]);
- for (j = 0; j < FFS_INOPB(&sblock); j++) {
+ for (j = 0; j < INOPB(&sblock); j++) {
dp1->di_gen = random();
dp1++;
}
- ffs_wtfs(FFS_FSBTODB(&sblock, cgimin(&sblock, cylno) + i),
+ ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
sblock.fs_bsize, &iobuf[start], fsopts);
}
}
diff --git a/usr.sbin/makefs/ffs/ufs_bmap.c b/usr.sbin/makefs/ffs/ufs_bmap.c
index c738b361492..58c9367c391 100644
--- a/usr.sbin/makefs/ffs/ufs_bmap.c
+++ b/usr.sbin/makefs/ffs/ufs_bmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_bmap.c,v 1.3 2016/10/18 17:23:21 natano Exp $ */
+/* $OpenBSD: ufs_bmap.c,v 1.4 2016/10/22 16:51:52 natano Exp $ */
/* $NetBSD: ufs_bmap.c,v 1.18 2013/06/19 17:51:27 dholland Exp $ */
/* From: NetBSD: ufs_bmap.c,v 1.14 2001/11/08 05:00:51 chs Exp */
@@ -47,10 +47,10 @@
#include "makefs.h"
-#include "ffs/dinode.h"
-#include "ffs/ufs_bswap.h"
-#include "ffs/fs.h"
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
+#include "ffs/ufs_bswap.h"
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
@@ -72,7 +72,7 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
int i, numlevels, off;
u_long lognindir;
- lognindir = ffs(FFS_NINDIR(ip->i_fs)) - 1;
+ lognindir = ffs(NINDIR(ip->i_fs)) - 1;
if (nump)
*nump = 0;
numlevels = 0;
@@ -80,17 +80,17 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
if ((long)bn < 0)
bn = -(long)bn;
- assert (bn >= UFS_NDADDR);
+ assert (bn >= NDADDR);
/*
* Determine the number of levels of indirection. After this loop
* is done, blockcnt indicates the number of data blocks possible
- * at the given level of indirection, and UFS_NIADDR - i is the number
+ * at the given level of indirection, and NIADDR - i is the number
* of levels of indirection needed to locate the requested block.
*/
- bn -= UFS_NDADDR;
- for (lbc = 0, i = UFS_NIADDR;; i--, bn -= blockcnt) {
+ bn -= NDADDR;
+ for (lbc = 0, i = NIADDR;; i--, bn -= blockcnt) {
if (i == 0)
return (EFBIG);
@@ -102,7 +102,7 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
}
/* Calculate the address of the first meta-block. */
- metalbn = -((realbn >= 0 ? realbn : -realbn) - bn + UFS_NIADDR - i);
+ metalbn = -((realbn >= 0 ? realbn : -realbn) - bn + NIADDR - i);
/*
* At each iteration, off is the offset into the bap array which is
@@ -111,17 +111,17 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
* into the argument array.
*/
ap->in_lbn = metalbn;
- ap->in_off = off = UFS_NIADDR - i;
+ ap->in_off = off = NIADDR - i;
ap->in_exists = 0;
ap++;
- for (++numlevels; i <= UFS_NIADDR; i++) {
+ for (++numlevels; i <= NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
if (metalbn == realbn)
break;
lbc -= lognindir;
blockcnt = (int64_t)1 << lbc;
- off = (bn >> lbc) & (FFS_NINDIR(ip->i_fs) - 1);
+ off = (bn >> lbc) & (NINDIR(ip->i_fs) - 1);
++numlevels;
ap->in_lbn = metalbn;