Prefix UFS symbols with UFS_ to reduce namespace pollution
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
This commit is contained in:
parent
f545864525
commit
e23f2eb452
@ -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:
|
||||
|
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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",
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -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) {
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
@ -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)
|
||||
@ -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);
|
||||
@ -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;
|
||||
|
@ -100,15 +100,15 @@ fsutilinit(void)
|
||||
int
|
||||
ftypeok(union dinode *dp)
|
||||
{
|
||||
switch (DIP(dp, di_mode) & IFMT) {
|
||||
switch (DIP(dp, di_mode) & UFS_IFMT) {
|
||||
|
||||
case IFDIR:
|
||||
case IFREG:
|
||||
case IFBLK:
|
||||
case IFCHR:
|
||||
case IFLNK:
|
||||
case IFSOCK:
|
||||
case IFIFO:
|
||||
case UFS_IFDIR:
|
||||
case UFS_IFREG:
|
||||
case UFS_IFBLK:
|
||||
case UFS_IFCHR:
|
||||
case UFS_IFLNK:
|
||||
case UFS_IFSOCK:
|
||||
case UFS_IFIFO:
|
||||
return (1);
|
||||
|
||||
default:
|
||||
|
@ -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)
|
||||
@ -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)) ||
|
||||
@ -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.
|
||||
@ -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) {
|
||||
@ -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:
|
||||
|
@ -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,
|
||||
@ -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:");
|
||||
@ -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.
|
||||
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
@ -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]);
|
||||
@ -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;
|
||||
|
||||
|
@ -605,7 +605,7 @@ ino_free(ino_t ino, int mode)
|
||||
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--;
|
||||
}
|
||||
@ -748,7 +748,7 @@ ino_blkatoff(union dinode *ip, ino_t ino, ufs_lbn_t lbn, int *frags)
|
||||
/*
|
||||
* 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) {
|
||||
@ -853,7 +853,7 @@ ino_isat(ino_t parent, off_t diroff, ino_t child, int *mode, int *isdot)
|
||||
*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
|
||||
@ -1013,7 +1013,7 @@ ino_visit(union dinode *ip, ino_t ino, ino_visitor visitor, int flags)
|
||||
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) {
|
||||
@ -1027,8 +1027,8 @@ ino_visit(union dinode *ip, ino_t ino, ino_visitor visitor, int flags)
|
||||
}
|
||||
}
|
||||
/* 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)
|
||||
@ -1265,7 +1265,7 @@ ino_reclaim(union dinode *ip, ino_t ino, int mode)
|
||||
(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);
|
||||
@ -1300,7 +1300,7 @@ ino_decr(ino_t ino)
|
||||
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;
|
||||
@ -1335,13 +1335,13 @@ ino_adjust(struct suj_ino *sino)
|
||||
|
||||
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;
|
||||
@ -1358,7 +1358,7 @@ ino_adjust(struct suj_ino *sino)
|
||||
* 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
|
||||
@ -1374,7 +1374,7 @@ ino_adjust(struct suj_ino *sino)
|
||||
}
|
||||
}
|
||||
ip = ino_read(ino);
|
||||
mode = DIP(ip, di_mode) & IFMT;
|
||||
mode = DIP(ip, di_mode) & UFS_IFMT;
|
||||
if (nlink > UFS_LINK_MAX)
|
||||
err_suj("ino %ju nlink manipulation error, new %ju, old %d\n",
|
||||
(uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink));
|
||||
@ -1393,7 +1393,7 @@ ino_adjust(struct suj_ino *sino)
|
||||
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;
|
||||
@ -1506,15 +1506,15 @@ ino_trunc(ino_t ino, off_t size)
|
||||
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)
|
||||
@ -1587,7 +1587,7 @@ ino_trunc(ino_t ino, off_t size)
|
||||
* 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;
|
||||
|
||||
@ -1635,7 +1635,7 @@ ino_check(struct suj_ino *sino)
|
||||
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)
|
||||
@ -1646,7 +1646,7 @@ ino_check(struct suj_ino *sino)
|
||||
(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;
|
||||
@ -1915,7 +1915,7 @@ ino_unlinked(void)
|
||||
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);
|
||||
/*
|
||||
@ -2371,7 +2371,7 @@ suj_verifyino(union dinode *ip)
|
||||
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);
|
||||
|
@ -512,14 +512,14 @@ CMDFUNCSTART(findblk)
|
||||
/* 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 &&
|
||||
@ -889,10 +889,10 @@ struct typemap {
|
||||
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)
|
||||
@ -902,7 +902,7 @@ CMDFUNCSTART(newtype)
|
||||
|
||||
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++) {
|
||||
@ -917,7 +917,7 @@ CMDFUNCSTART(newtype)
|
||||
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);
|
||||
|
@ -120,20 +120,20 @@ printstat(const char *cp, ino_t inum, union dinode *dp)
|
||||
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 &&
|
||||
@ -147,10 +147,10 @@ printstat(const char *cp, ino_t inum, union dinode *dp)
|
||||
putchar('\n');
|
||||
}
|
||||
break;
|
||||
case IFSOCK:
|
||||
case UFS_IFSOCK:
|
||||
puts("socket");
|
||||
break;
|
||||
case IFIFO:
|
||||
case UFS_IFIFO:
|
||||
puts("fifo");
|
||||
break;
|
||||
}
|
||||
@ -338,7 +338,7 @@ checkactivedir(void)
|
||||
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;
|
||||
}
|
||||
@ -350,14 +350,14 @@ printactive(int doblocks)
|
||||
{
|
||||
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
|
||||
@ -368,7 +368,7 @@ printactive(int doblocks)
|
||||
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;
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ fsinit(time_t utime)
|
||||
/*
|
||||
* 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);
|
||||
@ -919,7 +919,7 @@ fsinit(time_t utime)
|
||||
/*
|
||||
* 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);
|
||||
@ -1002,7 +1002,7 @@ alloc(int size, int mode)
|
||||
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++;
|
||||
|
@ -370,7 +370,7 @@ chkquota(char *specname, struct quotafile *qfu, struct quotafile *qfg)
|
||||
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
|
||||
@ -405,16 +405,16 @@ chkquota(char *specname, struct quotafile *qfu, struct quotafile *qfg)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ extractdirs(int genmode)
|
||||
for (;;) {
|
||||
curfile.name = "<directory file - name unknown>";
|
||||
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);
|
||||
@ -205,7 +205,7 @@ void
|
||||
skipdirs(void)
|
||||
{
|
||||
|
||||
while (curfile.ino && (curfile.mode & IFMT) == IFDIR) {
|
||||
while (curfile.ino && (curfile.mode & UFS_IFMT) == UFS_IFDIR) {
|
||||
skipfile();
|
||||
}
|
||||
}
|
||||
|
@ -741,9 +741,9 @@ glob_stat(const char *name, struct stat *stp)
|
||||
(!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);
|
||||
}
|
||||
|
||||
|
@ -592,19 +592,19 @@ extractfile(char *name)
|
||||
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)
|
||||
@ -615,7 +615,7 @@ extractfile(char *name)
|
||||
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);
|
||||
@ -639,7 +639,7 @@ extractfile(char *name)
|
||||
}
|
||||
return (FAIL);
|
||||
|
||||
case IFIFO:
|
||||
case UFS_IFIFO:
|
||||
vprintf(stdout, "extract fifo %s\n", name);
|
||||
if (Nflag) {
|
||||
skipfile();
|
||||
@ -667,8 +667,8 @@ extractfile(char *name)
|
||||
(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();
|
||||
@ -676,7 +676,7 @@ extractfile(char *name)
|
||||
}
|
||||
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));
|
||||
@ -697,7 +697,7 @@ extractfile(char *name)
|
||||
(void) chflags(name, flags);
|
||||
return (GOOD);
|
||||
|
||||
case IFREG:
|
||||
case UFS_IFREG:
|
||||
vprintf(stdout, "extract file %s\n", name);
|
||||
if (Nflag) {
|
||||
skipfile();
|
||||
|
@ -1021,7 +1021,7 @@ journal_alloc(int64_t size)
|
||||
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;
|
||||
@ -1030,7 +1030,7 @@ journal_alloc(int64_t size)
|
||||
} 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;
|
||||
|
@ -654,7 +654,7 @@ nandfs_lookup_path(struct nandfs *fs, const char *path)
|
||||
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_lookup_path(struct nandfs *fs, const char *path)
|
||||
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;
|
||||
|
@ -557,7 +557,7 @@ ufs_open(upath, f)
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@ -599,7 +599,7 @@ ufs_open(upath, f)
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
@ -393,7 +393,7 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
|
||||
* 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]++;
|
||||
@ -1290,7 +1290,7 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode)
|
||||
e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]) - 1);
|
||||
fs->e2fs->e2fs_ficount--;
|
||||
fs->e2fs_fmod = 1;
|
||||
if ((mode & IFMT) == IFDIR) {
|
||||
if ((mode & EXT2_IFMT) == EXT2_IFDIR) {
|
||||
e2fs_gd_set_ndirs(&fs->e2fs_gd[cg],
|
||||
e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) + 1);
|
||||
fs->e2fs_total_dir++;
|
||||
@ -1395,7 +1395,7 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode)
|
||||
EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
|
||||
e2fs_gd_set_i_unused(&fs->e2fs_gd[cg],
|
||||
e2fs_gd_get_i_unused(&fs->e2fs_gd[cg]) + 1);
|
||||
if ((mode & IFMT) == IFDIR) {
|
||||
if ((mode & EXT2_IFMT) == EXT2_IFDIR) {
|
||||
e2fs_gd_set_ndirs(&fs->e2fs_gd[cg],
|
||||
e2fs_gd_get_ndirs(&fs->e2fs_gd[cg]) - 1);
|
||||
fs->e2fs_total_dir--;
|
||||
|
@ -105,7 +105,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 */
|
||||
|
@ -591,7 +591,7 @@ ext2_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp
|
||||
* 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) {
|
||||
|
@ -352,7 +352,7 @@ ext2_getattr(struct vop_getattr_args *ap)
|
||||
*/
|
||||
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;
|
||||
@ -534,7 +534,7 @@ ext2_chmod(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
|
||||
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);
|
||||
@ -584,9 +584,10 @@ ext2_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred,
|
||||
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);
|
||||
}
|
||||
@ -843,7 +844,7 @@ ext2_rename(struct vop_rename_args *ap)
|
||||
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.
|
||||
*/
|
||||
@ -974,7 +975,7 @@ ext2_rename(struct vop_rename_args *ap)
|
||||
* 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)) {
|
||||
error = ENOTEMPTY;
|
||||
goto bad;
|
||||
@ -1318,7 +1319,7 @@ ext2_mkdir(struct vop_mkdir_args *ap)
|
||||
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
|
||||
@ -1341,8 +1342,8 @@ ext2_mkdir(struct vop_mkdir_args *ap)
|
||||
* '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;
|
||||
@ -1521,7 +1522,7 @@ ext2_symlink(struct vop_symlink_args *ap)
|
||||
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);
|
||||
@ -1958,8 +1959,8 @@ ext2_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
|
||||
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) {
|
||||
@ -1978,7 +1979,7 @@ ext2_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
|
||||
* 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;
|
||||
@ -1993,9 +1994,10 @@ ext2_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
|
||||
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)
|
||||
@ -2320,10 +2322,10 @@ ext2_write(struct vop_write_args *ap)
|
||||
* 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) {
|
||||
|
@ -92,7 +92,7 @@ struct inode {
|
||||
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. */
|
||||
int32_t i_nlink; /* File link count. */
|
||||
uint32_t i_uid; /* File owner. */
|
||||
uint32_t i_gid; /* File group. */
|
||||
@ -131,23 +131,23 @@ struct inode {
|
||||
#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. */
|
||||
|
@ -295,12 +295,12 @@ struct nandfs_node {
|
||||
#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"
|
||||
|
@ -284,7 +284,7 @@ nandfs_write(struct vop_write_args *ap)
|
||||
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 +
|
||||
@ -443,7 +443,7 @@ nandfs_lookup(struct vop_cachedlookup_args *ap)
|
||||
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) {
|
||||
@ -724,7 +724,7 @@ nandfs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
|
||||
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);
|
||||
@ -733,7 +733,7 @@ nandfs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
|
||||
/*
|
||||
* 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);
|
||||
@ -786,10 +786,10 @@ nandfs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred,
|
||||
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));
|
||||
|
@ -1052,7 +1052,7 @@ ffs_valloc(pvp, mode, cred, vpp)
|
||||
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;
|
||||
@ -1063,7 +1063,7 @@ ffs_valloc(pvp, mode, cred, vpp)
|
||||
* 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 {
|
||||
@ -1364,7 +1364,7 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
|
||||
* 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
|
||||
@ -1469,7 +1469,7 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
|
||||
* 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
|
||||
@ -2114,7 +2114,7 @@ ffs_nodealloccg(ip, cg, ipref, mode, unused)
|
||||
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++;
|
||||
@ -2478,7 +2478,7 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd)
|
||||
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--;
|
||||
@ -2866,7 +2866,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
return (EROFS);
|
||||
}
|
||||
fs = ump->um_fs;
|
||||
filetype = IFREG;
|
||||
filetype = UFS_IFREG;
|
||||
|
||||
switch (oidp->oid_number) {
|
||||
|
||||
@ -2921,7 +2921,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
break;
|
||||
|
||||
case FFS_DIR_FREE:
|
||||
filetype = IFDIR;
|
||||
filetype = UFS_IFDIR;
|
||||
/* fall through */
|
||||
|
||||
case FFS_FILE_FREE:
|
||||
@ -2930,12 +2930,12 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
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));
|
||||
}
|
||||
|
@ -5314,7 +5314,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp)
|
||||
* 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 @@ softdep_setup_allocindir_page(ip, lbn, bp, ptrno, newblkno, oldblkno, nbp)
|
||||
* 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 @@ initiate_write_bmsafemap(bmsafemap, bp)
|
||||
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);
|
||||
@ -11895,7 +11895,7 @@ handle_written_bmsafemap(bmsafemap, bp, flags)
|
||||
"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);
|
||||
|
@ -837,10 +837,10 @@ ffs_write(ap)
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@ -1080,9 +1080,10 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred)
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ struct inoref {
|
||||
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. */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -95,23 +95,23 @@ typedef int64_t ufs_lbn_t;
|
||||
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.
|
||||
@ -125,7 +125,7 @@ typedef int64_t ufs_time_t;
|
||||
#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. */
|
||||
@ -168,7 +168,7 @@ struct ufs2_dinode {
|
||||
* 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. */
|
||||
|
@ -113,7 +113,7 @@ struct inode {
|
||||
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. */
|
||||
};
|
||||
/*
|
||||
|
@ -125,7 +125,7 @@ ufs_delete_denied(struct vnode *vdp, struct vnode *tdp, struct ucred *cred,
|
||||
* 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);
|
||||
|
@ -470,7 +470,7 @@ ufs_getattr(ap)
|
||||
*/
|
||||
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;
|
||||
@ -750,7 +750,7 @@ ufs_chmod(vp, mode, cred, td)
|
||||
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);
|
||||
@ -759,7 +759,7 @@ ufs_chmod(vp, mode, cred, td)
|
||||
/*
|
||||
* 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);
|
||||
@ -888,9 +888,10 @@ ufs_chown(vp, uid, gid, cred, td)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1276,7 +1277,7 @@ ufs_rename(ap)
|
||||
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.
|
||||
*/
|
||||
@ -1408,7 +1409,7 @@ ufs_rename(ap)
|
||||
* 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;
|
||||
@ -1800,7 +1801,7 @@ ufs_mkdir(ap)
|
||||
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
|
||||
@ -1833,8 +1834,8 @@ ufs_mkdir(ap)
|
||||
* '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
|
||||
@ -2124,7 +2125,7 @@ ufs_symlink(ap)
|
||||
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);
|
||||
@ -2569,8 +2570,8 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc)
|
||||
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);
|
||||
@ -2597,7 +2598,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc)
|
||||
* 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);
|
||||
@ -2656,9 +2657,9 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -203,23 +203,24 @@ static int
|
||||
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
|
||||
}
|
||||
@ -389,8 +390,8 @@ dofsizes(int fd, struct fs *super, char *name)
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user