Skip to content

Commit

Permalink
Prefix UFS symbols with UFS_ to reduce namespace pollution
Browse files Browse the repository at this point in the history
Followup to r313780.  Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by:	kib
Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9623
  • Loading branch information
emaste committed Mar 17, 2018
1 parent 4e78ff7 commit 1e2b9af
Show file tree
Hide file tree
Showing 35 changed files with 254 additions and 247 deletions.
4 changes: 2 additions & 2 deletions lib/libufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ getino(struct uufsd *disk, void **dino, ino_t inode, int *mode)
gotit: switch (disk->d_ufs) {
case 1:
dp1 = &((struct ufs1_dinode *)inoblock)[inode - min];
*mode = dp1->di_mode & IFMT;
*mode = dp1->di_mode & UFS_IFMT;
*dino = dp1;
return (0);
case 2:
dp2 = &((struct ufs2_dinode *)inoblock)[inode - min];
*mode = dp2->di_mode & IFMT;
*mode = dp2->di_mode & UFS_IFMT;
*dino = dp2;
return (0);
default:
Expand Down
4 changes: 2 additions & 2 deletions sbin/dump/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ main(int argc, char *argv[])
* Skip directory inodes deleted and maybe reallocated
*/
dp = getinode(ino, &mode);
if (mode != IFDIR)
if (mode != UFS_IFDIR)
continue;
(void)dumpino(dp, ino);
}
Expand All @@ -569,7 +569,7 @@ main(int argc, char *argv[])
* Skip inodes deleted and reallocated as directories.
*/
dp = getinode(ino, &mode);
if (mode == IFDIR)
if (mode == UFS_IFDIR)
continue;
(void)dumpino(dp, ino);
}
Expand Down
20 changes: 10 additions & 10 deletions sbin/dump/traverse.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mapfiles(ino_t maxino, long *tapesize)
for (i = 0; i < inosused; i++, ino++) {
if (ino < UFS_ROOTINO ||
(dp = getinode(ino, &mode)) == NULL ||
(mode & IFMT) == 0)
(mode & UFS_IFMT) == 0)
continue;
if (ino >= maxino) {
msg("Skipping inode %ju >= maxino %ju\n",
Expand All @@ -209,19 +209,19 @@ mapfiles(ino_t maxino, long *tapesize)
* (this is used in mapdirs()).
*/
SETINO(ino, usedinomap);
if (mode == IFDIR)
if (mode == UFS_IFDIR)
SETINO(ino, dumpdirmap);
if (WANTTODUMP(dp)) {
SETINO(ino, dumpinomap);
if (mode != IFREG &&
mode != IFDIR &&
mode != IFLNK)
if (mode != UFS_IFREG &&
mode != UFS_IFDIR &&
mode != UFS_IFLNK)
*tapesize += 1;
else
*tapesize += blockest(dp);
continue;
}
if (mode == IFDIR) {
if (mode == UFS_IFDIR) {
if (!nonodump &&
(DIP(dp, di_flags) & UF_NODUMP))
CLRINO(ino, usedinomap);
Expand Down Expand Up @@ -429,7 +429,7 @@ searchdir(
* Add back to dumpdirmap and remove from usedinomap
* to propagate nodump.
*/
if (mode == IFDIR) {
if (mode == UFS_IFDIR) {
SETINO(dp->d_ino, dumpdirmap);
CLRINO(dp->d_ino, usedinomap);
ret |= HASSUBDIRS;
Expand Down Expand Up @@ -554,7 +554,7 @@ dumpino(union dinode *dp, ino_t ino)

default:
msg("Warning: undefined file type 0%o\n",
DIP(dp, di_mode) & IFMT);
DIP(dp, di_mode) & UFS_IFMT);
return;
}
if (DIP(dp, di_size) > UFS_NDADDR * sblock->fs_bsize) {
Expand Down Expand Up @@ -890,11 +890,11 @@ getinode(ino_t inum, int *modep)
gotit:
if (sblock->fs_magic == FS_UFS1_MAGIC) {
dp1 = &((struct ufs1_dinode *)inoblock)[inum - minino];
*modep = (dp1->di_mode & IFMT);
*modep = (dp1->di_mode & UFS_IFMT);
return ((union dinode *)dp1);
}
dp2 = &((struct ufs2_dinode *)inoblock)[inum - minino];
*modep = (dp2->di_mode & IFMT);
*modep = (dp2->di_mode & UFS_IFMT);
return ((union dinode *)dp2);
}

Expand Down
11 changes: 6 additions & 5 deletions sbin/fsck_ffs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fileerror(ino_t cwd, ino_t ino, const char *errmesg)
dp = ginode(ino);
if (ftypeok(dp))
pfatal("%s=%s\n",
(DIP(dp, di_mode) & IFMT) == IFDIR ? "DIR" : "FILE",
(DIP(dp, di_mode) & UFS_IFMT) == UFS_IFDIR ? "DIR" : "FILE",
pathbuf);
else
pfatal("NAME=%s\n", pathbuf);
Expand Down Expand Up @@ -308,7 +308,8 @@ adjust(struct inodesc *idesc, int lcnt)
}
if (lcnt != 0) {
pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
((DIP(dp, di_mode) & IFMT) == IFDIR ? "DIR" : "FILE"));
((DIP(dp, di_mode) & UFS_IFMT) == UFS_IFDIR ?
"DIR" : "FILE"));
pinode(idesc->id_number);
printf(" COUNT %d SHOULD BE %d",
DIP(dp, di_nlink), DIP(dp, di_nlink) - lcnt);
Expand Down Expand Up @@ -388,7 +389,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)

memset(&idesc, 0, sizeof(struct inodesc));
dp = ginode(orphan);
lostdir = (DIP(dp, di_mode) & IFMT) == IFDIR;
lostdir = (DIP(dp, di_mode) & UFS_IFMT) == UFS_IFDIR;
pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
pinode(orphan);
if (preen && DIP(dp, di_size) == 0)
Expand Down Expand Up @@ -436,7 +437,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
}
}
dp = ginode(lfdir);
if ((DIP(dp, di_mode) & IFMT) != IFDIR) {
if ((DIP(dp, di_mode) & UFS_IFMT) != UFS_IFDIR) {
pfatal("lost+found IS NOT A DIRECTORY");
if (reply("REALLOCATE") == 0)
return (0);
Expand Down Expand Up @@ -615,7 +616,7 @@ allocdir(ino_t parent, ino_t request, int mode)
struct inoinfo *inp;
struct dirtemplate *dirp;

ino = allocino(request, IFDIR|mode);
ino = allocino(request, UFS_IFDIR|mode);
dirp = &dirhead;
dirp->dot_ino = ino;
dirp->dotdot_ino = parent;
Expand Down
18 changes: 9 additions & 9 deletions sbin/fsck_ffs/fsutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ fsutilinit(void)
int
ftypeok(union dinode *dp)
{
switch (DIP(dp, di_mode) & IFMT) {

case IFDIR:
case IFREG:
case IFBLK:
case IFCHR:
case IFLNK:
case IFSOCK:
case IFIFO:
switch (DIP(dp, di_mode) & UFS_IFMT) {

case UFS_IFDIR:
case UFS_IFREG:
case UFS_IFBLK:
case UFS_IFCHR:
case UFS_IFLNK:
case UFS_IFSOCK:
case UFS_IFIFO:
return (1);

default:
Expand Down
20 changes: 10 additions & 10 deletions sbin/fsck_ffs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ ckinode(union dinode *dp, struct inodesc *idesc)
idesc->id_lbn = -1;
idesc->id_entryno = 0;
idesc->id_filesize = DIP(dp, di_size);
mode = DIP(dp, di_mode) & IFMT;
if (mode == IFBLK || mode == IFCHR || (mode == IFLNK &&
mode = DIP(dp, di_mode) & UFS_IFMT;
if (mode == UFS_IFBLK || mode == UFS_IFCHR || (mode == UFS_IFLNK &&
DIP(dp, di_size) < (unsigned)sblock.fs_maxsymlinklen))
return (KEEPON);
if (sblock.fs_magic == FS_UFS1_MAGIC)
Expand Down Expand Up @@ -347,7 +347,7 @@ getnextinode(ino_t inumber, int rebuildcg)
* Try to determine if we have reached the end of the
* allocated inodes.
*/
mode = DIP(dp, di_mode) & IFMT;
mode = DIP(dp, di_mode) & UFS_IFMT;
if (mode == 0) {
if (memcmp(dp->dp2.di_db, ufs2_zino.di_db,
UFS_NDADDR * sizeof(ufs2_daddr_t)) ||
Expand All @@ -362,9 +362,9 @@ getnextinode(ino_t inumber, int rebuildcg)
ndb = howmany(DIP(dp, di_size), sblock.fs_bsize);
if (ndb < 0)
return (NULL);
if (mode == IFBLK || mode == IFCHR)
if (mode == UFS_IFBLK || mode == UFS_IFCHR)
ndb++;
if (mode == IFLNK) {
if (mode == UFS_IFLNK) {
/*
* Fake ndb value so direct/indirect block checks below
* will detect any garbage after symlink string.
Expand Down Expand Up @@ -533,7 +533,7 @@ clri(struct inodesc *idesc, const char *type, int flag)
dp = ginode(idesc->id_number);
if (flag == 1) {
pwarn("%s %s", type,
(DIP(dp, di_mode) & IFMT) == IFDIR ? "DIR" : "FILE");
(DIP(dp, di_mode) & UFS_IFMT) == UFS_IFDIR ? "DIR":"FILE");
pinode(idesc->id_number);
}
if (preen || reply("CLEAR") == 1) {
Expand Down Expand Up @@ -681,13 +681,13 @@ allocino(ino_t request, int type)
return (0);
setbit(cg_inosused(cgp), ino % sblock.fs_ipg);
cgp->cg_cs.cs_nifree--;
switch (type & IFMT) {
case IFDIR:
switch (type & UFS_IFMT) {
case UFS_IFDIR:
inoinfo(ino)->ino_state = DSTATE;
cgp->cg_cs.cs_ndir++;
break;
case IFREG:
case IFLNK:
case UFS_IFREG:
case UFS_IFLNK:
inoinfo(ino)->ino_state = FSTATE;
break;
default:
Expand Down
20 changes: 10 additions & 10 deletions sbin/fsck_ffs/pass1.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)

if ((dp = getnextinode(inumber, rebuildcg)) == NULL)
return (0);
mode = DIP(dp, di_mode) & IFMT;
mode = DIP(dp, di_mode) & UFS_IFMT;
if (mode == 0) {
if ((sblock.fs_magic == FS_UFS1_MAGIC &&
(memcmp(dp->dp1.di_db, ufs1_zino.di_db,
Expand Down Expand Up @@ -284,25 +284,25 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
kernmaxfilesize = sblock.fs_maxfilesize;
if (DIP(dp, di_size) > kernmaxfilesize ||
DIP(dp, di_size) > sblock.fs_maxfilesize ||
(mode == IFDIR && DIP(dp, di_size) > MAXDIRSIZE)) {
(mode == UFS_IFDIR && DIP(dp, di_size) > MAXDIRSIZE)) {
if (debug)
printf("bad size %ju:", (uintmax_t)DIP(dp, di_size));
goto unknown;
}
if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
if (!preen && mode == UFS_IFMT && reply("HOLD BAD BLOCK") == 1) {
dp = ginode(inumber);
DIP_SET(dp, di_size, sblock.fs_fsize);
DIP_SET(dp, di_mode, IFREG|0600);
DIP_SET(dp, di_mode, UFS_IFREG|0600);
inodirty();
}
if ((mode == IFBLK || mode == IFCHR || mode == IFIFO ||
mode == IFSOCK) && DIP(dp, di_size) != 0) {
if ((mode == UFS_IFBLK || mode == UFS_IFCHR || mode == UFS_IFIFO ||
mode == UFS_IFSOCK) && DIP(dp, di_size) != 0) {
if (debug)
printf("bad special-file size %ju:",
(uintmax_t)DIP(dp, di_size));
goto unknown;
}
if ((mode == IFBLK || mode == IFCHR) &&
if ((mode == UFS_IFBLK || mode == UFS_IFCHR) &&
(dev_t)DIP(dp, di_rdev) == NODEV) {
if (debug)
printf("bad special-file rdev NODEV:");
Expand All @@ -315,9 +315,9 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
(uintmax_t)DIP(dp, di_size), (uintmax_t)ndb);
goto unknown;
}
if (mode == IFBLK || mode == IFCHR)
if (mode == UFS_IFBLK || mode == UFS_IFCHR)
ndb++;
if (mode == IFLNK) {
if (mode == UFS_IFLNK) {
/*
* Fake ndb value so direct/indirect block checks below
* will detect any garbage after symlink string.
Expand Down Expand Up @@ -357,7 +357,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
goto unknown;
n_files++;
inoinfo(inumber)->ino_linkcnt = DIP(dp, di_nlink);
if (mode == IFDIR) {
if (mode == UFS_IFDIR) {
if (DIP(dp, di_size) == 0)
inoinfo(inumber)->ino_state = DCLEAR;
else if (DIP(dp, di_nlink) <= 0)
Expand Down
9 changes: 5 additions & 4 deletions sbin/fsck_ffs/pass2.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pass2(void)
exit(EEXIT);
}
dp = ginode(UFS_ROOTINO);
DIP_SET(dp, di_mode, DIP(dp, di_mode) & ~IFMT);
DIP_SET(dp, di_mode, DIP(dp, di_mode) | IFDIR);
DIP_SET(dp, di_mode, DIP(dp, di_mode) & ~UFS_IFMT);
DIP_SET(dp, di_mode, DIP(dp, di_mode) | UFS_IFDIR);
inodirty();
break;

Expand Down Expand Up @@ -184,7 +184,7 @@ pass2(void)
}
dp = &dino;
memset(dp, 0, sizeof(struct ufs2_dinode));
DIP_SET(dp, di_mode, IFDIR);
DIP_SET(dp, di_mode, UFS_IFDIR);
DIP_SET(dp, di_size, inp->i_isize);
for (i = 0; i < MIN(inp->i_numblks, UFS_NDADDR); i++)
DIP_SET(dp, di_db[i], inp->i_blks[i]);
Expand Down Expand Up @@ -478,7 +478,8 @@ pass2check(struct inodesc *idesc)
break;
dp = ginode(dirp->d_ino);
inoinfo(dirp->d_ino)->ino_state =
(DIP(dp, di_mode) & IFMT) == IFDIR ? DSTATE : FSTATE;
(DIP(dp, di_mode) & UFS_IFMT) == UFS_IFDIR ?
DSTATE : FSTATE;
inoinfo(dirp->d_ino)->ino_linkcnt = DIP(dp, di_nlink);
goto again;

Expand Down
Loading

0 comments on commit 1e2b9af

Please sign in to comment.