prefix UFS symbols with UFS_ to reduce namespace pollution

Specifically:
  ROOTINO -> UFS_ROOTINO
  WINO -> UFS_WINO
  NXADDR -> UFS_NXADDR
  NDADDR -> UFS_NDADDR
  NIADDR -> UFS_NIADDR
  MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_

Reviewed by:	kib, mckusick
Obtained from:	NetBSD
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9536
This commit is contained in:
Ed Maste 2017-02-15 19:50:26 +00:00
parent 605703b5df
commit 1dc349ab95
63 changed files with 587 additions and 565 deletions

View File

@ -130,8 +130,8 @@ struct fs_ops ext2fs_fsops = {
#define EXT2_MINBSHIFT 10 /* mininum block shift */
#define EXT2_MINFSHIFT 10 /* mininum frag shift */
#define NDADDR 12 /* # of direct blocks */
#define NIADDR 3 /* # of indirect blocks */
#define EXT2_NDADDR 12 /* # of direct blocks */
#define EXT2_NIADDR 3 /* # of indirect blocks */
/*
* file system block to disk address
@ -162,7 +162,7 @@ struct fs_ops ext2fs_fsops = {
#define fragroundup(fs, size) /* roundup(size, fsize) */ \
(((size) + (fs)->fs_fmask) & ~(fs)->fs_fmask)
#define dblksize(fs, dip, lbn) \
(((lbn) >= NDADDR || (dip)->di_size >= smalllblktosize(fs, (lbn) + 1)) \
(((lbn) >= EXT2_NDADDR || (dip)->di_size >= smalllblktosize(fs, (lbn) + 1)) \
? (fs)->fs_bsize \
: (fragroundup(fs, blkoff(fs, (dip)->di_size))))
@ -275,8 +275,8 @@ struct ext2dinode {
u_int32_t di_osdep1; /* os dependent stuff */
u_int32_t di_db[NDADDR]; /* direct blocks */
u_int32_t di_ib[NIADDR]; /* indirect blocks */
u_int32_t di_db[EXT2_NDADDR]; /* direct blocks */
u_int32_t di_ib[EXT2_NIADDR]; /* indirect blocks */
u_int32_t di_version; /* version */
u_int32_t di_facl; /* file acl */
u_int32_t di_dacl; /* dir acl */
@ -305,12 +305,12 @@ struct file {
struct ext2fs *f_fs; /* pointer to super-block */
struct ext2blkgrp *f_bg; /* pointer to blkgrp map */
struct ext2dinode f_di; /* copy of on-disk inode */
int f_nindir[NIADDR]; /* number of blocks mapped by
int f_nindir[EXT2_NIADDR]; /* number of blocks mapped by
indirect block at level i */
char *f_blk[NIADDR]; /* buffer for indirect block
char *f_blk[EXT2_NIADDR]; /* buffer for indirect block
at level i */
size_t f_blksize[NIADDR]; /* size of buffer */
daddr_t f_blkno[NIADDR]; /* disk address of block in
size_t f_blksize[EXT2_NIADDR]; /* size of buffer */
daddr_t f_blkno[EXT2_NIADDR]; /* disk address of block in
buffer */
char *f_buf; /* buffer for data block */
size_t f_buf_size; /* size of data block */
@ -411,7 +411,7 @@ ext2fs_open(const char *upath, struct open_file *f)
* Calculate indirect block levels.
*/
mult = 1;
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < EXT2_NIADDR; i++) {
mult *= nindir(fs);
fp->f_nindir[i] = mult;
}
@ -582,7 +582,7 @@ read_inode(ino_t inumber, struct open_file *f)
fp->f_di = dp[ino_to_bo(fs, inumber)];
/* clear out old buffers */
for (level = 0; level < NIADDR; level++)
for (level = 0; level < EXT2_NIADDR; level++)
fp->f_blkno[level] = -1;
fp->f_buf_blkno = -1;
fp->f_seekp = 0;
@ -609,33 +609,33 @@ block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
/*
* Index structure of an inode:
*
* di_db[0..NDADDR-1] hold block numbers for blocks
* 0..NDADDR-1
* di_db[0..EXT2_NDADDR-1] hold block numbers for blocks
* 0..EXT2_NDADDR-1
*
* di_ib[0] index block 0 is the single indirect block
* holds block numbers for blocks
* NDADDR .. NDADDR + NINDIR(fs)-1
* EXT2_NDADDR .. EXT2_NDADDR + NINDIR(fs)-1
*
* di_ib[1] index block 1 is the double indirect block
* holds block numbers for INDEX blocks for blocks
* NDADDR + NINDIR(fs) ..
* NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
* EXT2_NDADDR + NINDIR(fs) ..
* EXT2_NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
*
* di_ib[2] index block 2 is the triple indirect block
* holds block numbers for double-indirect
* blocks for blocks
* NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
* NDADDR + NINDIR(fs) + NINDIR(fs)**2
* EXT2_NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
* EXT2_NDADDR + NINDIR(fs) + NINDIR(fs)**2
* + NINDIR(fs)**3 - 1
*/
if (file_block < NDADDR) {
if (file_block < EXT2_NDADDR) {
/* Direct block. */
*disk_block_p = fp->f_di.di_db[file_block];
return (0);
}
file_block -= NDADDR;
file_block -= EXT2_NDADDR;
/*
* nindir[0] = NINDIR
@ -643,12 +643,12 @@ block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
* nindir[2] = NINDIR**3
* etc
*/
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < EXT2_NIADDR; level++) {
if (file_block < fp->f_nindir[level])
break;
file_block -= fp->f_nindir[level];
}
if (level == NIADDR) {
if (level == EXT2_NIADDR) {
/* Block number too high */
return (EFBIG);
}
@ -800,7 +800,7 @@ ext2fs_close(struct open_file *f)
if (fp == (struct file *)0)
return (0);
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < EXT2_NIADDR; level++) {
if (fp->f_blk[level])
free(fp->f_blk[level]);
}

View File

@ -85,7 +85,7 @@ struct nandfs {
struct nandfs_mdt nf_datfile_mdt;
struct nandfs_mdt nf_ifile_mdt;
int nf_nindir[NIADDR];
int nf_nindir[NANDFS_NIADDR];
};
static int nandfs_open(const char *, struct open_file *);
@ -313,7 +313,7 @@ nandfs_mount(struct nandfs *fs, struct open_file *f)
nandfs_daddr_t mult;
mult = 1;
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < NANDFS_NIADDR; level++) {
mult *= NINDIR(fs);
fs->nf_nindir[level] = mult;
}
@ -392,7 +392,7 @@ nandfs_open(const char *path, struct open_file *f)
nandfs_daddr_t mult;
mult = 1;
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < NANDFS_NIADDR; level++) {
mult *= NINDIR(fs);
fs->nf_nindir[level] = mult;
}
@ -887,12 +887,12 @@ nandfs_bmap_lookup(struct nandfs *fs, struct nandfs_node *node,
ino = node->inode;
if (lblknr < NDADDR) {
if (lblknr < NANDFS_NDADDR) {
*vblknr = ino->i_db[lblknr];
return (0);
}
lblknr -= NDADDR;
lblknr -= NANDFS_NDADDR;
/*
* nindir[0] = NINDIR
@ -900,14 +900,14 @@ nandfs_bmap_lookup(struct nandfs *fs, struct nandfs_node *node,
* nindir[2] = NINDIR**3
* etc
*/
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < NANDFS_NIADDR; level++) {
NANDFS_DEBUG("lblknr=%jx fs->nf_nindir[%d]=%d\n", lblknr, level, fs->nf_nindir[level]);
if (lblknr < fs->nf_nindir[level])
break;
lblknr -= fs->nf_nindir[level];
}
if (level == NIADDR) {
if (level == NANDFS_NIADDR) {
/* Block number too high */
NANDFS_DEBUG("lblknr %jx too high\n", lblknr);
return (EFBIG);

View File

@ -112,14 +112,14 @@ struct file {
struct ufs1_dinode di1;
struct ufs2_dinode di2;
} f_di; /* copy of on-disk inode */
int f_nindir[NIADDR];
int f_nindir[UFS_NIADDR];
/* number of blocks mapped by
indirect block at level i */
char *f_blk[NIADDR]; /* buffer for indirect block at
char *f_blk[UFS_NIADDR]; /* buffer for indirect block at
level i */
size_t f_blksize[NIADDR];
size_t f_blksize[UFS_NIADDR];
/* size of buffer */
ufs2_daddr_t f_blkno[NIADDR];/* disk address of block in buffer */
ufs2_daddr_t f_blkno[UFS_NIADDR];/* disk address of block in buffer */
ufs2_daddr_t f_buf_blkno; /* block number of data block */
char *f_buf; /* buffer for data block */
size_t f_buf_size; /* size of data block */
@ -179,7 +179,7 @@ read_inode(inumber, f)
{
int level;
for (level = 0; level < NIADDR; level++)
for (level = 0; level < UFS_NIADDR; level++)
fp->f_blkno[level] = -1;
fp->f_buf_blkno = -1;
}
@ -209,33 +209,33 @@ block_map(f, file_block, disk_block_p)
/*
* Index structure of an inode:
*
* di_db[0..NDADDR-1] hold block numbers for blocks
* 0..NDADDR-1
* di_db[0..UFS_NDADDR-1] hold block numbers for blocks
* 0..UFS_NDADDR-1
*
* di_ib[0] index block 0 is the single indirect block
* holds block numbers for blocks
* NDADDR .. NDADDR + NINDIR(fs)-1
* UFS_NDADDR .. UFS_NDADDR + NINDIR(fs)-1
*
* di_ib[1] index block 1 is the double indirect block
* holds block numbers for INDEX blocks for blocks
* NDADDR + NINDIR(fs) ..
* NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
* UFS_NDADDR + NINDIR(fs) ..
* UFS_NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
*
* di_ib[2] index block 2 is the triple indirect block
* holds block numbers for double-indirect
* blocks for blocks
* NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
* NDADDR + NINDIR(fs) + NINDIR(fs)**2
* UFS_NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
* UFS_NDADDR + NINDIR(fs) + NINDIR(fs)**2
* + NINDIR(fs)**3 - 1
*/
if (file_block < NDADDR) {
if (file_block < UFS_NDADDR) {
/* Direct block. */
*disk_block_p = DIP(fp, di_db[file_block]);
return (0);
}
file_block -= NDADDR;
file_block -= UFS_NDADDR;
/*
* nindir[0] = NINDIR
@ -243,12 +243,12 @@ block_map(f, file_block, disk_block_p)
* nindir[2] = NINDIR**3
* etc
*/
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < UFS_NIADDR; level++) {
if (file_block < fp->f_nindir[level])
break;
file_block -= fp->f_nindir[level];
}
if (level == NIADDR) {
if (level == UFS_NIADDR) {
/* Block number too high */
return (EFBIG);
}
@ -545,13 +545,13 @@ ufs_open(upath, f)
int level;
mult = 1;
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < UFS_NIADDR; level++) {
mult *= NINDIR(fs);
fp->f_nindir[level] = mult;
}
}
inumber = ROOTINO;
inumber = UFS_ROOTINO;
if ((rc = read_inode(inumber, f)) != 0)
goto out;
@ -667,7 +667,7 @@ ufs_open(upath, f)
if (*cp != '/')
inumber = parent_inumber;
else
inumber = (ino_t)ROOTINO;
inumber = (ino_t)UFS_ROOTINO;
if ((rc = read_inode(inumber, f)) != 0)
goto out;
@ -704,7 +704,7 @@ ufs_close(f)
if (fp == (struct file *)0)
return (0);
for (level = 0; level < NIADDR; level++) {
for (level = 0; level < UFS_NIADDR; level++) {
if (fp->f_blk[level])
free(fp->f_blk[level]);
}

View File

@ -118,11 +118,10 @@ blockest(union dinode *dp)
sizeest = howmany(DIP(dp, di_size), TP_BSIZE);
if (blkest > sizeest)
blkest = sizeest;
if (DIP(dp, di_size) > sblock->fs_bsize * NDADDR) {
if (DIP(dp, di_size) > sblock->fs_bsize * UFS_NDADDR) {
/* calculate the number of indirect blocks on the dump tape */
blkest +=
howmany(sizeest - NDADDR * sblock->fs_bsize / TP_BSIZE,
TP_NINDIR);
blkest += howmany(sizeest -
UFS_NDADDR * sblock->fs_bsize / TP_BSIZE, TP_NINDIR);
}
return (blkest + 1);
}
@ -192,7 +191,7 @@ mapfiles(ino_t maxino, long *tapesize)
continue;
}
for (i = 0; i < inosused; i++, ino++) {
if (ino < ROOTINO ||
if (ino < UFS_ROOTINO ||
(dp = getino(ino, &mode)) == NULL ||
(mode & IFMT) == 0)
continue;
@ -232,7 +231,7 @@ mapfiles(ino_t maxino, long *tapesize)
* Restore gets very upset if the root is not dumped,
* so ensure that it always is dumped.
*/
SETINO(ROOTINO, dumpinomap);
SETINO(UFS_ROOTINO, dumpinomap);
return (anydirskipped);
}
@ -284,7 +283,7 @@ mapdirs(ino_t maxino, long *tapesize)
else
di.dp2 = dp->dp2;
filesize = DIP(&di, di_size);
for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
for (ret = 0, i = 0; filesize > 0 && i < UFS_NDADDR; i++) {
if (DIP(&di, di_db[i]) != 0)
ret |= searchdir(ino, DIP(&di, di_db[i]),
(long)sblksize(sblock, DIP(&di, di_size),
@ -294,7 +293,7 @@ mapdirs(ino_t maxino, long *tapesize)
else
filesize -= sblock->fs_bsize;
}
for (i = 0; filesize > 0 && i < NIADDR; i++) {
for (i = 0; filesize > 0 && i < UFS_NIADDR; i++) {
if (DIP(&di, di_ib[i]) == 0)
continue;
ret |= dirindir(ino, DIP(&di, di_ib[i]), i, &filesize,
@ -556,8 +555,8 @@ dumpino(union dinode *dp, ino_t ino)
DIP(dp, di_mode) & IFMT);
return;
}
if (DIP(dp, di_size) > NDADDR * sblock->fs_bsize) {
cnt = NDADDR * sblock->fs_frag;
if (DIP(dp, di_size) > UFS_NDADDR * sblock->fs_bsize) {
cnt = UFS_NDADDR * sblock->fs_frag;
last = 0;
} else {
cnt = howmany(DIP(dp, di_size), sblock->fs_fsize);
@ -567,9 +566,9 @@ dumpino(union dinode *dp, ino_t ino)
ufs1_blksout(&dp->dp1.di_db[0], cnt, ino);
else
ufs2_blksout(dp, &dp->dp2.di_db[0], cnt, ino, last);
if ((size = DIP(dp, di_size) - NDADDR * sblock->fs_bsize) <= 0)
if ((size = DIP(dp, di_size) - UFS_NDADDR * sblock->fs_bsize) <= 0)
return;
for (ind_level = 0; ind_level < NIADDR; ind_level++) {
for (ind_level = 0; ind_level < UFS_NIADDR; ind_level++) {
dmpindir(dp, ino, DIP(dp, di_ib[ind_level]), ind_level, &size);
if (size <= 0)
return;
@ -740,8 +739,8 @@ appendextdata(union dinode *dp)
* part of them here, we simply push them entirely into a
* new block rather than putting some here and some later.
*/
if (spcl.c_extsize > NXADDR * sblock->fs_bsize)
blks = howmany(NXADDR * sblock->fs_bsize, TP_BSIZE);
if (spcl.c_extsize > UFS_NXADDR * sblock->fs_bsize)
blks = howmany(UFS_NXADDR * sblock->fs_bsize, TP_BSIZE);
else
blks = howmany(spcl.c_extsize, TP_BSIZE);
if (spcl.c_count + blks > TP_NINDIR)
@ -784,8 +783,8 @@ writeextdata(union dinode *dp, ino_t ino, int added)
* dump them out in a new block, otherwise just dump the data.
*/
if (added == 0) {
if (spcl.c_extsize > NXADDR * sblock->fs_bsize) {
frags = NXADDR * sblock->fs_frag;
if (spcl.c_extsize > UFS_NXADDR * sblock->fs_bsize) {
frags = UFS_NXADDR * sblock->fs_frag;
last = 0;
} else {
frags = howmany(spcl.c_extsize, sblock->fs_fsize);
@ -793,8 +792,8 @@ writeextdata(union dinode *dp, ino_t ino, int added)
}
ufs2_blksout(dp, &dp->dp2.di_extb[0], frags, ino, last);
} else {
if (spcl.c_extsize > NXADDR * sblock->fs_bsize)
blks = howmany(NXADDR * sblock->fs_bsize, TP_BSIZE);
if (spcl.c_extsize > UFS_NXADDR * sblock->fs_bsize)
blks = howmany(UFS_NXADDR * sblock->fs_bsize, TP_BSIZE);
else
blks = howmany(spcl.c_extsize, TP_BSIZE);
tbperdb = sblock->fs_bsize >> tp_bshift;
@ -820,7 +819,7 @@ writeextdata(union dinode *dp, ino_t ino, int added)
* If the extended attributes fall into an indirect block,
* dump it as well.
*/
if ((size = spcl.c_extsize - NXADDR * sblock->fs_bsize) > 0)
if ((size = spcl.c_extsize - UFS_NXADDR * sblock->fs_bsize) > 0)
dmpindir(dp, ino, dp->dp2.di_exti, 0, &size);
}

View File

@ -377,7 +377,7 @@ dump_whole_ufs1_inode(ino_t inode, int level)
/*
* Ok, now prepare for dumping all direct and indirect pointers.
*/
rb=howmany(ino->di_size, sblock.fs_bsize)-NDADDR;
rb = howmany(ino->di_size, sblock.fs_bsize) - UFS_NDADDR;
if(rb>0) {
/*
* Dump single indirect block.
@ -529,7 +529,7 @@ dump_whole_ufs2_inode(ino_t inode, int level)
/*
* Ok, now prepare for dumping all direct and indirect pointers.
*/
rb = howmany(ino->di_size, sblock.fs_bsize) - NDADDR;
rb = howmany(ino->di_size, sblock.fs_bsize) - UFS_NDADDR;
if (rb > 0) {
/*
* Dump single indirect block.

View File

@ -255,7 +255,7 @@ fileerror(ino_t cwd, ino_t ino, const char *errmesg)
pinode(ino);
printf("\n");
getpathname(pathbuf, cwd, ino);
if (ino < ROOTINO || ino > maxino) {
if (ino < UFS_ROOTINO || ino > maxino) {
pfatal("NAME=%s\n", pathbuf);
return;
}
@ -401,24 +401,25 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
if (reply("RECONNECT") == 0)
return (0);
if (lfdir == 0) {
dp = ginode(ROOTINO);
dp = ginode(UFS_ROOTINO);
idesc.id_name = strdup(lfname);
idesc.id_type = DATA;
idesc.id_func = findino;
idesc.id_number = ROOTINO;
idesc.id_number = UFS_ROOTINO;
if ((ckinode(dp, &idesc) & FOUND) != 0) {
lfdir = idesc.id_parent;
} else {
pwarn("NO lost+found DIRECTORY");
if (preen || reply("CREATE")) {
lfdir = allocdir(ROOTINO, (ino_t)0, lfmode);
lfdir = allocdir(UFS_ROOTINO, (ino_t)0, lfmode);
if (lfdir != 0) {
if (makeentry(ROOTINO, lfdir, lfname) != 0) {
if (makeentry(UFS_ROOTINO, lfdir,
lfname) != 0) {
numdirs++;
if (preen)
printf(" (CREATED)\n");
} else {
freedir(lfdir, ROOTINO);
freedir(lfdir, UFS_ROOTINO);
lfdir = 0;
if (preen)
printf("\n");
@ -438,11 +439,11 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
if (reply("REALLOCATE") == 0)
return (0);
oldlfdir = lfdir;
if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
if ((lfdir = allocdir(UFS_ROOTINO, (ino_t)0, lfmode)) == 0) {
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
return (0);
}
if ((changeino(ROOTINO, lfname, lfdir) & ALTERED) == 0) {
if ((changeino(UFS_ROOTINO, lfname, lfdir) & ALTERED) == 0) {
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
return (0);
}
@ -519,8 +520,8 @@ makeentry(ino_t parent, ino_t ino, const char *name)
struct inodesc idesc;
char pathbuf[MAXPATHLEN + 1];
if (parent < ROOTINO || parent >= maxino ||
ino < ROOTINO || ino >= maxino)
if (parent < UFS_ROOTINO || parent >= maxino ||
ino < UFS_ROOTINO || ino >= maxino)
return (0);
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = DATA;
@ -554,7 +555,7 @@ expanddir(union dinode *dp, char *name)
char *cp, firstblk[DIRBLKSIZ];
lastbn = lblkno(&sblock, DIP(dp, di_size));
if (lastbn >= NDADDR - 1 || DIP(dp, di_db[lastbn]) == 0 ||
if (lastbn >= UFS_NDADDR - 1 || DIP(dp, di_db[lastbn]) == 0 ||
DIP(dp, di_size) == 0)
return (0);
if ((newblk = allocblk(sblock.fs_frag)) == 0)
@ -630,7 +631,7 @@ allocdir(ino_t parent, ino_t request, int mode)
dirty(bp);
DIP_SET(dp, di_nlink, 2);
inodirty();
if (ino == ROOTINO) {
if (ino == UFS_ROOTINO) {
inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
cacheino(dp, ino);
return(ino);

View File

@ -854,7 +854,7 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
struct inodesc idesc;
static int busy = 0;
if (curdir == ino && ino == ROOTINO) {
if (curdir == ino && ino == UFS_ROOTINO) {
(void)strcpy(namebuf, "/");
return;
}
@ -872,7 +872,7 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
idesc.id_parent = curdir;
goto namelookup;
}
while (ino != ROOTINO) {
while (ino != UFS_ROOTINO) {
idesc.id_number = ino;
idesc.id_func = findino;
idesc.id_name = strdup("..");
@ -894,7 +894,7 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
ino = idesc.id_number;
}
busy = 0;
if (ino != ROOTINO)
if (ino != UFS_ROOTINO)
*--cp = '?';
memmove(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp));
}

View File

@ -367,7 +367,7 @@ clear_inode(struct ufs2_dinode *dino)
osize = dino->di_extsize;
dino->di_blocks -= extblocks;
dino->di_extsize = 0;
for (i = 0; i < NXADDR; i++) {
for (i = 0; i < UFS_NXADDR; i++) {
if (dino->di_extb[i] == 0)
continue;
blkfree(dino->di_extb[i], sblksize(fs, osize, i));
@ -383,7 +383,7 @@ clear_inode(struct ufs2_dinode *dino)
freeindir(dino->di_ib[level], level);
}
/* deallocate direct blocks and fragments */
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
bn = dino->di_db[i];
if (bn == 0)
continue;

View File

@ -78,7 +78,7 @@ ckinode(union dinode *dp, struct inodesc *idesc)
else
dino.dp2 = dp->dp2;
ndb = howmany(DIP(&dino, di_size), sblock.fs_bsize);
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
idesc->id_lbn++;
if (--ndb == 0 &&
(offset = blkoff(&sblock, DIP(&dino, di_size))) != 0)
@ -115,9 +115,9 @@ ckinode(union dinode *dp, struct inodesc *idesc)
return (ret);
}
idesc->id_numfrags = sblock.fs_frag;
remsize = DIP(&dino, di_size) - sblock.fs_bsize * NDADDR;
remsize = DIP(&dino, di_size) - sblock.fs_bsize * UFS_NDADDR;
sizepb = sblock.fs_bsize;
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < UFS_NIADDR; i++) {
sizepb *= NINDIR(&sblock);
if (DIP(&dino, di_ib[i])) {
idesc->id_blkno = DIP(&dino, di_ib[i]);
@ -284,7 +284,7 @@ ginode(ino_t inumber)
{
ufs2_daddr_t iblk;
if (inumber < ROOTINO || inumber > maxino)
if (inumber < UFS_ROOTINO || inumber > maxino)
errx(EEXIT, "bad inode number %ju to ginode",
(uintmax_t)inumber);
if (startinum == 0 ||
@ -348,9 +348,9 @@ getnextinode(ino_t inumber, int rebuildcg)
mode = DIP(dp, di_mode) & IFMT;
if (mode == 0) {
if (memcmp(dp->dp2.di_db, ufs2_zino.di_db,
NDADDR * sizeof(ufs2_daddr_t)) ||
UFS_NDADDR * sizeof(ufs2_daddr_t)) ||
memcmp(dp->dp2.di_ib, ufs2_zino.di_ib,
NIADDR * sizeof(ufs2_daddr_t)) ||
UFS_NIADDR * sizeof(ufs2_daddr_t)) ||
dp->dp2.di_mode || dp->dp2.di_size)
return (NULL);
goto inodegood;
@ -370,20 +370,20 @@ getnextinode(ino_t inumber, int rebuildcg)
if (DIP(dp, di_size) < (off_t)sblock.fs_maxsymlinklen) {
ndb = howmany(DIP(dp, di_size),
sizeof(ufs2_daddr_t));
if (ndb > NDADDR) {
j = ndb - NDADDR;
if (ndb > UFS_NDADDR) {
j = ndb - UFS_NDADDR;
for (ndb = 1; j > 1; j--)
ndb *= NINDIR(&sblock);
ndb += NDADDR;
ndb += UFS_NDADDR;
}
}
}
for (j = ndb; ndb < NDADDR && j < NDADDR; j++)
for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++)
if (DIP(dp, di_db[j]) != 0)
return (NULL);
for (j = 0, ndb -= NDADDR; ndb > 0; j++)
for (j = 0, ndb -= UFS_NDADDR; ndb > 0; j++)
ndb /= NINDIR(&sblock);
for (; j < NIADDR; j++)
for (; j < UFS_NIADDR; j++)
if (DIP(dp, di_ib[j]) != 0)
return (NULL);
}
@ -449,8 +449,8 @@ cacheino(union dinode *dp, ino_t inumber)
struct inoinfo *inp, **inpp;
int i, blks;
if (howmany(DIP(dp, di_size), sblock.fs_bsize) > NDADDR)
blks = NDADDR + NIADDR;
if (howmany(DIP(dp, di_size), sblock.fs_bsize) > UFS_NDADDR)
blks = UFS_NDADDR + UFS_NIADDR;
else
blks = howmany(DIP(dp, di_size), sblock.fs_bsize);
inp = (struct inoinfo *)
@ -460,16 +460,16 @@ cacheino(union dinode *dp, ino_t inumber)
inpp = &inphead[inumber % dirhash];
inp->i_nexthash = *inpp;
*inpp = inp;
inp->i_parent = inumber == ROOTINO ? ROOTINO : (ino_t)0;
inp->i_parent = inumber == UFS_ROOTINO ? UFS_ROOTINO : (ino_t)0;
inp->i_dotdot = (ino_t)0;
inp->i_number = inumber;
inp->i_isize = DIP(dp, di_size);
inp->i_numblks = blks;
for (i = 0; i < MIN(blks, NDADDR); i++)
for (i = 0; i < MIN(blks, UFS_NDADDR); i++)
inp->i_blks[i] = DIP(dp, di_db[i]);
if (blks > NDADDR)
for (i = 0; i < NIADDR; i++)
inp->i_blks[NDADDR + i] = DIP(dp, di_ib[i]);
if (blks > UFS_NDADDR)
for (i = 0; i < UFS_NIADDR; i++)
inp->i_blks[UFS_NDADDR + i] = DIP(dp, di_ib[i]);
if (inplast == listmax) {
listmax += 100;
inpsort = (struct inoinfo **)realloc((char *)inpsort,
@ -575,7 +575,7 @@ findino(struct inodesc *idesc)
if (dirp->d_ino == 0)
return (KEEPON);
if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) {
dirp->d_ino >= UFS_ROOTINO && dirp->d_ino <= maxino) {
idesc->id_parent = dirp->d_ino;
return (STOP|FOUND);
}
@ -604,7 +604,7 @@ pinode(ino_t ino)
time_t t;
printf(" I=%lu ", (u_long)ino);
if (ino < ROOTINO || ino > maxino)
if (ino < UFS_ROOTINO || ino > maxino)
return;
dp = ginode(ino);
printf(" OWNER=");
@ -662,7 +662,7 @@ allocino(ino_t request, int type)
int cg;
if (request == 0)
request = ROOTINO;
request = UFS_ROOTINO;
else if (inoinfo(request)->ino_state != USTATE)
return (0);
for (ino = request; ino < maxino; ino++)

View File

@ -500,7 +500,7 @@ checkfilesys(char *filesys)
*/
n_ffree = sblock.fs_cstotal.cs_nffree;
n_bfree = sblock.fs_cstotal.cs_nbfree;
files = maxino - ROOTINO - sblock.fs_cstotal.cs_nifree - n_files;
files = maxino - UFS_ROOTINO - sblock.fs_cstotal.cs_nifree - n_files;
blks = n_blks +
sblock.fs_ncg * (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);

View File

@ -163,7 +163,7 @@ pass1(void)
* Scan the allocated inodes.
*/
for (i = 0; i < inosused; i++, inumber++) {
if (inumber < ROOTINO) {
if (inumber < UFS_ROOTINO) {
(void)getnextinode(inumber, rebuildcg);
continue;
}
@ -250,15 +250,15 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
if (mode == 0) {
if ((sblock.fs_magic == FS_UFS1_MAGIC &&
(memcmp(dp->dp1.di_db, ufs1_zino.di_db,
NDADDR * sizeof(ufs1_daddr_t)) ||
UFS_NDADDR * sizeof(ufs1_daddr_t)) ||
memcmp(dp->dp1.di_ib, ufs1_zino.di_ib,
NIADDR * sizeof(ufs1_daddr_t)) ||
UFS_NIADDR * sizeof(ufs1_daddr_t)) ||
dp->dp1.di_mode || dp->dp1.di_size)) ||
(sblock.fs_magic == FS_UFS2_MAGIC &&
(memcmp(dp->dp2.di_db, ufs2_zino.di_db,
NDADDR * sizeof(ufs2_daddr_t)) ||
UFS_NDADDR * sizeof(ufs2_daddr_t)) ||
memcmp(dp->dp2.di_ib, ufs2_zino.di_ib,
NIADDR * sizeof(ufs2_daddr_t)) ||
UFS_NIADDR * sizeof(ufs2_daddr_t)) ||
dp->dp2.di_mode || dp->dp2.di_size))) {
pfatal("PARTIALLY ALLOCATED INODE I=%lu",
(u_long)inumber);
@ -324,24 +324,24 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
else
ndb = howmany(DIP(dp, di_size),
sizeof(ufs2_daddr_t));
if (ndb > NDADDR) {
j = ndb - NDADDR;
if (ndb > UFS_NDADDR) {
j = ndb - UFS_NDADDR;
for (ndb = 1; j > 1; j--)
ndb *= NINDIR(&sblock);
ndb += NDADDR;
ndb += UFS_NDADDR;
}
}
}
for (j = ndb; ndb < NDADDR && j < NDADDR; j++)
for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++)
if (DIP(dp, di_db[j]) != 0) {
if (debug)
printf("bad direct addr[%d]: %ju\n", j,
(uintmax_t)DIP(dp, di_db[j]));
goto unknown;
}
for (j = 0, ndb -= NDADDR; ndb > 0; j++)
for (j = 0, ndb -= UFS_NDADDR; ndb > 0; j++)
ndb /= NINDIR(&sblock);
for (; j < NIADDR; j++)
for (; j < UFS_NIADDR; j++)
if (DIP(dp, di_ib[j]) != 0) {
if (debug)
printf("bad indirect addr: %ju\n",
@ -376,7 +376,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
if (sblock.fs_magic == FS_UFS2_MAGIC && dp->dp2.di_extsize > 0) {
idesc->id_type = ADDR;
ndb = howmany(dp->dp2.di_extsize, sblock.fs_bsize);
for (j = 0; j < NXADDR; j++) {
for (j = 0; j < UFS_NXADDR; j++) {
if (--ndb == 0 &&
(offset = blkoff(&sblock, dp->dp2.di_extsize)) != 0)
idesc->id_numfrags = numfrags(&sblock,

View File

@ -73,7 +73,7 @@ pass1b(void)
got_sigalarm = 0;
}
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
if (inumber < ROOTINO)
if (inumber < UFS_ROOTINO)
continue;
dp = ginode(inumber);
if (dp == NULL)

View File

@ -67,7 +67,7 @@ pass2(void)
int i;
char pathbuf[MAXPATHLEN + 1];
switch (inoinfo(ROOTINO)->ino_state) {
switch (inoinfo(UFS_ROOTINO)->ino_state) {
case USTATE:
pfatal("ROOT INODE UNALLOCATED");
@ -75,15 +75,16 @@ pass2(void)
ckfini(0);
exit(EEXIT);
}
if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
if (allocdir(UFS_ROOTINO, UFS_ROOTINO, 0755) != UFS_ROOTINO)
errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
break;
case DCLEAR:
pfatal("DUPS/BAD IN ROOT INODE");
if (reply("REALLOCATE")) {
freeino(ROOTINO);
if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
freeino(UFS_ROOTINO);
if (allocdir(UFS_ROOTINO, UFS_ROOTINO, 0755) !=
UFS_ROOTINO)
errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
break;
}
@ -98,8 +99,9 @@ pass2(void)
case FZLINK:
pfatal("ROOT INODE NOT DIRECTORY");
if (reply("REALLOCATE")) {
freeino(ROOTINO);
if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
freeino(UFS_ROOTINO);
if (allocdir(UFS_ROOTINO, UFS_ROOTINO, 0755) !=
UFS_ROOTINO)
errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
break;
}
@ -107,7 +109,7 @@ pass2(void)
ckfini(0);
exit(EEXIT);
}
dp = ginode(ROOTINO);
dp = ginode(UFS_ROOTINO);
DIP_SET(dp, di_mode, DIP(dp, di_mode) & ~IFMT);
DIP_SET(dp, di_mode, DIP(dp, di_mode) | IFDIR);
inodirty();
@ -119,11 +121,11 @@ pass2(void)
default:
errx(EEXIT, "BAD STATE %d FOR ROOT INODE",
inoinfo(ROOTINO)->ino_state);
inoinfo(UFS_ROOTINO)->ino_state);
}
inoinfo(ROOTINO)->ino_state = DFOUND;
inoinfo(WINO)->ino_state = FSTATE;
inoinfo(WINO)->ino_type = DT_WHT;
inoinfo(UFS_ROOTINO)->ino_state = DFOUND;
inoinfo(UFS_WINO)->ino_state = FSTATE;
inoinfo(UFS_WINO)->ino_type = DT_WHT;
/*
* Sort the directory list into disk block order.
*/
@ -182,11 +184,12 @@ pass2(void)
memset(dp, 0, sizeof(struct ufs2_dinode));
DIP_SET(dp, di_mode, IFDIR);
DIP_SET(dp, di_size, inp->i_isize);
for (i = 0; i < MIN(inp->i_numblks, NDADDR); i++)
for (i = 0; i < MIN(inp->i_numblks, UFS_NDADDR); i++)
DIP_SET(dp, di_db[i], inp->i_blks[i]);
if (inp->i_numblks > NDADDR)
for (i = 0; i < NIADDR; i++)
DIP_SET(dp, di_ib[i], inp->i_blks[NDADDR + i]);
if (inp->i_numblks > UFS_NDADDR)
for (i = 0; i < UFS_NIADDR; i++)
DIP_SET(dp, di_ib[i],
inp->i_blks[UFS_NDADDR + i]);
curino.id_number = inp->i_number;
curino.id_parent = inp->i_parent;
(void)ckinode(dp, &curino);
@ -411,10 +414,10 @@ pass2check(struct inodesc *idesc)
if (dirp->d_ino > maxino) {
fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
n = reply("REMOVE");
} else if (((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
(dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
} else if (((dirp->d_ino == UFS_WINO && dirp->d_type != DT_WHT) ||
(dirp->d_ino != UFS_WINO && dirp->d_type == DT_WHT))) {
fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
dirp->d_ino = WINO;
dirp->d_ino = UFS_WINO;
dirp->d_type = DT_WHT;
if (reply("FIX") == 1)
ret |= ALTERED;

View File

@ -68,7 +68,7 @@ pass3(void)
}
inp = inpsort[inpindex];
state = inoinfo(inp->i_number)->ino_state;
if (inp->i_number == ROOTINO ||
if (inp->i_number == UFS_ROOTINO ||
(inp->i_parent != 0 && !S_IS_DUNFOUND(state)))
continue;
if (state == DCLEAR)
@ -81,7 +81,7 @@ pass3(void)
*/
if ((preen || bkgrdflag) &&
resolved && usedsoftdep && S_IS_DUNFOUND(state)) {
if (inp->i_dotdot >= ROOTINO)
if (inp->i_dotdot >= UFS_ROOTINO)
inoinfo(inp->i_dotdot)->ino_linkcnt++;
continue;
}

View File

@ -71,7 +71,7 @@ pass4(void)
}
inumber = cg * sblock.fs_ipg;
for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
if (inumber < ROOTINO)
if (inumber < UFS_ROOTINO)
continue;
idesc.id_number = inumber;
switch (inoinfo(inumber)->ino_state) {

View File

@ -68,7 +68,7 @@ pass5(void)
struct cg *cg, *newcg = (struct cg *)buf;
struct bufarea *cgbp;
inoinfo(WINO)->ino_state = USTATE;
inoinfo(UFS_WINO)->ino_state = USTATE;
memset(newcg, 0, (size_t)fs->fs_cgsize);
newcg->cg_niblk = fs->fs_ipg;
if (cvtlevel >= 3) {
@ -234,14 +234,14 @@ pass5(void)
break;
default:
if (j < (int)ROOTINO)
if (j < (int)UFS_ROOTINO)
break;
errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
inoinfo(j)->ino_state, j);
}
}
if (c == 0)
for (i = 0; i < (int)ROOTINO; i++) {
for (i = 0; i < (int)UFS_ROOTINO; i++) {
setbit(cg_inosused(newcg), i);
newcg->cg_cs.cs_nifree--;
}

View File

@ -758,7 +758,7 @@ ino_blkatoff(union dinode *ip, ino_t ino, ufs_lbn_t lbn, int *frags)
/*
* Handle extattr blocks first.
*/
if (lbn < 0 && lbn >= -NXADDR) {
if (lbn < 0 && lbn >= -UFS_NXADDR) {
lbn = -1 - lbn;
if (lbn > lblkno(fs, ip->dp2.di_extsize - 1))
return (0);
@ -771,13 +771,13 @@ ino_blkatoff(union dinode *ip, ino_t ino, ufs_lbn_t lbn, int *frags)
if (DIP(ip, di_mode) == IFLNK &&
DIP(ip, di_size) < fs->fs_maxsymlinklen)
return (0);
if (lbn >= 0 && lbn < NDADDR) {
if (lbn >= 0 && lbn < UFS_NDADDR) {
*frags = numfrags(fs, sblksize(fs, DIP(ip, di_size), lbn));
return (DIP(ip, di_db[lbn]));
}
*frags = fs->fs_frag;
for (i = 0, tmpval = NINDIR(fs), cur = NDADDR; i < NIADDR; i++,
for (i = 0, tmpval = NINDIR(fs), cur = UFS_NDADDR; i < UFS_NIADDR; i++,
tmpval *= NINDIR(fs), cur = next) {
next = cur + tmpval;
if (lbn == -cur - i)
@ -1037,7 +1037,7 @@ ino_visit(union dinode *ip, ino_t ino, ino_visitor visitor, int flags)
fragcnt = 0;
if ((flags & VISIT_EXT) &&
fs->fs_magic == FS_UFS2_MAGIC && ip->dp2.di_extsize) {
for (i = 0; i < NXADDR; i++) {
for (i = 0; i < UFS_NXADDR; i++) {
if (ip->dp2.di_extb[i] == 0)
continue;
frags = sblksize(fs, ip->dp2.di_extsize, i);
@ -1050,7 +1050,7 @@ ino_visit(union dinode *ip, ino_t ino, ino_visitor visitor, int flags)
if (mode == IFBLK || mode == IFCHR ||
(mode == IFLNK && size < fs->fs_maxsymlinklen))
return (fragcnt);
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
if (DIP(ip, di_db[i]) == 0)
continue;
frags = sblksize(fs, size, i);
@ -1063,7 +1063,7 @@ ino_visit(union dinode *ip, ino_t ino, ino_visitor visitor, int flags)
* real pointers to them.
*/
flags |= VISIT_ROOT;
for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR; i++,
for (i = 0, tmpval = NINDIR(fs), lbn = UFS_NDADDR; i < UFS_NIADDR; i++,
lbn = nextlbn) {
nextlbn = lbn + tmpval;
tmpval *= NINDIR(fs);
@ -1123,7 +1123,7 @@ ino_adjblks(struct suj_ino *sino)
* to the size in the inode or the maximum size permitted by
* populated indirects.
*/
if (visitlbn >= NDADDR) {
if (visitlbn >= UFS_NDADDR) {
isize = DIP(ip, di_size);
size = lblktosize(fs, visitlbn + 1);
if (isize > size)
@ -1161,7 +1161,7 @@ blk_free_lbn(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn, int frags, int follow)
mask = blk_freemask(blk, ino, lbn, frags);
resid = 0;
if (lbn <= -NDADDR && follow && mask == 0)
if (lbn <= -UFS_NDADDR && follow && mask == 0)
indir_visit(ino, lbn, blk, &resid, blk_free_visit, VISIT_INDIR);
else
blk_free(blk, mask, frags);
@ -1253,7 +1253,7 @@ ino_free_children(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
dp = (struct direct *)&block[0];
for (dpoff = 0; dpoff < size && dp->d_reclen; dpoff += dp->d_reclen) {
dp = (struct direct *)&block[dpoff];
if (dp->d_ino == 0 || dp->d_ino == WINO)
if (dp->d_ino == 0 || dp->d_ino == UFS_WINO)
continue;
if (dp->d_namlen == 1 && dp->d_name[0] == '.')
continue;
@ -1278,8 +1278,8 @@ ino_reclaim(union dinode *ip, ino_t ino, int mode)
{
uint32_t gen;
if (ino == ROOTINO)
err_suj("Attempting to free ROOTINO\n");
if (ino == UFS_ROOTINO)
err_suj("Attempting to free UFS_ROOTINO\n");
if (debug)
printf("Truncating and freeing ino %ju, nlink %d, mode %o\n",
(uintmax_t)ino, DIP(ip, di_nlink), DIP(ip, di_mode));
@ -1540,7 +1540,7 @@ ino_trunc(ino_t ino, off_t size)
if (size > cursize)
size = cursize;
lastlbn = lblkno(fs, blkroundup(fs, size));
for (i = lastlbn; i < NDADDR; i++) {
for (i = lastlbn; i < UFS_NDADDR; i++) {
if (DIP(ip, di_db[i]) == 0)
continue;
frags = sblksize(fs, cursize, i);
@ -1551,7 +1551,7 @@ ino_trunc(ino_t ino, off_t size)
/*
* Follow indirect blocks, freeing anything required.
*/
for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR; i++,
for (i = 0, tmpval = NINDIR(fs), lbn = UFS_NDADDR; i < UFS_NIADDR; i++,
lbn = nextlbn) {
nextlbn = lbn + tmpval;
tmpval *= NINDIR(fs);
@ -1583,7 +1583,7 @@ ino_trunc(ino_t ino, off_t size)
* If we're truncating direct blocks we have to adjust frags
* accordingly.
*/
if (visitlbn < NDADDR && totalfrags) {
if (visitlbn < UFS_NDADDR && totalfrags) {
long oldspace, newspace;
bn = DIP(ip, di_db[visitlbn]);
@ -2655,7 +2655,8 @@ suj_find(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
return;
bytes = lfragtosize(fs, frags);
if (bread(disk, fsbtodb(fs, blk), block, bytes) <= 0)
err_suj("Failed to read ROOTINO directory block %jd\n", blk);
err_suj("Failed to read UFS_ROOTINO directory block %jd\n",
blk);
for (off = 0; off < bytes; off += dp->d_reclen) {
dp = (struct direct *)&block[off];
if (dp->d_reclen == 0)
@ -2708,9 +2709,9 @@ suj_check(const char *filesys)
/*
* Find the journal inode.
*/
ip = ino_read(ROOTINO);
ip = ino_read(UFS_ROOTINO);
sujino = 0;
ino_visit(ip, ROOTINO, suj_find, 0);
ino_visit(ip, UFS_ROOTINO, suj_find, 0);
if (sujino == 0) {
printf("Journal inode removed. Use tunefs to re-create.\n");
sblock.fs_flags &= ~FS_SUJ;

View File

@ -231,8 +231,8 @@ cmdloop(void)
EditLine *elptr;
HistEvent he;
curinode = ginode(ROOTINO);
curinum = ROOTINO;
curinode = ginode(UFS_ROOTINO);
curinum = UFS_ROOTINO;
printactive(0);
hist = history_init();
@ -299,11 +299,11 @@ union dinode *curinode;
ino_t curinum, ocurrent;
#define GETINUM(ac,inum) inum = strtoul(argv[ac], &cp, 0); \
if (inum < ROOTINO || inum > maxino || cp == argv[ac] || *cp != '\0' ) { \
if (inum < UFS_ROOTINO || inum > maxino || cp == argv[ac] || *cp != '\0' ) { \
printf("inode %ju out of range; range is [%ju,%ju]\n", \
(uintmax_t)inum, (uintmax_t)ROOTINO, (uintmax_t)maxino); \
(uintmax_t)inum, (uintmax_t)UFS_ROOTINO, (uintmax_t)maxino);\
return 1; \
}
}
/*
* Focus on given inode number
@ -486,8 +486,8 @@ CMDFUNCSTART(findblk)
inosused = sblock.fs_ipg;
for (; inosused > 0; inum++, inosused--) {
/* Skip magic inodes: 0, WINO, ROOTINO. */
if (inum < ROOTINO)
/* Skip magic inodes: 0, UFS_WINO, UFS_ROOTINO. */
if (inum < UFS_ROOTINO)
continue;
/*
* Check if the block we are looking for is just an inode block.
@ -531,10 +531,10 @@ CMDFUNCSTART(findblk)
}
/* Look through direct data blocks. */
if (is_ufs2 ?
find_blks64(curinode->dp2.di_db, NDADDR, wantedblk64) :
find_blks32(curinode->dp1.di_db, NDADDR, wantedblk32))
find_blks64(curinode->dp2.di_db, UFS_NDADDR, wantedblk64) :
find_blks32(curinode->dp1.di_db, UFS_NDADDR, wantedblk32))
goto end;
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < UFS_NIADDR; i++) {
/*
* Does the block we are looking for belongs to the
* indirect blocks?
@ -726,8 +726,8 @@ CMDFUNCSTART(focusname)
ocurrent = curinum;
if (argv[1][0] == '/') {
curinum = ROOTINO;
curinode = ginode(ROOTINO);
curinum = UFS_ROOTINO;
curinode = ginode(UFS_ROOTINO);
} else {
if (!checkactivedir())
return 1;

View File

@ -292,13 +292,13 @@ printblocks(ino_t inum, union dinode *dp)
printf("Blocks for inode %ju:\n", (uintmax_t)inum);
printf("Direct blocks:\n");
ndb = howmany(DIP(dp, di_size), sblock.fs_bsize);
for (i = 0; i < NDADDR && i < ndb; i++) {
for (i = 0; i < UFS_NDADDR && i < ndb; i++) {
if (i > 0)
printf(", ");
blkno = DIP(dp, di_db[i]);
printf("%jd", (intmax_t)blkno);
}
if (ndb <= NDADDR) {
if (ndb <= UFS_NDADDR) {
offset = blkoff(&sblock, DIP(dp, di_size));
if (offset != 0) {
nfrags = numfrags(&sblock, fragroundup(&sblock, offset));
@ -306,14 +306,14 @@ printblocks(ino_t inum, union dinode *dp)
}
}
putchar('\n');
if (ndb <= NDADDR)
if (ndb <= UFS_NDADDR)
return;
bufp = malloc((unsigned int)sblock.fs_bsize);
if (bufp == NULL)
errx(EEXIT, "cannot allocate indirect block buffer");
printf("Indirect blocks:\n");
for (i = 0; i < NIADDR; i++)
for (i = 0; i < UFS_NIADDR; i++)
printindir(DIP(dp, di_ib[i]), i, bufp);
free(bufp);
}

View File

@ -261,7 +261,7 @@ fsirand(char *device)
dp1 = &((struct ufs1_dinode *)inodebuf)[n];
else
dp2 = &((struct ufs2_dinode *)inodebuf)[n];
if (inumber >= ROOTINO) {
if (inumber >= UFS_ROOTINO) {
if (printonly)
(void)printf("ino %ju gen %08x\n",
(uintmax_t)inumber,

View File

@ -694,11 +694,11 @@ dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino)
ino->di_ctimensec);
remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
for (ictr = 0; ictr < MIN(UFS_NDADDR, remaining_blocks); ictr++) {
fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr,
ino->di_db[ictr]);
}
remaining_blocks -= NDADDR;
remaining_blocks -= UFS_NDADDR;
if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
ino->di_ib[0]);
@ -768,14 +768,14 @@ dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino)
fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
fprintf(dbg_log, "extsize u_int32_t 0x%08x\n", ino->di_extsize);
/* XXX: What do we do with di_extb[NXADDR]? */
/* XXX: What do we do with di_extb[UFS_NXADDR]? */
remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
for (ictr = 0; ictr < MIN(UFS_NDADDR, remaining_blocks); ictr++) {
fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr,
ino->di_db[ictr]);
}
remaining_blocks -= NDADDR;
remaining_blocks -= UFS_NDADDR;
if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n",
ino->di_ib[0]);

View File

@ -388,7 +388,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
if (cylno == 0)
for (ino = 0; ino < ROOTINO; ino++) {
for (ino = 0; ino < UFS_ROOTINO; ino++) {
setbit(cg_inosused(&acg), ino);
acg.cg_cs.cs_nifree--;
}

View File

@ -273,7 +273,7 @@ mkfs(struct partition *pp, char *fsys)
sblock.fs_sblockloc = SBLOCK_UFS1;
sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
sizeof(ufs1_daddr_t));
sblock.fs_old_inodefmt = FS_44INODEFMT;
sblock.fs_old_cgoffset = 0;
@ -292,7 +292,7 @@ mkfs(struct partition *pp, char *fsys)
sblock.fs_sblockloc = SBLOCK_UFS2;
sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
sizeof(ufs2_daddr_t));
}
sblock.fs_sblkno =
@ -301,8 +301,8 @@ mkfs(struct partition *pp, char *fsys)
sblock.fs_cblkno = 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 * NDADDR - 1;
for (sizepb = sblock.fs_bsize, i = 0; i < NIADDR; i++) {
sblock.fs_maxfilesize = sblock.fs_bsize * UFS_NDADDR - 1;
for (sizepb = sblock.fs_bsize, i = 0; i < UFS_NIADDR; i++) {
sizepb *= NINDIR(&sblock);
sblock.fs_maxfilesize += sizepb;
}
@ -473,7 +473,8 @@ mkfs(struct partition *pp, char *fsys)
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_nifree =
sblock.fs_ncg * sblock.fs_ipg - UFS_ROOTINO;
sblock.fs_cstotal.cs_ndir = 0;
sblock.fs_dsize -= csfrags;
sblock.fs_time = utime;
@ -696,7 +697,7 @@ initcg(int cylno, time_t utime)
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
if (cylno == 0)
for (i = 0; i < (long)ROOTINO; i++) {
for (i = 0; i < (long)UFS_ROOTINO; i++) {
setbit(cg_inosused(&acg), i);
acg.cg_cs.cs_nifree--;
}
@ -808,16 +809,16 @@ initcg(int cylno, time_t utime)
#define ROOTLINKCNT 3
static struct direct root_dir[] = {
{ ROOTINO, sizeof(struct direct), DT_DIR, 1, "." },
{ ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
{ ROOTINO + 1, sizeof(struct direct), DT_DIR, 5, ".snap" },
{ UFS_ROOTINO, sizeof(struct direct), DT_DIR, 1, "." },
{ UFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
{ UFS_ROOTINO + 1, sizeof(struct direct), DT_DIR, 5, ".snap" },
};
#define SNAPLINKCNT 2
static struct direct snap_dir[] = {
{ ROOTINO + 1, sizeof(struct direct), DT_DIR, 1, "." },
{ ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
{ UFS_ROOTINO + 1, sizeof(struct direct), DT_DIR, 1, "." },
{ UFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
};
void
@ -854,7 +855,7 @@ fsinit(time_t utime)
btodb(fragroundup(&sblock, node.dp1.di_size));
wtfs(fsbtodb(&sblock, node.dp1.di_db[0]), sblock.fs_fsize,
iobuf);
iput(&node, ROOTINO);
iput(&node, UFS_ROOTINO);
if (!nflag) {
/*
* create the .snap directory
@ -869,7 +870,7 @@ fsinit(time_t utime)
btodb(fragroundup(&sblock, node.dp1.di_size));
wtfs(fsbtodb(&sblock, node.dp1.di_db[0]),
sblock.fs_fsize, iobuf);
iput(&node, ROOTINO + 1);
iput(&node, UFS_ROOTINO + 1);
}
} else {
/*
@ -890,7 +891,7 @@ fsinit(time_t utime)
btodb(fragroundup(&sblock, node.dp2.di_size));
wtfs(fsbtodb(&sblock, node.dp2.di_db[0]), sblock.fs_fsize,
iobuf);
iput(&node, ROOTINO);
iput(&node, UFS_ROOTINO);
if (!nflag) {
/*
* create the .snap directory
@ -905,7 +906,7 @@ fsinit(time_t utime)
btodb(fragroundup(&sblock, node.dp2.di_size));
wtfs(fsbtodb(&sblock, node.dp2.di_db[0]),
sblock.fs_fsize, iobuf);
iput(&node, ROOTINO + 1);
iput(&node, UFS_ROOTINO + 1);
}
}
}

View File

@ -314,8 +314,8 @@ count_su_blocks(void)
}
debug("bad segment needs %#jx", blk);
if (blk >= NDADDR) {
printf("nandfs: file too big (%jd > %d)\n", blk, NDADDR);
if (blk >= NANDFS_NDADDR) {
printf("nandfs: file too big (%jd > %d)\n", blk, NANDFS_NDADDR);
exit(2);
}

View File

@ -371,7 +371,8 @@ chkquota(char *specname, struct quotafile *qfu, struct quotafile *qfg)
continue;
}
for (i = 0; i < inosused; i++, ino++) {
if ((dp = getnextinode(ino)) == NULL || ino < ROOTINO ||
if ((dp = getnextinode(ino)) == NULL ||
ino < UFS_ROOTINO ||
(mode = DIP(dp, di_mode) & IFMT) == 0)
continue;
/*

View File

@ -272,7 +272,7 @@ treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int))
}
/*
* Lookup a pathname which is always assumed to start from the ROOTINO.
* Lookup a pathname which is always assumed to start from the UFS_ROOTINO.
*/
struct direct *
pathsearch(const char *pathname)
@ -283,7 +283,7 @@ pathsearch(const char *pathname)
strcpy(buffer, pathname);
path = buffer;
ino = ROOTINO;
ino = UFS_ROOTINO;
while (*path == '/')
path++;
dp = NULL;
@ -632,7 +632,7 @@ setdirmodes(int flags)
ep->e_flags &= ~NEW;
continue;
}
if (node.ino == ROOTINO &&
if (node.ino == UFS_ROOTINO &&
reply("set owner/mode for '.'") == FAIL)
continue;
}

View File

@ -505,7 +505,7 @@ printlist(char *name, char *basename)
dp = pathsearch(name);
if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
(!vflag && dp->d_ino == WINO))
(!vflag && dp->d_ino == UFS_WINO))
return;
if ((dirp = rst_opendir(name)) == NULL) {
entries = 1;
@ -540,7 +540,7 @@ printlist(char *name, char *basename)
break;
if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0)
continue;
if (!vflag && (dp->d_ino == WINO ||
if (!vflag && (dp->d_ino == UFS_WINO ||
strcmp(dp->d_name, ".") == 0 ||
strcmp(dp->d_name, "..") == 0))
continue;
@ -644,7 +644,7 @@ formatf(struct afile *list, int nentry)
width = 0;
haveprefix = 0;
havepostfix = 0;
bigino = ROOTINO;
bigino = UFS_ROOTINO;
endlist = &list[nentry];
for (fp = &list[0]; fp < endlist; fp++) {
if (bigino < fp->fnum)
@ -713,7 +713,7 @@ glob_readdir(void *dirp)
static struct dirent adirent;
while ((dp = rst_readdir(dirp)) != NULL) {
if (!vflag && dp->d_ino == WINO)
if (!vflag && dp->d_ino == UFS_WINO)
continue;
if (dflag || TSTINO(dp->d_ino, dumpmap))
break;
@ -736,7 +736,7 @@ glob_stat(const char *name, struct stat *stp)
dp = pathsearch(name);
if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
(!vflag && dp->d_ino == WINO))
(!vflag && dp->d_ino == UFS_WINO))
return (-1);
if (inodetype(dp->d_ino) == NODE)
stp->st_mode = IFDIR;

View File

@ -212,7 +212,7 @@ main(int argc, char *argv[])
extractdirs(1);
removeoldleaves();
vprintf(stdout, "Calculate node updates.\n");
treescan(".", ROOTINO, nodeupdates);
treescan(".", UFS_ROOTINO, nodeupdates);
findunreflinks();
removeoldnodes();
} else {
@ -223,7 +223,7 @@ main(int argc, char *argv[])
initsymtable((char *)0);
extractdirs(1);
vprintf(stdout, "Calculate extraction list.\n");
treescan(".", ROOTINO, nodeupdates);
treescan(".", UFS_ROOTINO, nodeupdates);
}
createleaves(symtbl);
createlinks();
@ -231,7 +231,7 @@ main(int argc, char *argv[])
checkrestore();
if (dflag) {
vprintf(stdout, "Verify the directory structure\n");
treescan(".", ROOTINO, verifyfile);
treescan(".", UFS_ROOTINO, verifyfile);
}
dumpsymtable(symtbl, (long)1);
break;

View File

@ -81,7 +81,7 @@ addfile(char *name, ino_t ino, int type)
dprintf(stdout, "%s: not on the tape\n", name);
return (descend);
}
if (ino == WINO && command == 'i' && !vflag)
if (ino == UFS_WINO && command == 'i' && !vflag)
return (descend);
if (!mflag) {
(void) sprintf(buf, "./%ju", (uintmax_t)ino);
@ -156,7 +156,7 @@ removeoldleaves(void)
ino_t i, mydirino;
vprintf(stdout, "Mark entries to be removed.\n");
if ((ep = lookupino(WINO))) {
if ((ep = lookupino(UFS_WINO))) {
vprintf(stdout, "Delete whiteouts\n");
for ( ; ep != NULL; ep = nextep) {
nextep = ep->e_links;
@ -172,7 +172,7 @@ removeoldleaves(void)
freeentry(ep);
}
}
for (i = ROOTINO + 1; i < maxino; i++) {
for (i = UFS_ROOTINO + 1; i < maxino; i++) {
ep = lookupino(i);
if (ep == NULL)
continue;
@ -516,7 +516,7 @@ findunreflinks(void)
ino_t i;
vprintf(stdout, "Find unreferenced names.\n");
for (i = ROOTINO; i < maxino; i++) {
for (i = UFS_ROOTINO; i < maxino; i++) {
ep = lookupino(i);
if (ep == NULL || ep->e_type == LEAF || TSTINO(i, dumpmap) == 0)
continue;
@ -599,7 +599,7 @@ createleaves(char *symtabfile)
vprintf(stdout, "Extract new leaves.\n");
dumpsymtable(symtabfile, volno);
}
first = lowerbnd(ROOTINO);
first = lowerbnd(UFS_ROOTINO);
curvol = volno;
while (curfile.ino < maxino) {
first = lowerbnd(first);
@ -677,7 +677,7 @@ createfiles(void)
getvol((long)1);
skipmaps();
skipdirs();
first = lowerbnd(ROOTINO);
first = lowerbnd(UFS_ROOTINO);
last = upperbnd(maxino - 1);
for (;;) {
curvol = volno;
@ -780,7 +780,7 @@ createlinks(void)
ino_t i;
char name[BUFSIZ];
if ((ep = lookupino(WINO))) {
if ((ep = lookupino(UFS_WINO))) {
vprintf(stdout, "Add whiteouts\n");
for ( ; ep != NULL; ep = ep->e_links) {
if ((ep->e_flags & NEW) == 0)
@ -790,7 +790,7 @@ createlinks(void)
}
}
vprintf(stdout, "Add links\n");
for (i = ROOTINO; i < maxino; i++) {
for (i = UFS_ROOTINO; i < maxino; i++) {
ep = lookupino(i);
if (ep == NULL)
continue;
@ -820,7 +820,7 @@ checkrestore(void)
ino_t i;
vprintf(stdout, "Check the symbol table.\n");
for (i = WINO; i < maxino; i++) {
for (i = UFS_WINO; i < maxino; i++) {
for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
ep->e_flags &= ~KEEP;
if (ep->e_type == NODE)

View File

@ -84,7 +84,7 @@ lookupino(ino_t inum)
{
struct entry *ep;
if (inum < WINO || inum >= maxino)
if (inum < UFS_WINO || inum >= maxino)
return (NULL);
for (ep = entry[inum % entrytblsize]; ep != NULL; ep = ep->e_next)
if (ep->e_ino == inum)
@ -100,7 +100,7 @@ addino(ino_t inum, struct entry *np)
{
struct entry **epp;
if (inum < WINO || inum >= maxino)
if (inum < UFS_WINO || inum >= maxino)
panic("addino: out of range %ju\n", (uintmax_t)inum);
epp = &entry[inum % entrytblsize];
np->e_ino = inum;
@ -121,7 +121,7 @@ deleteino(ino_t inum)
struct entry *next;
struct entry **prev;
if (inum < WINO || inum >= maxino)
if (inum < UFS_WINO || inum >= maxino)
panic("deleteino: out of range %ju\n", (uintmax_t)inum);
prev = &entry[inum % entrytblsize];
for (next = *prev; next != NULL; next = next->e_next) {
@ -146,7 +146,7 @@ lookupname(char *name)
char buf[MAXPATHLEN];
cp = name;
for (ep = lookupino(ROOTINO); ep != NULL; ep = ep->e_entries) {
for (ep = lookupino(UFS_ROOTINO); ep != NULL; ep = ep->e_entries) {
for (np = buf; *cp != '/' && *cp != '\0' &&
np < &buf[sizeof(buf)]; )
*np++ = *cp++;
@ -198,7 +198,7 @@ myname(struct entry *ep)
for (cp = &namebuf[MAXPATHLEN - 2]; cp > &namebuf[ep->e_namlen]; ) {
cp -= ep->e_namlen;
memmove(cp, ep->e_name, (long)ep->e_namlen);
if (ep == lookupino(ROOTINO))
if (ep == lookupino(UFS_ROOTINO))
return (cp);
*(--cp) = '/';
ep = ep->e_parent;
@ -233,12 +233,12 @@ addentry(char *name, ino_t inum, int type)
np->e_type = type & ~LINK;
ep = lookupparent(name);
if (ep == NULL) {
if (inum != ROOTINO || lookupino(ROOTINO) != NULL)
if (inum != UFS_ROOTINO || lookupino(UFS_ROOTINO) != NULL)
panic("bad name to addentry %s\n", name);
np->e_name = savename(name);
np->e_namlen = strlen(name);
np->e_parent = np;
addino(ROOTINO, np);
addino(UFS_ROOTINO, np);
return (np);
}
np->e_name = savename(strrchr(name, '/') + 1);
@ -458,7 +458,7 @@ dumpsymtable(char *filename, long checkpt)
* Assign indices to each entry
* Write out the string entries
*/
for (i = WINO; i <= maxino; i++) {
for (i = UFS_WINO; i <= maxino; i++) {
for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
ep->e_index = mynum++;
(void) fwrite(ep->e_name, sizeof(char),
@ -470,7 +470,7 @@ dumpsymtable(char *filename, long checkpt)
*/
tep = &temp;
stroff = 0;
for (i = WINO; i <= maxino; i++) {
for (i = UFS_WINO; i <= maxino; i++) {
for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
memmove(tep, ep, (long)sizeof(struct entry));
tep->e_name = (char *)stroff;
@ -538,7 +538,7 @@ initsymtable(char *filename)
entry = calloc((unsigned)entrytblsize, sizeof(struct entry *));
if (entry == NULL)
panic("no memory for entry table\n");
ep = addentry(".", ROOTINO, NODE);
ep = addentry(".", UFS_ROOTINO, NODE);
ep->e_flags |= NEW;
return;
}

View File

@ -301,7 +301,7 @@ setup(void)
* whiteout inode exists, so that the whiteout entries can be
* extracted.
*/
SETINO(WINO, dumpmap);
SETINO(UFS_WINO, dumpmap);
/* 'r' restores don't call getvol() for tape 1, so mark it as read. */
if (command == 'r')
tapesread = 1;

View File

@ -303,7 +303,7 @@ upperbnd(ino_t start)
{
struct entry *ep;
for ( ; start > ROOTINO; start--) {
for ( ; start > UFS_ROOTINO; start--) {
ep = lookupino(start);
if (ep == NULL || ep->e_type == NODE)
continue;

View File

@ -671,7 +671,7 @@ dir_search(ufs2_daddr_t blk, int bytes)
}
/*
* Search in the ROOTINO for the SUJ_FILE. If it exists we can not enable
* Search in the UFS_ROOTINO for the SUJ_FILE. If it exists we can not enable
* journaling.
*/
static ino_t
@ -684,18 +684,18 @@ journal_findfile(void)
void *ip;
int i;
if (getino(&disk, &ip, ROOTINO, &mode) != 0) {
if (getino(&disk, &ip, UFS_ROOTINO, &mode) != 0) {
warn("Failed to get root inode");
return (-1);
}
dp2 = ip;
dp1 = ip;
if (sblock.fs_magic == FS_UFS1_MAGIC) {
if ((off_t)dp1->di_size >= lblktosize(&sblock, NDADDR)) {
warnx("ROOTINO extends beyond direct blocks.");
if ((off_t)dp1->di_size >= lblktosize(&sblock, UFS_NDADDR)) {
warnx("UFS_ROOTINO extends beyond direct blocks.");
return (-1);
}
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
if (dp1->di_db[i] == 0)
break;
if ((ino = dir_search(dp1->di_db[i],
@ -703,11 +703,11 @@ journal_findfile(void)
return (ino);
}
} else {
if ((off_t)dp2->di_size >= lblktosize(&sblock, NDADDR)) {
warnx("ROOTINO extends beyond direct blocks.");
if ((off_t)dp2->di_size >= lblktosize(&sblock, UFS_NDADDR)) {
warnx("UFS_ROOTINO extends beyond direct blocks.");
return (-1);
}
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
if (dp2->di_db[i] == 0)
break;
if ((ino = dir_search(dp2->di_db[i],
@ -787,7 +787,7 @@ dir_extend(ufs2_daddr_t blk, ufs2_daddr_t nblk, off_t size, ino_t ino)
}
/*
* Insert the journal file into the ROOTINO directory. We always extend the
* Insert the journal file into the UFS_ROOTINO directory. We always extend the
* last frag
*/
static int
@ -803,7 +803,7 @@ journal_insertfile(ino_t ino)
int mode;
int off;
if (getino(&disk, &ip, ROOTINO, &mode) != 0) {
if (getino(&disk, &ip, UFS_ROOTINO, &mode) != 0) {
warn("Failed to get root inode");
sbdirty();
return (-1);
@ -816,7 +816,7 @@ journal_insertfile(ino_t ino)
if (nblk <= 0)
return (-1);
/*
* For simplicity sake we aways extend the ROOTINO into a new
* For simplicity sake we aways extend the UFS_ROOTINO into a new
* directory block rather than searching for space and inserting
* into an existing block. However, if the rootino has frags
* have to free them and extend the block.
@ -1036,7 +1036,7 @@ journal_alloc(int64_t size)
dp2->di_ctime = utime;
dp2->di_birthtime = utime;
}
for (i = 0; i < NDADDR && resid; i++, resid--) {
for (i = 0; i < UFS_NDADDR && resid; i++, resid--) {
blk = journal_balloc();
if (blk <= 0)
goto out;
@ -1048,7 +1048,7 @@ journal_alloc(int64_t size)
dp2->di_blocks++;
}
}
for (i = 0; i < NIADDR && resid; i++) {
for (i = 0; i < UFS_NIADDR && resid; i++) {
blk = journal_balloc();
if (blk <= 0)
goto out;

View File

@ -127,7 +127,7 @@ lookup(const char *path)
ssize_t n;
uint8_t dt;
ino = ROOTINO;
ino = UFS_ROOTINO;
dt = DT_DIR;
for (;;) {
if (*path == '/')
@ -261,19 +261,19 @@ fsread_size(ufs_ino_t inode, void *buf, size_t nbyte, size_t *fsizep)
while (nb) {
lbn = lblkno(&fs, fs_off);
off = blkoff(&fs, fs_off);
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
addr2 = DIP(di_db[lbn]);
} else if (lbn < NDADDR + NINDIR(&fs)) {
} else if (lbn < UFS_NDADDR + NINDIR(&fs)) {
n = INDIRPERVBLK(&fs);
addr2 = DIP(di_ib[0]);
u = (u_int)(lbn - NDADDR) / n * DBPERVBLK;
u = (u_int)(lbn - UFS_NDADDR) / n * DBPERVBLK;
vbaddr = fsbtodb(&fs, addr2) + u;
if (indmap != vbaddr) {
if (dskread(indbuf, vbaddr, DBPERVBLK))
return -1;
indmap = vbaddr;
}
n = (lbn - NDADDR) & (n - 1);
n = (lbn - UFS_NDADDR) & (n - 1);
#if defined(UFS1_ONLY)
memcpy(&addr1, (ufs1_daddr_t *)indbuf + n,
sizeof(ufs1_daddr_t));

View File

@ -167,7 +167,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap)
uint32_t *bap, *sbap, *ebap;
struct ext2mount *ump;
struct cluster_save *buflist;
struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
struct indir start_ap[EXT2_NIADDR + 1], end_ap[EXT2_NIADDR + 1], *idp;
e2fs_lbn_t start_lbn, end_lbn;
int soff;
e2fs_daddr_t newblk, blkno;
@ -203,7 +203,7 @@ ext2_reallocblks(struct vop_reallocblks_args *ap)
* this for other indirect block boundaries, but it is only
* important for the first one.
*/
if (start_lbn < NDADDR && end_lbn >= NDADDR)
if (start_lbn < EXT2_NDADDR && end_lbn >= EXT2_NDADDR)
return (ENOSPC);
/*
* If the latest allocation is in a new cylinder group, assume that
@ -403,9 +403,9 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
ip->i_mode = 0;
ip->i_flags = 0;
/* now we want to make sure that the block pointers are zeroed out */
for (i = 0; i < NDADDR; i++)
for (i = 0; i < EXT2_NDADDR; i++)
ip->i_db[i] = 0;
for (i = 0; i < NIADDR; i++)
for (i = 0; i < EXT2_NIADDR; i++)
ip->i_ib[i] = 0;
/*

View File

@ -64,7 +64,7 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size, struct ucred *cred,
struct ext2mount *ump;
struct buf *bp, *nbp;
struct vnode *vp = ITOV(ip);
struct indir indirs[NIADDR + 2];
struct indir indirs[EXT2_NIADDR + 2];
e4fs_daddr_t nb, newb;
e2fs_daddr_t *bap, pref;
int osize, nsize, num, i, error;
@ -85,9 +85,9 @@ ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size, struct ucred *cred,
ip->i_next_alloc_goal++;
}
/*
* The first NDADDR blocks are direct blocks
* The first EXT2_NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
if (lbn < EXT2_NDADDR) {
nb = ip->i_db[lbn];
/*
* no new block is to be allocated, and no need to expand

View File

@ -163,7 +163,7 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, int *runp, int *runb)
struct buf *bp;
struct ext2mount *ump;
struct mount *mp;
struct indir a[NIADDR + 1], *ap;
struct indir a[EXT2_NIADDR + 1], *ap;
daddr_t daddr;
e2fs_lbn_t metalbn;
int error, num, maxrun = 0, bsize;
@ -198,7 +198,7 @@ ext2_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, int *runp, int *runb)
} else if (runp) {
daddr_t bnb = bn;
for (++bn; bn < NDADDR && *runp < maxrun &&
for (++bn; bn < EXT2_NDADDR && *runp < maxrun &&
is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]);
++bn, ++*runp);
bn = bnb;
@ -325,17 +325,18 @@ ext2_getlbns(struct vnode *vp, daddr_t bn, struct indir *ap, int *nump)
if ((long)bn < 0)
bn = -(long)bn;
/* The first NDADDR blocks are direct blocks. */
if (bn < NDADDR)
/* The first EXT2_NDADDR blocks are direct blocks. */
if (bn < EXT2_NDADDR)
return (0);
/*
* Determine the number of levels of indirection. After this loop
* is done, blockcnt indicates the number of data blocks possible
* at the previous level of indirection, and NIADDR - i is the number
* of levels of indirection needed to locate the requested block.
* at the previous level of indirection, and EXT2_NIADDR - i is the
* number of levels of indirection needed to locate the requested block.
*/
for (blockcnt = 1, i = NIADDR, bn -= NDADDR;; i--, bn -= blockcnt) {
for (blockcnt = 1, i = EXT2_NIADDR, bn -= EXT2_NDADDR; ;
i--, bn -= blockcnt) {
if (i == 0)
return (EFBIG);
/*
@ -351,9 +352,9 @@ ext2_getlbns(struct vnode *vp, daddr_t bn, struct indir *ap, int *nump)
/* Calculate the address of the first meta-block. */
if (realbn >= 0)
metalbn = -(realbn - bn + NIADDR - i);
metalbn = -(realbn - bn + EXT2_NIADDR - i);
else
metalbn = -(-realbn - bn + NIADDR - i);
metalbn = -(-realbn - bn + EXT2_NIADDR - i);
/*
* At each iteration, off is the offset into the bap array which is
@ -362,9 +363,9 @@ ext2_getlbns(struct vnode *vp, daddr_t bn, struct indir *ap, int *nump)
* into the argument array.
*/
ap->in_lbn = metalbn;
ap->in_off = off = NIADDR - i;
ap->in_off = off = EXT2_NIADDR - i;
ap++;
for (++numlevels; i <= NIADDR; i++) {
for (++numlevels; i <= EXT2_NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
if (metalbn == realbn)
break;

View File

@ -113,8 +113,9 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
struct vnode *ovp = vp;
int32_t lastblock;
struct inode *oip;
int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR];
uint32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
int32_t bn, lbn, lastiblock[EXT2_NIADDR], indir_lbn[EXT2_NIADDR];
uint32_t oldblks[EXT2_NDADDR + EXT2_NIADDR];
uint32_t newblks[EXT2_NDADDR + EXT2_NIADDR];
struct m_ext2fs *fs;
struct buf *bp;
int offset, size, level;
@ -218,7 +219,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
* the file is truncated to 0.
*/
lastblock = lblkno(fs, length + fs->e2fs_bsize - 1) - 1;
lastiblock[SINGLE] = lastblock - NDADDR;
lastiblock[SINGLE] = lastblock - EXT2_NDADDR;
lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
nblocks = btodb(fs->e2fs_bsize);
@ -229,13 +230,13 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
* normalized to -1 for calls to ext2_indirtrunc below.
*/
for (level = TRIPLE; level >= SINGLE; level--) {
oldblks[NDADDR + level] = oip->i_ib[level];
oldblks[EXT2_NDADDR + level] = oip->i_ib[level];
if (lastiblock[level] < 0) {
oip->i_ib[level] = 0;
lastiblock[level] = -1;
}
}
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < EXT2_NDADDR; i++) {
oldblks[i] = oip->i_db[i];
if (i > lastblock)
oip->i_db[i] = 0;
@ -249,13 +250,13 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
* Note that we save the new block configuration so we can check it
* when we are done.
*/
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < EXT2_NDADDR; i++) {
newblks[i] = oip->i_db[i];
oip->i_db[i] = oldblks[i];
}
for (i = 0; i < NIADDR; i++) {
newblks[NDADDR + i] = oip->i_ib[i];
oip->i_ib[i] = oldblks[NDADDR + i];
for (i = 0; i < EXT2_NIADDR; i++) {
newblks[EXT2_NDADDR + i] = oip->i_ib[i];
oip->i_ib[i] = oldblks[EXT2_NDADDR + i];
}
oip->i_size = osize;
error = vtruncbuf(ovp, cred, length, (int)fs->e2fs_bsize);
@ -266,7 +267,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
/*
* Indirect blocks first.
*/
indir_lbn[SINGLE] = -NDADDR;
indir_lbn[SINGLE] = -EXT2_NDADDR;
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
for (level = TRIPLE; level >= SINGLE; level--) {
@ -290,7 +291,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
/*
* All whole direct blocks or frags.
*/
for (i = NDADDR - 1; i > lastblock; i--) {
for (i = EXT2_NDADDR - 1; i > lastblock; i--) {
long bsize;
bn = oip->i_db[i];
@ -335,9 +336,9 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
done:
#ifdef INVARIANTS
for (level = SINGLE; level <= TRIPLE; level++)
if (newblks[NDADDR + level] != oip->i_ib[level])
if (newblks[EXT2_NDADDR + level] != oip->i_ib[level])
panic("itrunc1");
for (i = 0; i < NDADDR; i++)
for (i = 0; i < EXT2_NDADDR; i++)
if (newblks[i] != oip->i_db[i])
panic("itrunc2");
BO_LOCK(bo);

View File

@ -123,9 +123,9 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
ip->i_uid = ei->e2di_uid;
ip->i_gid = ei->e2di_gid;
/* XXX use memcpy */
for (i = 0; i < NDADDR; i++)
for (i = 0; i < EXT2_NDADDR; i++)
ip->i_db[i] = ei->e2di_blocks[i];
for (i = 0; i < NIADDR; i++)
for (i = 0; i < EXT2_NIADDR; i++)
ip->i_ib[i] = ei->e2di_blocks[EXT2_NDIR_BLOCKS + i];
}
@ -169,8 +169,8 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei)
ei->e2di_uid = ip->i_uid;
ei->e2di_gid = ip->i_gid;
/* XXX use memcpy */
for (i = 0; i < NDADDR; i++)
for (i = 0; i < EXT2_NDADDR; i++)
ei->e2di_blocks[i] = ip->i_db[i];
for (i = 0; i < NIADDR; i++)
for (i = 0; i < EXT2_NIADDR; i++)
ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i];
}

View File

@ -50,8 +50,8 @@
*/
#define doff_t int32_t
#define NDADDR 12 /* Direct addresses in inode. */
#define NIADDR 3 /* Indirect addresses in inode. */
#define EXT2_NDADDR 12 /* Direct addresses in inode. */
#define EXT2_NIADDR 3 /* Indirect addresses in inode. */
/*
* The size of physical and logical block numbers in EXT2FS.
@ -106,8 +106,8 @@ struct inode {
int32_t i_birthnsec; /* Inode creation time. */
uint32_t i_gen; /* Generation number. */
uint32_t i_flags; /* Status flags (chflags). */
uint32_t i_db[NDADDR]; /* Direct disk blocks. */
uint32_t i_ib[NIADDR]; /* Indirect disk blocks. */
uint32_t i_db[EXT2_NDADDR]; /* Direct disk blocks. */
uint32_t i_ib[EXT2_NIADDR]; /* Indirect disk blocks. */
struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */
};

View File

@ -67,7 +67,7 @@ int
bmap_lookup(struct nandfs_node *node, nandfs_lbn_t lblk, nandfs_daddr_t *vblk)
{
struct nandfs_inode *ip;
struct nandfs_indir a[NIADDR + 1], *ap;
struct nandfs_indir a[NANDFS_NIADDR + 1], *ap;
nandfs_daddr_t daddr;
struct buf *bp;
int error;
@ -129,7 +129,7 @@ bmap_lookup(struct nandfs_node *node, nandfs_lbn_t lblk, nandfs_daddr_t *vblk)
int
bmap_dirty_meta(struct nandfs_node *node, nandfs_lbn_t lblk, int force)
{
struct nandfs_indir a[NIADDR+1], *ap;
struct nandfs_indir a[NANDFS_NIADDR+1], *ap;
#ifdef DEBUG
nandfs_daddr_t daddr;
#endif
@ -179,7 +179,7 @@ bmap_insert_block(struct nandfs_node *node, nandfs_lbn_t lblk,
nandfs_daddr_t vblk)
{
struct nandfs_inode *ip;
struct nandfs_indir a[NIADDR+1], *ap;
struct nandfs_indir a[NANDFS_NIADDR+1], *ap;
struct buf *bp;
nandfs_daddr_t daddr;
int error;
@ -267,7 +267,7 @@ bmap_insert_block(struct nandfs_node *node, nandfs_lbn_t lblk,
return (error);
}
CTASSERT(NIADDR <= 3);
CTASSERT(NANDFS_NIADDR <= 3);
#define SINGLE 0 /* index of single indirect block */
#define DOUBLE 1 /* index of double indirect block */
#define TRIPLE 2 /* index of triple indirect block */
@ -399,8 +399,8 @@ bmap_truncate_mapping(struct nandfs_node *node, nandfs_lbn_t lastblk,
nandfs_lbn_t todo)
{
struct nandfs_inode *ip;
struct nandfs_indir a[NIADDR + 1], f[NIADDR], *ap;
nandfs_daddr_t indir_lbn[NIADDR];
struct nandfs_indir a[NANDFS_NIADDR + 1], f[NANDFS_NIADDR], *ap;
nandfs_daddr_t indir_lbn[NANDFS_NIADDR];
nandfs_daddr_t *copy;
int error, level;
nandfs_lbn_t left, tosub;
@ -421,12 +421,12 @@ bmap_truncate_mapping(struct nandfs_node *node, nandfs_lbn_t lastblk,
if (error)
return (error);
indir_lbn[SINGLE] = -NDADDR;
indir_lbn[SINGLE] = -NANDFS_NDADDR;
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - MNINDIR(fsdev) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - MNINDIR(fsdev)
* MNINDIR(fsdev) - 1;
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < NANDFS_NIADDR; i++) {
f[i].in_off = MNINDIR(fsdev) - 1;
f[i].in_lbn = 0xdeadbeef;
}
@ -482,7 +482,7 @@ bmap_truncate_mapping(struct nandfs_node *node, nandfs_lbn_t lastblk,
if (num < 0)
i = lastblk;
else
i = NDADDR - 1;
i = NANDFS_NDADDR - 1;
for (; i >= 0 && left > 0; i--) {
if (ip->i_db[i] != 0) {
@ -508,13 +508,13 @@ bmap_truncate_mapping(struct nandfs_node *node, nandfs_lbn_t lastblk,
nandfs_lbn_t
get_maxfilesize(struct nandfs_device *fsdev)
{
struct nandfs_indir f[NIADDR];
struct nandfs_indir f[NANDFS_NIADDR];
nandfs_lbn_t max;
int i;
max = NDADDR;
max = NANDFS_NDADDR;
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < NANDFS_NIADDR; i++) {
f[i].in_off = MNINDIR(fsdev) - 1;
max += blocks_inside(fsdev, i, f);
}
@ -557,17 +557,17 @@ bmap_getlbns(struct nandfs_node *node, nandfs_lbn_t bn, struct nandfs_indir *ap,
if (bn < 0)
bn = -bn;
/* The first NDADDR blocks are direct blocks. */
if (bn < NDADDR)
/* The first NANDFS_NDADDR blocks are direct blocks. */
if (bn < NANDFS_NDADDR)
return (0);
/*
* Determine the number of levels of indirection. After this loop
* is done, blockcnt indicates the number of data blocks possible
* at the previous level of indirection, and NIADDR - i is the number
* of levels of indirection needed to locate the requested block.
* at the previous level of indirection, and NANDFS_NIADDR - i is the
* number of levels of indirection needed to locate the requested block.
*/
for (blockcnt = 1, i = NIADDR, bn -= NDADDR;; i--, bn -= blockcnt) {
for (blockcnt = 1, i = NANDFS_NIADDR, bn -= NANDFS_NDADDR;; i--, bn -= blockcnt) {
DPRINTF(BMAP, ("%s: blockcnt=%jd i=%d bn=%jd\n", __func__,
blockcnt, i, bn));
if (i == 0)
@ -579,9 +579,9 @@ bmap_getlbns(struct nandfs_node *node, nandfs_lbn_t bn, struct nandfs_indir *ap,
/* Calculate the address of the first meta-block. */
if (realbn >= 0)
metalbn = -(realbn - bn + NIADDR - i);
metalbn = -(realbn - bn + NANDFS_NIADDR - i);
else
metalbn = -(-realbn - bn + NIADDR - i);
metalbn = -(-realbn - bn + NANDFS_NIADDR - i);
/*
* At each iteration, off is the offset into the bap array which is
@ -590,13 +590,13 @@ bmap_getlbns(struct nandfs_node *node, nandfs_lbn_t bn, struct nandfs_indir *ap,
* into the argument array.
*/
ap->in_lbn = metalbn;
ap->in_off = off = NIADDR - i;
ap->in_off = off = NANDFS_NIADDR - i;
DPRINTF(BMAP, ("%s: initial: ap->in_lbn=%jx ap->in_off=%d\n", __func__,
metalbn, off));
ap++;
for (++numlevels; i <= NIADDR; i++) {
for (++numlevels; i <= NANDFS_NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
if (metalbn == realbn)
break;

View File

@ -56,8 +56,8 @@
#define NANDFS_SYS_NODE(ino) \
(((ino) >= NANDFS_DAT_INO) && ((ino) <= NANDFS_GC_INO))
#define NDADDR 12 /* Direct addresses in inode. */
#define NIADDR 3 /* Indirect addresses in inode. */
#define NANDFS_NDADDR 12 /* Direct addresses in inode. */
#define NANDFS_NIADDR 3 /* Indirect addresses in inode. */
typedef int64_t nandfs_daddr_t;
typedef int64_t nandfs_lbn_t;
@ -75,8 +75,8 @@ struct nandfs_inode {
uint16_t i_links_count; /* 50: number of references to the inode*/
uint32_t i_flags; /* 52: NANDFS_*_FL flags */
nandfs_daddr_t i_special; /* 56: special */
nandfs_daddr_t i_db[NDADDR]; /* 64: Direct disk blocks. */
nandfs_daddr_t i_ib[NIADDR]; /* 160: Indirect disk blocks. */
nandfs_daddr_t i_db[NANDFS_NDADDR]; /* 64: Direct disk blocks. */
nandfs_daddr_t i_ib[NANDFS_NIADDR]; /* 160: Indirect disk blocks. */
uint64_t i_xattr; /* 184: reserved for extended attributes*/
uint32_t i_generation; /* 192: file generation for NFS */
uint32_t i_pad[15]; /* 196: make it 64 bits aligned */

View File

@ -1541,7 +1541,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
* traversals of the mount point (i.e. "..") will not work if
* the nfsnode gets flushed out of the cache. Ufs does not have
* this problem, because one can identify root inodes by their
* number == ROOTINO (2).
* number == UFS_ROOTINO (2).
*/
if (nmp->nm_fhsize > 0) {
/*

View File

@ -303,7 +303,7 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, flags, cred, bpp)
}
if (bp->b_blkno == bp->b_lblkno) {
if (lbprev >= NDADDR)
if (lbprev >= UFS_NDADDR)
panic("ffs_realloccg: lbprev out of range");
bp->b_blkno = fsbtodb(fs, bprev);
}
@ -524,7 +524,7 @@ ffs_reallocblks_ufs1(ap)
ufs_lbn_t start_lbn, end_lbn;
ufs1_daddr_t soff, newblk, blkno;
ufs2_daddr_t pref;
struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
struct indir start_ap[UFS_NIADDR + 1], end_ap[UFS_NIADDR + 1], *idp;
int i, cg, len, start_lvl, end_lvl, ssize;
vp = ap->a_vp;
@ -567,7 +567,7 @@ ffs_reallocblks_ufs1(ap)
* this for other indirect block boundaries, but it is only
* important for the first one.
*/
if (start_lbn < NDADDR && end_lbn >= NDADDR)
if (start_lbn < UFS_NDADDR && end_lbn >= UFS_NDADDR)
return (ENOSPC);
/*
* If the latest allocation is in a new cylinder group, assume that
@ -773,7 +773,7 @@ ffs_reallocblks_ufs2(ap)
struct ufsmount *ump;
ufs_lbn_t start_lbn, end_lbn;
ufs2_daddr_t soff, newblk, blkno, pref;
struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
struct indir start_ap[UFS_NIADDR + 1], end_ap[UFS_NIADDR + 1], *idp;
int i, cg, len, start_lvl, end_lvl, ssize;
vp = ap->a_vp;
@ -816,7 +816,7 @@ ffs_reallocblks_ufs2(ap)
* this for other indirect block boundaries, but it is only
* important for the first one.
*/
if (start_lbn < NDADDR && end_lbn >= NDADDR)
if (start_lbn < UFS_NDADDR && end_lbn >= UFS_NDADDR)
return (ENOSPC);
/*
* If the latest allocation is in a new cylinder group, assume that
@ -1334,9 +1334,9 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
* If we are allocating the first indirect block, try to
* place it immediately following the last direct block.
*/
if (indx == -1 && lbn < NDADDR + NINDIR(fs) &&
ip->i_din1->di_db[NDADDR - 1] != 0)
pref = ip->i_din1->di_db[NDADDR - 1] + fs->fs_frag;
if (indx == -1 && lbn < UFS_NDADDR + NINDIR(fs) &&
ip->i_din1->di_db[UFS_NDADDR - 1] != 0)
pref = ip->i_din1->di_db[UFS_NDADDR - 1] + fs->fs_frag;
return (pref);
}
/*
@ -1344,7 +1344,7 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
* block and the indirect has been allocated in the data block area,
* try to place it immediately following the indirect block.
*/
if (lbn == NDADDR) {
if (lbn == UFS_NDADDR) {
pref = ip->i_din1->di_ib[0];
if (pref != 0 && pref >= cgdata(fs, inocg) &&
pref < cgbase(fs, inocg + 1))
@ -1368,7 +1368,7 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
* blocks, we try to allocate in the data area of the inode's
* cylinder group.
*/
if (lbn < NDADDR + NINDIR(fs))
if (lbn < UFS_NDADDR + NINDIR(fs))
return (cgdata(fs, inocg));
/*
* Find a cylinder with greater than average number of
@ -1439,9 +1439,9 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
* If we are allocating the first indirect block, try to
* place it immediately following the last direct block.
*/
if (indx == -1 && lbn < NDADDR + NINDIR(fs) &&
ip->i_din2->di_db[NDADDR - 1] != 0)
pref = ip->i_din2->di_db[NDADDR - 1] + fs->fs_frag;
if (indx == -1 && lbn < UFS_NDADDR + NINDIR(fs) &&
ip->i_din2->di_db[UFS_NDADDR - 1] != 0)
pref = ip->i_din2->di_db[UFS_NDADDR - 1] + fs->fs_frag;
return (pref);
}
/*
@ -1449,7 +1449,7 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
* block and the indirect has been allocated in the data block area,
* try to place it immediately following the indirect block.
*/
if (lbn == NDADDR) {
if (lbn == UFS_NDADDR) {
pref = ip->i_din2->di_ib[0];
if (pref != 0 && pref >= cgdata(fs, inocg) &&
pref < cgbase(fs, inocg + 1))
@ -1473,7 +1473,7 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
* blocks, we try to allocate in the data area of the inode's
* cylinder group.
*/
if (lbn < NDADDR + NINDIR(fs))
if (lbn < UFS_NDADDR + NINDIR(fs))
return (cgdata(fs, inocg));
/*
* Find a cylinder with greater than average number of
@ -2916,7 +2916,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
if (blksize > blkcnt)
blksize = blkcnt;
ffs_blkfree(ump, fs, ump->um_devvp, blkno,
blksize * fs->fs_fsize, ROOTINO, VDIR, NULL);
blksize * fs->fs_fsize, UFS_ROOTINO, VDIR, NULL);
blkno += blksize;
blkcnt -= blksize;
blksize = fs->fs_frag;

View File

@ -97,12 +97,12 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
ufs1_daddr_t nb;
struct buf *bp, *nbp;
struct ufsmount *ump;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
int deallocated, osize, nsize, num, i, error;
ufs2_daddr_t newb;
ufs1_daddr_t *bap, pref;
ufs1_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1];
ufs2_daddr_t *lbns_remfree, lbns[NIADDR + 1];
ufs1_daddr_t *allocib, *blkp, *allocblk, allociblk[UFS_NIADDR + 1];
ufs2_daddr_t *lbns_remfree, lbns[UFS_NIADDR + 1];
int unwindidx = -1;
int saved_inbdflush;
static struct timeval lastfail;
@ -133,7 +133,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
* this fragment has to be extended to be a full block.
*/
lastlbn = lblkno(fs, ip->i_size);
if (lastlbn < NDADDR && lastlbn < lbn) {
if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
nb = lastlbn;
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
@ -161,9 +161,9 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
}
}
/*
* The first NDADDR blocks are direct blocks
* The first UFS_NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
if (flags & BA_METAONLY)
panic("ffs_balloc_ufs1: BA_METAONLY for direct block");
nb = dp->di_db[lbn];
@ -265,8 +265,9 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
bp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(bp);
if (DOINGSOFTDEP(vp)) {
softdep_setup_allocdirect(ip, NDADDR + indirs[0].in_off,
newb, 0, fs->fs_bsize, 0, bp);
softdep_setup_allocdirect(ip,
UFS_NDADDR + indirs[0].in_off, newb, 0,
fs->fs_bsize, 0, bp);
bdwrite(bp);
} else if ((flags & IO_SYNC) == 0 && DOINGASYNC(vp)) {
if (bp->b_bufsize == fs->fs_bsize)
@ -383,7 +384,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
* the file. Otherwise it has been allocated in the metadata
* area, so we want to find our own place out in the data area.
*/
if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
if (pref == 0 || (lbn > UFS_NDADDR && fs->fs_metaspace != 0))
pref = ffs_blkpref_ufs1(ip, lbn, indirs[i].in_off,
&bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
@ -571,10 +572,10 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
struct fs *fs;
struct buf *bp, *nbp;
struct ufsmount *ump;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
ufs2_daddr_t nb, newb, *bap, pref;
ufs2_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1];
ufs2_daddr_t *lbns_remfree, lbns[NIADDR + 1];
ufs2_daddr_t *allocib, *blkp, *allocblk, allociblk[UFS_NIADDR + 1];
ufs2_daddr_t *lbns_remfree, lbns[UFS_NIADDR + 1];
int deallocated, osize, nsize, num, i, error;
int unwindidx = -1;
int saved_inbdflush;
@ -603,7 +604,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
* Check for allocating external data.
*/
if (flags & IO_EXT) {
if (lbn >= NXADDR)
if (lbn >= UFS_NXADDR)
return (EFBIG);
/*
* If the next write will extend the data into a new block,
@ -717,7 +718,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
* this fragment has to be extended to be a full block.
*/
lastlbn = lblkno(fs, ip->i_size);
if (lastlbn < NDADDR && lastlbn < lbn) {
if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
nb = lastlbn;
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
@ -744,9 +745,9 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
}
}
/*
* The first NDADDR blocks are direct blocks
* The first UFS_NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
if (flags & BA_METAONLY)
panic("ffs_balloc_ufs2: BA_METAONLY for direct block");
nb = dp->di_db[lbn];
@ -851,8 +852,9 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
bp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(bp);
if (DOINGSOFTDEP(vp)) {
softdep_setup_allocdirect(ip, NDADDR + indirs[0].in_off,
newb, 0, fs->fs_bsize, 0, bp);
softdep_setup_allocdirect(ip,
UFS_NDADDR + indirs[0].in_off, newb, 0,
fs->fs_bsize, 0, bp);
bdwrite(bp);
} else if ((flags & IO_SYNC) == 0 && DOINGASYNC(vp)) {
if (bp->b_bufsize == fs->fs_bsize)
@ -970,7 +972,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
* the file. Otherwise it has been allocated in the metadata
* area, so we want to find our own place out in the data area.
*/
if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
if (pref == 0 || (lbn > UFS_NDADDR && fs->fs_metaspace != 0))
pref = ffs_blkpref_ufs2(ip, lbn, indirs[i].in_off,
&bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,

View File

@ -183,8 +183,9 @@ ffs_truncate(vp, length, flags, cred)
struct ucred *cred;
{
struct inode *ip;
ufs2_daddr_t bn, lbn, lastblock, lastiblock[NIADDR], indir_lbn[NIADDR];
ufs2_daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
ufs2_daddr_t bn, lbn, lastblock, lastiblock[UFS_NIADDR];
ufs2_daddr_t indir_lbn[UFS_NIADDR], oldblks[UFS_NDADDR + UFS_NIADDR];
ufs2_daddr_t newblks[UFS_NDADDR + UFS_NIADDR];
ufs2_daddr_t count, blocksreleased = 0, datablocks, blkno;
struct bufobj *bo;
struct fs *fs;
@ -260,14 +261,14 @@ ffs_truncate(vp, length, flags, cred)
osize = ip->i_din2->di_extsize;
ip->i_din2->di_blocks -= extblocks;
ip->i_din2->di_extsize = 0;
for (i = 0; i < NXADDR; i++) {
for (i = 0; i < UFS_NXADDR; i++) {
oldblks[i] = ip->i_din2->di_extb[i];
ip->i_din2->di_extb[i] = 0;
}
ip->i_flag |= IN_CHANGE;
if ((error = ffs_update(vp, waitforupdate)))
return (error);
for (i = 0; i < NXADDR; i++) {
for (i = 0; i < UFS_NXADDR; i++) {
if (oldblks[i] == 0)
continue;
ffs_blkfree(ump, fs, ITODEVVP(ip), oldblks[i],
@ -338,14 +339,14 @@ ffs_truncate(vp, length, flags, cred)
lbn = lblkno(fs, length - 1);
if (length == 0) {
blkno = -1;
} else if (lbn < NDADDR) {
} else if (lbn < UFS_NDADDR) {
blkno = DIP(ip, i_db[lbn]);
} else {
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize,
cred, BA_METAONLY, &bp);
if (error)
return (error);
indiroff = (lbn - NDADDR) % NINDIR(fs);
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
if (I_IS_UFS1(ip))
blkno = ((ufs1_daddr_t *)(bp->b_data))[indiroff];
else
@ -428,7 +429,7 @@ ffs_truncate(vp, length, flags, cred)
* so that we do not get a soft updates inconsistency
* when we create the fragment below.
*/
if (DOINGSOFTDEP(vp) && lbn < NDADDR &&
if (DOINGSOFTDEP(vp) && lbn < UFS_NDADDR &&
fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize &&
(error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
return (error);
@ -456,7 +457,7 @@ ffs_truncate(vp, length, flags, cred)
* the file is truncated to 0.
*/
lastblock = lblkno(fs, length + fs->fs_bsize - 1) - 1;
lastiblock[SINGLE] = lastblock - NDADDR;
lastiblock[SINGLE] = lastblock - UFS_NDADDR;
lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
nblocks = btodb(fs->fs_bsize);
@ -467,13 +468,13 @@ ffs_truncate(vp, length, flags, cred)
* normalized to -1 for calls to ffs_indirtrunc below.
*/
for (level = TRIPLE; level >= SINGLE; level--) {
oldblks[NDADDR + level] = DIP(ip, i_ib[level]);
oldblks[UFS_NDADDR + level] = DIP(ip, i_ib[level]);
if (lastiblock[level] < 0) {
DIP_SET(ip, i_ib[level], 0);
lastiblock[level] = -1;
}
}
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
oldblks[i] = DIP(ip, i_db[i]);
if (i > lastblock)
DIP_SET(ip, i_db[i], 0);
@ -487,13 +488,13 @@ ffs_truncate(vp, length, flags, cred)
* Note that we save the new block configuration so we can check it
* when we are done.
*/
for (i = 0; i < NDADDR; i++) {
for (i = 0; i < UFS_NDADDR; i++) {
newblks[i] = DIP(ip, i_db[i]);
DIP_SET(ip, i_db[i], oldblks[i]);
}
for (i = 0; i < NIADDR; i++) {
newblks[NDADDR + i] = DIP(ip, i_ib[i]);
DIP_SET(ip, i_ib[i], oldblks[NDADDR + i]);
for (i = 0; i < UFS_NIADDR; i++) {
newblks[UFS_NDADDR + i] = DIP(ip, i_ib[i]);
DIP_SET(ip, i_ib[i], oldblks[UFS_NDADDR + i]);
}
ip->i_size = osize;
DIP_SET(ip, i_size, osize);
@ -505,7 +506,7 @@ ffs_truncate(vp, length, flags, cred)
/*
* Indirect blocks first.
*/
indir_lbn[SINGLE] = -NDADDR;
indir_lbn[SINGLE] = -UFS_NDADDR;
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
for (level = TRIPLE; level >= SINGLE; level--) {
@ -531,7 +532,7 @@ ffs_truncate(vp, length, flags, cred)
/*
* All whole direct blocks or frags.
*/
for (i = NDADDR - 1; i > lastblock; i--) {
for (i = UFS_NDADDR - 1; i > lastblock; i--) {
long bsize;
bn = DIP(ip, i_db[i]);
@ -579,9 +580,9 @@ ffs_truncate(vp, length, flags, cred)
done:
#ifdef INVARIANTS
for (level = SINGLE; level <= TRIPLE; level++)
if (newblks[NDADDR + level] != DIP(ip, i_ib[level]))
if (newblks[UFS_NDADDR + level] != DIP(ip, i_ib[level]))
panic("ffs_truncate1");
for (i = 0; i < NDADDR; i++)
for (i = 0; i < UFS_NDADDR; i++)
if (newblks[i] != DIP(ip, i_db[i]))
panic("ffs_truncate2");
BO_LOCK(bo);

View File

@ -330,7 +330,7 @@ ffs_snapshot(mp, snapfile)
* Allocate all indirect blocks and mark all of them as not
* needing to be copied.
*/
for (blkno = NDADDR; blkno < numblks; blkno += NINDIR(fs)) {
for (blkno = UFS_NDADDR; blkno < numblks; blkno += NINDIR(fs)) {
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, td->td_ucred, BA_METAONLY, &ibp);
if (error)
@ -576,7 +576,7 @@ ffs_snapshot(mp, snapfile)
*/
blkno = 0;
loc = howmany(xp->i_size, fs->fs_bsize) - 1;
if (loc < NDADDR) {
if (loc < UFS_NDADDR) {
len = fragroundup(fs, blkoff(fs, xp->i_size));
if (len != 0 && len < fs->fs_bsize) {
ffs_blkfree(ump, copy_fs, vp,
@ -816,7 +816,7 @@ ffs_snapshot(mp, snapfile)
* update the non-integrity-critical time fields and
* allocated-block count.
*/
for (blockno = 0; blockno < NDADDR; blockno++) {
for (blockno = 0; blockno < UFS_NDADDR; blockno++) {
if (DIP(ip, i_db[blockno]) != 0)
continue;
error = UFS_BALLOC(vp, lblktosize(fs, blockno),
@ -923,8 +923,8 @@ cgaccount(cg, vp, nbp, passno)
if (base + len >= numblks)
len = numblks - base - 1;
loc = 0;
if (base < NDADDR) {
for ( ; loc < NDADDR; loc++) {
if (base < UFS_NDADDR) {
for ( ; loc < UFS_NDADDR; loc++) {
if (ffs_isblock(fs, cg_blksfree(cgp), loc))
DIP_SET(ip, i_db[loc], BLK_NOCOPY);
else if (passno == 2 && DIP(ip, i_db[loc])== BLK_NOCOPY)
@ -938,7 +938,7 @@ cgaccount(cg, vp, nbp, passno)
if (error) {
return (error);
}
indiroff = (base + loc - NDADDR) % NINDIR(fs);
indiroff = (base + loc - UFS_NDADDR) % NINDIR(fs);
for ( ; loc < len; loc++, indiroff++) {
if (indiroff >= NINDIR(fs)) {
if (passno == 2)
@ -1010,7 +1010,7 @@ expunge_ufs1(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
*/
lbn = fragstoblks(fs, ino_to_fsba(fs, cancelip->i_number));
blkno = 0;
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkno = VTOI(snapvp)->i_din1->di_db[lbn];
} else {
if (DOINGSOFTDEP(snapvp))
@ -1021,7 +1021,7 @@ expunge_ufs1(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
return (error);
indiroff = (lbn - NDADDR) % NINDIR(fs);
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
blkno = ((ufs1_daddr_t *)(bp->b_data))[indiroff];
bqrelse(bp);
}
@ -1047,7 +1047,7 @@ expunge_ufs1(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
dip->di_size = 0;
dip->di_blocks = 0;
dip->di_flags &= ~SF_SNAPSHOT;
bzero(&dip->di_db[0], (NDADDR + NIADDR) * sizeof(ufs1_daddr_t));
bzero(&dip->di_db[0], (UFS_NDADDR + UFS_NIADDR) * sizeof(ufs1_daddr_t));
bdwrite(bp);
/*
* Now go through and expunge all the blocks in the file
@ -1055,16 +1055,16 @@ expunge_ufs1(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
*/
numblks = howmany(cancelip->i_size, fs->fs_bsize);
if ((error = (*acctfunc)(snapvp, &cancelip->i_din1->di_db[0],
&cancelip->i_din1->di_db[NDADDR], fs, 0, expungetype)))
&cancelip->i_din1->di_db[UFS_NDADDR], fs, 0, expungetype)))
return (error);
if ((error = (*acctfunc)(snapvp, &cancelip->i_din1->di_ib[0],
&cancelip->i_din1->di_ib[NIADDR], fs, -1, expungetype)))
&cancelip->i_din1->di_ib[UFS_NIADDR], fs, -1, expungetype)))
return (error);
blksperindir = 1;
lbn = -NDADDR;
len = numblks - NDADDR;
rlbn = NDADDR;
for (i = 0; len > 0 && i < NIADDR; i++) {
lbn = -UFS_NDADDR;
len = numblks - UFS_NDADDR;
rlbn = UFS_NDADDR;
for (i = 0; len > 0 && i < UFS_NIADDR; i++) {
error = indiracct_ufs1(snapvp, ITOV(cancelip), i,
cancelip->i_din1->di_ib[i], lbn, rlbn, len,
blksperindir, fs, acctfunc, expungetype);
@ -1100,7 +1100,7 @@ indiracct_ufs1(snapvp, cancelvp, level, blkno, lbn, rlbn, remblks,
{
int error, num, i;
ufs_lbn_t subblksperindir;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
ufs1_daddr_t last, *bap;
struct buf *bp;
@ -1196,7 +1196,7 @@ snapacct_ufs1(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
if (blkno == 0 || blkno == BLK_NOCOPY || blkno == BLK_SNAP)
continue;
lbn = fragstoblks(fs, blkno);
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkp = &ip->i_din1->di_db[lbn];
ip->i_flag |= IN_CHANGE | IN_UPDATE;
} else {
@ -1205,7 +1205,7 @@ snapacct_ufs1(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
if (error)
return (error);
blkp = &((ufs1_daddr_t *)(ibp->b_data))
[(lbn - NDADDR) % NINDIR(fs)];
[(lbn - UFS_NDADDR) % NINDIR(fs)];
}
/*
* If we are expunging a snapshot vnode and we
@ -1214,13 +1214,13 @@ snapacct_ufs1(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
* we took our current snapshot and can be ignored.
*/
if (expungetype == BLK_SNAP && *blkp == BLK_NOCOPY) {
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
brelse(ibp);
} else {
if (*blkp != 0)
panic("snapacct_ufs1: bad block");
*blkp = expungetype;
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
bdwrite(ibp);
}
}
@ -1294,7 +1294,7 @@ expunge_ufs2(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
*/
lbn = fragstoblks(fs, ino_to_fsba(fs, cancelip->i_number));
blkno = 0;
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkno = VTOI(snapvp)->i_din2->di_db[lbn];
} else {
if (DOINGSOFTDEP(snapvp))
@ -1305,7 +1305,7 @@ expunge_ufs2(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
return (error);
indiroff = (lbn - NDADDR) % NINDIR(fs);
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
blkno = ((ufs2_daddr_t *)(bp->b_data))[indiroff];
bqrelse(bp);
}
@ -1331,7 +1331,7 @@ expunge_ufs2(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
dip->di_size = 0;
dip->di_blocks = 0;
dip->di_flags &= ~SF_SNAPSHOT;
bzero(&dip->di_db[0], (NDADDR + NIADDR) * sizeof(ufs2_daddr_t));
bzero(&dip->di_db[0], (UFS_NDADDR + UFS_NIADDR) * sizeof(ufs2_daddr_t));
bdwrite(bp);
/*
* Now go through and expunge all the blocks in the file
@ -1339,16 +1339,16 @@ expunge_ufs2(snapvp, cancelip, fs, acctfunc, expungetype, clearmode)
*/
numblks = howmany(cancelip->i_size, fs->fs_bsize);
if ((error = (*acctfunc)(snapvp, &cancelip->i_din2->di_db[0],
&cancelip->i_din2->di_db[NDADDR], fs, 0, expungetype)))
&cancelip->i_din2->di_db[UFS_NDADDR], fs, 0, expungetype)))
return (error);
if ((error = (*acctfunc)(snapvp, &cancelip->i_din2->di_ib[0],
&cancelip->i_din2->di_ib[NIADDR], fs, -1, expungetype)))
&cancelip->i_din2->di_ib[UFS_NIADDR], fs, -1, expungetype)))
return (error);
blksperindir = 1;
lbn = -NDADDR;
len = numblks - NDADDR;
rlbn = NDADDR;
for (i = 0; len > 0 && i < NIADDR; i++) {
lbn = -UFS_NDADDR;
len = numblks - UFS_NDADDR;
rlbn = UFS_NDADDR;
for (i = 0; len > 0 && i < UFS_NIADDR; i++) {
error = indiracct_ufs2(snapvp, ITOV(cancelip), i,
cancelip->i_din2->di_ib[i], lbn, rlbn, len,
blksperindir, fs, acctfunc, expungetype);
@ -1384,7 +1384,7 @@ indiracct_ufs2(snapvp, cancelvp, level, blkno, lbn, rlbn, remblks,
{
int error, num, i;
ufs_lbn_t subblksperindir;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
ufs2_daddr_t last, *bap;
struct buf *bp;
@ -1480,7 +1480,7 @@ snapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
if (blkno == 0 || blkno == BLK_NOCOPY || blkno == BLK_SNAP)
continue;
lbn = fragstoblks(fs, blkno);
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkp = &ip->i_din2->di_db[lbn];
ip->i_flag |= IN_CHANGE | IN_UPDATE;
} else {
@ -1489,7 +1489,7 @@ snapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
if (error)
return (error);
blkp = &((ufs2_daddr_t *)(ibp->b_data))
[(lbn - NDADDR) % NINDIR(fs)];
[(lbn - UFS_NDADDR) % NINDIR(fs)];
}
/*
* If we are expunging a snapshot vnode and we
@ -1498,13 +1498,13 @@ snapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype)
* we took our current snapshot and can be ignored.
*/
if (expungetype == BLK_SNAP && *blkp == BLK_NOCOPY) {
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
brelse(ibp);
} else {
if (*blkp != 0)
panic("snapacct_ufs2: bad block");
*blkp = expungetype;
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
bdwrite(ibp);
}
}
@ -1639,7 +1639,7 @@ ffs_snapremove(vp)
* Clear all BLK_NOCOPY fields. Pass any block claims to other
* snapshots that want them (see ffs_snapblkfree below).
*/
for (blkno = 1; blkno < NDADDR; blkno++) {
for (blkno = 1; blkno < UFS_NDADDR; blkno++) {
dblk = DIP(ip, i_db[blkno]);
if (dblk == 0)
continue;
@ -1654,7 +1654,7 @@ ffs_snapremove(vp)
}
}
numblks = howmany(ip->i_size, fs->fs_bsize);
for (blkno = NDADDR; blkno < numblks; blkno += NINDIR(fs)) {
for (blkno = UFS_NDADDR; blkno < numblks; blkno += NINDIR(fs)) {
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp);
if (error)
@ -1771,7 +1771,7 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
/*
* Lookup block being written.
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkno = DIP(ip, i_db[lbn]);
} else {
td->td_pflags |= TDP_COWINPROGRESS;
@ -1780,7 +1780,7 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
indiroff = (lbn - NDADDR) % NINDIR(fs);
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
if (I_IS_UFS1(ip))
blkno=((ufs1_daddr_t *)(ibp->b_data))[indiroff];
else
@ -1803,7 +1803,7 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
*/
if (claimedblk)
panic("snapblkfree: inconsistent block type");
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
DIP_SET(ip, i_db[lbn], BLK_NOCOPY);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
} else if (I_IS_UFS1(ip)) {
@ -1822,7 +1822,7 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
* (default), or does not care about the block,
* it is not needed.
*/
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
bqrelse(ibp);
continue;
}
@ -1846,13 +1846,13 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
* the work to the inode or indirect being written.
*/
if (wkhd != NULL) {
if (lbn < NDADDR)
if (lbn < UFS_NDADDR)
softdep_inode_append(ip,
curthread->td_ucred, wkhd);
else
softdep_buf_append(ibp, wkhd);
}
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
DIP_SET(ip, i_db[lbn], bno);
} else if (I_IS_UFS1(ip)) {
((ufs1_daddr_t *)(ibp->b_data))[indiroff] = bno;
@ -1866,7 +1866,7 @@ ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, wkhd)
lockmgr(vp->v_vnlock, LK_RELEASE, NULL);
return (1);
}
if (lbn >= NDADDR)
if (lbn >= UFS_NDADDR)
bqrelse(ibp);
/*
* Allocate the block into which to do the copy. Note that this
@ -2327,7 +2327,7 @@ ffs_copyonwrite(devvp, bp)
* will never require any additional allocations for the
* snapshot inode.
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
blkno = DIP(ip, i_db[lbn]);
} else {
td->td_pflags |= TDP_COWINPROGRESS | TDP_NORUNNINGBUF;
@ -2336,7 +2336,7 @@ ffs_copyonwrite(devvp, bp)
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
indiroff = (lbn - NDADDR) % NINDIR(fs);
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
if (I_IS_UFS1(ip))
blkno=((ufs1_daddr_t *)(ibp->b_data))[indiroff];
else

View File

@ -2732,7 +2732,7 @@ softdep_journal_lookup(mp, vpp)
ino_t sujournal;
int error;
error = VFS_VGET(mp, ROOTINO, LK_EXCLUSIVE, &dvp);
error = VFS_VGET(mp, UFS_ROOTINO, LK_EXCLUSIVE, &dvp);
if (error)
return (error);
bzero(&cnp, sizeof(cnp));
@ -4133,8 +4133,8 @@ newfreework(ump, freeblks, parent, lbn, nb, frags, off, journal)
freework->fw_blkno = nb;
freework->fw_frags = frags;
freework->fw_indir = NULL;
freework->fw_ref = (MOUNTEDSUJ(UFSTOVFS(ump)) == 0 || lbn >= -NXADDR)
? 0 : NINDIR(ump->um_fs) + 1;
freework->fw_ref = (MOUNTEDSUJ(UFSTOVFS(ump)) == 0 ||
lbn >= -UFS_NXADDR) ? 0 : NINDIR(ump->um_fs) + 1;
freework->fw_start = freework->fw_off = off;
if (journal)
newjfreeblk(freeblks, lbn, nb, frags);
@ -5296,7 +5296,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp)
"off %jd newsize %ld oldsize %d",
ip->i_number, newblkno, oldblkno, off, newsize, oldsize);
ACQUIRE_LOCK(ITOUMP(ip));
if (off >= NDADDR) {
if (off >= UFS_NDADDR) {
if (lbn > 0)
panic("softdep_setup_allocdirect: bad lbn %jd, off %jd",
lbn, off);
@ -5464,7 +5464,7 @@ allocdirect_merge(adphead, newadp, oldadp)
LOCK_OWNED(VFSTOUFS(newadp->ad_list.wk_mp));
if (newadp->ad_oldblkno != oldadp->ad_newblkno ||
newadp->ad_oldsize != oldadp->ad_newsize ||
newadp->ad_offset >= NDADDR)
newadp->ad_offset >= UFS_NDADDR)
panic("%s %jd != new %jd || old size %ld != new %ld",
"allocdirect_merge: old blkno",
(intmax_t)newadp->ad_oldblkno,
@ -5669,8 +5669,8 @@ softdep_setup_allocext(ip, off, newblkno, oldblkno, newsize, oldsize, bp)
ump = VFSTOUFS(mp);
KASSERT(MOUNTEDSOFTDEP(mp) != 0,
("softdep_setup_allocext called on non-softdep filesystem"));
KASSERT(off < NXADDR, ("softdep_setup_allocext: lbn %lld > NXADDR",
(long long)off));
KASSERT(off < UFS_NXADDR,
("softdep_setup_allocext: lbn %lld > UFS_NXADDR", (long long)off));
lbn = bp->b_lblkno;
if (oldblkno && oldblkno != newblkno)
@ -6430,12 +6430,12 @@ blkcount(fs, datablocks, length)
totblks = 0;
numblks = howmany(length, fs->fs_bsize);
if (numblks <= NDADDR) {
if (numblks <= UFS_NDADDR) {
totblks = howmany(length, fs->fs_fsize);
goto out;
}
totblks = blkstofrags(fs, numblks);
numblks -= NDADDR;
numblks -= UFS_NDADDR;
/*
* Count all single, then double, then triple indirects required.
* Subtracting one indirects worth of blocks for each pass
@ -6553,12 +6553,12 @@ softdep_journal_freeblocks(ip, cred, length, flags)
/*
* Compute frags we are keeping in lastlbn. 0 means all.
*/
if (lastlbn >= 0 && lastlbn < NDADDR) {
if (lastlbn >= 0 && lastlbn < UFS_NDADDR) {
frags = fragroundup(fs, lastoff);
/* adp offset of last valid allocdirect. */
iboff = lastlbn;
} else if (lastlbn > 0)
iboff = NDADDR;
iboff = UFS_NDADDR;
if (fs->fs_magic == FS_UFS2_MAGIC)
extblocks = btodb(fragroundup(fs, ip->i_din2->di_extsize));
/*
@ -6570,9 +6570,10 @@ softdep_journal_freeblocks(ip, cred, length, flags)
/*
* Handle truncation of whole direct and indirect blocks.
*/
for (i = iboff + 1; i < NDADDR; i++)
for (i = iboff + 1; i < UFS_NDADDR; i++)
setup_freedirect(freeblks, ip, i, needj);
for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR;
for (i = 0, tmpval = NINDIR(fs), lbn = UFS_NDADDR;
i < UFS_NIADDR;
i++, lbn += tmpval, tmpval *= NINDIR(fs)) {
/* Release a whole indirect tree. */
if (lbn > lastlbn) {
@ -6580,7 +6581,7 @@ softdep_journal_freeblocks(ip, cred, length, flags)
needj);
continue;
}
iboff = i + NDADDR;
iboff = i + UFS_NDADDR;
/*
* Traverse partially truncated indirect tree.
*/
@ -6614,7 +6615,7 @@ softdep_journal_freeblocks(ip, cred, length, flags)
* handling indirect blocks. Non-indirects need no extra
* journaling.
*/
if (length != 0 && lastlbn >= NDADDR) {
if (length != 0 && lastlbn >= UFS_NDADDR) {
ip->i_flag |= IN_TRUNCATED;
newjtrunc(freeblks, length, 0);
}
@ -6626,7 +6627,7 @@ softdep_journal_freeblocks(ip, cred, length, flags)
freeblks->fb_len = length;
}
if ((flags & IO_EXT) != 0) {
for (i = 0; i < NXADDR; i++)
for (i = 0; i < UFS_NXADDR; i++)
setup_freeext(freeblks, ip, i, needj);
ip->i_din2->di_extsize = 0;
datablocks += extblocks;
@ -6877,9 +6878,10 @@ softdep_setup_freeblocks(ip, length, flags)
if (fs->fs_magic == FS_UFS2_MAGIC)
extblocks = btodb(fragroundup(fs, ip->i_din2->di_extsize));
if ((flags & IO_NORMAL) != 0) {
for (i = 0; i < NDADDR; i++)
for (i = 0; i < UFS_NDADDR; i++)
setup_freedirect(freeblks, ip, i, 0);
for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR;
for (i = 0, tmpval = NINDIR(fs), lbn = UFS_NDADDR;
i < UFS_NIADDR;
i++, lbn += tmpval, tmpval *= NINDIR(fs))
setup_freeindir(freeblks, ip, i, -lbn -i, 0);
ip->i_size = 0;
@ -6887,7 +6889,7 @@ softdep_setup_freeblocks(ip, length, flags)
datablocks = DIP(ip, i_blocks) - extblocks;
}
if ((flags & IO_EXT) != 0) {
for (i = 0; i < NXADDR; i++)
for (i = 0; i < UFS_NXADDR; i++)
setup_freeext(freeblks, ip, i, 0);
ip->i_din2->di_extsize = 0;
datablocks += extblocks;
@ -7022,9 +7024,9 @@ trunc_pages(ip, length, extblocks, flags)
* to verify how many levels are required.
*/
lbn = lblkno(fs, length);
if (lbn >= NDADDR) {
if (lbn >= UFS_NDADDR) {
/* Calculate the virtual lbn of the triple indirect. */
lbn = -lbn - (NIADDR - 1);
lbn = -lbn - (UFS_NIADDR - 1);
end = OFF_TO_IDX(lblktosize(fs, lbn));
} else
end = extend;
@ -7753,7 +7755,7 @@ freework_freeblock(freework)
* blocks to expire so that we know the checker will not confuse
* a re-allocated indirect block with its old contents.
*/
if (needj && freework->fw_lbn <= -NDADDR)
if (needj && freework->fw_lbn <= -UFS_NDADDR)
indirblk_insert(freework);
/*
* If we are canceling an existing jnewblk pass it to the free
@ -7926,7 +7928,7 @@ handle_workitem_freeblocks(freeblks, flags)
case D_FREEWORK:
freework = WK_FREEWORK(wk);
if (freework->fw_lbn <= -NDADDR)
if (freework->fw_lbn <= -UFS_NDADDR)
handle_workitem_indirblk(freework);
else
freework_freeblock(freework);
@ -8476,7 +8478,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk)
/*
* Whiteouts have no dependencies.
*/
if (newinum == WINO) {
if (newinum == UFS_WINO) {
if (newdirbp != NULL)
bdwrite(newdirbp);
return (0);
@ -8493,7 +8495,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk)
dap->da_newinum = newinum;
dap->da_state = ATTACHED;
LIST_INIT(&dap->da_jwork);
isindir = bp->b_lblkno >= NDADDR;
isindir = bp->b_lblkno >= UFS_NDADDR;
newdirblk = NULL;
if (isnewblk &&
(isindir ? blkoff(fs, diroffset) : fragoff(fs, diroffset)) == 0) {
@ -9306,7 +9308,7 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir)
/*
* Whiteouts do not need diradd dependencies.
*/
if (newinum != WINO) {
if (newinum != UFS_WINO) {
dap = malloc(sizeof(struct diradd),
M_DIRADD, M_SOFTDEP_FLAGS|M_ZERO);
workitem_alloc(&dap->da_list, D_DIRADD, mp);
@ -9340,7 +9342,7 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir)
* Whiteouts have no additional dependencies,
* so just put the dirrem on the correct list.
*/
if (newinum == WINO) {
if (newinum == UFS_WINO) {
if ((dirrem->dm_state & COMPLETE) == 0) {
LIST_INSERT_HEAD(&pagedep->pd_dirremhd, dirrem,
dm_next);
@ -10217,19 +10219,19 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
if (deplist != 0 && prevlbn >= adp->ad_offset)
panic("softdep_write_inodeblock: lbn order");
prevlbn = adp->ad_offset;
if (adp->ad_offset < NDADDR &&
if (adp->ad_offset < UFS_NDADDR &&
dp->di_db[adp->ad_offset] != adp->ad_newblkno)
panic("%s: direct pointer #%jd mismatch %d != %jd",
"softdep_write_inodeblock",
(intmax_t)adp->ad_offset,
dp->di_db[adp->ad_offset],
(intmax_t)adp->ad_newblkno);
if (adp->ad_offset >= NDADDR &&
dp->di_ib[adp->ad_offset - NDADDR] != adp->ad_newblkno)
if (adp->ad_offset >= UFS_NDADDR &&
dp->di_ib[adp->ad_offset - UFS_NDADDR] != adp->ad_newblkno)
panic("%s: indirect pointer #%jd mismatch %d != %jd",
"softdep_write_inodeblock",
(intmax_t)adp->ad_offset - NDADDR,
dp->di_ib[adp->ad_offset - NDADDR],
(intmax_t)adp->ad_offset - UFS_NDADDR,
dp->di_ib[adp->ad_offset - UFS_NDADDR],
(intmax_t)adp->ad_newblkno);
deplist |= 1 << adp->ad_offset;
if ((adp->ad_state & ATTACHED) == 0)
@ -10247,24 +10249,24 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
*/
for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
lastadp = adp, adp = TAILQ_NEXT(adp, ad_next)) {
if (adp->ad_offset >= NDADDR)
if (adp->ad_offset >= UFS_NDADDR)
break;
dp->di_db[adp->ad_offset] = adp->ad_oldblkno;
/* keep going until hitting a rollback to a frag */
if (adp->ad_oldsize == 0 || adp->ad_oldsize == fs->fs_bsize)
continue;
dp->di_size = fs->fs_bsize * adp->ad_offset + adp->ad_oldsize;
for (i = adp->ad_offset + 1; i < NDADDR; i++) {
for (i = adp->ad_offset + 1; i < UFS_NDADDR; i++) {
#ifdef INVARIANTS
if (dp->di_db[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep1");
#endif /* INVARIANTS */
dp->di_db[i] = 0;
}
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < UFS_NIADDR; i++) {
#ifdef INVARIANTS
if (dp->di_ib[i] != 0 &&
(deplist & ((1 << NDADDR) << i)) == 0)
(deplist & ((1 << UFS_NDADDR) << i)) == 0)
panic("softdep_write_inodeblock: lost dep2");
#endif /* INVARIANTS */
dp->di_ib[i] = 0;
@ -10296,7 +10298,7 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
* postpone fsck, we are stuck with this argument.
*/
for (; adp; adp = TAILQ_NEXT(adp, ad_next))
dp->di_ib[adp->ad_offset - NDADDR] = 0;
dp->di_ib[adp->ad_offset - UFS_NDADDR] = 0;
}
/*
@ -10416,7 +10418,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
if (adp->ad_oldsize == 0 || adp->ad_oldsize == fs->fs_bsize)
continue;
dp->di_extsize = fs->fs_bsize * adp->ad_offset + adp->ad_oldsize;
for (i = adp->ad_offset + 1; i < NXADDR; i++) {
for (i = adp->ad_offset + 1; i < UFS_NXADDR; i++) {
#ifdef INVARIANTS
if (dp->di_extb[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep1");
@ -10450,19 +10452,19 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
if ((adp->ad_state & ATTACHED) == 0)
panic("inodedep %p and adp %p not attached", inodedep, adp);
prevlbn = adp->ad_offset;
if (adp->ad_offset < NDADDR &&
if (adp->ad_offset < UFS_NDADDR &&
dp->di_db[adp->ad_offset] != adp->ad_newblkno)
panic("%s: direct pointer #%jd mismatch %jd != %jd",
"softdep_write_inodeblock",
(intmax_t)adp->ad_offset,
(intmax_t)dp->di_db[adp->ad_offset],
(intmax_t)adp->ad_newblkno);
if (adp->ad_offset >= NDADDR &&
dp->di_ib[adp->ad_offset - NDADDR] != adp->ad_newblkno)
if (adp->ad_offset >= UFS_NDADDR &&
dp->di_ib[adp->ad_offset - UFS_NDADDR] != adp->ad_newblkno)
panic("%s indirect pointer #%jd mismatch %jd != %jd",
"softdep_write_inodeblock:",
(intmax_t)adp->ad_offset - NDADDR,
(intmax_t)dp->di_ib[adp->ad_offset - NDADDR],
(intmax_t)adp->ad_offset - UFS_NDADDR,
(intmax_t)dp->di_ib[adp->ad_offset - UFS_NDADDR],
(intmax_t)adp->ad_newblkno);
deplist |= 1 << adp->ad_offset;
if ((adp->ad_state & ATTACHED) == 0)
@ -10480,24 +10482,24 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
*/
for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
lastadp = adp, adp = TAILQ_NEXT(adp, ad_next)) {
if (adp->ad_offset >= NDADDR)
if (adp->ad_offset >= UFS_NDADDR)
break;
dp->di_db[adp->ad_offset] = adp->ad_oldblkno;
/* keep going until hitting a rollback to a frag */
if (adp->ad_oldsize == 0 || adp->ad_oldsize == fs->fs_bsize)
continue;
dp->di_size = fs->fs_bsize * adp->ad_offset + adp->ad_oldsize;
for (i = adp->ad_offset + 1; i < NDADDR; i++) {
for (i = adp->ad_offset + 1; i < UFS_NDADDR; i++) {
#ifdef INVARIANTS
if (dp->di_db[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep2");
#endif /* INVARIANTS */
dp->di_db[i] = 0;
}
for (i = 0; i < NIADDR; i++) {
for (i = 0; i < UFS_NIADDR; i++) {
#ifdef INVARIANTS
if (dp->di_ib[i] != 0 &&
(deplist & ((1 << NDADDR) << i)) == 0)
(deplist & ((1 << UFS_NDADDR) << i)) == 0)
panic("softdep_write_inodeblock: lost dep3");
#endif /* INVARIANTS */
dp->di_ib[i] = 0;
@ -10529,7 +10531,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
* postpone fsck, we are stuck with this argument.
*/
for (; adp; adp = TAILQ_NEXT(adp, ad_next))
dp->di_ib[adp->ad_offset - NDADDR] = 0;
dp->di_ib[adp->ad_offset - UFS_NDADDR] = 0;
}
/*
@ -11456,7 +11458,7 @@ handle_written_inodeblock(inodedep, bp, flags)
if (adp->ad_state & ATTACHED)
panic("handle_written_inodeblock: new entry");
if (fstype == UFS1) {
if (adp->ad_offset < NDADDR) {
if (adp->ad_offset < UFS_NDADDR) {
if (dp1->di_db[adp->ad_offset]!=adp->ad_oldblkno)
panic("%s %s #%jd mismatch %d != %jd",
"handle_written_inodeblock:",
@ -11466,17 +11468,20 @@ handle_written_inodeblock(inodedep, bp, flags)
(intmax_t)adp->ad_oldblkno);
dp1->di_db[adp->ad_offset] = adp->ad_newblkno;
} else {
if (dp1->di_ib[adp->ad_offset - NDADDR] != 0)
if (dp1->di_ib[adp->ad_offset - UFS_NDADDR] !=
0)
panic("%s: %s #%jd allocated as %d",
"handle_written_inodeblock",
"indirect pointer",
(intmax_t)adp->ad_offset - NDADDR,
dp1->di_ib[adp->ad_offset - NDADDR]);
dp1->di_ib[adp->ad_offset - NDADDR] =
(intmax_t)adp->ad_offset -
UFS_NDADDR,
dp1->di_ib[adp->ad_offset -
UFS_NDADDR]);
dp1->di_ib[adp->ad_offset - UFS_NDADDR] =
adp->ad_newblkno;
}
} else {
if (adp->ad_offset < NDADDR) {
if (adp->ad_offset < UFS_NDADDR) {
if (dp2->di_db[adp->ad_offset]!=adp->ad_oldblkno)
panic("%s: %s #%jd %s %jd != %jd",
"handle_written_inodeblock",
@ -11486,14 +11491,17 @@ handle_written_inodeblock(inodedep, bp, flags)
(intmax_t)adp->ad_oldblkno);
dp2->di_db[adp->ad_offset] = adp->ad_newblkno;
} else {
if (dp2->di_ib[adp->ad_offset - NDADDR] != 0)
if (dp2->di_ib[adp->ad_offset - UFS_NDADDR] !=
0)
panic("%s: %s #%jd allocated as %jd",
"handle_written_inodeblock",
"indirect pointer",
(intmax_t)adp->ad_offset - NDADDR,
(intmax_t)adp->ad_offset -
UFS_NDADDR,
(intmax_t)
dp2->di_ib[adp->ad_offset - NDADDR]);
dp2->di_ib[adp->ad_offset - NDADDR] =
dp2->di_ib[adp->ad_offset -
UFS_NDADDR]);
dp2->di_ib[adp->ad_offset - UFS_NDADDR] =
adp->ad_newblkno;
}
}

View File

@ -1431,7 +1431,7 @@ ffs_statfs(mp, sbp)
fs->fs_cstotal.cs_nffree + dbtofsb(fs, fs->fs_pendingblocks);
sbp->f_bavail = freespace(fs, fs->fs_minfree) +
dbtofsb(fs, fs->fs_pendingblocks);
sbp->f_files = fs->fs_ncg * fs->fs_ipg - ROOTINO;
sbp->f_files = fs->fs_ncg * fs->fs_ipg - UFS_ROOTINO;
sbp->f_ffree = fs->fs_cstotal.cs_nifree + fs->fs_pendinginodes;
UFS_UNLOCK(ump);
sbp->f_namemax = NAME_MAX;
@ -1848,7 +1848,7 @@ ffs_fhtovp(mp, fhp, flags, vpp)
ino = ufhp->ufid_ino;
ump = VFSTOUFS(mp);
fs = ump->um_fs;
if (ino < ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg)
if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg)
return (ESTALE);
/*
* Need to check if inode is initialized because UFS2 does lazy

View File

@ -271,7 +271,7 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
* active. Otherwise we must flush them with data,
* since dependencies prevent data block writes.
*/
if (waitfor == MNT_WAIT && bp->b_lblkno <= -NDADDR &&
if (waitfor == MNT_WAIT && bp->b_lblkno <= -UFS_NDADDR &&
(lbn_level(bp->b_lblkno) >= passes ||
((flags & DATA_ONLY) != 0 && !DOINGSOFTDEP(vp))))
continue;
@ -356,7 +356,7 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
*/
still_dirty = false;
TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) {
if (bp->b_lblkno > -NDADDR) {
if (bp->b_lblkno > -UFS_NDADDR) {
still_dirty = true;
break;
}
@ -373,7 +373,7 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
}
/* switch between sync/async. */
wait = !wait;
if (wait || ++passes < NIADDR + 2)
if (wait || ++passes < UFS_NIADDR + 2)
goto loop;
#ifdef INVARIANTS
if (!vn_isdisk(vp, NULL))
@ -1002,7 +1002,8 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred)
uio->uio_offset = dp->di_extsize;
KASSERT(uio->uio_offset >= 0, ("ffs_extwrite: uio->uio_offset < 0"));
KASSERT(uio->uio_resid >= 0, ("ffs_extwrite: uio->uio_resid < 0"));
if ((uoff_t)uio->uio_offset + uio->uio_resid > NXADDR * fs->fs_bsize)
if ((uoff_t)uio->uio_offset + uio->uio_resid >
UFS_NXADDR * fs->fs_bsize)
return (EFBIG);
resid = uio->uio_resid;
@ -1145,7 +1146,7 @@ ffs_rdextattr(u_char **p, struct vnode *vp, struct thread *td, int extra)
fs = ITOFS(ip);
dp = ip->i_din2;
easize = dp->di_extsize;
if ((uoff_t)easize + extra > NXADDR * fs->fs_bsize)
if ((uoff_t)easize + extra > UFS_NXADDR * fs->fs_bsize)
return (EFBIG);
eae = malloc(easize + extra, M_TEMP, M_WAITOK);
@ -1296,7 +1297,7 @@ struct vop_strategy_args {
vp = ap->a_vp;
lbn = ap->a_bp->b_lblkno;
if (I_IS_UFS2(VTOI(vp)) && lbn < 0 && lbn >= -NXADDR)
if (I_IS_UFS2(VTOI(vp)) && lbn < 0 && lbn >= -UFS_NXADDR)
return (VOP_STRATEGY_APV(&ufs_vnodeops, ap));
if (vp->v_type == VFIFO)
return (VOP_STRATEGY_APV(&ufs_fifoops, ap));
@ -1584,7 +1585,7 @@ vop_setextattr {
return (EROFS);
ealen = ap->a_uio->uio_resid;
if (ealen < 0 || ealen > lblktosize(fs, NXADDR))
if (ealen < 0 || ealen > lblktosize(fs, UFS_NXADDR))
return (EINVAL);
error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
@ -1635,7 +1636,7 @@ vop_setextattr {
easize += (ealength - ul);
}
}
if (easize > lblktosize(fs, NXADDR)) {
if (easize > lblktosize(fs, UFS_NXADDR)) {
free(eae, M_TEMP);
ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
if (ip->i_ea_area != NULL && ip->i_ea_error == 0)

View File

@ -575,7 +575,7 @@ struct cg {
(((off_t)(frag)) << (fs)->fs_fshift)
#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \
(((off_t)(blk)) << (fs)->fs_bshift)
/* Use this only when `blk' is known to be small, e.g., < NDADDR. */
/* Use this only when `blk' is known to be small, e.g., < UFS_NDADDR. */
#define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \
((blk) << (fs)->fs_bshift)
#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
@ -608,11 +608,11 @@ struct cg {
* Determining the size of a file block in the filesystem.
*/
#define blksize(fs, ip, lbn) \
(((lbn) >= NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \
(((lbn) >= UFS_NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \
? (fs)->fs_bsize \
: (fragroundup(fs, blkoff(fs, (ip)->i_size))))
#define sblksize(fs, size, lbn) \
(((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
(((lbn) >= UFS_NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
? (fs)->fs_bsize \
: (fragroundup(fs, blkoff(fs, (size)))))
@ -622,7 +622,7 @@ struct cg {
#define NINDIR(fs) ((fs)->fs_nindir)
/*
* Indirect lbns are aligned on NDADDR addresses where single indirects
* Indirect lbns are aligned on UFS_NDADDR addresses where single indirects
* are the negated address of the lowest lbn reachable, double indirects
* are this lbn - 1 and triple indirects are this lbn - 2. This yields
* an unusual bit order to determine level.

View File

@ -74,15 +74,15 @@
* 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 ROOTINO ((ino_t)2)
#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_WHT entry.
* See the comments about ROOTINO above.
* See the comments about UFS_ROOTINO above.
*/
#define WINO ((ino_t)1)
#define UFS_WINO ((ino_t)1)
/*
* The size of physical and logical block numbers and time fields in UFS.
@ -118,9 +118,9 @@ typedef int64_t ufs_time_t;
* are defined by types with precise widths.
*/
#define NXADDR 2 /* External addresses in inode. */
#define NDADDR 12 /* Direct addresses in inode. */
#define NIADDR 3 /* Indirect addresses in inode. */
#define UFS_NXADDR 2 /* External addresses in inode. */
#define UFS_NDADDR 12 /* Direct addresses in inode. */
#define UFS_NIADDR 3 /* Indirect addresses in inode. */
struct ufs2_dinode {
u_int16_t di_mode; /* 0: IFMT, permissions; see below. */
@ -142,9 +142,9 @@ struct ufs2_dinode {
u_int32_t di_kernflags; /* 84: Kernel flags. */
u_int32_t di_flags; /* 88: Status flags (chflags). */
u_int32_t di_extsize; /* 92: External attributes size. */
ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */
ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */
ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */
ufs2_daddr_t di_extb[UFS_NXADDR];/* 96: External attributes block. */
ufs2_daddr_t di_db[UFS_NDADDR]; /* 112: Direct disk blocks. */
ufs2_daddr_t di_ib[UFS_NIADDR]; /* 208: Indirect disk blocks. */
u_int64_t di_modrev; /* 232: i_modrev for NFSv4 */
uint32_t di_freelink; /* 240: SUJ: Next unlinked inode. */
uint32_t di_spare[3]; /* 244: Reserved; currently unused */
@ -176,8 +176,8 @@ struct ufs1_dinode {
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. */
ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */
ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */
ufs1_daddr_t di_db[UFS_NDADDR]; /* 40: Direct disk blocks. */
ufs1_daddr_t di_ib[UFS_NIADDR]; /* 88: Indirect disk blocks. */
u_int32_t di_flags; /* 100: Status flags (chflags). */
u_int32_t di_blocks; /* 104: Blocks actually held. */
u_int32_t di_gen; /* 108: Generation number. */

View File

@ -115,7 +115,7 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
struct buf *bp;
struct ufsmount *ump;
struct mount *mp;
struct indir a[NIADDR+1], *ap;
struct indir a[UFS_NIADDR+1], *ap;
ufs2_daddr_t daddr;
ufs_lbn_t metalbn;
int error, num, maxrun = 0;
@ -144,9 +144,9 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
num = *nump;
if (num == 0) {
if (bn >= 0 && bn < NDADDR) {
if (bn >= 0 && bn < UFS_NDADDR) {
*bnp = blkptrtodb(ump, DIP(ip, i_db[bn]));
} else if (bn < 0 && bn >= -NXADDR) {
} else if (bn < 0 && bn >= -UFS_NXADDR) {
*bnp = blkptrtodb(ump, ip->i_din2->di_extb[-1 - bn]);
if (*bnp == 0)
*bnp = -1;
@ -175,7 +175,7 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
*bnp = -1;
} else if (runp) {
ufs2_daddr_t bnb = bn;
for (++bn; bn < NDADDR && *runp < maxrun &&
for (++bn; bn < UFS_NDADDR && *runp < maxrun &&
is_sequential(ump, DIP(ip, i_db[bn - 1]),
DIP(ip, i_db[bn]));
++bn, ++*runp);
@ -330,17 +330,18 @@ ufs_getlbns(vp, bn, ap, nump)
if (bn < 0)
bn = -bn;
/* The first NDADDR blocks are direct blocks. */
if (bn < NDADDR)
/* The first UFS_NDADDR blocks are direct blocks. */
if (bn < UFS_NDADDR)
return (0);
/*
* Determine the number of levels of indirection. After this loop
* is done, blockcnt indicates the number of data blocks possible
* at the previous level of indirection, and NIADDR - i is the number
* of levels of indirection needed to locate the requested block.
* at the previous level of indirection, and UFS_NIADDR - i is the
* number of levels of indirection needed to locate the requested block.
*/
for (blockcnt = 1, i = NIADDR, bn -= NDADDR;; i--, bn -= blockcnt) {
for (blockcnt = 1, i = UFS_NIADDR, bn -= UFS_NDADDR; ;
i--, bn -= blockcnt) {
if (i == 0)
return (EFBIG);
blockcnt *= MNINDIR(ump);
@ -350,9 +351,9 @@ ufs_getlbns(vp, bn, ap, nump)
/* Calculate the address of the first meta-block. */
if (realbn >= 0)
metalbn = -(realbn - bn + NIADDR - i);
metalbn = -(realbn - bn + UFS_NIADDR - i);
else
metalbn = -(-realbn - bn + NIADDR - i);
metalbn = -(-realbn - bn + UFS_NIADDR - i);
/*
* At each iteration, off is the offset into the bap array which is
@ -361,9 +362,9 @@ ufs_getlbns(vp, bn, ap, nump)
* into the argument array.
*/
ap->in_lbn = metalbn;
ap->in_off = off = NIADDR - i;
ap->in_off = off = UFS_NIADDR - i;
ap++;
for (++numlevels; i <= NIADDR; i++) {
for (++numlevels; i <= UFS_NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
if (metalbn == realbn)
break;

View File

@ -1069,7 +1069,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename)
namlen = ep->d_namlen;
# endif
if (ep->d_ino == 0 ||
(ep->d_ino == WINO && namlen == dirp->d_namlen &&
(ep->d_ino == UFS_WINO && namlen == dirp->d_namlen &&
bcmp(ep->d_name, dirp->d_name, dirp->d_namlen) == 0)) {
if (spacefree + dsize < newentrysize)
panic("ufs_direnter: compact1");
@ -1178,12 +1178,12 @@ ufs_dirremove(dvp, ip, flags, isrmdir)
}
if (flags & DOWHITEOUT) {
/*
* Whiteout entry: set d_ino to WINO.
* Whiteout entry: set d_ino to UFS_WINO.
*/
if ((error =
UFS_BLKATOFF(dvp, (off_t)dp->i_offset, (char **)&ep, &bp)) != 0)
return (error);
ep->d_ino = WINO;
ep->d_ino = UFS_WINO;
ep->d_type = DT_WHT;
goto out;
}
@ -1353,7 +1353,7 @@ ufs_dirempty(ip, parentino, cred)
if (dp->d_reclen == 0)
return (0);
/* skip empty entries */
if (dp->d_ino == 0 || dp->d_ino == WINO)
if (dp->d_ino == 0 || dp->d_ino == UFS_WINO)
continue;
/* accept only "." and ".." */
# if (BYTE_ORDER == LITTLE_ENDIAN)
@ -1445,7 +1445,7 @@ ufs_checkpath(ino_t source_ino, ino_t parent_ino, struct inode *target, struct u
return (EEXIST);
if (target->i_number == parent_ino)
return (0);
if (target->i_number == ROOTINO)
if (target->i_number == UFS_ROOTINO)
return (0);
for (;;) {
error = ufs_dir_dd_ino(vp, cred, &dd_ino, &vp1);
@ -1455,7 +1455,7 @@ ufs_checkpath(ino_t source_ino, ino_t parent_ino, struct inode *target, struct u
error = EINVAL;
break;
}
if (dd_ino == ROOTINO)
if (dd_ino == UFS_ROOTINO)
break;
if (dd_ino == parent_ino)
break;

View File

@ -74,7 +74,7 @@ ufs_root(mp, flags, vpp)
struct vnode *nvp;
int error;
error = VFS_VGET(mp, (ino_t)ROOTINO, flags, &nvp);
error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, flags, &nvp);
if (error)
return (error);
*vpp = nvp;

View File

@ -1053,7 +1053,7 @@ ufs_whiteout(ap)
panic("ufs_whiteout: old format filesystem");
#endif
newdir.d_ino = WINO;
newdir.d_ino = UFS_WINO;
newdir.d_namlen = cnp->cn_namelen;
bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1);
newdir.d_type = DT_WHT;
@ -2564,7 +2564,7 @@ ufs_vinit(mntp, fifoops, vpp)
if (vp->v_type == VFIFO)
vp->v_op = fifoops;
ASSERT_VOP_LOCKED(vp, "ufs_vinit");
if (ip->i_number == ROOTINO)
if (ip->i_number == UFS_ROOTINO)
vp->v_vflag |= VV_ROOT;
*vpp = vp;
return (0);

View File

@ -278,7 +278,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 = ROOTINO;
fsopts->curinode = UFS_ROOTINO;
if (debug & DEBUG_FS_MAKEFS)
putchar('\n');
@ -371,7 +371,7 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
/* calculate size of tree */
ffs_size_dir(root, fsopts);
fsopts->inodes += ROOTINO; /* include first two inodes */
fsopts->inodes += UFS_ROOTINO; /* include first two inodes */
if (debug & DEBUG_FS_VALIDATE)
printf("ffs_validate: size of tree: %lld bytes, %lld inodes\n",
@ -565,11 +565,11 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
(long long)fs->fs_cstotal.cs_ndir);
}
if (fs->fs_cstotal.cs_nifree + ROOTINO < fsopts->inodes) {
if (fs->fs_cstotal.cs_nifree + UFS_ROOTINO < fsopts->inodes) {
warnx(
"Image file `%s' has %lld free inodes; %lld are required.",
image,
(long long)(fs->fs_cstotal.cs_nifree + ROOTINO),
(long long)(fs->fs_cstotal.cs_nifree + UFS_ROOTINO),
(long long)fsopts->inodes);
return (-1);
}
@ -636,8 +636,8 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
slen = strlen(node->symlink) + 1;
if (slen >= (ffs_opts->version == 1 ?
MAXSYMLINKLEN_UFS1 :
MAXSYMLINKLEN_UFS2))
UFS1_MAXSYMLINKLEN :
UFS2_MAXSYMLINKLEN))
ADDSIZE(slen);
}
}
@ -690,7 +690,7 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
ufs_rw32(cur->inode->st.st_rdev, fsopts->needswap);
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
if (slen < MAXSYMLINKLEN_UFS1) { /* short link */
if (slen < UFS1_MAXSYMLINKLEN) { /* short link */
memcpy(dinp->di_db, cur->symlink, slen);
} else
membuf = cur->symlink;
@ -742,7 +742,7 @@ ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
ufs_rw64(cur->inode->st.st_rdev, fsopts->needswap);
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
if (slen < MAXSYMLINKLEN_UFS2) { /* short link */
if (slen < UFS2_MAXSYMLINKLEN) { /* short link */
memcpy(dinp->di_db, cur->symlink, slen);
} else
membuf = cur->symlink;

View File

@ -157,7 +157,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 < NDADDR + NINDIR(fs)) {
if (lbn < UFS_NDADDR + NINDIR(fs)) {
cg = ino_to_cg(fs, ip->i_number);
return (fs->fs_fpg * cg + fs->fs_frag);
}
@ -196,7 +196,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 < NDADDR + NINDIR(fs)) {
if (lbn < UFS_NDADDR + NINDIR(fs)) {
cg = ino_to_cg(fs, ip->i_number);
return (fs->fs_fpg * cg + fs->fs_frag);
}

View File

@ -82,11 +82,11 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
int32_t nb;
struct buf *bp, *nbp;
struct fs *fs = ip->i_fs;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
daddr_t newb, pref;
int32_t *bap;
int osize, nsize, num, i, error;
int32_t *allocblk, allociblk[NIADDR + 1];
int32_t *allocblk, allociblk[UFS_NIADDR + 1];
int32_t *allocib;
const int needswap = UFS_FSNEEDSWAP(fs);
struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
@ -108,7 +108,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
lastlbn = lblkno(fs, ip->i_ffs1_size);
if (lastlbn < NDADDR && lastlbn < lbn) {
if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
nb = lastlbn;
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
@ -118,10 +118,10 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
/*
* The first NDADDR blocks are direct blocks
* The first UFS_NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
nb = ufs_rw32(ip->i_ffs1_db[lbn], needswap);
if (nb != 0 && ip->i_ffs1_size >= lblktosize(fs, lbn + 1)) {
@ -332,11 +332,11 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
int size;
struct buf *bp, *nbp;
struct fs *fs = ip->i_fs;
struct indir indirs[NIADDR + 2];
struct indir indirs[UFS_NIADDR + 2];
daddr_t newb, pref, nb;
int64_t *bap;
int osize, nsize, num, i, error;
int64_t *allocblk, allociblk[NIADDR + 1];
int64_t *allocblk, allociblk[UFS_NIADDR + 1];
int64_t *allocib;
const int needswap = UFS_FSNEEDSWAP(fs);
struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
@ -358,7 +358,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
lastlbn = lblkno(fs, ip->i_ffs2_size);
if (lastlbn < NDADDR && lastlbn < lbn) {
if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
nb = lastlbn;
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
@ -368,10 +368,10 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
/*
* The first NDADDR blocks are direct blocks
* The first UFS_NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
if (lbn < UFS_NDADDR) {
nb = ufs_rw64(ip->i_ffs2_db[lbn], needswap);
if (nb != 0 && ip->i_ffs2_size >= lblktosize(fs, lbn + 1)) {

View File

@ -148,8 +148,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_old_flags = 0;
} else {
sblock.fs_old_inodefmt = FS_44INODEFMT;
sblock.fs_maxsymlinklen = (Oflag == 1 ? MAXSYMLINKLEN_UFS1 :
MAXSYMLINKLEN_UFS2);
sblock.fs_maxsymlinklen = (Oflag == 1 ? UFS1_MAXSYMLINKLEN :
UFS2_MAXSYMLINKLEN);
sblock.fs_old_flags = FS_FLAGS_UPDATED;
sblock.fs_flags = 0;
}
@ -256,7 +256,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_sblockloc = SBLOCK_UFS1;
sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
sizeof (ufs1_daddr_t));
sblock.fs_old_inodefmt = FS_44INODEFMT;
sblock.fs_old_cgoffset = 0;
@ -276,7 +276,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_sblockloc = SBLOCK_UFS2;
sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
sizeof (ufs2_daddr_t));
}
@ -286,8 +286,8 @@ 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 * NDADDR - 1;
for (sizepb = sblock.fs_bsize, i = 0; i < NIADDR; i++) {
sblock.fs_maxfilesize = sblock.fs_bsize * UFS_NDADDR - 1;
for (sizepb = sblock.fs_bsize, i = 0; i < UFS_NIADDR; i++) {
sizepb *= NINDIR(&sblock);
sblock.fs_maxfilesize += sizepb;
}
@ -447,7 +447,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
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_nifree =
sblock.fs_ncg * sblock.fs_ipg - UFS_ROOTINO;
sblock.fs_cstotal.cs_ndir = 0;
sblock.fs_dsize -= csfrags;
sblock.fs_time = tstamp;
@ -654,7 +655,7 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts)
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
if (cylno == 0)
for (i = 0; i < ROOTINO; i++) {
for (i = 0; i < UFS_ROOTINO; i++) {
setbit(cg_inosused_swap(&acg, 0), i);
acg.cg_cs.cs_nifree--;
}

View File

@ -82,17 +82,17 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
if ((long)bn < 0)
bn = -(long)bn;
assert (bn >= NDADDR);
assert (bn >= UFS_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 NIADDR - i is the number
* at the given level of indirection, and UFS_NIADDR - i is the number
* of levels of indirection needed to locate the requested block.
*/
bn -= NDADDR;
for (lbc = 0, i = NIADDR;; i--, bn -= blockcnt) {
bn -= UFS_NDADDR;
for (lbc = 0, i = UFS_NIADDR;; i--, bn -= blockcnt) {
if (i == 0)
return (EFBIG);
@ -105,9 +105,9 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
/* Calculate the address of the first meta-block. */
if (realbn >= 0)
metalbn = -(realbn - bn + NIADDR - i);
metalbn = -(realbn - bn + UFS_NIADDR - i);
else
metalbn = -(-realbn - bn + NIADDR - i);
metalbn = -(-realbn - bn + UFS_NIADDR - i);
/*
* At each iteration, off is the offset into the bap array which is
@ -116,9 +116,9 @@ 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 = NIADDR - i;
ap->in_off = off = UFS_NIADDR - i;
ap++;
for (++numlevels; i <= NIADDR; i++) {
for (++numlevels; i <= UFS_NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
if (metalbn == realbn)
break;

View File

@ -255,8 +255,8 @@ extern struct stat stampst;
#define DINODE1_SIZE (sizeof(struct ufs1_dinode))
#define DINODE2_SIZE (sizeof(struct ufs2_dinode))
#define MAXSYMLINKLEN_UFS1 ((NDADDR + NIADDR) * sizeof(ufs1_daddr_t))
#define MAXSYMLINKLEN_UFS2 ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t))
#define UFS1_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(ufs1_daddr_t))
#define UFS2_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(ufs2_daddr_t))
#if (BYTE_ORDER == LITTLE_ENDIAN)
#define DIRSIZ_SWAP(oldfmt, dp, needswap) \

View File

@ -170,7 +170,7 @@ static int virtualblocks(struct fs *super, union dinode *dp)
sz = DIP(super, dp, di_size);
#ifdef COMPAT
if (lblkno(super,sz) >= NDADDR) {
if (lblkno(super,sz) >= UFS_NDADDR) {
nblk = blkroundup(super,sz);
if (sz == nblk)
nblk += super->fs_bsize;
@ -180,10 +180,10 @@ static int virtualblocks(struct fs *super, union dinode *dp)
#else /* COMPAT */
if (lblkno(super,sz) >= NDADDR) {
if (lblkno(super,sz) >= UFS_NDADDR) {
nblk = blkroundup(super,sz);
sz = lblkno(super,nblk);
sz = (sz - NDADDR + NINDIR(super) - 1) / NINDIR(super);
sz = (sz - UFS_NDADDR + NINDIR(super) - 1) / NINDIR(super);
while (sz > 0) {
nblk += sz * super->fs_bsize;
/* sz - 1 rounded up */