Index: lib/libstand/nandfs.c =================================================================== --- lib/libstand/nandfs.c +++ lib/libstand/nandfs.c @@ -654,7 +654,7 @@ while ((strp = strsep(&lpath, "/")) != NULL) { if (*strp == '\0') continue; - if ((node->inode->i_mode & IFMT) != IFDIR) { + if ((node->inode->i_mode & NANDFS_IFMT) != NANDFS_IFDIR) { nandfs_free_node(node); node = NULL; goto out; @@ -710,7 +710,7 @@ NANDFS_DEBUG("%s: %.*s has mode %o\n", __func__, dirent->name_len, dirent->name, node->inode->i_mode); - if ((node->inode->i_mode & IFMT) == IFLNK) { + if ((node->inode->i_mode & NANDFS_IFMT) == NANDFS_IFLNK) { NANDFS_DEBUG("%s: %.*s is symlink\n", __func__, dirent->name_len, dirent->name); link_len = node->inode->i_size; Index: lib/libstand/ufs.c =================================================================== --- lib/libstand/ufs.c +++ lib/libstand/ufs.c @@ -573,7 +573,7 @@ /* * Check that current node is a directory. */ - if ((DIP(fp, di_mode) & IFMT) != IFDIR) { + if ((DIP(fp, di_mode) & UFS_IFMT) != UFS_IFDIR) { rc = ENOTDIR; goto out; } @@ -615,7 +615,7 @@ /* * Check for symbolic link. */ - if ((DIP(fp, di_mode) & IFMT) == IFLNK) { + if ((DIP(fp, di_mode) & UFS_IFMT) == UFS_IFLNK) { int link_len = DIP(fp, di_size); int len; Index: lib/libufs/inode.c =================================================================== --- lib/libufs/inode.c +++ lib/libufs/inode.c @@ -79,12 +79,12 @@ 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: Index: sbin/badsect/badsect.c =================================================================== --- sbin/badsect/badsect.c +++ sbin/badsect/badsect.c @@ -108,7 +108,7 @@ if (lstat(name, &devstat) < 0) err(4, "%s", name); if (stbuf.st_dev == devstat.st_rdev && - (devstat.st_mode & IFMT) == IFCHR) + (devstat.st_mode & UFS_IFMT) == UFS_IFCHR) break; } closedir(dirp); @@ -141,7 +141,7 @@ (long)number); errs++; } - else if (mknod(*argv, IFMT|0600, (dev_t)diskbn) < 0) { + else if (mknod(*argv, UFS_IFMT|0600, (dev_t)diskbn) < 0) { warn("%s", *argv); errs++; } Index: sbin/dump/main.c =================================================================== --- sbin/dump/main.c +++ sbin/dump/main.c @@ -555,7 +555,7 @@ * Skip directory inodes deleted and maybe reallocated */ dp = getino(ino, &mode); - if (mode != IFDIR) + if (mode != UFS_IFDIR) continue; (void)dumpino(dp, ino); } @@ -574,7 +574,7 @@ * Skip inodes deleted and reallocated as directories. */ dp = getino(ino, &mode); - if (mode == IFDIR) + if (mode == UFS_IFDIR) continue; (void)dumpino(dp, ino); } Index: sbin/dump/traverse.c =================================================================== --- sbin/dump/traverse.c +++ sbin/dump/traverse.c @@ -193,7 +193,7 @@ for (i = 0; i < inosused; i++, ino++) { if (ino < UFS_ROOTINO || (dp = getino(ino, &mode)) == NULL || - (mode & IFMT) == 0) + (mode & UFS_IFMT) == 0) continue; if (ino >= maxino) { msg("Skipping inode %ju >= maxino %ju\n", @@ -207,19 +207,19 @@ * (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); @@ -427,7 +427,7 @@ * 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; @@ -552,7 +552,7 @@ 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) { @@ -888,11 +888,11 @@ 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); } Index: sbin/fsck_ffs/dir.c =================================================================== --- sbin/fsck_ffs/dir.c +++ sbin/fsck_ffs/dir.c @@ -262,7 +262,7 @@ 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); @@ -306,7 +306,8 @@ } 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); @@ -386,7 +387,7 @@ 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) @@ -434,7 +435,7 @@ } } 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); @@ -613,7 +614,7 @@ 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; Index: sbin/fsck_ffs/fsutil.c =================================================================== --- sbin/fsck_ffs/fsutil.c +++ sbin/fsck_ffs/fsutil.c @@ -97,15 +97,15 @@ 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: Index: sbin/fsck_ffs/inode.c =================================================================== --- sbin/fsck_ffs/inode.c +++ sbin/fsck_ffs/inode.c @@ -69,8 +69,8 @@ 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) @@ -345,7 +345,7 @@ * 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)) || @@ -360,9 +360,9 @@ 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. @@ -529,7 +529,7 @@ 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) { @@ -677,13 +677,13 @@ 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: Index: sbin/fsck_ffs/pass1.c =================================================================== --- sbin/fsck_ffs/pass1.c +++ sbin/fsck_ffs/pass1.c @@ -246,7 +246,7 @@ 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, @@ -279,25 +279,25 @@ 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:"); @@ -310,9 +310,9 @@ (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. @@ -352,7 +352,7 @@ 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) Index: sbin/fsck_ffs/pass2.c =================================================================== --- sbin/fsck_ffs/pass2.c +++ sbin/fsck_ffs/pass2.c @@ -110,8 +110,8 @@ 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; @@ -182,7 +182,7 @@ } 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]); @@ -476,7 +476,8 @@ 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; Index: sbin/fsck_ffs/suj.c =================================================================== --- sbin/fsck_ffs/suj.c +++ sbin/fsck_ffs/suj.c @@ -625,7 +625,7 @@ if (ino < cgp->cg_irotor) cgp->cg_irotor = ino; cgp->cg_cs.cs_nifree++; - if ((mode & IFMT) == IFDIR) { + if ((mode & UFS_IFMT) == UFS_IFDIR) { freedir++; cgp->cg_cs.cs_ndir--; } @@ -768,7 +768,7 @@ /* * Now direct and indirect. */ - if (DIP(ip, di_mode) == IFLNK && + if (DIP(ip, di_mode) == UFS_IFLNK && DIP(ip, di_size) < fs->fs_maxsymlinklen) return (0); if (lbn >= 0 && lbn < UFS_NDADDR) { @@ -873,7 +873,7 @@ *isdot = 0; dip = ino_read(parent); *mode = DIP(dip, di_mode); - if ((*mode & IFMT) != IFDIR) { + if ((*mode & UFS_IFMT) != UFS_IFDIR) { if (debug) { /* * This can happen if the parent inode @@ -1033,7 +1033,7 @@ int i; size = DIP(ip, di_size); - mode = DIP(ip, di_mode) & IFMT; + mode = DIP(ip, di_mode) & UFS_IFMT; fragcnt = 0; if ((flags & VISIT_EXT) && fs->fs_magic == FS_UFS2_MAGIC && ip->dp2.di_extsize) { @@ -1047,8 +1047,8 @@ } } /* Skip datablocks for short links and devices. */ - if (mode == IFBLK || mode == IFCHR || - (mode == IFLNK && size < fs->fs_maxsymlinklen)) + if (mode == UFS_IFBLK || mode == UFS_IFCHR || + (mode == UFS_IFLNK && size < fs->fs_maxsymlinklen)) return (fragcnt); for (i = 0; i < UFS_NDADDR; i++) { if (DIP(ip, di_db[i]) == 0) @@ -1285,7 +1285,7 @@ (uintmax_t)ino, DIP(ip, di_nlink), DIP(ip, di_mode)); /* We are freeing an inode or directory. */ - if ((DIP(ip, di_mode) & IFMT) == IFDIR) + if ((DIP(ip, di_mode) & UFS_IFMT) == UFS_IFDIR) ino_visit(ip, ino, ino_free_children, 0); DIP_SET(ip, di_nlink, 0); ino_visit(ip, ino, blk_free_visit, VISIT_EXT | VISIT_INDIR); @@ -1320,7 +1320,7 @@ if (mode == 0) err_suj("Inode %d has a link of %d with 0 mode\n", ino, nlink); nlink--; - if ((mode & IFMT) == IFDIR) + if ((mode & UFS_IFMT) == UFS_IFDIR) reqlink = 2; else reqlink = 1; @@ -1355,13 +1355,13 @@ nlink = sino->si_nlink; ino = sino->si_ino; - mode = sino->si_mode & IFMT; + mode = sino->si_mode & UFS_IFMT; /* * If it's a directory with no dot links, it was truncated before * the name was cleared. We need to clear the dirent that * points at it. */ - if (mode == IFDIR && nlink == 1 && sino->si_dotlinks == 0) { + if (mode == UFS_IFDIR && nlink == 1 && sino->si_dotlinks == 0) { sino->si_nlink = nlink = 0; TAILQ_FOREACH(srec, &sino->si_recs, sr_next) { rrec = (struct jrefrec *)srec->sr_rec; @@ -1378,7 +1378,7 @@ * If it's a directory with no real names pointing to it go ahead * and truncate it. This will free any children. */ - if (mode == IFDIR && nlink - sino->si_dotlinks == 0) { + if (mode == UFS_IFDIR && nlink - sino->si_dotlinks == 0) { sino->si_nlink = nlink = 0; /* * Mark any .. links so they know not to free this inode @@ -1394,7 +1394,7 @@ } } ip = ino_read(ino); - mode = DIP(ip, di_mode) & IFMT; + mode = DIP(ip, di_mode) & UFS_IFMT; if (nlink > LINK_MAX) err_suj("ino %ju nlink manipulation error, new %ju, old %d\n", (uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink)); @@ -1413,7 +1413,7 @@ if (mode != sino->si_mode && debug) printf("ino %ju, mode %o != %o\n", (uintmax_t)ino, mode, sino->si_mode); - if ((mode & IFMT) == IFDIR) + if ((mode & UFS_IFMT) == UFS_IFDIR) reqlink = 2; else reqlink = 1; @@ -1526,15 +1526,15 @@ int mode; ip = ino_read(ino); - mode = DIP(ip, di_mode) & IFMT; + mode = DIP(ip, di_mode) & UFS_IFMT; cursize = DIP(ip, di_size); if (debug) printf("Truncating ino %ju, mode %o to size %jd from size %jd\n", (uintmax_t)ino, mode, size, cursize); /* Skip datablocks for short links and devices. */ - if (mode == 0 || mode == IFBLK || mode == IFCHR || - (mode == IFLNK && cursize < fs->fs_maxsymlinklen)) + if (mode == 0 || mode == UFS_IFBLK || mode == UFS_IFCHR || + (mode == UFS_IFLNK && cursize < fs->fs_maxsymlinklen)) return; /* Don't extend. */ if (size > cursize) @@ -1607,7 +1607,7 @@ * uninitialized space later. */ off = blkoff(fs, size); - if (off && DIP(ip, di_mode) != IFDIR) { + if (off && DIP(ip, di_mode) != UFS_IFDIR) { uint8_t *buf; long clrsize; @@ -1655,7 +1655,7 @@ rrec = (struct jrefrec *)srec->sr_rec; isat = ino_isat(rrec->jr_parent, rrec->jr_diroff, rrec->jr_ino, &mode, &isdot); - if (isat && (mode & IFMT) != (rrec->jr_mode & IFMT)) + if (isat && (mode & UFS_IFMT) != (rrec->jr_mode & UFS_IFMT)) err_suj("Inode mode/directory type mismatch %o != %o\n", mode, rrec->jr_mode); if (debug) @@ -1666,7 +1666,7 @@ (uintmax_t)rrec->jr_parent, (uintmax_t)rrec->jr_diroff, rrec->jr_mode, isat, isdot); - mode = rrec->jr_mode & IFMT; + mode = rrec->jr_mode & UFS_IFMT; if (rrec->jr_op == JOP_REMREF) removes++; newlinks += isat; @@ -1936,7 +1936,7 @@ fs->fs_sujfree = 0; while (ino != 0) { ip = ino_read(ino); - mode = DIP(ip, di_mode) & IFMT; + mode = DIP(ip, di_mode) & UFS_IFMT; inon = DIP(ip, di_freelink); DIP_SET(ip, di_freelink, 0); /* @@ -2392,7 +2392,7 @@ return (-1); } - if (DIP(ip, di_mode) != (IFREG | IREAD)) { + if (DIP(ip, di_mode) != (UFS_IFREG | UFS_IREAD)) { printf("Invalid mode %o for journal inode %ju\n", DIP(ip, di_mode), (uintmax_t)sujino); return (-1); Index: sbin/fsdb/fsdb.c =================================================================== --- sbin/fsdb/fsdb.c +++ sbin/fsdb/fsdb.c @@ -510,14 +510,14 @@ /* Get on-disk inode aka dinode. */ curinum = inum; curinode = ginode(inum); - /* Find IFLNK dinode with allocated data blocks. */ - switch (DIP(curinode, di_mode) & IFMT) { - case IFDIR: - case IFREG: + /* Find UFS_IFLNK dinode with allocated data blocks. */ + switch (DIP(curinode, di_mode) & UFS_IFMT) { + case UFS_IFDIR: + case UFS_IFREG: if (DIP(curinode, di_blocks) == 0) continue; break; - case IFLNK: + case UFS_IFLNK: { uint64_t size = DIP(curinode, di_size); if (size > 0 && size < sblock.fs_maxsymlinklen && @@ -883,10 +883,10 @@ const char *typename; int typebits; } typenamemap[] = { - {"file", IFREG}, - {"dir", IFDIR}, - {"socket", IFSOCK}, - {"fifo", IFIFO}, + {"file", UFS_IFREG}, + {"dir", UFS_IFDIR}, + {"socket", UFS_IFSOCK}, + {"fifo", UFS_IFIFO}, }; CMDFUNCSTART(newtype) @@ -896,7 +896,7 @@ if (!checkactive()) return 1; - type = DIP(curinode, di_mode) & IFMT; + type = DIP(curinode, di_mode) & UFS_IFMT; for (tp = typenamemap; tp < &typenamemap[nitems(typenamemap)]; tp++) { @@ -911,7 +911,7 @@ warnx("try one of `file', `dir', `socket', `fifo'"); return 1; } - DIP_SET(curinode, di_mode, DIP(curinode, di_mode) & ~IFMT); + DIP_SET(curinode, di_mode, DIP(curinode, di_mode) & ~UFS_IFMT); DIP_SET(curinode, di_mode, DIP(curinode, di_mode) | type); inodirty(); printactive(0); Index: sbin/fsdb/fsdbutil.c =================================================================== --- sbin/fsdb/fsdbutil.c +++ sbin/fsdb/fsdbutil.c @@ -118,20 +118,20 @@ time_t t; printf("%s: ", cp); - switch (DIP(dp, di_mode) & IFMT) { - case IFDIR: + switch (DIP(dp, di_mode) & UFS_IFMT) { + case UFS_IFDIR: puts("directory"); break; - case IFREG: + case UFS_IFREG: puts("regular file"); break; - case IFBLK: + case UFS_IFBLK: printf("block special (%#jx)", (uintmax_t)DIP(dp, di_rdev)); break; - case IFCHR: + case UFS_IFCHR: printf("character special (%#jx)", DIP(dp, di_rdev)); break; - case IFLNK: + case UFS_IFLNK: fputs("symlink",stdout); if (DIP(dp, di_size) > 0 && DIP(dp, di_size) < sblock.fs_maxsymlinklen && @@ -145,10 +145,10 @@ putchar('\n'); } break; - case IFSOCK: + case UFS_IFSOCK: puts("socket"); break; - case IFIFO: + case UFS_IFIFO: puts("fifo"); break; } @@ -336,7 +336,7 @@ warnx("no current inode\n"); return 0; } - if ((DIP(curinode, di_mode) & IFMT) != IFDIR) { + if ((DIP(curinode, di_mode) & UFS_IFMT) != UFS_IFDIR) { warnx("inode %ju not a directory", (uintmax_t)curinum); return 0; } @@ -348,14 +348,14 @@ { if (!checkactive()) return 1; - switch (DIP(curinode, di_mode) & IFMT) { - case IFDIR: - case IFREG: - case IFBLK: - case IFCHR: - case IFLNK: - case IFSOCK: - case IFIFO: + switch (DIP(curinode, 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: if (doblocks) printblocks(curinum, curinode); else @@ -366,7 +366,7 @@ break; default: printf("current inode %ju: screwy itype 0%o (mode 0%o)?\n", - (uintmax_t)curinum, DIP(curinode, di_mode) & IFMT, + (uintmax_t)curinum, DIP(curinode, di_mode) & UFS_IFMT, DIP(curinode, di_mode)); break; } Index: sbin/newfs/mkfs.c =================================================================== --- sbin/newfs/mkfs.c +++ sbin/newfs/mkfs.c @@ -847,7 +847,7 @@ /* * create the root directory */ - node.dp1.di_mode = IFDIR | UMASK; + node.dp1.di_mode = UFS_IFDIR | UMASK; node.dp1.di_nlink = entries; node.dp1.di_size = makedir(root_dir, entries); node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode); @@ -883,7 +883,7 @@ /* * create the root directory */ - node.dp2.di_mode = IFDIR | UMASK; + node.dp2.di_mode = UFS_IFDIR | UMASK; node.dp2.di_nlink = entries; node.dp2.di_size = makedir(root_dir, entries); node.dp2.di_db[0] = alloc(sblock.fs_fsize, node.dp2.di_mode); @@ -966,7 +966,7 @@ acg.cg_cs.cs_nbfree--; sblock.fs_cstotal.cs_nbfree--; fscs[0].cs_nbfree--; - if (mode & IFDIR) { + if (mode & UFS_IFDIR) { acg.cg_cs.cs_ndir++; sblock.fs_cstotal.cs_ndir++; fscs[0].cs_ndir++; Index: sbin/quotacheck/quotacheck.c =================================================================== --- sbin/quotacheck/quotacheck.c +++ sbin/quotacheck/quotacheck.c @@ -373,7 +373,7 @@ for (i = 0; i < inosused; i++, ino++) { if ((dp = getnextinode(ino)) == NULL || ino < UFS_ROOTINO || - (mode = DIP(dp, di_mode) & IFMT) == 0) + (mode = DIP(dp, di_mode) & UFS_IFMT) == 0) continue; /* * XXX: Do not account for UIDs or GIDs that appear @@ -408,16 +408,16 @@ fup = addid((u_long)DIP(dp, di_gid), GRPQUOTA, (char *)0, mntpt); fup->fu_curinodes++; - if (mode == IFREG || mode == IFDIR || - mode == IFLNK) + if (mode == UFS_IFREG || mode == UFS_IFDIR || + mode == UFS_IFLNK) fup->fu_curblocks += DIP(dp, di_blocks); } if (qfu) { fup = addid((u_long)DIP(dp, di_uid), USRQUOTA, (char *)0, mntpt); fup->fu_curinodes++; - if (mode == IFREG || mode == IFDIR || - mode == IFLNK) + if (mode == UFS_IFREG || mode == UFS_IFDIR || + mode == UFS_IFLNK) fup->fu_curblocks += DIP(dp, di_blocks); } } Index: sbin/restore/dirs.c =================================================================== --- sbin/restore/dirs.c +++ sbin/restore/dirs.c @@ -175,7 +175,7 @@ for (;;) { curfile.name = ""; curfile.action = USING; - if (curfile.mode == 0 || (curfile.mode & IFMT) != IFDIR) + if (curfile.mode == 0 || (curfile.mode & UFS_IFMT) != UFS_IFDIR) break; itp = allocinotab(&curfile, seekpt); getfile(putdir, putdirattrs, xtrnull); @@ -202,7 +202,7 @@ skipdirs(void) { - while (curfile.ino && (curfile.mode & IFMT) == IFDIR) { + while (curfile.ino && (curfile.mode & UFS_IFMT) == UFS_IFDIR) { skipfile(); } } Index: sbin/restore/interactive.c =================================================================== --- sbin/restore/interactive.c +++ sbin/restore/interactive.c @@ -739,9 +739,9 @@ (!vflag && dp->d_ino == UFS_WINO)) return (-1); if (inodetype(dp->d_ino) == NODE) - stp->st_mode = IFDIR; + stp->st_mode = UFS_IFDIR; else - stp->st_mode = IFREG; + stp->st_mode = UFS_IFREG; return (0); } Index: sbin/restore/tape.c =================================================================== --- sbin/restore/tape.c +++ sbin/restore/tape.c @@ -590,19 +590,19 @@ gid = curfile.gid; mode = curfile.mode; flags = curfile.file_flags; - switch (mode & IFMT) { + switch (mode & UFS_IFMT) { default: fprintf(stderr, "%s: unknown file mode 0%o\n", name, mode); skipfile(); return (FAIL); - case IFSOCK: + case UFS_IFSOCK: vprintf(stdout, "skipped socket %s\n", name); skipfile(); return (GOOD); - case IFDIR: + case UFS_IFDIR: if (mflag) { ep = lookupname(name); if (ep == NULL || ep->e_flags & EXTRACT) @@ -613,7 +613,7 @@ vprintf(stdout, "extract file %s\n", name); return (genliteraldir(name, curfile.ino)); - case IFLNK: + case UFS_IFLNK: lnkbuf[0] = '\0'; pathlen = 0; buf = setupextattr(extsize); @@ -637,7 +637,7 @@ } return (FAIL); - case IFIFO: + case UFS_IFIFO: vprintf(stdout, "extract fifo %s\n", name); if (Nflag) { skipfile(); @@ -665,8 +665,8 @@ (void) chflags(name, flags); return (GOOD); - case IFCHR: - case IFBLK: + case UFS_IFCHR: + case UFS_IFBLK: vprintf(stdout, "extract special file %s\n", name); if (Nflag) { skipfile(); @@ -674,7 +674,7 @@ } if (uflag) (void) unlink(name); - if (mknod(name, (mode & (IFCHR | IFBLK)) | 0600, + if (mknod(name, (mode & (UFS_IFCHR | UFS_IFBLK)) | 0600, (int)curfile.rdev) < 0) { fprintf(stderr, "%s: cannot create special file: %s\n", name, strerror(errno)); @@ -695,7 +695,7 @@ (void) chflags(name, flags); return (GOOD); - case IFREG: + case UFS_IFREG: vprintf(stdout, "extract file %s\n", name); if (Nflag) { skipfile(); Index: sbin/tunefs/tunefs.c =================================================================== --- sbin/tunefs/tunefs.c +++ sbin/tunefs/tunefs.c @@ -1019,7 +1019,7 @@ if (sblock.fs_magic == FS_UFS1_MAGIC) { bzero(dp1, sizeof(*dp1)); dp1->di_size = size; - dp1->di_mode = IFREG | IREAD; + dp1->di_mode = UFS_IFREG | UFS_IREAD; dp1->di_nlink = 1; dp1->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP; dp1->di_atime = utime; @@ -1028,7 +1028,7 @@ } else { bzero(dp2, sizeof(*dp2)); dp2->di_size = size; - dp2->di_mode = IFREG | IREAD; + dp2->di_mode = UFS_IFREG | UFS_IREAD; dp2->di_nlink = 1; dp2->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP; dp2->di_atime = utime; Index: sys/fs/ext2fs/ext2_alloc.c =================================================================== --- sys/fs/ext2fs/ext2_alloc.c +++ sys/fs/ext2fs/ext2_alloc.c @@ -371,7 +371,7 @@ * ext2_dirpref else obtain it using ino_to_cg. The preferred inode is * always the next inode. */ - if ((mode & IFMT) == IFDIR) { + if ((mode & EXT2_IFMT) == EXT2_IFDIR) { cg = ext2_dirpref(pip); if (fs->e2fs_contigdirs[cg] < 255) fs->e2fs_contigdirs[cg]++; @@ -947,7 +947,7 @@ fs->e2fs_gd[cg].ext2bgd_nifree--; fs->e2fs->e2fs_ficount--; fs->e2fs_fmod = 1; - if ((mode & IFMT) == IFDIR) { + if ((mode & EXT2_IFMT) == EXT2_IFDIR) { fs->e2fs_gd[cg].ext2bgd_ndirs++; fs->e2fs_total_dir++; } @@ -1043,7 +1043,7 @@ EXT2_LOCK(ump); fs->e2fs->e2fs_ficount++; fs->e2fs_gd[cg].ext2bgd_nifree++; - if ((mode & IFMT) == IFDIR) { + if ((mode & EXT2_IFMT) == EXT2_IFDIR) { fs->e2fs_gd[cg].ext2bgd_ndirs--; fs->e2fs_total_dir--; } Index: sys/fs/ext2fs/ext2_dinode.h =================================================================== --- sys/fs/ext2fs/ext2_dinode.h +++ sys/fs/ext2fs/ext2_dinode.h @@ -103,7 +103,7 @@ * Structure of an inode on the disk */ struct ext2fs_dinode { - uint16_t e2di_mode; /* 0: IFMT, permissions; see below. */ + uint16_t e2di_mode; /* 0: EXT2_IFMT, permissions; below.*/ uint16_t e2di_uid; /* 2: Owner UID */ uint32_t e2di_size; /* 4: Size (in bytes) */ uint32_t e2di_atime; /* 8: Access time */ Index: sys/fs/ext2fs/ext2_lookup.c =================================================================== --- sys/fs/ext2fs/ext2_lookup.c +++ sys/fs/ext2fs/ext2_lookup.c @@ -585,7 +585,7 @@ * may not delete it (unless she's root). This * implements append-only directories. */ - if ((dp->i_mode & ISVTX) && + if ((dp->i_mode & EXT2_ISVTX) && cred->cr_uid != 0 && cred->cr_uid != dp->i_uid && VTOI(tdp)->i_uid != cred->cr_uid) { Index: sys/fs/ext2fs/ext2_vnops.c =================================================================== --- sys/fs/ext2fs/ext2_vnops.c +++ sys/fs/ext2fs/ext2_vnops.c @@ -334,7 +334,7 @@ */ vap->va_fsid = dev2udev(ip->i_devvp->v_rdev); vap->va_fileid = ip->i_number; - vap->va_mode = ip->i_mode & ~IFMT; + vap->va_mode = ip->i_mode & ~EXT2_IFMT; vap->va_nlink = ip->i_nlink; vap->va_uid = ip->i_uid; vap->va_gid = ip->i_gid; @@ -516,7 +516,7 @@ if (error) return (EFTYPE); } - if (!groupmember(ip->i_gid, cred) && (mode & ISGID)) { + if (!groupmember(ip->i_gid, cred) && (mode & EXT2_ISGID)) { error = priv_check_cred(cred, PRIV_VFS_SETGID, 0); if (error) return (error); @@ -566,9 +566,10 @@ ip->i_gid = gid; ip->i_uid = uid; ip->i_flag |= IN_CHANGE; - if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) { + if ((ip->i_mode & (EXT2_ISUID | EXT2_ISGID)) && + (ouid != uid || ogid != gid)) { if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID, 0) != 0) - ip->i_mode &= ~(ISUID | ISGID); + ip->i_mode &= ~(EXT2_ISUID | EXT2_ISGID); } return (0); } @@ -786,7 +787,7 @@ error = EPERM; goto abortit; } - if ((ip->i_mode & IFMT) == IFDIR) { + if ((ip->i_mode & EXT2_IFMT) == EXT2_IFDIR) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ @@ -918,7 +919,7 @@ * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ - if ((xp->i_mode & IFMT) == IFDIR) { + if ((xp->i_mode & EXT2_IFMT) == EXT2_IFDIR) { if (!ext2_dirempty(xp, dp->i_number, tcnp->cn_cred) || xp->i_nlink > 2) { error = ENOTEMPTY; @@ -1096,7 +1097,7 @@ goto out; } dmode = vap->va_mode & 0777; - dmode |= IFDIR; + dmode |= EXT2_IFDIR; /* * Must simulate part of ext2_makeinode here to acquire the inode, * but not have it entered in the parent directory. The entry is @@ -1118,8 +1119,8 @@ * 'give it away' so that the SUID is still forced on. */ if ((dvp->v_mount->mnt_flag & MNT_SUIDDIR) && - (dp->i_mode & ISUID) && dp->i_uid) { - dmode |= ISUID; + (dp->i_mode & EXT2_ISUID) && dp->i_uid) { + dmode |= EXT2_ISUID; ip->i_uid = dp->i_uid; } else { ip->i_uid = cnp->cn_cred->cr_uid; @@ -1281,7 +1282,7 @@ struct inode *ip; int len, error; - error = ext2_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp, + error = ext2_makeinode(EXT2_IFLNK | ap->a_vap->va_mode, ap->a_dvp, vpp, ap->a_cnp); if (error) return (error); @@ -1536,8 +1537,8 @@ panic("ext2_makeinode: no name"); #endif *vpp = NULL; - if ((mode & IFMT) == 0) - mode |= IFREG; + if ((mode & EXT2_IFMT) == 0) + mode |= EXT2_IFREG; error = ext2_valloc(dvp, mode, cnp->cn_cred, &tvp); if (error) { @@ -1556,7 +1557,7 @@ * Note that this drops off the execute bits for security. */ if ((dvp->v_mount->mnt_flag & MNT_SUIDDIR) && - (pdir->i_mode & ISUID) && + (pdir->i_mode & EXT2_ISUID) && (pdir->i_uid != cnp->cn_cred->cr_uid) && pdir->i_uid) { ip->i_uid = pdir->i_uid; mode &= ~07111; @@ -1571,9 +1572,10 @@ ip->i_mode = mode; tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */ ip->i_nlink = 1; - if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred)) { + if ((ip->i_mode & EXT2_ISGID) && + !groupmember(ip->i_gid, cnp->cn_cred)) { if (priv_check_cred(cnp->cn_cred, PRIV_VFS_RETAINSUGID, 0)) - ip->i_mode &= ~ISGID; + ip->i_mode &= ~EXT2_ISGID; } if (cnp->cn_flags & ISWHITEOUT) @@ -2026,10 +2028,10 @@ * we clear the setuid and setgid bits as a precaution against * tampering. */ - if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && - ap->a_cred) { + if ((ip->i_mode & (EXT2_ISUID | EXT2_ISGID)) && + resid > uio->uio_resid && ap->a_cred) { if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID, 0)) - ip->i_mode &= ~(ISUID | ISGID); + ip->i_mode &= ~(EXT2_ISUID | EXT2_ISGID); } if (error) { if (ioflag & IO_UNIT) { Index: sys/fs/ext2fs/inode.h =================================================================== --- sys/fs/ext2fs/inode.h +++ sys/fs/ext2fs/inode.h @@ -90,7 +90,7 @@ uint32_t i_next_alloc_goal; /* Fields from struct dinode in UFS. */ - uint16_t i_mode; /* IFMT, permissions; see below. */ + uint16_t i_mode; /* EXT2_IFMT, permissions; see below. */ int16_t i_nlink; /* File link count. */ uint32_t i_uid; /* File owner. */ uint32_t i_gid; /* File group. */ @@ -123,23 +123,23 @@ #define i_rdev i_db[0] /* File permissions. */ -#define IEXEC 0000100 /* Executable. */ -#define IWRITE 0000200 /* Writeable. */ -#define IREAD 0000400 /* Readable. */ -#define ISVTX 0001000 /* Sticky bit. */ -#define ISGID 0002000 /* Set-gid. */ -#define ISUID 0004000 /* Set-uid. */ +#define EXT2_IEXEC 0000100 /* Executable. */ +#define EXT2_IWRITE 0000200 /* Writeable. */ +#define EXT2_IREAD 0000400 /* Readable. */ +#define EXT2_ISVTX 0001000 /* Sticky bit. */ +#define EXT2_ISGID 0002000 /* Set-gid. */ +#define EXT2_ISUID 0004000 /* Set-uid. */ /* File types. */ -#define IFMT 0170000 /* Mask of file type. */ -#define IFIFO 0010000 /* Named pipe (fifo). */ -#define IFCHR 0020000 /* Character device. */ -#define IFDIR 0040000 /* Directory file. */ -#define IFBLK 0060000 /* Block device. */ -#define IFREG 0100000 /* Regular file. */ -#define IFLNK 0120000 /* Symbolic link. */ -#define IFSOCK 0140000 /* UNIX domain socket. */ -#define IFWHT 0160000 /* Whiteout. */ +#define EXT2_IFMT 0170000 /* Mask of file type. */ +#define EXT2_IFIFO 0010000 /* Named pipe (fifo). */ +#define EXT2_IFCHR 0020000 /* Character device. */ +#define EXT2_IFDIR 0040000 /* Directory file. */ +#define EXT2_IFBLK 0060000 /* Block device. */ +#define EXT2_IFREG 0100000 /* Regular file. */ +#define EXT2_IFLNK 0120000 /* Symbolic link. */ +#define EXT2_IFSOCK 0140000 /* UNIX domain socket. */ +#define EXT2_IFWHT 0160000 /* Whiteout. */ /* These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ Index: sys/fs/nandfs/nandfs.h =================================================================== --- sys/fs/nandfs/nandfs.h +++ sys/fs/nandfs/nandfs.h @@ -293,12 +293,12 @@ #define IN_RENAME 0x0010 /* node is being renamed. */ /* File permissions. */ -#define IEXEC 0000100 /* Executable. */ -#define IWRITE 0000200 /* Writeable. */ -#define IREAD 0000400 /* Readable. */ -#define ISVTX 0001000 /* Sticky bit. */ -#define ISGID 0002000 /* Set-gid. */ -#define ISUID 0004000 /* Set-uid. */ +#define NANDFS_IEXEC 0000100 /* Executable. */ +#define NANDFS_IWRITE 0000200 /* Writeable. */ +#define NANDFS_IREAD 0000400 /* Readable. */ +#define NANDFS_ISVTX 0001000 /* Sticky bit. */ +#define NANDFS_ISGID 0002000 /* Set-gid. */ +#define NANDFS_ISUID 0004000 /* Set-uid. */ #define PRINT_NODE_FLAGS \ "\10\1IN_ACCESS\2IN_CHANGE\3IN_UPDATE\4IN_MODIFIED\5IN_RENAME" Index: sys/fs/nandfs/nandfs_vnops.c =================================================================== --- sys/fs/nandfs/nandfs_vnops.c +++ sys/fs/nandfs/nandfs_vnops.c @@ -282,7 +282,7 @@ if (modified) { if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0) - node->nn_inode.i_mode &= ~(ISUID | ISGID); + node->nn_inode.i_mode &= ~(NANDFS_ISUID | NANDFS_ISGID); if (file_size < uio->uio_offset + uio->uio_resid) { node->nn_inode.i_size = uio->uio_offset + @@ -441,7 +441,7 @@ node->nn_diroff = off; } - if ((dir_node->nn_inode.i_mode & ISVTX) && + if ((dir_node->nn_inode.i_mode & NANDFS_ISVTX)&& cred->cr_uid != 0 && cred->cr_uid != dir_node->nn_inode.i_uid && node->nn_inode.i_uid != cred->cr_uid) { @@ -722,7 +722,7 @@ if (priv_check_cred(cred, PRIV_VFS_STICKYFILE, 0)) return (EFTYPE); } - if (!groupmember(inode->i_gid, cred) && (mode & ISGID)) { + if (!groupmember(inode->i_gid, cred) && (mode & NANDFS_ISGID)) { error = priv_check_cred(cred, PRIV_VFS_SETGID, 0); if (error) return (error); @@ -731,7 +731,7 @@ /* * Deny setting setuid if we are not the file owner. */ - if ((mode & ISUID) && inode->i_uid != cred->cr_uid) { + if ((mode & NANDFS_ISUID) && inode->i_uid != cred->cr_uid) { error = priv_check_cred(cred, PRIV_VFS_ADMIN, 0); if (error) return (error); @@ -784,10 +784,10 @@ inode->i_uid = uid; node->nn_flags |= IN_CHANGE; - if ((inode->i_mode & (ISUID | ISGID)) && + if ((inode->i_mode & (NANDFS_ISUID | NANDFS_ISGID)) && (ouid != uid || ogid != gid)) { if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID, 0)) - inode->i_mode &= ~(ISUID | ISGID); + inode->i_mode &= ~(NANDFS_ISUID | NANDFS_ISGID); } DPRINTF(VNCALL, ("%s: vp %p, cred %p, td %p - ret OK\n", __func__, vp, cred, td)); Index: sys/ufs/ffs/ffs_alloc.c =================================================================== --- sys/ufs/ffs/ffs_alloc.c +++ sys/ufs/ffs/ffs_alloc.c @@ -1049,7 +1049,7 @@ if (fs->fs_cstotal.cs_nifree == 0) goto noinodes; - if ((mode & IFMT) == IFDIR) + if ((mode & UFS_IFMT) == UFS_IFDIR) ipref = ffs_dirpref(pip); else ipref = pip->i_number; @@ -1060,7 +1060,7 @@ * Track number of dirs created one after another * in a same cg without intervening by files. */ - if ((mode & IFMT) == IFDIR) { + if ((mode & UFS_IFMT) == UFS_IFDIR) { if (fs->fs_contigdirs[cg] < 255) fs->fs_contigdirs[cg]++; } else { @@ -1361,7 +1361,7 @@ * If we are allocating a directory data block, we want * to place it in the metadata area. */ - if ((ip->i_mode & IFMT) == IFDIR) + if ((ip->i_mode & UFS_IFMT) == UFS_IFDIR) return (cgmeta(fs, inocg)); /* * Until we fill all the direct and all the first indirect's @@ -1466,7 +1466,7 @@ * If we are allocating a directory data block, we want * to place it in the metadata area. */ - if ((ip->i_mode & IFMT) == IFDIR) + if ((ip->i_mode & UFS_IFMT) == UFS_IFDIR) return (cgmeta(fs, inocg)); /* * Until we fill all the direct and all the first indirect's @@ -2126,7 +2126,7 @@ fs->fs_cstotal.cs_nifree--; fs->fs_cs(fs, cg).cs_nifree--; fs->fs_fmod = 1; - if ((mode & IFMT) == IFDIR) { + if ((mode & UFS_IFMT) == UFS_IFDIR) { cgp->cg_cs.cs_ndir++; fs->fs_cstotal.cs_ndir++; fs->fs_cs(fs, cg).cs_ndir++; @@ -2518,7 +2518,7 @@ UFS_LOCK(ump); fs->fs_cstotal.cs_nifree++; fs->fs_cs(fs, cg).cs_nifree++; - if ((mode & IFMT) == IFDIR) { + if ((mode & UFS_IFMT) == UFS_IFDIR) { cgp->cg_cs.cs_ndir--; fs->fs_cstotal.cs_ndir--; fs->fs_cs(fs, cg).cs_ndir--; @@ -2812,7 +2812,7 @@ return (EROFS); } fs = ump->um_fs; - filetype = IFREG; + filetype = UFS_IFREG; switch (oidp->oid_number) { @@ -2867,7 +2867,7 @@ break; case FFS_DIR_FREE: - filetype = IFDIR; + filetype = UFS_IFDIR; /* fall through */ case FFS_FILE_FREE: @@ -2876,12 +2876,12 @@ if (cmd.size == 1) printf("%s: free %s inode %ju\n", mp->mnt_stat.f_mntonname, - filetype == IFDIR ? "directory" : "file", + filetype == UFS_IFDIR ? "directory":"file", (uintmax_t)cmd.value); else printf("%s: free %s inodes %ju-%ju\n", mp->mnt_stat.f_mntonname, - filetype == IFDIR ? "directory" : "file", + filetype == UFS_IFDIR ? "directory":"file", (uintmax_t)cmd.value, (uintmax_t)(cmd.value + cmd.size - 1)); } Index: sys/ufs/ffs/ffs_softdep.c =================================================================== --- sys/ufs/ffs/ffs_softdep.c +++ sys/ufs/ffs/ffs_softdep.c @@ -5314,7 +5314,7 @@ * allocate an associated pagedep to track additions and * deletions. */ - if ((ip->i_mode & IFMT) == IFDIR) + if ((ip->i_mode & UFS_IFMT) == UFS_IFDIR) pagedep_lookup(mp, bp, ip->i_number, off, DEPALLOC, &pagedep); } @@ -5851,7 +5851,7 @@ * allocate an associated pagedep to track additions and * deletions. */ - if ((ip->i_mode & IFMT) == IFDIR) + if ((ip->i_mode & UFS_IFMT) == UFS_IFDIR) pagedep_lookup(mp, nbp, ip->i_number, lbn, DEPALLOC, &pagedep); WORKLIST_INSERT(&nbp->b_dep, &aip->ai_block.nb_list); freefrag = setup_allocindir_phase2(bp, ip, inodedep, aip, lbn); @@ -10922,7 +10922,7 @@ LIST_FOREACH(jaddref, &bmsafemap->sm_jaddrefhd, ja_bmdeps) { ino = jaddref->ja_ino % fs->fs_ipg; if (isset(inosused, ino)) { - if ((jaddref->ja_mode & IFMT) == IFDIR) + if ((jaddref->ja_mode & UFS_IFMT) == UFS_IFDIR) cgp->cg_cs.cs_ndir--; cgp->cg_cs.cs_nifree++; clrbit(inosused, ino); @@ -11891,7 +11891,7 @@ "re-allocated inode"); /* Do the roll-forward only if it's a real copy. */ if (foreground) { - if ((jaddref->ja_mode & IFMT) == IFDIR) + if ((jaddref->ja_mode & UFS_IFMT) == UFS_IFDIR) cgp->cg_cs.cs_ndir++; cgp->cg_cs.cs_nifree--; setbit(inosused, ino); Index: sys/ufs/ffs/ffs_vnops.c =================================================================== --- sys/ufs/ffs/ffs_vnops.c +++ sys/ufs/ffs/ffs_vnops.c @@ -835,10 +835,10 @@ * we clear the setuid and setgid bits as a precaution against * tampering. */ - if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && + if ((ip->i_mode & (UFS_ISUID | UFS_ISGID)) && resid > uio->uio_resid && ap->a_cred) { if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID, 0)) { - ip->i_mode &= ~(ISUID | ISGID); + ip->i_mode &= ~(UFS_ISUID | UFS_ISGID); DIP_SET(ip, i_mode, ip->i_mode); } } @@ -1078,9 +1078,10 @@ * we clear the setuid and setgid bits as a precaution against * tampering. */ - if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && ucred) { + if ((ip->i_mode & (UFS_ISUID | UFS_ISGID)) && resid > uio->uio_resid && + ucred) { if (priv_check_cred(ucred, PRIV_VFS_RETAINSUGID, 0)) { - ip->i_mode &= ~(ISUID | ISGID); + ip->i_mode &= ~(UFS_ISUID | UFS_ISGID); dp->di_mode = ip->i_mode; } } Index: sys/ufs/ffs/softdep.h =================================================================== --- sys/ufs/ffs/softdep.h +++ sys/ufs/ffs/softdep.h @@ -781,7 +781,7 @@ ino_t if_ino; /* Inode number. */ ino_t if_parent; /* Parent inode number. */ nlink_t if_nlink; /* nlink before addition. */ - uint16_t if_mode; /* File mode, needed for IFMT. */ + uint16_t if_mode; /* File mode, needed for UFS_IFMT. */ }; /* Index: sys/ufs/ufs/dinode.h =================================================================== --- sys/ufs/ufs/dinode.h +++ sys/ufs/ufs/dinode.h @@ -93,23 +93,23 @@ typedef int64_t ufs_time_t; /* File permissions. */ -#define IEXEC 0000100 /* Executable. */ -#define IWRITE 0000200 /* Writeable. */ -#define IREAD 0000400 /* Readable. */ -#define ISVTX 0001000 /* Sticky bit. */ -#define ISGID 0002000 /* Set-gid. */ -#define ISUID 0004000 /* Set-uid. */ +#define UFS_IEXEC 0000100 /* Executable. */ +#define UFS_IWRITE 0000200 /* Writeable. */ +#define UFS_IREAD 0000400 /* Readable. */ +#define UFS_ISVTX 0001000 /* Sticky bit. */ +#define UFS_ISGID 0002000 /* Set-gid. */ +#define UFS_ISUID 0004000 /* Set-uid. */ /* File types. */ -#define IFMT 0170000 /* Mask of file type. */ -#define IFIFO 0010000 /* Named pipe (fifo). */ -#define IFCHR 0020000 /* Character device. */ -#define IFDIR 0040000 /* Directory file. */ -#define IFBLK 0060000 /* Block device. */ -#define IFREG 0100000 /* Regular file. */ -#define IFLNK 0120000 /* Symbolic link. */ -#define IFSOCK 0140000 /* UNIX domain socket. */ -#define IFWHT 0160000 /* Whiteout. */ +#define UFS_IFMT 0170000 /* Mask of file type. */ +#define UFS_IFIFO 0010000 /* Named pipe (fifo). */ +#define UFS_IFCHR 0020000 /* Character device. */ +#define UFS_IFDIR 0040000 /* Directory file. */ +#define UFS_IFBLK 0060000 /* Block device. */ +#define UFS_IFREG 0100000 /* Regular file. */ +#define UFS_IFLNK 0120000 /* Symbolic link. */ +#define UFS_IFSOCK 0140000 /* UNIX domain socket. */ +#define UFS_IFWHT 0160000 /* Whiteout. */ /* * A dinode contains all the meta-data associated with a UFS2 file. @@ -123,7 +123,7 @@ #define UFS_NIADDR 3 /* Indirect addresses in inode. */ struct ufs2_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + u_int16_t di_mode; /* 0: UFS_IFMT, permissions; below. */ int16_t di_nlink; /* 2: File link count. */ u_int32_t di_uid; /* 4: File owner. */ u_int32_t di_gid; /* 8: File group. */ @@ -166,7 +166,7 @@ * are defined by types with precise widths. */ struct ufs1_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + u_int16_t di_mode; /* 0: UFS_IFMT, permissions; below. */ int16_t di_nlink; /* 2: File link count. */ uint32_t di_freelink; /* 4: SUJ: Next unlinked inode. */ u_int64_t di_size; /* 8: File byte count. */ Index: sys/ufs/ufs/inode.h =================================================================== --- sys/ufs/ufs/inode.h +++ sys/ufs/ufs/inode.h @@ -111,7 +111,7 @@ u_int32_t i_flags; /* Status flags (chflags). */ u_int32_t i_uid; /* File owner. */ u_int32_t i_gid; /* File group. */ - u_int16_t i_mode; /* IFMT, permissions; see below. */ + u_int16_t i_mode; /* UFS_IFMT, permissions; see below. */ int16_t i_nlink; /* File link count. */ }; /* Index: sys/ufs/ufs/ufs_lookup.c =================================================================== --- sys/ufs/ufs/ufs_lookup.c +++ sys/ufs/ufs/ufs_lookup.c @@ -123,7 +123,7 @@ * may not delete it (unless she's root). This * implements append-only directories. */ - if ((VTOI(vdp)->i_mode & ISVTX) && + if ((VTOI(vdp)->i_mode & UFS_ISVTX) && VOP_ACCESS(vdp, VADMIN, cred, td) && VOP_ACCESS(tdp, VADMIN, cred, td)) return (EPERM); Index: sys/ufs/ufs/ufs_vnops.c =================================================================== --- sys/ufs/ufs/ufs_vnops.c +++ sys/ufs/ufs/ufs_vnops.c @@ -469,7 +469,7 @@ */ vap->va_fsid = dev2udev(ITOUMP(ip)->um_dev); vap->va_fileid = ip->i_number; - vap->va_mode = ip->i_mode & ~IFMT; + vap->va_mode = ip->i_mode & ~UFS_IFMT; vap->va_nlink = ip->i_effnlink; vap->va_uid = ip->i_uid; vap->va_gid = ip->i_gid; @@ -749,7 +749,7 @@ if (priv_check_cred(cred, PRIV_VFS_STICKYFILE, 0)) return (EFTYPE); } - if (!groupmember(ip->i_gid, cred) && (mode & ISGID)) { + if (!groupmember(ip->i_gid, cred) && (mode & UFS_ISGID)) { error = priv_check_cred(cred, PRIV_VFS_SETGID, 0); if (error) return (error); @@ -758,7 +758,7 @@ /* * Deny setting setuid if we are not the file owner. */ - if ((mode & ISUID) && ip->i_uid != cred->cr_uid) { + if ((mode & UFS_ISUID) && ip->i_uid != cred->cr_uid) { error = priv_check_cred(cred, PRIV_VFS_ADMIN, 0); if (error) return (error); @@ -887,9 +887,10 @@ panic("ufs_chown: lost quota"); #endif /* QUOTA */ ip->i_flag |= IN_CHANGE; - if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) { + if ((ip->i_mode & (UFS_ISUID | UFS_ISGID)) && + (ouid != uid || ogid != gid)) { if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID, 0)) { - ip->i_mode &= ~(ISUID | ISGID); + ip->i_mode &= ~(UFS_ISUID | UFS_ISGID); DIP_SET(ip, i_mode, ip->i_mode); } } @@ -1275,7 +1276,7 @@ error = EPERM; goto unlockout; } - if ((fip->i_mode & IFMT) == IFDIR) { + if ((fip->i_mode & UFS_IFMT) == UFS_IFDIR) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ @@ -1407,7 +1408,7 @@ * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ - if ((tip->i_mode & IFMT) == IFDIR) { + if ((tip->i_mode & UFS_IFMT) == UFS_IFDIR) { if ((tip->i_effnlink > 2) || !ufs_dirempty(tip, tdp->i_number, tcnp->cn_cred)) { error = ENOTEMPTY; @@ -1798,7 +1799,7 @@ goto out; } dmode = vap->va_mode & 0777; - dmode |= IFDIR; + dmode |= UFS_IFDIR; /* * Must simulate part of ufs_makeinode here to acquire the inode, * but not have it entered in the parent directory. The entry is @@ -1831,8 +1832,8 @@ * 'give it away' so that the SUID is still forced on. */ if ((dvp->v_mount->mnt_flag & MNT_SUIDDIR) && - (dp->i_mode & ISUID) && dp->i_uid) { - dmode |= ISUID; + (dp->i_mode & UFS_ISUID) && dp->i_uid) { + dmode |= UFS_ISUID; ip->i_uid = dp->i_uid; DIP_SET(ip, i_uid, dp->i_uid); #ifdef QUOTA @@ -2122,7 +2123,7 @@ struct inode *ip; int len, error; - error = ufs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp, + error = ufs_makeinode(UFS_IFLNK | ap->a_vap->va_mode, ap->a_dvp, vpp, ap->a_cnp, "ufs_symlink"); if (error) return (error); @@ -2593,8 +2594,8 @@ panic("%s: no name", callfunc); #endif *vpp = NULL; - if ((mode & IFMT) == 0) - mode |= IFREG; + if ((mode & UFS_IFMT) == 0) + mode |= UFS_IFREG; if (pdir->i_effnlink < 2) { print_bad_link_count(callfunc, dvp); @@ -2621,7 +2622,7 @@ * Note that this drops off the execute bits for security. */ if ((dvp->v_mount->mnt_flag & MNT_SUIDDIR) && - (pdir->i_mode & ISUID) && + (pdir->i_mode & UFS_ISUID) && (pdir->i_uid != cnp->cn_cred->cr_uid) && pdir->i_uid) { ip->i_uid = pdir->i_uid; DIP_SET(ip, i_uid, ip->i_uid); @@ -2680,9 +2681,9 @@ DIP_SET(ip, i_nlink, 1); if (DOINGSOFTDEP(tvp)) softdep_setup_create(VTOI(dvp), ip); - if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) && + if ((ip->i_mode & UFS_ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) && priv_check_cred(cnp->cn_cred, PRIV_VFS_SETGID, 0)) { - ip->i_mode &= ~ISGID; + ip->i_mode &= ~UFS_ISGID; DIP_SET(ip, i_mode, ip->i_mode); } Index: usr.sbin/quot/quot.c =================================================================== --- usr.sbin/quot/quot.c +++ usr.sbin/quot/quot.c @@ -200,23 +200,24 @@ isfree(struct fs *super, union dinode *dp) { #ifdef COMPAT - return (DIP(super, dp, di_mode) & IFMT) == 0; + return (DIP(super, dp, di_mode) & UFS_IFMT) == 0; #else /* COMPAT */ - switch (DIP(super, dp, di_mode) & IFMT) { - case IFIFO: - case IFLNK: /* should check FASTSYMLINK? */ - case IFDIR: - case IFREG: + switch (DIP(super, dp, di_mode) & UFS_IFMT) { + case UFS_IFIFO: + case UFS_IFLNK: /* should check FASTSYMLINK? */ + case UFS_IFDIR: + case UFS_IFREG: return 0; - case IFCHR: - case IFBLK: - case IFSOCK: - case IFWHT: + case UFS_IFCHR: + case UFS_IFBLK: + case UFS_IFSOCK: + case UFS_IFWHT: case 0: return 1; default: - errx(1, "unknown IFMT 0%o", DIP(super, dp, di_mode) & IFMT); + errx(1, "unknown UFS_IFMT 0%o", + DIP(super, dp, di_mode) & UFS_IFMT); } #endif } @@ -386,8 +387,8 @@ errno = 0; if ((dp = get_inode(fd,super,inode)) #ifdef COMPAT - && ((DIP(super, dp, di_mode) & IFMT) == IFREG - || (DIP(super, dp, di_mode) & IFMT) == IFDIR) + && ((DIP(super, dp, di_mode) & UFS_IFMT) == UFS_IFREG + || (DIP(super, dp, di_mode) & UFS_IFMT) == UFS_IFDIR) #else /* COMPAT */ && !isfree(super, dp) #endif /* COMPAT */