Hi,
In theory ffs code support a maximum of UINT_MAX inodes, but in
practice, due to integer overflows in the current code, the limit is
INT_MAX inodes.
This fixes that, and allows me to create and use filesystems with more
than INT_MAX inodes. This is partly from FreeBSD code.
Main change is in fs.h, modifying a few fields to unsigned, most
notably fs_ipg (inodes per cylinder group) and fs_ncg (number of
cylinder groups). In various places fs_ipg * fs_ncg is computed, so
both should be unsigned. I also made sure cg indexes are unsigned and
ino_t is used for inode numbers.
Tested on a 30TB partition with various parameters (notably -f x -b y
and -i z combinations).
Please test and/or review,
-Otto
Index: sbin/clri/clri.c
===================================================================
RCS file: /cvs/src/sbin/clri/clri.c,v
retrieving revision 1.20
diff -u -p -r1.20 clri.c
--- sbin/clri/clri.c 28 Jun 2019 13:32:43 -0000 1.20
+++ sbin/clri/clri.c 26 May 2020 09:41:18 -0000
@@ -68,7 +68,8 @@ main(int argc, char *argv[])
char *fs, sblock[SBLOCKSIZE];
size_t bsize;
off_t offset;
- int i, fd, imax, inonum;
+ int i, fd;
+ ino_t imax, inonum;
if (argc < 3)
usage();
Index: sbin/dumpfs/dumpfs.c
===================================================================
RCS file: /cvs/src/sbin/dumpfs/dumpfs.c,v
retrieving revision 1.35
diff -u -p -r1.35 dumpfs.c
--- sbin/dumpfs/dumpfs.c 17 Feb 2020 16:11:25 -0000 1.35
+++ sbin/dumpfs/dumpfs.c 26 May 2020 09:41:18 -0000
@@ -69,7 +69,7 @@ union {
#define acg cgun.cg
int dumpfs(int, const char *);
-int dumpcg(const char *, int, int);
+int dumpcg(const char *, int, u_int);
int marshal(const char *);
int open_disk(const char *);
void pbits(void *, int);
@@ -163,6 +163,7 @@ dumpfs(int fd, const char *name)
size_t size;
off_t off;
int i, j;
+ u_int cg;
switch (afs.fs_magic) {
case FS_UFS2_MAGIC:
@@ -172,7 +173,7 @@ dumpfs(int fd, const char *name)
afs.fs_magic, ctime(&fstime));
printf("superblock location\t%jd\tid\t[ %x %x ]\n",
(intmax_t)afs.fs_sblockloc, afs.fs_id[0], afs.fs_id[1]);
- printf("ncg\t%d\tsize\t%jd\tblocks\t%jd\n",
+ printf("ncg\t%u\tsize\t%jd\tblocks\t%jd\n",
afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
break;
case FS_UFS1_MAGIC:
@@ -198,7 +199,7 @@ dumpfs(int fd, const char *name)
printf("cylgrp\t%s\tinodes\t%s\tfslevel %d\n",
i < 1 ? "static" : "dynamic",
i < 2 ? "4.2/4.3BSD" : "4.4BSD", i);
- printf("ncg\t%d\tncyl\t%d\tsize\t%d\tblocks\t%d\n",
+ printf("ncg\t%u\tncyl\t%d\tsize\t%d\tblocks\t%d\n",
afs.fs_ncg, afs.fs_ncyl, afs.fs_ffs1_size,
afs.fs_ffs1_dsize);
break;
default:
@@ -223,9 +224,9 @@ dumpfs(int fd, const char *name)
(intmax_t)afs.fs_cstotal.cs_ndir,
(intmax_t)afs.fs_cstotal.cs_nifree,
(intmax_t)afs.fs_cstotal.cs_nffree);
- printf("bpg\t%d\tfpg\t%d\tipg\t%d\n",
+ printf("bpg\t%d\tfpg\t%d\tipg\t%u\n",
afs.fs_fpg / afs.fs_frag, afs.fs_fpg, afs.fs_ipg);
- printf("nindir\t%d\tinopb\t%d\tmaxfilesize\t%ju\n",
+ printf("nindir\t%d\tinopb\t%u\tmaxfilesize\t%ju\n",
afs.fs_nindir, afs.fs_inopb,
(uintmax_t)afs.fs_maxfilesize);
printf("sbsize\t%d\tcgsize\t%d\tcsaddr\t%jd\tcssize\t%d\n",
@@ -238,10 +239,10 @@ dumpfs(int fd, const char *name)
printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
afs.fs_ffs1_cstotal.cs_nbfree, afs.fs_ffs1_cstotal.cs_ndir,
afs.fs_ffs1_cstotal.cs_nifree,
afs.fs_ffs1_cstotal.cs_nffree);
- printf("cpg\t%d\tbpg\t%d\tfpg\t%d\tipg\t%d\n",
+ printf("cpg\t%d\tbpg\t%d\tfpg\t%d\tipg\t%u\n",
afs.fs_cpg, afs.fs_fpg / afs.fs_frag, afs.fs_fpg,
afs.fs_ipg);
- printf("nindir\t%d\tinopb\t%d\tnspf\t%d\tmaxfilesize\t%ju\n",
+ printf("nindir\t%d\tinopb\t%u\tnspf\t%d\tmaxfilesize\t%ju\n",
afs.fs_nindir, afs.fs_inopb, afs.fs_nspf,
(uintmax_t)afs.fs_maxfilesize);
printf("sbsize\t%d\tcgsize\t%d\tcgoffset %d\tcgmask\t0x%08x\n",
@@ -261,7 +262,7 @@ dumpfs(int fd, const char *name)
afs.fs_sblkno, afs.fs_cblkno, afs.fs_iblkno, afs.fs_dblkno);
printf("cgrotor\t%d\tfmod\t%d\tronly\t%d\tclean\t%d\n",
afs.fs_cgrotor, afs.fs_fmod, afs.fs_ronly, afs.fs_clean);
- printf("avgfpdir %d\tavgfilesize %d\n",
+ printf("avgfpdir %u\tavgfilesize %u\n",
afs.fs_avgfpdir, afs.fs_avgfilesize);
printf("flags\t");
if (afs.fs_magic == FS_UFS2_MAGIC ||
@@ -296,8 +297,8 @@ dumpfs(int fd, const char *name)
if (pread(fd, (char *)afs.fs_csp + i, size, off) != size)
goto err;
}
- for (i = 0; i < afs.fs_ncg; i++) {
- struct csum *cs = &afs.fs_cs(&afs, i);
+ for (cg = 0; cg < afs.fs_ncg; cg++) {
+ struct csum *cs = &afs.fs_cs(&afs, cg);
if (i && i % 4 == 0)
printf("\n\t");
printf("(%d,%d,%d,%d) ",
@@ -312,8 +313,8 @@ dumpfs(int fd, const char *name)
printf("blocks in last group %ld\n\n",
(long)((fssize % afs.fs_fpg) / afs.fs_frag));
}
- for (i = 0; i < afs.fs_ncg; i++)
- if (dumpcg(name, fd, i))
+ for (cg = 0; cg < afs.fs_ncg; cg++)
+ if (dumpcg(name, fd, cg))
goto err;
return (0);
@@ -322,13 +323,13 @@ err: warn("%s", name);
}
int
-dumpcg(const char *name, int fd, int c)
+dumpcg(const char *name, int fd, u_int c)
{
time_t cgtime;
off_t cur;
int i, j;
- printf("\ncg %d:\n", c);
+ printf("\ncg %u:\n", c);
cur = (off_t)fsbtodb(&afs, cgtod(&afs, c)) * DEV_BSIZE;
if (pread(fd, &acg, afs.fs_bsize, cur) != afs.fs_bsize) {
warn("%s: error reading cg", name);
@@ -339,7 +340,7 @@ dumpcg(const char *name, int fd, int c)
cgtime = acg.cg_ffs2_time;
printf("magic\t%x\ttell\t%jx\ttime\t%s",
acg.cg_magic, (intmax_t)cur, ctime(&cgtime));
- printf("cgx\t%d\tndblk\t%d\tniblk\t%d\tinitiblk %d\n",
+ printf("cgx\t%u\tndblk\t%u\tniblk\t%u\tinitiblk %u\n",
acg.cg_cgx, acg.cg_ndblk, acg.cg_ffs2_niblk,
acg.cg_initediblk);
break;
@@ -349,7 +350,7 @@ dumpcg(const char *name, int fd, int c)
afs.fs_postblformat == FS_42POSTBLFMT ?
((struct ocg *)&acg)->cg_magic : acg.cg_magic,
(intmax_t)cur, ctime(&cgtime));
- printf("cgx\t%d\tncyl\t%d\tniblk\t%d\tndblk\t%d\n",
+ printf("cgx\t%u\tncyl\t%d\tniblk\t%d\tndblk\t%u\n",
acg.cg_cgx, acg.cg_ncyl, acg.cg_niblk, acg.cg_ndblk);
break;
default:
@@ -358,10 +359,10 @@ dumpcg(const char *name, int fd, int c)
printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
acg.cg_cs.cs_nbfree, acg.cg_cs.cs_ndir,
acg.cg_cs.cs_nifree, acg.cg_cs.cs_nffree);
- printf("rotor\t%d\tirotor\t%d\tfrotor\t%d\nfrsum",
+ printf("rotor\t%u\tirotor\t%u\tfrotor\t%u\nfrsum",
acg.cg_rotor, acg.cg_irotor, acg.cg_frotor);
for (i = 1, j = 0; i < afs.fs_frag; i++) {
- printf("\t%d", acg.cg_frsum[i]);
+ printf("\t%u", acg.cg_frsum[i]);
j += i * acg.cg_frsum[i];
}
printf("\nsum of frsum: %d", j);
@@ -416,8 +417,8 @@ marshal(const char *name)
/* -c unimplemented */
printf("-e %d ", afs.fs_maxbpg);
printf("-f %d ", afs.fs_fsize);
- printf("-g %d ", afs.fs_avgfilesize);
- printf("-h %d ", afs.fs_avgfpdir);
+ printf("-g %u ", afs.fs_avgfilesize);
+ printf("-h %u ", afs.fs_avgfpdir);
/* -i unimplemented */
printf("-m %d ", afs.fs_minfree);
printf("-o ");
Index: sbin/fsck_ffs/pass1.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass1.c,v
retrieving revision 1.45
diff -u -p -r1.45 pass1.c
--- sbin/fsck_ffs/pass1.c 12 Apr 2017 15:23:08 -0000 1.45
+++ sbin/fsck_ffs/pass1.c 26 May 2020 09:41:18 -0000
@@ -66,7 +66,7 @@ pass1(void)
ino_t inumber, inosused, ninosused;
size_t inospace;
struct inostat *info;
- int c;
+ u_int c;
struct inodesc idesc;
daddr_t i, cgd;
u_int8_t *cp;
Index: sbin/fsck_ffs/pass1b.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass1b.c,v
retrieving revision 1.21
diff -u -p -r1.21 pass1b.c
--- sbin/fsck_ffs/pass1b.c 20 Jan 2015 18:22:21 -0000 1.21
+++ sbin/fsck_ffs/pass1b.c 26 May 2020 09:41:18 -0000
@@ -55,7 +55,7 @@ pass1b_info(char *buf, size_t buflen)
void
pass1b(void)
{
- int c, i;
+ u_int c, i;
union dinode *dp;
struct inodesc idesc;
ino_t inumber;
Index: sbin/fsck_ffs/pass4.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass4.c,v
retrieving revision 1.25
diff -u -p -r1.25 pass4.c
--- sbin/fsck_ffs/pass4.c 13 Apr 2017 07:30:21 -0000 1.25
+++ sbin/fsck_ffs/pass4.c 26 May 2020 09:41:18 -0000
@@ -59,7 +59,8 @@ pass4(void)
struct zlncnt *zlnp;
union dinode *dp;
struct inodesc idesc;
- int n, c, i;
+ int n, i;
+ u_int c;
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
Index: sbin/fsck_ffs/pass5.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass5.c,v
retrieving revision 1.48
diff -u -p -r1.48 pass5.c
--- sbin/fsck_ffs/pass5.c 20 Jan 2015 18:22:21 -0000 1.48
+++ sbin/fsck_ffs/pass5.c 26 May 2020 09:41:18 -0000
@@ -48,26 +48,28 @@
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
-static int info_cg;
-static int info_maxcg;
+static u_int info_cg;
+static u_int info_maxcg;
static int
pass5_info(char *buf, size_t buflen)
{
- return (snprintf(buf, buflen, "phase 5, cg %d/%d",
+ return (snprintf(buf, buflen, "phase 5, cg %u/%u",
info_cg, info_maxcg) > 0);
}
void
pass5(void)
{
- int c, blk, frags, basesize, sumsize, mapsize, savednrpos=0;
+ int blk, frags, basesize, sumsize, mapsize, savednrpos=0;
+ u_int c;
int inomapsize, blkmapsize;
struct fs *fs = &sblock;
struct cg *cg = &cgrp;
daddr_t dbase, dmax;
daddr_t d;
- long i, j, k, rewritecg = 0;
+ long i, k, rewritecg = 0;
+ ino_t j;
struct csum *cs;
struct csum_total cstotal;
struct inodesc idesc[3];
@@ -179,7 +181,7 @@ pass5(void)
info_cg = c;
getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
if (!cg_chkmagic(cg))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
+ pfatal("CG %u: BAD MAGIC NUMBER\n", c);
dbase = cgbase(fs, c);
dmax = dbase + fs->fs_fpg;
if (dmax > fs->fs_size)
@@ -215,7 +217,7 @@ pass5(void)
newcg->cg_irotor = cg->cg_irotor;
} else {
newcg->cg_ncyl = 0;
- if ((unsigned)cg->cg_initediblk > fs->fs_ipg)
+ if (cg->cg_initediblk > fs->fs_ipg)
newcg->cg_initediblk = fs->fs_ipg;
else
newcg->cg_initediblk = cg->cg_initediblk;
@@ -228,7 +230,7 @@ pass5(void)
memset(cg_inosused(newcg), 0, (size_t)(mapsize));
if (fs->fs_postblformat == FS_42POSTBLFMT)
ocg->cg_magic = CG_MAGIC;
- j = fs->fs_ipg * c;
+ j = fs->fs_ipg * (ino_t)c;
for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
switch (GET_ISTATE(j)) {
@@ -339,8 +341,8 @@ pass5(void)
continue;
if (cg_inosused(cg)[i] & (1 << k))
continue;
- pwarn("ALLOCATED INODE %lld MARKED
FREE\n",
- ((long long)c * fs->fs_ipg + i *
8) + k);
+ pwarn("ALLOCATED INODE %llu MARKED
FREE\n",
+ ((ino_t)c * fs->fs_ipg + i * 8) +
k);
}
}
for (i = 0; i < blkmapsize; i++) {
Index: sbin/fsck_ffs/setup.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/setup.c,v
retrieving revision 1.66
diff -u -p -r1.66 setup.c
--- sbin/fsck_ffs/setup.c 28 Jun 2019 13:32:43 -0000 1.66
+++ sbin/fsck_ffs/setup.c 26 May 2020 09:41:18 -0000
@@ -366,7 +366,7 @@ found:
else
inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
if (INOPB(&sblock) != inopb) {
- pwarn("INCONSISTENT INOPB=%d\n", INOPB(&sblock));
+ pwarn("INCONSISTENT INOPB=%u\n", INOPB(&sblock));
sblock.fs_inopb = inopb;
if (preen)
printf(" (FIXED)\n");
Index: sbin/fsck_ffs/utilities.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/utilities.c,v
retrieving revision 1.52
diff -u -p -r1.52 utilities.c
--- sbin/fsck_ffs/utilities.c 6 Feb 2019 13:26:13 -0000 1.52
+++ sbin/fsck_ffs/utilities.c 26 May 2020 09:41:18 -0000
@@ -581,7 +581,7 @@ dofix(struct inodesc *idesc, char *msg)
return (0);
default:
- errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
+ errexit("UNKNOWN INODESC FIX MODE %u\n", idesc->id_fix);
}
/* NOTREACHED */
}
Index: sbin/fsirand/fsirand.c
===================================================================
RCS file: /cvs/src/sbin/fsirand/fsirand.c,v
retrieving revision 1.42
diff -u -p -r1.42 fsirand.c
--- sbin/fsirand/fsirand.c 17 Feb 2020 19:00:58 -0000 1.42
+++ sbin/fsirand/fsirand.c 26 May 2020 09:41:18 -0000
@@ -101,7 +101,8 @@ fsirand(char *device)
ino_t inumber;
daddr_t sblockloc, dblk;
char sbuf[SBSIZE], sbuftmp[SBSIZE];
- int devfd, n, cg, i;
+ int devfd, n, i;
+ u_int cg;
char *devpath, *ib;
u_int32_t bsize = DEV_BSIZE;
struct disklabel label;
Index: sbin/growfs/growfs.c
===================================================================
RCS file: /cvs/src/sbin/growfs/growfs.c,v
retrieving revision 1.53
diff -u -p -r1.53 growfs.c
--- sbin/growfs/growfs.c 3 Jul 2019 03:24:01 -0000 1.53
+++ sbin/growfs/growfs.c 26 May 2020 09:41:18 -0000
@@ -136,8 +136,8 @@ static void usage(void);
static int isblock(struct fs *, unsigned char *, int);
static void clrblock(struct fs *, unsigned char *, int);
static void setblock(struct fs *, unsigned char *, int);
-static void initcg(int, time_t, int, unsigned int);
-static void updjcg(int, time_t, int, int, unsigned int);
+static void initcg(u_int, time_t, int, unsigned int);
+static void updjcg(u_int, time_t, int, int, unsigned int);
static void updcsloc(time_t, int, int, unsigned int);
static struct disklabel *get_disklabel(int);
static void return_disklabel(int, struct disklabel *, unsigned int);
@@ -167,8 +167,8 @@ int colwidth;
static void
growfs(int fsi, int fso, unsigned int Nflag)
{
- int i;
- int cylno, j;
+ int i, j;
+ u_int cg;
time_t utime;
char tmpbuf[100];
@@ -199,7 +199,7 @@ growfs(int fsi, int fso, unsigned int Nf
(float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR,
(intmax_t)fsbtodb(&sblock, sblock.fs_size), sblock.fs_bsize,
sblock.fs_fsize);
- printf("\tusing %d cylinder groups of %.2fMB, %d blks, %d inodes.\n",
+ printf("\tusing %u cylinder groups of %.2fMB, %d blks, %u inodes.\n",
sblock.fs_ncg, (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR,
sblock.fs_fpg / sblock.fs_frag, sblock.fs_ipg);
if (sblock.fs_flags & FS_DOSOFTDEP)
@@ -217,13 +217,13 @@ growfs(int fsi, int fso, unsigned int Nf
/*
* Iterate for only the new cylinder groups.
*/
- for (cylno = osblock.fs_ncg; cylno < sblock.fs_ncg; cylno++) {
- initcg(cylno, utime, fso, Nflag);
+ for (cg = osblock.fs_ncg; cg < sblock.fs_ncg; cg++) {
+ initcg(cg, utime, fso, Nflag);
if (quiet)
continue;
j = snprintf(tmpbuf, sizeof(tmpbuf), " %lld%s",
- fsbtodb(&sblock, cgsblock(&sblock, cylno)),
- cylno < (sblock.fs_ncg - 1) ? "," : "");
+ fsbtodb(&sblock, cgsblock(&sblock, cg)),
+ cg < (sblock.fs_ncg - 1) ? "," : "");
if (j >= sizeof(tmpbuf))
j = sizeof(tmpbuf) - 1;
if (j < 0 || i + j >= colwidth) {
@@ -310,8 +310,8 @@ growfs(int fsi, int fso, unsigned int Nf
/*
* Write out the duplicate superblocks.
*/
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
- wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)),
+ for (cg = 0; cg < sblock.fs_ncg; cg++) {
+ wtfs(fsbtodb(&sblock, cgsblock(&sblock, cg)),
(size_t)SBLOCKSIZE, (void *)&sblock, fso, Nflag);
}
}
@@ -323,7 +323,7 @@ growfs(int fsi, int fso, unsigned int Nf
* provisions for that case are removed here.
*/
static void
-initcg(int cylno, time_t utime, int fso, unsigned int Nflag)
+initcg(u_int cg, time_t utime, int fso, unsigned int Nflag)
{
static char *iobuf;
daddr_t d, dlower, dupper, blkno, start;
@@ -348,19 +348,19 @@ initcg(int cylno, time_t utime, int fso,
* Allow space for super block summary information in first
* cylinder group.
*/
- cbase = cgbase(&sblock, cylno);
+ cbase = cgbase(&sblock, cg);
dmax = cbase + sblock.fs_fpg;
if (dmax > sblock.fs_size)
dmax = sblock.fs_size;
- dlower = cgsblock(&sblock, cylno) - cbase;
- dupper = cgdmin(&sblock, cylno) - cbase;
- if (cylno == 0) /* XXX fscs may be relocated */
+ dlower = cgsblock(&sblock, cg) - cbase;
+ dupper = cgdmin(&sblock, cg) - cbase;
+ if (cg == 0) /* XXX fscs may be relocated */
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
- cs = &fscs[cylno];
+ cs = &fscs[cg];
memset(&acg, 0, sblock.fs_cgsize);
acg.cg_ffs2_time = utime;
acg.cg_magic = CG_MAGIC;
- acg.cg_cgx = cylno;
+ acg.cg_cgx = cg;
acg.cg_ffs2_niblk = sblock.fs_ipg;
acg.cg_initediblk = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock));
acg.cg_ndblk = dmax - cbase;
@@ -370,7 +370,7 @@ initcg(int cylno, time_t utime, int fso,
if (sblock.fs_magic == FS_UFS2_MAGIC) {
acg.cg_iusedoff = start;
} else {
- if (cylno == sblock.fs_ncg - 1)
+ if (cg == sblock.fs_ncg - 1)
acg.cg_ncyl = sblock.fs_ncyl % sblock.fs_cpg;
else
acg.cg_ncyl = sblock.fs_cpg;
@@ -404,15 +404,15 @@ initcg(int cylno, time_t utime, int fso,
errx(37, "panic: cylinder group too big");
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
- if (cylno == 0) {
+ if (cg == 0) {
for (i = 0; i < ROOTINO; i++) {
setbit(cg_inosused(&acg), i);
acg.cg_cs.cs_nifree--;
}
}
- if (cylno > 0) {
+ if (cg > 0) {
/*
- * In cylno 0, beginning space is reserved
+ * In cg 0, beginning space is reserved
* for boot and super blocks.
*/
for (d = 0; d < dlower; d += sblock.fs_frag) {
@@ -501,7 +501,7 @@ initcg(int cylno, time_t utime, int fso,
dp2++;
}
}
- wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), iobufsize,
+ wtfs(fsbtodb(&sblock, cgsblock(&sblock, cg)), iobufsize,
iobuf, fso, Nflag);
/* Initialize inodes for FFS1. */
@@ -513,7 +513,7 @@ initcg(int cylno, time_t utime, int fso,
dp1->di_gen = arc4random();
dp1++;
}
- wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
+ wtfs(fsbtodb(&sblock, cgimin(&sblock, cg) + i),
(size_t)sblock.fs_bsize, &iobuf[start], fso, Nflag);
}
}
@@ -626,7 +626,7 @@ cond_bl_upd(daddr_t *block, struct gfs_b
* tables and cluster summary during all those operations.
*/
static void
-updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag)
+updjcg(u_int cg, time_t utime, int fsi, int fso, unsigned int Nflag)
{
daddr_t cbase, dmax, dupper;
struct csum *cs;
@@ -637,7 +637,7 @@ updjcg(int cylno, time_t utime, int fsi,
* Read the former last (joining) cylinder group from disk, and make
* a copy.
*/
- rdfs(fsbtodb(&osblock, cgtod(&osblock, cylno)),
+ rdfs(fsbtodb(&osblock, cgtod(&osblock, cg)),
(size_t)osblock.fs_cgsize, (void *)&aocg, fsi);
memcpy(&cgun1, &cgun2, sizeof(cgun2));
@@ -649,11 +649,11 @@ updjcg(int cylno, time_t utime, int fsi,
* to be zero instead of fs_cpg. As this is now no longer the last
* cylinder group we have to change that value now to fs_cpg.
*/
- if (cgbase(&osblock, cylno+1) == osblock.fs_size) {
+ if (cgbase(&osblock, cg+1) == osblock.fs_size) {
if (sblock.fs_magic == FS_UFS1_MAGIC)
acg.cg_ncyl = sblock.fs_cpg;
- wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)),
+ wtfs(fsbtodb(&sblock, cgtod(&sblock, cg)),
(size_t)sblock.fs_cgsize, (void *)&acg, fso, Nflag);
return;
@@ -662,18 +662,18 @@ updjcg(int cylno, time_t utime, int fsi,
/*
* Set up some variables needed later.
*/
- cbase = cgbase(&sblock, cylno);
+ cbase = cgbase(&sblock, cg);
dmax = cbase + sblock.fs_fpg;
if (dmax > sblock.fs_size)
dmax = sblock.fs_size;
- dupper = cgdmin(&sblock, cylno) - cbase;
- if (cylno == 0) /* XXX fscs may be relocated */
+ dupper = cgdmin(&sblock, cg) - cbase;
+ if (cg == 0) /* XXX fscs may be relocated */
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
/*
* Set pointer to the cylinder summary for our cylinder group.
*/
- cs = fscs + cylno;
+ cs = fscs + cg;
/*
* Touch the cylinder group, update all fields in the cylinder group as
@@ -681,7 +681,7 @@ updjcg(int cylno, time_t utime, int fsi,
*/
acg.cg_time = utime;
if (sblock.fs_magic == FS_UFS1_MAGIC) {
- if (cylno == sblock.fs_ncg - 1) {
+ if (cg == sblock.fs_ncg - 1) {
/*
* This is still the last cylinder group.
*/
@@ -727,7 +727,7 @@ updjcg(int cylno, time_t utime, int fsi,
* filesystem.
*/
if (isblock(&sblock, cg_blksfree(&acg),
- ((osblock.fs_size - cgbase(&sblock, cylno))/
+ ((osblock.fs_size - cgbase(&sblock, cg))/
Sblock.Fs_Frag))) {
/*
* The Block Is Now Completely Available.
@@ -822,7 +822,7 @@ Updjcg(Int Cylno, Time_T Utime, int fsi,
/*
* Write the updated "joining" cylinder group back to disk.
*/
- wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), (size_t)sblock.fs_cgsize,
+ wtfs(fsbtodb(&sblock, cgtod(&sblock, cg)), (size_t)sblock.fs_cgsize,
(void *)&acg, fso, Nflag);
}
@@ -850,7 +850,7 @@ updcsloc(time_t utime, int fsi, int fso,
int blocks;
daddr_t cbase, dupper, odupper, d, f, g;
int ind;
- int cylno, inc;
+ u_int cg, inc;
struct gfs_bpp *bp;
int i, l;
int lcs = 0;
@@ -1337,9 +1337,9 @@ updcsloc(time_t utime, int fsi, int fso,
* cylinder groups, within those over all non zero length
* inodes.
*/
- for (cylno = 0; cylno < osblock.fs_ncg; cylno++) {
+ for (cg = 0; cg < osblock.fs_ncg; cg++) {
for (inc = osblock.fs_ipg - 1; inc > 0; inc--) {
- updrefs(cylno, (ino_t)inc, bp, fsi, fso, Nflag);
+ updrefs(cg, (ino_t)inc, bp, fsi, fso, Nflag);
}
}
@@ -1906,6 +1906,8 @@ main(int argc, char **argv)
sblock.fs_ncyl++;
}
sblock.fs_ncg = howmany(sblock.fs_size, sblock.fs_fpg);
+ if ((ino_t)sblock.fs_ncg * sblock.fs_ipg > UINT_MAX)
+ errx(1, "more than 2^32 inodes requested");
maxino = sblock.fs_ncg * sblock.fs_ipg;
if (sblock.fs_size % sblock.fs_fpg != 0 &&
Index: sbin/newfs/mkfs.c
===================================================================
RCS file: /cvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.99
diff -u -p -r1.99 mkfs.c
--- sbin/newfs/mkfs.c 19 May 2020 12:48:54 -0000 1.99
+++ sbin/newfs/mkfs.c 26 May 2020 09:41:18 -0000
@@ -131,7 +131,7 @@ static long iobufsize;
daddr_t alloc(int, int);
static int charsperline(void);
static int ilog2(int);
-void initcg(int, time_t);
+void initcg(u_int, time_t);
void wtfs(daddr_t, int, void *);
int fsinit1(time_t, mode_t, uid_t, gid_t);
int fsinit2(time_t, mode_t, uid_t, gid_t);
@@ -170,7 +170,8 @@ mkfs(struct partition *pp, char *fsys, i
int i, j, width, origdensity, fragsperinode, minfpg, optimalfpg;
int lastminfpg, mincylgrps;
uint32_t bpg;
- long cylno, csfrags;
+ long csfrags;
+ u_int cg;
char tmpbuf[100]; /* XXX this will break in about 2,500 years */
if ((fsun = calloc(1, sizeof (union fs_u))) == NULL ||
@@ -427,6 +428,10 @@ mkfs(struct partition *pp, char *fsys, i
" to %d to enlarge last cylinder group", optimalfpg,
sblock.fs_fpg);
+ if ((ino_t)sblock.fs_ipg * sblock.fs_ncg > UINT_MAX)
+ errx(42, "more than 2^32 inodes, increase density, block or "
+ "fragment size");
+
/*
* Back to filling superblock fields.
*/
@@ -498,7 +503,7 @@ mkfs(struct partition *pp, char *fsys, i
(float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR,
(intmax_t)fsbtodb(&sblock, sblock.fs_size) /
(sectorsize / DEV_BSIZE), sectorsize);
- printf("%d cylinder groups of %.2fMB, %d blocks, %d"
+ printf("%u cylinder groups of %.2fMB, %d blocks, %u"
" inodes each\n", sblock.fs_ncg,
(float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR,
sblock.fs_fpg / sblock.fs_frag, sblock.fs_ipg);
@@ -558,13 +563,13 @@ mkfs(struct partition *pp, char *fsys, i
* writing out in each cylinder group.
*/
bcopy((char *)&sblock, iobuf, SBLOCKSIZE);
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
- cur_cylno = (sig_atomic_t)cylno;
- initcg(cylno, utime);
+ for (cg = 0; cg < sblock.fs_ncg; cg++) {
+ cur_cylno = (sig_atomic_t)cg;
+ initcg(cg, utime);
if (quiet)
continue;
j = snprintf(tmpbuf, sizeof tmpbuf, " %lld,",
- (long long)fsbtodb(&sblock, cgsblock(&sblock, cylno)));
+ (long long)fsbtodb(&sblock, cgsblock(&sblock, cg)));
if (j >= sizeof tmpbuf)
j = sizeof tmpbuf - 1;
if (j < 0 || i+j >= width) {
@@ -619,9 +624,9 @@ mkfs(struct partition *pp, char *fsys, i
* Initialize a cylinder group.
*/
void
-initcg(int cylno, time_t utime)
+initcg(u_int cg, time_t utime)
{
- int i, j, d, dlower, dupper, blkno, start;
+ u_int i, j, d, dlower, dupper, blkno, start;
daddr_t cbase, dmax;
struct ufs1_dinode *dp1;
struct ufs2_dinode *dp2;
@@ -631,23 +636,23 @@ initcg(int cylno, time_t utime)
* Determine block bounds for cylinder group. Allow space for
* super block summary information in first cylinder group.
*/
- cbase = cgbase(&sblock, cylno);
+ cbase = cgbase(&sblock, cg);
dmax = cbase + sblock.fs_fpg;
if (dmax > sblock.fs_size)
dmax = sblock.fs_size;
- if (fsbtodb(&sblock, cgsblock(&sblock, cylno)) + iobufsize / DEV_BSIZE
+ if (fsbtodb(&sblock, cgsblock(&sblock, cg)) + iobufsize / DEV_BSIZE
> fssize)
errx(40, "inode table does not fit in cylinder group");
- dlower = cgsblock(&sblock, cylno) - cbase;
- dupper = cgdmin(&sblock, cylno) - cbase;
- if (cylno == 0)
+ dlower = cgsblock(&sblock, cg) - cbase;
+ dupper = cgdmin(&sblock, cg) - cbase;
+ if (cg == 0)
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
- cs = &fscs[cylno];
+ cs = &fscs[cg];
memset(&acg, 0, sblock.fs_cgsize);
acg.cg_ffs2_time = utime;
acg.cg_magic = CG_MAGIC;
- acg.cg_cgx = cylno;
+ acg.cg_cgx = cg;
acg.cg_ffs2_niblk = sblock.fs_ipg;
acg.cg_initediblk = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock));
acg.cg_ndblk = dmax - cbase;
@@ -655,7 +660,7 @@ initcg(int cylno, time_t utime)
start = sizeof(struct cg);
if (Oflag <= 1) {
/* Hack to maintain compatibility with old fsck. */
- if (cylno == sblock.fs_ncg - 1)
+ if (cg == sblock.fs_ncg - 1)
acg.cg_ncyl = 0;
else
acg.cg_ncyl = sblock.fs_cpg;
@@ -675,18 +680,18 @@ initcg(int cylno, time_t utime)
acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, CHAR_BIT);
acg.cg_nextfreeoff = acg.cg_freeoff + howmany(sblock.fs_fpg, CHAR_BIT);
if (acg.cg_nextfreeoff > sblock.fs_cgsize)
- errx(37, "panic: cylinder group too big: %d > %d",
+ errx(37, "panic: cylinder group too big: %u > %d",
acg.cg_nextfreeoff, sblock.fs_cgsize);
acg.cg_cs.cs_nifree += sblock.fs_ipg;
- if (cylno == 0) {
+ if (cg == 0) {
for (i = 0; i < ROOTINO; i++) {
setbit(cg_inosused(&acg), i);
acg.cg_cs.cs_nifree--;
}
}
- if (cylno > 0) {
+ if (cg > 0) {
/*
- * In cylno 0, space is reserved for boot and super blocks.
+ * In cg 0, space is reserved for boot and super blocks.
*/
for (d = 0; d < dlower; d += sblock.fs_frag) {
blkno = d / sblock.fs_frag;
@@ -732,6 +737,10 @@ initcg(int cylno, time_t utime)
* and two blocks worth of inodes in a single write.
*/
start = sblock.fs_bsize > SBLOCKSIZE ? sblock.fs_bsize : SBLOCKSIZE;
+
+ if (cg == 0 && acg.cg_cs.cs_nbfree == 0)
+ errx(42, "cg 0: summary info is too large to fit");
+
bcopy((char *)&acg, &iobuf[start], sblock.fs_cgsize);
start += sblock.fs_bsize;
dp1 = (struct ufs1_dinode *)(&iobuf[start]);
@@ -745,7 +754,7 @@ initcg(int cylno, time_t utime)
dp2++;
}
}
- wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), iobufsize, iobuf);
+ wtfs(fsbtodb(&sblock, cgsblock(&sblock, cg)), iobufsize, iobuf);
if (Oflag <= 1) {
/* Initialize inodes for FFS1. */
@@ -757,7 +766,7 @@ initcg(int cylno, time_t utime)
dp1->di_gen = (u_int32_t)arc4random();
dp1++;
}
- wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
+ wtfs(fsbtodb(&sblock, cgimin(&sblock, cg) + i),
sblock.fs_bsize, &iobuf[start]);
}
}
Index: sys/ufs/ffs/ffs_alloc.c
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.110
diff -u -p -r1.110 ffs_alloc.c
--- sys/ufs/ffs/ffs_alloc.c 21 Feb 2020 11:13:55 -0000 1.110
+++ sys/ufs/ffs/ffs_alloc.c 26 May 2020 09:41:20 -0000
@@ -63,14 +63,14 @@
(fs)->fs_fsmnt, (cp)); \
} while (0)
-daddr_t ffs_alloccg(struct inode *, int, daddr_t, int);
-struct buf * ffs_cgread(struct fs *, struct inode *, int);
+daddr_t ffs_alloccg(struct inode *, u_int, daddr_t, int);
+struct buf * ffs_cgread(struct fs *, struct inode *, u_int);
daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t);
ufsino_t ffs_dirpref(struct inode *);
-daddr_t ffs_fragextend(struct inode *, int, daddr_t, int, int);
-daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int,
- daddr_t (*)(struct inode *, int, daddr_t, int));
-daddr_t ffs_nodealloccg(struct inode *, int, daddr_t, int);
+daddr_t ffs_fragextend(struct inode *, u_int, daddr_t, int,
int);
+daddr_t ffs_hashalloc(struct inode *, u_int, daddr_t, int,
+ daddr_t (*)(struct inode *, u_int, daddr_t, int));
+daddr_t ffs_nodealloccg(struct inode *, u_int, daddr_t, int);
daddr_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
static const struct timeval fserr_interval = { 2, 0 };
@@ -102,7 +102,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
static struct timeval fsfull_last;
struct fs *fs;
daddr_t bno;
- int cg;
+ u_int cg;
int error;
*bnp = 0;
@@ -174,7 +174,8 @@ ffs_realloccg(struct inode *ip, daddr_t
struct fs *fs;
struct buf *bp = NULL;
daddr_t quota_updated = 0;
- int cg, request, error;
+ int request, error;
+ u_int cg;
daddr_t bprev, bno;
if (bpp != NULL)
@@ -360,7 +361,8 @@ ffs_inode_alloc(struct inode *pip, mode_
struct fs *fs;
struct inode *ip;
ufsino_t ino, ipref;
- int cg, error;
+ u_int cg;
+ int error;
*vpp = NULL;
fs = pip->i_fs;
@@ -452,11 +454,12 @@ ufsino_t
ffs_dirpref(struct inode *pip)
{
struct fs *fs;
- int cg, prefcg, dirsize, cgsize;
- int avgifree, avgbfree, avgndir, curdirsize;
- int minifree, minbfree, maxndir;
- int mincg, minndir;
- int maxcontigdirs;
+ u_int cg, prefcg;
+ u_int dirsize, cgsize;
+ u_int avgifree, avgbfree, avgndir, curdirsize;
+ u_int minifree, minbfree, maxndir;
+ u_int mincg, minndir;
+ u_int maxcontigdirs;
fs = pip->i_fs;
@@ -518,7 +521,7 @@ ffs_dirpref(struct inode *pip)
maxcontigdirs = 1;
/*
- * Limit number of dirs in one cg and reserve space for
+ * Limit number of dirs in one cg and reserve space for
* regular files, but only if we have no deficit in
* inodes or space.
*
@@ -527,16 +530,17 @@ ffs_dirpref(struct inode *pip)
* We scan from our preferred cylinder group forward looking
* for a cylinder group that meets our criterion. If we get
* to the final cylinder group and do not find anything,
- * we start scanning backwards from our preferred cylinder
- * group. The ideal would be to alternate looking forward
- * and backward, but tha tis just too complex to code for
- * the gain it would get. The most likely place where the
- * backward scan would take effect is when we start near
- * the end of the filesystem and do not find anything from
- * where we are to the end. In that case, scanning backward
- * will likely find us a suitable cylinder group much closer
- * to our desired location than if we were to start scanning
- * forward from the beginning for the filesystem.
+ * we start scanning forwards from the beginning of the
+ * filesystem. While it might seem sensible to start scanning
+ * backwards or even to alternate looking forward and backward,
+ * this approach fails badly when the filesystem is nearly full.
+ * Specifically, we first search all the areas that have no space
+ * and finally try the one preceding that. We repeat this on
+ * every request and in the case of the final block end up
+ * searching the entire filesystem. By jumping to the front
+ * of the filesystem, our future forward searches always look
+ * in new cylinder groups so finds every possible block after
+ * one pass over the filesystem.
*/
for (cg = prefcg; cg < fs->fs_ncg; cg++)
if (fs->fs_cs(fs, cg).cs_ndir < maxndir &&
@@ -545,7 +549,7 @@ ffs_dirpref(struct inode *pip)
if (fs->fs_contigdirs[cg] < maxcontigdirs)
goto end;
}
- for (cg = prefcg - 1; cg >= 0; cg--)
+ for (cg = 0; cg < prefcg; cg++)
if (fs->fs_cs(fs, cg).cs_ndir < maxndir &&
fs->fs_cs(fs, cg).cs_nifree >= minifree &&
fs->fs_cs(fs, cg).cs_nbfree >= minbfree) {
@@ -558,7 +562,7 @@ ffs_dirpref(struct inode *pip)
for (cg = prefcg; cg < fs->fs_ncg; cg++)
if (fs->fs_cs(fs, cg).cs_nifree >= avgifree)
goto end;
- for (cg = prefcg - 1; cg >= 0; cg--)
+ for (cg = 0; cg < prefcg; cg++)
if (fs->fs_cs(fs, cg).cs_nifree >= avgifree)
goto end;
end:
@@ -594,7 +598,8 @@ int32_t
ffs1_blkpref(struct inode *ip, daddr_t lbn, int indx, int32_t *bap)
{
struct fs *fs;
- int cg, inocg, avgbfree, startcg;
+ u_int cg, inocg;
+ u_int avgbfree, startcg;
uint32_t pref;
KASSERT(indx <= 0 || bap != NULL);
@@ -694,7 +699,8 @@ int64_t
ffs2_blkpref(struct inode *ip, daddr_t lbn, int indx, int64_t *bap)
{
struct fs *fs;
- int cg, inocg, avgbfree, startcg;
+ u_int cg, inocg;
+ u_int avgbfree, startcg;
uint64_t pref;
KASSERT(indx <= 0 || bap != NULL);
@@ -798,12 +804,12 @@ ffs2_blkpref(struct inode *ip, daddr_t l
* 3) brute force search for a free block.
*/
daddr_t
-ffs_hashalloc(struct inode *ip, int cg, daddr_t pref, int size,
- daddr_t (*allocator)(struct inode *, int, daddr_t, int))
+ffs_hashalloc(struct inode *ip, u_int cg, daddr_t pref, int size,
+ daddr_t (*allocator)(struct inode *, u_int, daddr_t, int))
{
struct fs *fs;
daddr_t result;
- int i, icg = cg;
+ u_int i, icg = cg;
fs = ip->i_fs;
/*
@@ -841,7 +847,7 @@ ffs_hashalloc(struct inode *ip, int cg,
}
struct buf *
-ffs_cgread(struct fs *fs, struct inode *ip, int cg)
+ffs_cgread(struct fs *fs, struct inode *ip, u_int cg)
{
struct buf *bp;
@@ -866,7 +872,7 @@ ffs_cgread(struct fs *fs, struct inode *
* if they are, allocate them.
*/
daddr_t
-ffs_fragextend(struct inode *ip, int cg, daddr_t bprev, int osize, int nsize)
+ffs_fragextend(struct inode *ip, u_int cg, daddr_t bprev, int osize, int nsize)
{
struct fs *fs;
struct cg *cgp;
@@ -932,7 +938,7 @@ ffs_fragextend(struct inode *ip, int cg,
* and if it is, allocate it.
*/
daddr_t
-ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
+ffs_alloccg(struct inode *ip, u_int cg, daddr_t bpref, int size)
{
struct fs *fs;
struct cg *cgp;
@@ -1087,7 +1093,7 @@ gotit:
/* inode allocation routine */
daddr_t
-ffs_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode)
+ffs_nodealloccg(struct inode *ip, u_int cg, daddr_t ipref, int mode)
{
struct fs *fs;
struct cg *cgp;
@@ -1380,10 +1386,10 @@ ffs_freefile(struct inode *pip, ufsino_t
struct cg *cgp;
struct buf *bp;
struct timespec now;
- int cg;
+ u_int cg;
fs = pip->i_fs;
- if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
+ if (ino >= fs->fs_ipg * fs->fs_ncg)
panic("ffs_freefile: range: dev = 0x%x, ino = %d, fs = %s",
pip->i_dev, ino, fs->fs_fsmnt);
Index: sys/ufs/ffs/fs.h
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/fs.h,v
retrieving revision 1.42
diff -u -p -r1.42 fs.h
--- sys/ufs/ffs/fs.h 27 Nov 2016 13:27:55 -0000 1.42
+++ sys/ufs/ffs/fs.h 26 May 2020 09:41:20 -0000
@@ -202,7 +202,7 @@ struct fs {
int32_t fs_ffs1_time; /* last time written */
int32_t fs_ffs1_size; /* # of blocks in fs / frags */
int32_t fs_ffs1_dsize; /* # of data blocks in fs */
- int32_t fs_ncg; /* # of cylinder groups */
+ u_int32_t fs_ncg; /* # of cylinder groups */
int32_t fs_bsize; /* size of basic blocks / bytes */
int32_t fs_fsize; /* size of frag blocks / bytes */
int32_t fs_frag; /* # of frags in a block in fs */
@@ -225,7 +225,7 @@ struct fs {
int32_t fs_csmask; /* csum block offset (now unused) */
int32_t fs_csshift; /* csum block number (now unused) */
int32_t fs_nindir; /* value of NINDIR */
- int32_t fs_inopb; /* inodes per file system block */
+ u_int32_t fs_inopb; /* inodes per file system block */
int32_t fs_nspf; /* DEV_BSIZE sectors per frag */
/* yet another configuration parameter */
int32_t fs_optim; /* optimization preference, see below */
@@ -247,7 +247,7 @@ struct fs {
int32_t fs_ncyl; /* cylinders in file system */
/* these fields can be computed from the others */
int32_t fs_cpg; /* cylinders per group */
- int32_t fs_ipg; /* inodes per group */
+ u_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_ffs1_cstotal; /* cylinder summary information */
@@ -278,11 +278,11 @@ struct 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];/* space reserved for snapshots */
+ u_int32_t fs_pendinginodes; /* inodes in process of being freed */
+ u_int32_t fs_snapinum[FSMAXSNAP];/* space reserved for snapshots */
/* 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 */
+ u_int32_t fs_avgfilesize; /* expected average file size */
+ u_int32_t fs_avgfpdir; /* expected # of files per directory */
int32_t fs_sparecon[26]; /* reserved for future constants */
u_int32_t fs_flags; /* see FS_ flags below */
int32_t fs_fscktime; /* last time fsck(8)ed */
@@ -377,25 +377,25 @@ struct cg {
int32_t cg_firstfield; /* historic cyl groups linked list */
int32_t cg_magic; /* magic number */
int32_t cg_time; /* time last written */
- int32_t cg_cgx; /* we are the cgx'th cylinder group */
+ u_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 */
+ u_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 */
+ U_int32_t cg_rotor; /* position of last used block */
+ u_int32_t cg_frotor; /* position of last used frag */
+ u_int32_t cg_irotor; /* position of last used inode */
+ u_int32_t cg_frsum[MAXFRAG]; /* counts of available frags */
int32_t cg_btotoff; /* (int32) block totals per cylinder */
int32_t cg_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_ffs2_niblk; /* number of inode blocks this cg */
- int32_t cg_initediblk; /* last initialized inode */
+ u_int32_t cg_iusedoff; /* (u_int8) used inode map */
+ u_int32_t cg_freeoff; /* (u_int8) free block map */
+ u_int32_t cg_nextfreeoff; /* (u_int8) next available space */
+ u_int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */
+ u_int32_t cg_clusteroff; /* (u_int8) free cluster map */
+ u_int32_t cg_nclusterblks; /* number of clusters this cg */
+ u_int32_t cg_ffs2_niblk; /* number of inode blocks this cg */
+ u_int32_t cg_initediblk; /* last initialized inode */
int32_t cg_sparecon32[3]; /* reserved for future use */
int64_t cg_ffs2_time; /* time last written */
int64_t cg_sparecon64[3]; /* reserved for future use */