From: Sascha Wildner Date: Sat, 7 Apr 2018 22:03:47 +0000 (+0200) Subject: ufs: Rename a number of UFS constants throughout the tree. X-Git-Tag: v5.5.0~859 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/c309c6d4b7544672e5babaa14ab7290f4a777e79 ufs: Rename a number of UFS constants throughout the tree. ROOTINO -> UFS_ROOTINO WINO -> UFS_WINO NDADDR -> UFS_NDADDR NIADDR -> UFS_NIADDR MAXSYMLINKLEN -> UFS1_MAXSYMLINKLEN This helps to better sepate them from identically named EXT2 constants which I'll rename in a later commit. It also helps with my makefs(8) port. I went with FreeBSD's names, so it is UFS1_MAXSYMLINKLEN even though we'll probably never have UFS2, but since they are in public headers, some stuff in dports might benefit from it in the future. For safety, bump too. --- diff --git a/lib/libstand/ufs.c b/lib/libstand/ufs.c index 9ca3988583..c47774fa3c 100644 --- a/lib/libstand/ufs.c +++ b/lib/libstand/ufs.c @@ -1,5 +1,4 @@ /* $FreeBSD: src/lib/libstand/ufs.c,v 1.5.6.1 2000/05/04 13:47:53 ps Exp $ */ -/* $DragonFly: src/lib/libstand/ufs.c,v 1.9 2006/04/03 01:58:45 dillon Exp $ */ /* $NetBSD: ufs.c,v 1.20 1998/03/01 07:15:39 ross Exp $ */ /*- @@ -99,14 +98,14 @@ struct file { off_t f_seekp; /* seek pointer */ struct fs *f_fs; /* pointer to super-block */ struct ufs1_dinode 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 */ - daddr_t f_blkno[NIADDR];/* disk address of block in buffer */ + daddr_t f_blkno[UFS_NIADDR];/* disk address of block in buffer */ char *f_buf; /* buffer for data block */ size_t f_buf_size; /* size of data block */ daddr_t f_buf_blkno; /* block number of data block */ @@ -163,7 +162,7 @@ read_inode(ino_t inumber, struct open_file *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; } @@ -193,33 +192,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..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 = fp->f_di.di_db[file_block]; return (0); } - file_block -= NDADDR; + file_block -= UFS_NDADDR; /* * nindir[0] = NINDIR @@ -227,12 +226,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 < 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); } @@ -445,7 +444,7 @@ ufs_open(const char *upath, struct open_file *f) omult = 0; mult = 1; - for (level = 0; level < NIADDR; level++) { + for (level = 0; level < UFS_NIADDR; level++) { mult *= NINDIR(fs); if (mult < omult) mult = 0x7FFFFFFF; @@ -454,7 +453,7 @@ ufs_open(const char *upath, struct open_file *f) } } - inumber = ROOTINO; + inumber = UFS_ROOTINO; if ((rc = read_inode(inumber, f)) != 0) goto out; @@ -567,7 +566,7 @@ ufs_open(const char *upath, struct open_file *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; @@ -604,7 +603,7 @@ ufs_close(struct open_file *f) if (fp == NULL) 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]); } @@ -734,8 +733,8 @@ ffs_oldfscompat(struct fs *fs) if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ quad_t sizepb = fs->fs_bsize; /* XXX */ /* XXX */ - fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ - for (i = 0; i < NIADDR; i++) { /* XXX */ + fs->fs_maxfilesize = fs->fs_bsize * UFS_NDADDR - 1; /* XXX */ + for (i = 0; i < UFS_NIADDR; i++) { /* XXX */ sizepb *= NINDIR(fs); /* XXX */ fs->fs_maxfilesize += sizepb; /* XXX */ } /* XXX */ diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index 78c0822f3a..e606be014a 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -89,10 +89,10 @@ blockest(struct ufs1_dinode *dp) sizeest = howmany(dp->di_size, TP_BSIZE); if (blkest > sizeest) blkest = sizeest; - if (dp->di_size > (unsigned)sblock->fs_bsize * NDADDR) { + if (dp->di_size > (unsigned)sblock->fs_bsize * UFS_NDADDR) { /* calculate the number of indirect blocks on the dump tape */ blkest += - howmany(sizeest - NDADDR * sblock->fs_bsize / TP_BSIZE, + howmany(sizeest - UFS_NDADDR * sblock->fs_bsize / TP_BSIZE, TP_NINDIR); } return (blkest + 1); @@ -126,7 +126,7 @@ mapfiles(ufs1_ino_t maxino, long *tape_size) struct ufs1_dinode *dp; int anydirskipped = 0; - for (ino = ROOTINO; ino < maxino; ino++) { + for (ino = UFS_ROOTINO; ino < maxino; ino++) { dp = getino(ino); if ((mode = (dp->di_mode & IFMT)) == 0) continue; @@ -157,7 +157,7 @@ mapfiles(ufs1_ino_t maxino, long *tape_size) * 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); } @@ -204,7 +204,7 @@ mapdirs(ufs1_ino_t maxino, long *tape_size) dp = getino(ino); di = *dp; /* inode buf may change in searchdir(). */ filesize = 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 (di.di_db[i] != 0) { ret |= searchdir(ino, di.di_db[i], (long)dblksize(sblock, &di, i), @@ -215,7 +215,7 @@ mapdirs(ufs1_ino_t maxino, long *tape_size) else filesize -= sblock->fs_bsize; } - for (i = 0; filesize > 0 && i < NIADDR; i++) { + for (i = 0; filesize > 0 && i < UFS_NIADDR; i++) { if (di.di_ib[i] == 0) continue; ret |= dirindir(ino, di.di_ib[i], i, &filesize, @@ -405,14 +405,14 @@ dumpino(struct ufs1_dinode *dp, ufs1_ino_t ino) msg("Warning: undefined file type 0%o\n", dp->di_mode & IFMT); return; } - if (dp->di_size > NDADDR * (unsigned)sblock->fs_bsize) - cnt = NDADDR * sblock->fs_frag; + if (dp->di_size > UFS_NDADDR * (unsigned)sblock->fs_bsize) + cnt = UFS_NDADDR * sblock->fs_frag; else cnt = howmany(dp->di_size, sblock->fs_fsize); blksout(&dp->di_db[0], cnt, ino); - if ((size = dp->di_size - NDADDR * sblock->fs_bsize) <= 0) + if ((size = 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(ino, dp->di_ib[ind_level], ind_level, &size); if (size <= 0) return; diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c index 52fade69a1..39b1e04751 100644 --- a/sbin/ffsinfo/ffsinfo.c +++ b/sbin/ffsinfo/ffsinfo.c @@ -438,7 +438,7 @@ dump_whole_inode(ino_t inode, int fsi, 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. diff --git a/sbin/fsck/dir.c b/sbin/fsck/dir.c index e38443720e..95a556171c 100644 --- a/sbin/fsck/dir.c +++ b/sbin/fsck/dir.c @@ -273,7 +273,7 @@ fileerror(ufs1_ino_t cwd, ufs1_ino_t ino, 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; } @@ -423,24 +423,25 @@ linkup(ufs1_ino_t orphan, ufs1_ino_t parentdir, char *name) if (reply("RECONNECT") == 0) return (0); if (lfdir == 0) { - dp = ginode(ROOTINO); + dp = ginode(UFS_ROOTINO); idesc.id_name = 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, (ufs1_ino_t)0, lfmode); + lfdir = allocdir(UFS_ROOTINO, (ufs1_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"); @@ -460,11 +461,11 @@ linkup(ufs1_ino_t orphan, ufs1_ino_t parentdir, char *name) if (reply("REALLOCATE") == 0) return (0); oldlfdir = lfdir; - if ((lfdir = allocdir(ROOTINO, (ufs1_ino_t)0, lfmode)) == 0) { + if ((lfdir = allocdir(UFS_ROOTINO, (ufs1_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); } @@ -541,8 +542,8 @@ makeentry(ufs1_ino_t parent, ufs1_ino_t ino, 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; @@ -576,7 +577,8 @@ expanddir(struct ufs1_dinode *dp, char *name) char *cp, firstblk[DIRBLKSIZ]; lastbn = lblkno(&sblock, dp->di_size); - if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0) + if (lastbn >= UFS_NDADDR - 1 || dp->di_db[lastbn] == 0 || + dp->di_size == 0) return (0); if ((newblk = allocblk(sblock.fs_frag)) == 0) return (0); @@ -653,7 +655,7 @@ allocdir(ufs1_ino_t parent, ufs1_ino_t request, int mode) dirty(bp); dp->di_nlink = 2; inodirty(); - if (ino == ROOTINO) { + if (ino == UFS_ROOTINO) { inoinfo(ino)->ino_linkcnt = dp->di_nlink; cacheino(dp, ino); return(ino); diff --git a/sbin/fsck/inode.c b/sbin/fsck/inode.c index d41e96c56f..92bd26a186 100644 --- a/sbin/fsck/inode.c +++ b/sbin/fsck/inode.c @@ -69,7 +69,7 @@ ckinode(struct ufs1_dinode *dp, struct inodesc *idesc) return (KEEPON); dino = *dp; ndb = howmany(dino.di_size, sblock.fs_bsize); - for (ap = &dino.di_db[0]; ap < &dino.di_db[NDADDR]; ap++) { + for (ap = &dino.di_db[0]; ap < &dino.di_db[UFS_NDADDR]; ap++) { if (--ndb == 0 && (offset = blkoff(&sblock, dino.di_size)) != 0) idesc->id_numfrags = numfrags(&sblock, fragroundup(&sblock, offset)); @@ -104,9 +104,9 @@ ckinode(struct ufs1_dinode *dp, struct inodesc *idesc) return (ret); } idesc->id_numfrags = sblock.fs_frag; - remsize = dino.di_size - sblock.fs_bsize * NDADDR; + remsize = dino.di_size - sblock.fs_bsize * UFS_NDADDR; sizepb = sblock.fs_bsize; - for (ap = &dino.di_ib[0], n = 1; n <= NIADDR; ap++, n++) { + for (ap = &dino.di_ib[0], n = 1; n <= UFS_NIADDR; ap++, n++) { if (*ap) { idesc->id_blkno = *ap; ret = iblock(idesc, n, remsize); @@ -269,7 +269,7 @@ ginode(ufs1_ino_t inumber) { ufs_daddr_t iblk; - if (inumber < ROOTINO || inumber > maxino) + if (inumber < UFS_ROOTINO || inumber > maxino) errx(EEXIT, "bad inode number %d to ginode", inumber); if (startinum == 0 || inumber < startinum || inumber >= startinum + INOPB(&sblock)) { @@ -372,8 +372,8 @@ cacheino(struct ufs1_dinode *dp, ufs1_ino_t inumber) int blks; blks = howmany(dp->di_size, sblock.fs_bsize); - if (blks > NDADDR) - blks = NDADDR + NIADDR; + if (blks > UFS_NDADDR) + blks = UFS_NDADDR + UFS_NIADDR; inp = mzalloc(&inoinfo_zone, sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t)); if (inp == NULL) @@ -381,7 +381,7 @@ cacheino(struct ufs1_dinode *dp, ufs1_ino_t inumber) inpp = &inphead[DIRHASH(inumber)]; inp->i_nexthash = *inpp; *inpp = inp; - inp->i_parent = inumber == ROOTINO ? ROOTINO : (ufs1_ino_t)0; + inp->i_parent = inumber == UFS_ROOTINO ? UFS_ROOTINO : (ufs1_ino_t)0; inp->i_dotdot = (ufs1_ino_t)0; inp->i_number = inumber; inp->i_isize = dp->di_size; @@ -478,7 +478,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); } @@ -507,7 +507,7 @@ pinode(ufs1_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="); @@ -562,7 +562,7 @@ allocino(ufs1_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++) diff --git a/sbin/fsck/main.c b/sbin/fsck/main.c index 49b84dea0b..ecea86b046 100644 --- a/sbin/fsck/main.c +++ b/sbin/fsck/main.c @@ -284,7 +284,7 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child) printf("(%d frags, %d blocks, %.1f%% fragmentation)\n", n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize); if (debug && - (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree)) + (n_files -= maxino - UFS_ROOTINO - sblock.fs_cstotal.cs_nifree)) printf("%d files missing\n", n_files); if (debug) { n_blks += sblock.fs_ncg * diff --git a/sbin/fsck/pass1.c b/sbin/fsck/pass1.c index 8be48b87dc..efa9d9ec67 100644 --- a/sbin/fsck/pass1.c +++ b/sbin/fsck/pass1.c @@ -131,7 +131,7 @@ pass1(void) * Scan the allocated inodes. */ for (i = 0; i < inosused; i++, inumber++) { - if (inumber < ROOTINO) { + if (inumber < UFS_ROOTINO) { getnextinode(inumber); continue; } @@ -180,9 +180,9 @@ checkinode(ufs1_ino_t inumber, struct inodesc *idesc) mode = dp->di_mode & IFMT; if (mode == 0) { if (memcmp(dp->di_db, zino.di_db, - NDADDR * sizeof(ufs_daddr_t)) || + UFS_NDADDR * sizeof(ufs_daddr_t)) || memcmp(dp->di_ib, zino.di_ib, - NIADDR * sizeof(ufs_daddr_t)) || + UFS_NIADDR * sizeof(ufs_daddr_t)) || dp->di_mode || dp->di_size) { pfatal("PARTIALLY ALLOCATED INODE I=%u", inumber); if (reply("CLEAR") == 1) { @@ -229,7 +229,7 @@ checkinode(ufs1_ino_t inumber, struct inodesc *idesc) ndb++; if (mode == IFLNK) { if (doinglevel2 && - dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && + dp->di_size > 0 && dp->di_size < UFS1_MAXSYMLINKLEN && dp->di_blocks != 0) { symbuf = alloca(secsize); if (bread(fsreadfd, symbuf, @@ -252,24 +252,24 @@ checkinode(ufs1_ino_t inumber, struct inodesc *idesc) */ if (dp->di_size < sblock.fs_maxsymlinklen) { ndb = howmany(dp->di_size, sizeof(ufs_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; j < NDADDR; j++) + for (j = ndb; j < UFS_NDADDR; j++) if (dp->di_db[j] != 0) { if (debug) printf("bad direct addr: %ld\n", (long)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 (dp->di_ib[j] != 0) { if (debug) printf("bad indirect addr: %ld\n", diff --git a/sbin/fsck/pass1b.c b/sbin/fsck/pass1b.c index d5b6e6ec9b..19239df610 100644 --- a/sbin/fsck/pass1b.c +++ b/sbin/fsck/pass1b.c @@ -28,7 +28,6 @@ * * @(#)pass1b.c 8.4 (Berkeley) 4/28/95 * $FreeBSD: src/sbin/fsck/pass1b.c,v 1.7.2.1 2001/01/23 23:11:07 iedowse Exp $ - * $DragonFly: src/sbin/fsck/pass1b.c,v 1.8 2006/10/12 04:04:03 dillon Exp $ */ #include @@ -64,7 +63,7 @@ pass1b(void) got_siginfo = 0; } for (i = 0; i < sblock.fs_ipg; i++, inumber++) { - if (inumber < ROOTINO) + if (inumber < UFS_ROOTINO) continue; dp = ginode(inumber); if (dp == NULL) diff --git a/sbin/fsck/pass2.c b/sbin/fsck/pass2.c index fdc85a91ae..b713b505df 100644 --- a/sbin/fsck/pass2.c +++ b/sbin/fsck/pass2.c @@ -56,7 +56,7 @@ pass2(void) char pathbuf[MAXPATHLEN + 1]; long i, n; - switch (inoinfo(ROOTINO)->ino_state) { + switch (inoinfo(UFS_ROOTINO)->ino_state) { case USTATE: pfatal("ROOT INODE UNALLOCATED"); @@ -64,15 +64,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; } @@ -86,8 +87,9 @@ pass2(void) case FCLEAR: 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; } @@ -95,7 +97,7 @@ pass2(void) ckfini(0); exit(EEXIT); } - dp = ginode(ROOTINO); + dp = ginode(UFS_ROOTINO); dp->di_mode &= ~IFMT; dp->di_mode |= IFDIR; inodirty(); @@ -106,12 +108,12 @@ 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(UFS_ROOTINO)->ino_state = DFOUND; if (newinofmt) { - inoinfo(WINO)->ino_state = FSTATE; - inoinfo(WINO)->ino_type = DT_WHT; + inoinfo(UFS_WINO)->ino_state = FSTATE; + inoinfo(UFS_WINO)->ino_type = DT_WHT; } /* * Sort the directory list into disk block order. Do this in blocks @@ -390,10 +392,10 @@ chk2: fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE"); n = reply("REMOVE"); } else if (newinofmt && - ((dirp->d_ino == WINO && dirp->d_type != DT_WHT) || - (dirp->d_ino != WINO && dirp->d_type == DT_WHT))) { + ((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; diff --git a/sbin/fsck/pass3.c b/sbin/fsck/pass3.c index e852687a1d..ddde30e455 100644 --- a/sbin/fsck/pass3.c +++ b/sbin/fsck/pass3.c @@ -58,7 +58,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 && state != DSTATE)) continue; if (state == DCLEAR) @@ -70,7 +70,7 @@ pass3(void) * in pass 4. */ if (preen && resolved && usedsoftdep && state == DSTATE) { - if (inp->i_dotdot >= ROOTINO) + if (inp->i_dotdot >= UFS_ROOTINO) inoinfo(inp->i_dotdot)->ino_linkcnt++; continue; } diff --git a/sbin/fsck/pass4.c b/sbin/fsck/pass4.c index 6a962694f6..a8fdb75f52 100644 --- a/sbin/fsck/pass4.c +++ b/sbin/fsck/pass4.c @@ -61,7 +61,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) { diff --git a/sbin/fsck/pass5.c b/sbin/fsck/pass5.c index 1007248e9a..c91a674bdd 100644 --- a/sbin/fsck/pass5.c +++ b/sbin/fsck/pass5.c @@ -57,7 +57,7 @@ pass5(void) struct cg *newcg = (struct cg *)buf; struct ocg *ocg = (struct ocg *)buf; - 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) { @@ -223,14 +223,14 @@ pass5(void) break; default: - if (j < ROOTINO) + if (j < UFS_ROOTINO) break; errx(EEXIT, "BAD STATE %d FOR INODE I=%ld", inoinfo(j)->ino_state, j); } } if (c == 0) - for (i = 0; i < ROOTINO; i++) { + for (i = 0; i < UFS_ROOTINO; i++) { setbit(cg_inosused(newcg), i); newcg->cg_cs.cs_nifree--; } diff --git a/sbin/fsck/setup.c b/sbin/fsck/setup.c index c8c14f7aa4..82ea98c037 100644 --- a/sbin/fsck/setup.c +++ b/sbin/fsck/setup.c @@ -205,12 +205,12 @@ setup(char *dev) doinglevel2++; sblock.fs_inodefmt = FS_44INODEFMT; sizepb = sblock.fs_bsize; - sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1; - for (i = 0; i < NIADDR; i++) { + sblock.fs_maxfilesize = sblock.fs_bsize * UFS_NDADDR - 1; + for (i = 0; i < UFS_NIADDR; i++) { sizepb *= NINDIR(&sblock); sblock.fs_maxfilesize += sizepb; } - sblock.fs_maxsymlinklen = MAXSYMLINKLEN; + sblock.fs_maxsymlinklen = UFS1_MAXSYMLINKLEN; sblock.fs_qbmask = ~sblock.fs_bmask; sblock.fs_qfmask = ~sblock.fs_fmask; sbdirty(); diff --git a/sbin/fsck/utilities.c b/sbin/fsck/utilities.c index e0fa73ef98..da7181f413 100644 --- a/sbin/fsck/utilities.c +++ b/sbin/fsck/utilities.c @@ -427,7 +427,7 @@ getpathname(char *namebuf, ufs1_ino_t curdir, ufs1_ino_t ino) struct inodesc idesc; static int busy = 0; - if (curdir == ino && ino == ROOTINO) { + if (curdir == ino && ino == UFS_ROOTINO) { strcpy(namebuf, "/"); return; } @@ -447,7 +447,7 @@ getpathname(char *namebuf, ufs1_ino_t curdir, ufs1_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 = ".."; @@ -469,7 +469,7 @@ getpathname(char *namebuf, ufs1_ino_t curdir, ufs1_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)); } diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index 667ae84d49..482ec1080c 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -214,8 +214,8 @@ cmdloop(void) HistEvent he; EditLine *elptr; - curinode = ginode(ROOTINO); - curinum = ROOTINO; + curinode = ginode(UFS_ROOTINO); + curinum = UFS_ROOTINO; printactive(0); hist = history_init(); @@ -276,9 +276,10 @@ struct ufs1_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; \ } @@ -441,8 +442,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; diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c index 772606dd63..8457843db2 100644 --- a/sbin/fsdb/fsdbutil.c +++ b/sbin/fsdb/fsdbutil.c @@ -107,7 +107,7 @@ printstat(const char *cp, ino_t inum, struct ufs1_dinode *dp) break; case IFLNK: fputs("symlink",stdout); - if (dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && + if (dp->di_size > 0 && dp->di_size < UFS1_MAXSYMLINKLEN && dp->di_blocks == 0) printf(" to `%.*s'\n", (int) dp->di_size, (char *)dp->di_shortlink); else @@ -239,7 +239,7 @@ printblocks(ino_t inum, struct ufs1_dinode *dp) printf("Blocks for inode %ju:\n", (uintmax_t)inum); printf("Direct blocks:\n"); ndb = howmany(dp->di_size, sblock.fs_bsize); - for (i = 0; i < NDADDR; i++) { + for (i = 0; i < UFS_NDADDR; i++) { if (dp->di_db[i] == 0) { putchar('\n'); return; @@ -260,7 +260,7 @@ printblocks(ino_t inum, struct ufs1_dinode *dp) 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++) if (printindir(dp->di_ib[i], i, bufp) == 0) break; free(bufp); diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index bdc671f021..9f7536d91f 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -250,7 +250,7 @@ fsirand(char *device) } for (n = 0; n < sblock->fs_ipg; n++, inumber++) { - if (inumber >= ROOTINO) { + if (inumber >= UFS_ROOTINO) { if (printonly) { printf("ino %jd gen %x\n", (intmax_t)inumber, diff --git a/sbin/growfs/debug.c b/sbin/growfs/debug.c index a58bce0949..0ad3004f5b 100644 --- a/sbin/growfs/debug.c +++ b/sbin/growfs/debug.c @@ -37,9 +37,6 @@ * * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ * $FreeBSD: src/sbin/growfs/debug.c,v 1.3.2.1 2001/07/16 15:02:13 tomsoft Exp $ - * $DragonFly: src/sbin/growfs/debug.c,v 1.5 2007/05/20 23:21:36 dillon Exp $ - * - * $FreeBSD: src/sbin/growfs/debug.c,v 1.3.2.1 2001/07/16 15:02:13 tomsoft Exp $ */ /* ********************************************************** INCLUDES ***** */ @@ -626,11 +623,11 @@ dbg_dump_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]); diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index bda65fe08d..e31341d3c9 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -410,7 +410,7 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) } acg.cg_cs.cs_nifree += sblock.fs_ipg; if (cylno == 0) - for (i = 0; (size_t)i < ROOTINO; i++) { + for (i = 0; (size_t)i < UFS_ROOTINO; i++) { setbit(cg_inosused(&acg), i); acg.cg_cs.cs_nifree--; } @@ -2269,7 +2269,7 @@ updrefs(int cg, ino_t in, struct gfs_bpp *bp, int fsi, int fso, unsigned int DBG_LEAVE; return; /* only check DIR, FILE, LINK */ } - if(((ino->di_mode & IFMT)==IFLNK) && (ino->di_sizedi_mode & IFMT)==IFLNK) && (ino->di_sizedi_size, sblock.fs_bsize); - for(ictr=0; ictr < MIN(NDADDR, (unsigned int)remaining_blocks); + for(ictr=0; ictr < MIN(UFS_NDADDR, (unsigned int)remaining_blocks); ictr++) { iptr=&(ino->di_db[ictr]); if(*iptr) { @@ -2298,7 +2298,7 @@ updrefs(int cg, ino_t in, struct gfs_bpp *bp, int fsi, int fso, unsigned int } DBG_PRINT0("~~scg direct blocks checked\n"); - remaining_blocks-=NDADDR; + remaining_blocks-=UFS_NDADDR; if(remaining_blocks<0) { DBG_LEAVE; return; diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 807070e427..71f205b31f 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -230,7 +230,7 @@ mkfs(char *fsys, int fi, int fo, const char *mfscopy) sblock.fs_maxsymlinklen = 0; } else { sblock.fs_inodefmt = FS_44INODEFMT; - sblock.fs_maxsymlinklen = MAXSYMLINKLEN; + sblock.fs_maxsymlinklen = UFS1_MAXSYMLINKLEN; } if (Uflag) sblock.fs_flags |= FS_DOSOFTDEP; @@ -329,8 +329,8 @@ mkfs(char *fsys, int fi, int fo, const char *mfscopy) sblock.fs_cgmask <<= 1; if (!POWEROF2(sblock.fs_ntrak)) sblock.fs_cgmask <<= 1; - 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; } @@ -823,7 +823,7 @@ initcg(int cylno, time_t utime) } acg.cg_cs.cs_nifree += sblock.fs_ipg; if (cylno == 0) { - for (k = 0; k < ROOTINO; k++) { + for (k = 0; k < UFS_ROOTINO; k++) { setbit(cg_inosused(&acg), k); acg.cg_cs.cs_nifree--; } @@ -932,8 +932,8 @@ struct ufs1_dinode node; #endif struct direct root_dir[] = { - { ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, + { UFS_ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, + { UFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, #ifdef LOSTDIR { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found" }, #endif @@ -944,8 +944,8 @@ struct odirect { u_short d_namlen; u_char d_name[MAXNAMLEN + 1]; } oroot_dir[] = { - { ROOTINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, + { UFS_ROOTINO, sizeof(struct direct), 1, "." }, + { UFS_ROOTINO, sizeof(struct direct), 2, ".." }, #ifdef LOSTDIR { LOSTFOUNDINO, sizeof(struct direct), 10, "lost+found" }, #endif @@ -953,12 +953,12 @@ struct odirect { #ifdef LOSTDIR struct direct lost_found_dir[] = { { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, + { UFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, { 0, DIRBLKSIZ, 0, 0, 0 }, }; struct odirect olost_found_dir[] = { { LOSTFOUNDINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, + { UFS_ROOTINO, sizeof(struct direct), 2, ".." }, { 0, DIRBLKSIZ, 0, 0 }, }; #endif @@ -1015,7 +1015,7 @@ fsinit(time_t utime) node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode); node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); wtfs(fsbtodb(&sblock, node.di_db[0]), sblock.fs_fsize, buf); - iput(&node, ROOTINO); + iput(&node, UFS_ROOTINO); } /* diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c index 66f554a12a..230f0c4104 100644 --- a/sbin/quotacheck/quotacheck.c +++ b/sbin/quotacheck/quotacheck.c @@ -254,7 +254,7 @@ chkquota(char *fsname, char *mntpt, struct quotaname *qnp) resetinodebuf(); for (ino = 0, cg = 0; cg < sblock.fs_ncg; cg++) { for (i = 0; i < sblock.fs_ipg; i++, ino++) { - if (ino < ROOTINO) + if (ino < UFS_ROOTINO) continue; if ((dp = getnextinode(ino)) == NULL) continue; @@ -560,7 +560,7 @@ resetinodebuf(void) if (inodebuf == NULL && (inodebuf = malloc((u_int)inobufsize)) == NULL) errx(1, "malloc failed"); - while (nextino < ROOTINO) + while (nextino < UFS_ROOTINO) getnextinode(nextino); } diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index bfca32eaf8..969eb8c43c 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -275,7 +275,7 @@ treescan(char *pname, ufs1_ino_t ino, long (*todo)(char *, ufs1_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) @@ -286,7 +286,7 @@ pathsearch(const char *pathname) strcpy(buffer, pathname); path = buffer; - ino = ROOTINO; + ino = UFS_ROOTINO; while (*path == '/') path++; dp = NULL; @@ -604,7 +604,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; } diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index 194e8e0cdf..0faa267003 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -491,7 +491,7 @@ printlist(const 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; @@ -526,7 +526,7 @@ printlist(const 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; @@ -631,7 +631,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) @@ -706,7 +706,7 @@ glob_readdir(RST_DIR *dirp) struct dirent *adp; 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; @@ -730,7 +730,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; diff --git a/sbin/restore/main.c b/sbin/restore/main.c index 24e887803a..f7efc9c3fa 100644 --- a/sbin/restore/main.c +++ b/sbin/restore/main.c @@ -196,7 +196,8 @@ main(int argc, char *argv[]) extractdirs(1); removeoldleaves(); vprintf(stdout, "Calculate node updates.\n"); - treescan(__DECONST(char *, "."), ROOTINO, nodeupdates); + treescan(__DECONST(char *, "."), UFS_ROOTINO, + nodeupdates); findunreflinks(); removeoldnodes(); } else { @@ -207,7 +208,8 @@ main(int argc, char *argv[]) initsymtable(NULL); extractdirs(1); vprintf(stdout, "Calculate extraction list.\n"); - treescan(__DECONST(char *, "."), ROOTINO, nodeupdates); + treescan(__DECONST(char *, "."), UFS_ROOTINO, + nodeupdates); } createleaves(symtbl); createlinks(); @@ -215,7 +217,8 @@ main(int argc, char *argv[]) checkrestore(); if (dflag) { vprintf(stdout, "Verify the directory structure\n"); - treescan(__DECONST(char *, "."), ROOTINO, verifyfile); + treescan(__DECONST(char *, "."), UFS_ROOTINO, + verifyfile); } dumpsymtable(symtbl, (long)1); break; diff --git a/sbin/restore/restore.c b/sbin/restore/restore.c index 0ee52ae42b..36573e3b7c 100644 --- a/sbin/restore/restore.c +++ b/sbin/restore/restore.c @@ -73,7 +73,7 @@ addfile(char *name, ufs1_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) { sprintf(buf, "./%u", ino); @@ -148,7 +148,7 @@ removeoldleaves(void) ufs1_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; @@ -164,7 +164,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; @@ -508,7 +508,7 @@ findunreflinks(void) ufs1_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; @@ -591,7 +591,7 @@ createleaves(const 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); @@ -669,7 +669,7 @@ createfiles(void) getvol((long)1); skipmaps(); skipdirs(); - first = lowerbnd(ROOTINO); + first = lowerbnd(UFS_ROOTINO); last = upperbnd(maxino - 1); for (;;) { curvol = volno; @@ -760,7 +760,7 @@ createlinks(void) ufs1_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) @@ -770,7 +770,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; @@ -800,7 +800,7 @@ checkrestore(void) ufs1_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) diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c index 06a13c2211..e041c866d9 100644 --- a/sbin/restore/symtab.c +++ b/sbin/restore/symtab.c @@ -77,7 +77,7 @@ lookupino(ufs1_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) @@ -93,7 +93,7 @@ addino(ufs1_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 %d\n", inum); epp = &entry[inum % entrytblsize]; np->e_ino = inum; @@ -114,7 +114,7 @@ deleteino(ufs1_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 %d\n", inum); prev = &entry[inum % entrytblsize]; for (next = *prev; next != NULL; next = next->e_next) { @@ -140,7 +140,7 @@ lookupname(const 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++; @@ -192,7 +192,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; @@ -227,12 +227,12 @@ addentry(const char *name, ufs1_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); @@ -452,7 +452,7 @@ dumpsymtable(const 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++; fwrite(ep->e_name, sizeof(char), @@ -464,7 +464,7 @@ dumpsymtable(const 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; @@ -533,7 +533,7 @@ initsymtable(const char *filename) 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; } diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 83cd7e1c1b..6b117da2b9 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -271,7 +271,7 @@ setup(void) * extracted. */ if (oldinofmt == 0) - 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; diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index 75a3ea8ecf..cbfc50b027 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -297,7 +297,7 @@ upperbnd(ufs1_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; diff --git a/sys/sys/param.h b/sys/sys/param.h index a5f102cac5..53871f8424 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -171,9 +171,10 @@ * 500107 - removal * 500200 - 5.2 release * 500300 - 5.3 development + * 500301 - rename some public UFS constants */ #undef __DragonFly_version -#define __DragonFly_version 500300 /* propagated to newvers */ +#define __DragonFly_version 500301 /* propagated to newvers */ #include diff --git a/sys/vfs/nfs/nfs_vfsops.c b/sys/vfs/nfs/nfs_vfsops.c index af1224e63a..c64d44b4ef 100644 --- a/sys/vfs/nfs/nfs_vfsops.c +++ b/sys/vfs/nfs/nfs_vfsops.c @@ -1111,7 +1111,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). */ error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np, NULL); if (error) diff --git a/sys/vfs/ufs/dinode.h b/sys/vfs/ufs/dinode.h index 133071c74b..a4e3d14e63 100644 --- a/sys/vfs/ufs/dinode.h +++ b/sys/vfs/ufs/dinode.h @@ -33,7 +33,6 @@ * * @(#)dinode.h 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/ufs/ufs/dinode.h,v 1.7 1999/08/28 00:52:27 peter Exp $ - * $DragonFly: src/sys/vfs/ufs/dinode.h,v 1.8 2008/08/04 18:15:47 dillon Exp $ */ #ifndef _VFS_UFS_DINODE_H_ @@ -47,15 +46,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_W 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) /* * A dinode contains all the meta-data associated with a UFS file. @@ -64,8 +63,8 @@ * are defined by types with precise widths. */ -#define NDADDR 12 /* Direct addresses in inode. */ -#define NIADDR 3 /* Indirect addresses in inode. */ +#define UFS_NDADDR 12 /* Direct addresses in inode. */ +#define UFS_NIADDR 3 /* Indirect addresses in inode. */ struct ufs1_dinode { uint16_t di_mode; /* 0: IFMT, permissions; see below. */ @@ -81,8 +80,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. */ - ufs_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ - ufs_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ + ufs_daddr_t di_db[UFS_NDADDR]; /* 40: Direct disk blocks. */ + ufs_daddr_t di_ib[UFS_NIADDR]; /* 88: Indirect disk blocks. */ uint32_t di_flags; /* 100: Status flags (chflags). */ int32_t di_blocks; /* 104: Blocks actually held. */ int32_t di_gen; /* 108: Generation number. */ @@ -106,7 +105,7 @@ struct ufs1_dinode { #define di_rdev di_db[0] #define di_shortlink di_db #define di_spare di_v.spare /* ext2fs */ -#define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(ufs_daddr_t)) +#define UFS1_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(ufs_daddr_t)) /* File permissions. */ #define IEXEC 0000100 /* Executable. */ diff --git a/sys/vfs/ufs/ffs_alloc.c b/sys/vfs/ufs/ffs_alloc.c index b0fd7c90d0..1c01b9a1ff 100644 --- a/sys/vfs/ufs/ffs_alloc.c +++ b/sys/vfs/ufs/ffs_alloc.c @@ -208,7 +208,7 @@ ffs_realloccg(struct inode *ip, ufs_daddr_t lbprev, ufs_daddr_t bpref, } if(bp->b_bio2.bio_offset == NOOFFSET) { - if( lbprev >= NDADDR) + if (lbprev >= UFS_NDADDR) panic("ffs_realloccg: lbprev out of range"); bp->b_bio2.bio_offset = fsbtodoff(fs, bprev); } @@ -357,7 +357,7 @@ ffs_reallocblks(struct vop_reallocblks_args *ap) #ifdef DIAGNOSTIC off_t boffset; #endif - 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, len, slen, start_lvl, end_lvl, pref, ssize; if (doreallocblks == 0) @@ -404,7 +404,7 @@ ffs_reallocblks(struct vop_reallocblks_args *ap) if (start_lvl == 0) { sbap = &ip->i_db[0]; soff = start_lbn; - slen = NDADDR - soff; + slen = UFS_NDADDR - soff; } else { idp = &start_ap[start_lvl - 1]; if (bread(vp, lblktodoff(fs, idp->in_lbn), (int)fs->fs_bsize, &sbp)) { @@ -802,7 +802,7 @@ ffs_blkpref(struct inode *ip, ufs_daddr_t lbn, int indx, ufs_daddr_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); } diff --git a/sys/vfs/ufs/ffs_balloc.c b/sys/vfs/ufs/ffs_balloc.c index 136e53bd12..f774a4d1b3 100644 --- a/sys/vfs/ufs/ffs_balloc.c +++ b/sys/vfs/ufs/ffs_balloc.c @@ -28,7 +28,6 @@ * * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95 * $FreeBSD: src/sys/ufs/ffs/ffs_balloc.c,v 1.26.2.1 2002/10/10 19:48:20 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_balloc.c,v 1.19 2008/05/21 18:49:49 dillon Exp $ */ #include @@ -73,11 +72,11 @@ ffs_balloc(struct vop_balloc_args *ap) ufs_daddr_t nb; struct buf *bp, *nbp, *dbp; struct vnode *vp; - struct indir indirs[NIADDR + 2]; + struct indir indirs[UFS_NIADDR + 2]; ufs_daddr_t newb, *bap, pref; int deallocated, osize, nsize, num, i, error; - ufs_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1]; - ufs_daddr_t *lbns_remfree, lbns[NIADDR + 1]; + ufs_daddr_t *allocib, *blkp, *allocblk, allociblk[UFS_NIADDR + 1]; + ufs_daddr_t *lbns_remfree, lbns[UFS_NIADDR + 1]; int unwindidx; int seqcount; @@ -108,7 +107,7 @@ ffs_balloc(struct vop_balloc_args *ap) * this fragment has to be extended to be a full block. */ nb = lblkno(fs, ip->i_size); - if (nb < NDADDR && nb < lbn) { + if (nb < UFS_NDADDR && nb < lbn) { /* * The filesize prior to this write can fit in direct * blocks (ex. fragmentation is possibly done) @@ -146,9 +145,9 @@ ffs_balloc(struct vop_balloc_args *ap) } } /* - * The first NDADDR blocks are direct blocks + * The first UFS_NDADDR blocks are direct blocks */ - if (lbn < NDADDR) { + if (lbn < UFS_NDADDR) { nb = ip->i_db[lbn]; if (nb != 0 && ip->i_size >= smalllblktosize(fs, lbn + 1)) { error = bread(vp, lblktodoff(fs, lbn), fs->fs_bsize, &bp); @@ -264,7 +263,8 @@ ffs_balloc(struct vop_balloc_args *ap) bp->b_bio2.bio_offset = fsbtodoff(fs, nb); vfs_bio_clrbuf(bp); if (DOINGSOFTDEP(vp)) { - softdep_setup_allocdirect(ip, NDADDR + indirs[0].in_off, + softdep_setup_allocdirect(ip, + UFS_NDADDR + indirs[0].in_off, newb, 0, fs->fs_bsize, 0, bp); bdwrite(bp); } else { diff --git a/sys/vfs/ufs/ffs_inode.c b/sys/vfs/ufs/ffs_inode.c index 74d4f8df18..c6334f9e6d 100644 --- a/sys/vfs/ufs/ffs_inode.c +++ b/sys/vfs/ufs/ffs_inode.c @@ -139,8 +139,9 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred) struct vnode *ovp = vp; ufs_daddr_t lastblock; struct inode *oip; - ufs_daddr_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; - ufs_daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; + ufs_daddr_t bn, lbn, lastiblock[UFS_NIADDR], indir_lbn[UFS_NIADDR]; + ufs_daddr_t oldblks[UFS_NDADDR + UFS_NIADDR]; + ufs_daddr_t newblks[UFS_NDADDR + UFS_NIADDR]; struct fs *fs; struct buf *bp; int offset, size, level; @@ -275,7 +276,7 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred) * throw away anyway, and we will b*write() the remainder * anyway down below. */ - if (DOINGSOFTDEP(ovp) && lbn < NDADDR && + if (DOINGSOFTDEP(ovp) && lbn < UFS_NDADDR && fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize) { bundirty(bp); error = VOP_FSYNC(ovp, MNT_WAIT, 0); @@ -308,7 +309,7 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *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); @@ -320,13 +321,13 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred) * normalized to -1 for calls to ffs_indirtrunc below. */ for (level = TRIPLE; level >= SINGLE; level--) { - oldblks[NDADDR + level] = oip->i_ib[level]; + oldblks[UFS_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 < UFS_NDADDR; i++) { oldblks[i] = oip->i_db[i]; if (i > lastblock) oip->i_db[i] = 0; @@ -342,13 +343,13 @@ ffs_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 < UFS_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 < UFS_NIADDR; i++) { + newblks[UFS_NDADDR + i] = oip->i_ib[i]; + oip->i_ib[i] = oldblks[UFS_NDADDR + i]; } oip->i_size = osize; @@ -358,7 +359,7 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *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--) { @@ -382,7 +383,7 @@ ffs_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 = UFS_NDADDR - 1; i > lastblock; i--) { long bsize; bn = oip->i_db[i]; @@ -427,9 +428,9 @@ ffs_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred) done: #ifdef DIAGNOSTIC for (level = SINGLE; level <= TRIPLE; level++) - if (newblks[NDADDR + level] != oip->i_ib[level]) + if (newblks[UFS_NDADDR + level] != oip->i_ib[level]) panic("ffs_truncate1"); - for (i = 0; i < NDADDR; i++) + for (i = 0; i < UFS_NDADDR; i++) if (newblks[i] != oip->i_db[i]) panic("ffs_truncate2"); if (length == 0 && !RB_EMPTY(&ovp->v_rbdirty_tree)) diff --git a/sys/vfs/ufs/ffs_softdep.c b/sys/vfs/ufs/ffs_softdep.c index a497357a37..3cbc395d93 100644 --- a/sys/vfs/ufs/ffs_softdep.c +++ b/sys/vfs/ufs/ffs_softdep.c @@ -1318,7 +1318,7 @@ softdep_setup_allocdirect(struct inode *ip, ufs_lbn_t lbn, ufs_daddr_t newblkno, kfree(newblk, M_NEWBLK); WORKLIST_INSERT_BP(bp, &adp->ad_list); - if (lbn >= NDADDR) { + if (lbn >= UFS_NDADDR) { /* allocating an indirect block */ if (oldblkno != 0) { panic("softdep_setup_allocdirect: non-zero indir"); @@ -1392,10 +1392,10 @@ allocdirect_merge(struct allocdirectlst *adphead, if (newadp->ad_oldblkno != oldadp->ad_newblkno || newadp->ad_oldsize != oldadp->ad_newsize || - newadp->ad_lbn >= NDADDR) { + newadp->ad_lbn >= UFS_NDADDR) { panic("allocdirect_check: old %d != new %d || lbn %ld >= %d", newadp->ad_oldblkno, oldadp->ad_newblkno, newadp->ad_lbn, - NDADDR); + UFS_NDADDR); } newadp->ad_oldblkno = oldadp->ad_oldblkno; newadp->ad_oldsize = oldadp->ad_oldsize; @@ -1759,11 +1759,11 @@ softdep_setup_freeblocks(struct inode *ip, off_t length) freeblks->fb_oldsize = ip->i_size; freeblks->fb_newsize = length; freeblks->fb_chkcnt = ip->i_blocks; - for (i = 0; i < NDADDR; i++) { + for (i = 0; i < UFS_NDADDR; i++) { freeblks->fb_dblks[i] = ip->i_db[i]; ip->i_db[i] = 0; } - for (i = 0; i < NIADDR; i++) { + for (i = 0; i < UFS_NIADDR; i++) { freeblks->fb_iblks[i] = ip->i_ib[i]; ip->i_ib[i] = 0; } @@ -2142,7 +2142,7 @@ handle_workitem_freeblocks(struct freeblks *freeblks) int i, level, bsize; long nblocks, blocksreleased = 0; int error, allerror = 0; - ufs_lbn_t baselbns[NIADDR], tmpval; + ufs_lbn_t baselbns[UFS_NIADDR], tmpval; tip.i_number = freeblks->fb_previousinum; tip.i_devvp = freeblks->fb_devvp; @@ -2152,8 +2152,8 @@ handle_workitem_freeblocks(struct freeblks *freeblks) tip.i_uid = freeblks->fb_uid; fs = freeblks->fb_fs; tmpval = 1; - baselbns[0] = NDADDR; - for (i = 1; i < NIADDR; i++) { + baselbns[0] = UFS_NDADDR; + for (i = 1; i < UFS_NIADDR; i++) { tmpval *= NINDIR(fs); baselbns[i] = baselbns[i - 1] + tmpval; } @@ -2162,7 +2162,7 @@ handle_workitem_freeblocks(struct freeblks *freeblks) /* * Indirect blocks first. */ - for (level = (NIADDR - 1); level >= 0; level--) { + for (level = (UFS_NIADDR - 1); level >= 0; level--) { if ((bn = freeblks->fb_iblks[level]) == 0) continue; if ((error = indir_trunc(&tip, fsbtodoff(fs, bn), level, @@ -2174,7 +2174,7 @@ handle_workitem_freeblocks(struct freeblks *freeblks) /* * All direct blocks or frags. */ - for (i = (NDADDR - 1); i >= 0; i--) { + for (i = (UFS_NDADDR - 1); i >= 0; i--) { if ((bn = freeblks->fb_dblks[i]) == 0) continue; bsize = blksize(fs, &tip, i); @@ -2341,7 +2341,7 @@ softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, /* * Whiteouts have no dependencies. */ - if (newinum == WINO) { + if (newinum == UFS_WINO) { if (newdirbp != NULL) bdwrite(newdirbp); return; @@ -2718,7 +2718,7 @@ softdep_setup_directory_change(struct buf *bp, struct inode *dp, /* * Whiteouts do not need diradd dependencies. */ - if (newinum != WINO) { + if (newinum != UFS_WINO) { dap = kmalloc(sizeof(struct diradd), M_DIRADD, M_SOFTDEP_FLAGS | M_ZERO); dap->da_list.wk_type = D_DIRADD; @@ -2751,7 +2751,7 @@ softdep_setup_directory_change(struct buf *bp, struct inode *dp, * 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); @@ -3201,17 +3201,19 @@ initiate_write_inodeblock(struct inodedep *inodedep, struct buf *bp) panic("softdep_write_inodeblock: lbn order"); } prevlbn = adp->ad_lbn; - if (adp->ad_lbn < NDADDR && + if (adp->ad_lbn < UFS_NDADDR && dp->di_db[adp->ad_lbn] != adp->ad_newblkno) { panic("%s: direct pointer #%ld mismatch %d != %d", "softdep_write_inodeblock", adp->ad_lbn, dp->di_db[adp->ad_lbn], adp->ad_newblkno); } - if (adp->ad_lbn >= NDADDR && - dp->di_ib[adp->ad_lbn - NDADDR] != adp->ad_newblkno) { + if (adp->ad_lbn >= UFS_NDADDR && + dp->di_ib[adp->ad_lbn - UFS_NDADDR] != adp->ad_newblkno) { panic("%s: indirect pointer #%ld mismatch %d != %d", - "softdep_write_inodeblock", adp->ad_lbn - NDADDR, - dp->di_ib[adp->ad_lbn - NDADDR], adp->ad_newblkno); + "softdep_write_inodeblock", + adp->ad_lbn - UFS_NDADDR, + dp->di_ib[adp->ad_lbn - UFS_NDADDR], + adp->ad_newblkno); } deplist |= 1 << adp->ad_lbn; if ((adp->ad_state & ATTACHED) == 0) { @@ -3230,14 +3232,14 @@ initiate_write_inodeblock(struct inodedep *inodedep, struct buf *bp) */ for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp; lastadp = adp, adp = TAILQ_NEXT(adp, ad_next)) { - if (adp->ad_lbn >= NDADDR) + if (adp->ad_lbn >= UFS_NDADDR) break; dp->di_db[adp->ad_lbn] = 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_lbn + adp->ad_oldsize; - for (i = adp->ad_lbn + 1; i < NDADDR; i++) { + for (i = adp->ad_lbn + 1; i < UFS_NDADDR; i++) { #ifdef DIAGNOSTIC if (dp->di_db[i] != 0 && (deplist & (1 << i)) == 0) { panic("softdep_write_inodeblock: lost dep1"); @@ -3245,10 +3247,10 @@ initiate_write_inodeblock(struct inodedep *inodedep, struct buf *bp) #endif /* DIAGNOSTIC */ dp->di_db[i] = 0; } - for (i = 0; i < NIADDR; i++) { + for (i = 0; i < UFS_NIADDR; i++) { #ifdef DIAGNOSTIC if (dp->di_ib[i] != 0 && - (deplist & ((1 << NDADDR) << i)) == 0) { + (deplist & ((1 << UFS_NDADDR) << i)) == 0) { panic("softdep_write_inodeblock: lost dep2"); } #endif /* DIAGNOSTIC */ @@ -3282,7 +3284,7 @@ initiate_write_inodeblock(struct inodedep *inodedep, struct buf *bp) * postpone fsck, we are stuck with this argument. */ for (; adp; adp = TAILQ_NEXT(adp, ad_next)) - dp->di_ib[adp->ad_lbn - NDADDR] = 0; + dp->di_ib[adp->ad_lbn - UFS_NDADDR] = 0; FREE_LOCK(&lk); } @@ -3566,7 +3568,7 @@ handle_written_inodeblock(struct inodedep *inodedep, struct buf *bp) if (adp->ad_state & ATTACHED) panic("handle_written_inodeblock: new entry"); - if (adp->ad_lbn < NDADDR) { + if (adp->ad_lbn < UFS_NDADDR) { if (dp->di_db[adp->ad_lbn] != adp->ad_oldblkno) { panic("%s: %s #%ld mismatch %d != %d", "handle_written_inodeblock", @@ -3575,13 +3577,14 @@ handle_written_inodeblock(struct inodedep *inodedep, struct buf *bp) } dp->di_db[adp->ad_lbn] = adp->ad_newblkno; } else { - if (dp->di_ib[adp->ad_lbn - NDADDR] != 0) { + if (dp->di_ib[adp->ad_lbn - UFS_NDADDR] != 0) { panic("%s: %s #%ld allocated as %d", "handle_written_inodeblock", - "indirect pointer", adp->ad_lbn - NDADDR, - dp->di_ib[adp->ad_lbn - NDADDR]); + "indirect pointer", + adp->ad_lbn - UFS_NDADDR, + dp->di_ib[adp->ad_lbn - UFS_NDADDR]); } - dp->di_ib[adp->ad_lbn - NDADDR] = adp->ad_newblkno; + dp->di_ib[adp->ad_lbn - UFS_NDADDR] = adp->ad_newblkno; } adp->ad_state &= ~UNDONE; adp->ad_state |= ATTACHED; diff --git a/sys/vfs/ufs/ffs_vfsops.c b/sys/vfs/ufs/ffs_vfsops.c index 0a13292836..a610d660cd 100644 --- a/sys/vfs/ufs/ffs_vfsops.c +++ b/sys/vfs/ufs/ffs_vfsops.c @@ -808,8 +808,8 @@ ffs_oldfscompat(struct fs *fs) int i; /* XXX */ uint64_t sizepb = fs->fs_bsize; /* XXX */ /* XXX */ - fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ - for (i = 0; i < NIADDR; i++) { /* XXX */ + fs->fs_maxfilesize = fs->fs_bsize * UFS_NDADDR - 1; /* XXX */ + for (i = 0; i < UFS_NIADDR; i++) { /* XXX */ sizepb *= NINDIR(fs); /* XXX */ fs->fs_maxfilesize += sizepb; /* XXX */ } /* XXX */ @@ -933,7 +933,7 @@ ffs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + fs->fs_cstotal.cs_nffree; sbp->f_bavail = freespace(fs, fs->fs_minfree); - 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; if (sbp != &mp->mnt_stat) { sbp->f_type = mp->mnt_vfc->vfc_typenum; @@ -1214,7 +1214,7 @@ ffs_fhtovp(struct mount *mp, struct vnode *rootvp, ufhp = (struct ufid *)fhp; fs = VFSTOUFS(mp)->um_fs; - if (ufhp->ufid_ino < ROOTINO || + if (ufhp->ufid_ino < UFS_ROOTINO || ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); return (ufs_fhtovp(mp, rootvp, ufhp, vpp)); diff --git a/sys/vfs/ufs/ffs_vnops.c b/sys/vfs/ufs/ffs_vnops.c index 170783305b..768f3d0c13 100644 --- a/sys/vfs/ufs/ffs_vnops.c +++ b/sys/vfs/ufs/ffs_vnops.c @@ -111,7 +111,7 @@ ffs_fsync(struct vop_fsync_args *ap) /* * Flush all dirty buffers associated with a vnode. */ - error = vfsync(vp, ap->a_waitfor, NIADDR + 1, ffs_checkdeferred, + error = vfsync(vp, ap->a_waitfor, UFS_NIADDR + 1, ffs_checkdeferred, softdep_sync_metadata); if (error == 0) error = ffs_update(vp, (ap->a_waitfor == MNT_WAIT)); diff --git a/sys/vfs/ufs/fs.h b/sys/vfs/ufs/fs.h index 5b04b3eec8..8971b742ff 100644 --- a/sys/vfs/ufs/fs.h +++ b/sys/vfs/ufs/fs.h @@ -28,7 +28,6 @@ * * @(#)fs.h 8.13 (Berkeley) 3/21/95 * $FreeBSD: src/sys/ufs/ffs/fs.h,v 1.14.2.3 2001/09/21 19:15:22 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/fs.h,v 1.6 2008/08/04 18:15:47 dillon Exp $ */ #ifndef _VFS_UFS_FS_H_ @@ -505,7 +504,7 @@ struct ocg { #define dbtodoff(fs, b) ((off_t)(b) * ((fs)->fs_fsize / (fs)->fs_nspf)) #define dofftofsb(fs, b) ((ufs_daddr_t)((b) >> (fs)->fs_fshift)) -/* 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) */ \ @@ -538,15 +537,17 @@ struct ocg { * 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 dblksize(fs, dip, lbn) \ - (((lbn) >= NDADDR || (dip)->di_size >= smalllblktosize(fs, (lbn) + 1)) \ + (((lbn) >= UFS_NDADDR || \ + (dip)->di_size >= smalllblktosize(fs, (lbn) + 1)) \ ? (fs)->fs_bsize \ : (fragroundup(fs, blkoff(fs, (dip)->di_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))))) diff --git a/sys/vfs/ufs/softdep.h b/sys/vfs/ufs/softdep.h index c99396afdf..bb5bcdf5c9 100644 --- a/sys/vfs/ufs/softdep.h +++ b/sys/vfs/ufs/softdep.h @@ -37,7 +37,6 @@ * * @(#)softdep.h 9.7 (McKusick) 6/21/00 * $FreeBSD: src/sys/ufs/ffs/softdep.h,v 1.7.2.1 2000/06/22 19:27:42 peter Exp $ - * $DragonFly: src/sys/vfs/ufs/softdep.h,v 1.6 2007/06/26 07:47:28 hasso Exp $ */ #include @@ -405,8 +404,8 @@ struct freeblks { off_t fb_newsize; /* new file size */ int fb_chkcnt; /* used to check cnt of blks released */ uid_t fb_uid; /* uid of previous owner of blocks */ - ufs_daddr_t fb_dblks[NDADDR]; /* direct blk ptrs to deallocate */ - ufs_daddr_t fb_iblks[NIADDR]; /* indirect blk ptrs to deallocate */ + ufs_daddr_t fb_dblks[UFS_NDADDR]; /* direct blk ptrs to deallocate */ + ufs_daddr_t fb_iblks[UFS_NIADDR]; /* indirect blk ptrs to deallocate */ }; /* diff --git a/sys/vfs/ufs/ufs_bmap.c b/sys/vfs/ufs/ufs_bmap.c index 04dc46b6bf..a7c67f4961 100644 --- a/sys/vfs/ufs/ufs_bmap.c +++ b/sys/vfs/ufs/ufs_bmap.c @@ -117,7 +117,7 @@ ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, struct ufsmount *ump; struct mount *mp; struct fs *fs; - struct indir a[NIADDR+1], *xap; + struct indir a[UFS_NIADDR+1], *xap; ufs_daddr_t daddr; long metalbn; int error, maxrun, num; @@ -155,7 +155,7 @@ ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, *bnp = -1; else if (runp) { daddr_t bnb = bn; - for (++bn; bn < NDADDR && *runp < maxrun && + for (++bn; bn < UFS_NDADDR && *runp < maxrun && is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]); ++bn, ++*runp); bn = bnb; @@ -268,17 +268,17 @@ ufs_getlbns(struct vnode *vp, ufs_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 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 + * 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); /* @@ -294,9 +294,9 @@ ufs_getlbns(struct vnode *vp, ufs_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 @@ -305,9 +305,9 @@ ufs_getlbns(struct vnode *vp, ufs_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; diff --git a/sys/vfs/ufs/ufs_lookup.c b/sys/vfs/ufs/ufs_lookup.c index 288dedeba7..3d493b10c1 100644 --- a/sys/vfs/ufs/ufs_lookup.c +++ b/sys/vfs/ufs/ufs_lookup.c @@ -33,7 +33,6 @@ * * @(#)ufs_lookup.c 8.15 (Berkeley) 6/16/95 * $FreeBSD: src/sys/ufs/ufs/ufs_lookup.c,v 1.33.2.7 2001/09/22 19:22:13 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_lookup.c,v 1.29 2008/10/15 12:12:51 aggelos Exp $ */ #include "opt_ufs.h" @@ -853,7 +852,7 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, * copy in the new entry, and write out the block. */ if (ep->d_ino == 0 || - (ep->d_ino == WINO && + (ep->d_ino == UFS_WINO && bcmp(ep->d_name, dirp->d_name, dirp->d_namlen) == 0)) { if (spacefree + dsize < newentrysize) panic("ufs_direnter: compact1"); @@ -936,12 +935,12 @@ ufs_dirremove(struct vnode *dvp, struct inode *ip, int flags, int isrmdir) if (flags & CNP_DOWHITEOUT) { /* - * Whiteout entry: set d_ino to WINO. + * Whiteout entry: set d_ino to UFS_WINO. */ if ((error = ffs_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; } @@ -1077,7 +1076,7 @@ ufs_dirempty(struct inode *ip, ino_t parentino, struct ucred *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) @@ -1123,7 +1122,7 @@ ufs_checkpath(struct inode *source, struct inode *target, struct ucred *cred) error = EEXIST; goto out; } - rootino = ROOTINO; + rootino = UFS_ROOTINO; error = 0; if (target->i_number == rootino) goto out; diff --git a/sys/vfs/ufs/ufs_vfsops.c b/sys/vfs/ufs/ufs_vfsops.c index 3802777f7b..61bef2cde2 100644 --- a/sys/vfs/ufs/ufs_vfsops.c +++ b/sys/vfs/ufs/ufs_vfsops.c @@ -33,7 +33,6 @@ * * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 * $FreeBSD: src/sys/ufs/ufs/ufs_vfsops.c,v 1.17.2.3 2001/10/14 19:08:16 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.17 2008/09/17 21:44:25 dillon Exp $ */ #include "opt_quota.h" @@ -61,7 +60,7 @@ ufs_root(struct mount *mp, struct vnode **vpp) struct vnode *nvp; int error; - error = VFS_VGET(mp, NULL, (ino_t)ROOTINO, &nvp); + error = VFS_VGET(mp, NULL, (ino_t)UFS_ROOTINO, &nvp); if (error) return (error); *vpp = nvp; diff --git a/sys/vfs/ufs/ufs_vnops.c b/sys/vfs/ufs/ufs_vnops.c index 73b02cff3f..33244a354d 100644 --- a/sys/vfs/ufs/ufs_vnops.c +++ b/sys/vfs/ufs/ufs_vnops.c @@ -765,7 +765,7 @@ ufs_whiteout(struct vop_old_whiteout_args *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; @@ -1978,7 +1978,7 @@ ufs_vinit(struct mount *mntp, struct vnode **vpp) } - if (ip->i_number == ROOTINO) + if (ip->i_number == UFS_ROOTINO) vsetflags(vp, VROOT); /* * Initialize modrev times diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index 09654ad78f..79a6ef1e14 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -136,7 +136,7 @@ virtualblocks(struct fs *super, struct ufs1_dinode *ip) sz = ip->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; @@ -146,10 +146,10 @@ virtualblocks(struct fs *super, struct ufs1_dinode *ip) #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 */