SCCS-vsn: sbin/fsck/dir.c 3.4
SCCS-vsn: sbin/fsck/inode.c 3.4
SCCS-vsn: sbin/fsck/pass1.c 3.4
SCCS-vsn: sbin/fsck/pass2.c 3.4
SCCS-vsn: sbin/fsck/pass3.c 3.3
-static char version[] = "@(#)dir.c 3.3 (Berkeley) %G%";
+static char version[] = "@(#)dir.c 3.4 (Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
if (statemap[inumber] != DSTATE)
errexit("BAD INODE %d TO DESCEND", statemap[inumber]);
statemap[inumber] = DFOUND;
if (statemap[inumber] != DSTATE)
errexit("BAD INODE %d TO DESCEND", statemap[inumber]);
statemap[inumber] = DFOUND;
- if ((dp = ginode(inumber)) == NULL)
- return;
if (dp->di_size == 0) {
direrr(inumber, "ZERO LENGTH DIRECTORY");
if (reply("REMOVE") == 1)
if (dp->di_size == 0) {
direrr(inumber, "ZERO LENGTH DIRECTORY");
if (reply("REMOVE") == 1)
pwarn("%s ", s);
pinode(ino);
printf("\n");
pwarn("%s ", s);
pinode(ino);
printf("\n");
- if ((dp = ginode(ino)) != NULL && ftypeok(dp))
+ if (ino < ROOTINO || ino > imax) {
+ pfatal("NAME=%s\n", pathname);
+ return;
+ }
+ dp = ginode(ino);
+ if (ftypeok(dp))
pfatal("%s=%s\n", DIRCT(dp) ? "DIR" : "FILE", pathname);
else
pfatal("NAME=%s\n", pathname);
pfatal("%s=%s\n", DIRCT(dp) ? "DIR" : "FILE", pathname);
else
pfatal("NAME=%s\n", pathname);
- if ((dp = ginode(idesc->id_number)) == NULL)
- return;
+ dp = ginode(idesc->id_number);
if (dp->di_nlink == lcnt) {
if (linkup(idesc->id_number, (ino_t)0) == 0)
clri(idesc, "UNREF", 0);
if (dp->di_nlink == lcnt) {
if (linkup(idesc->id_number, (ino_t)0) == 0)
clri(idesc, "UNREF", 0);
struct inodesc idesc;
bzero((char *)&idesc, sizeof(struct inodesc));
struct inodesc idesc;
bzero((char *)&idesc, sizeof(struct inodesc));
- if ((dp = ginode(orphan)) == NULL)
- return (0);
lostdir = DIRCT(dp);
pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
pinode(orphan);
lostdir = DIRCT(dp);
pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
pinode(orphan);
*pathp++ = '/';
*pathp = '\0';
if (lfdir == 0) {
*pathp++ = '/';
*pathp = '\0';
if (lfdir == 0) {
- if ((dp = ginode(ROOTINO)) == NULL)
- return (0);
idesc.id_name = lfname;
idesc.id_type = DATA;
idesc.id_func = findino;
idesc.id_number = ROOTINO;
idesc.id_filesize = dp->di_size;
(void)ckinode(dp, &idesc);
idesc.id_name = lfname;
idesc.id_type = DATA;
idesc.id_func = findino;
idesc.id_number = ROOTINO;
idesc.id_filesize = dp->di_size;
(void)ckinode(dp, &idesc);
- if ((lfdir = idesc.id_parent) == 0) {
+ lfdir = idesc.id_parent;
+ if (lfdir < ROOTINO || lfdir > imax)
+ lfdir = 0;
+ if (lfdir == 0) {
pfatal("SORRY. NO lost+found DIRECTORY");
printf("\n\n");
return (0);
}
}
pfatal("SORRY. NO lost+found DIRECTORY");
printf("\n\n");
return (0);
}
}
- if ((dp = ginode(lfdir)) == NULL ||
- !DIRCT(dp) || statemap[lfdir] != DFOUND) {
+ dp = ginode(lfdir);
+ if (!DIRCT(dp) || statemap[lfdir] != DFOUND) {
pfatal("SORRY. NO lost+found DIRECTORY");
printf("\n\n");
return (0);
pfatal("SORRY. NO lost+found DIRECTORY");
printf("\n\n");
return (0);
idesc.id_filesize = dp->di_size;
idesc.id_fix = DONTKNOW;
(void)ckinode(dp, &idesc);
idesc.id_filesize = dp->di_size;
idesc.id_fix = DONTKNOW;
(void)ckinode(dp, &idesc);
- if ((dp = ginode(lfdir)) != NULL) {
- dp->di_nlink++;
- inodirty();
- lncntp[lfdir]++;
- }
+ dp = ginode(lfdir);
+ dp->di_nlink++;
+ inodirty();
+ lncntp[lfdir]++;
pwarn("DIR I=%u CONNECTED. ", orphan);
printf("PARENT WAS I=%u\n", pdir);
if (preen == 0)
pwarn("DIR I=%u CONNECTED. ", orphan);
printf("PARENT WAS I=%u\n", pdir);
if (preen == 0)
-static char version[] = "@(#)inode.c 3.3 (Berkeley) %G%";
+static char version[] = "@(#)inode.c 3.4 (Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
static ino_t startinum = 0; /* blk num of first in raw area */
static ino_t startinum = 0; /* blk num of first in raw area */
- if (inumber < ROOTINO || inumber > imax) {
- if (debug && inumber > imax)
- printf("inumber out of range (%d)\n", inumber);
- return (NULL);
- }
+ if (inumber < ROOTINO || inumber > imax)
+ errexit("bad inode number %d to ginode\n", inumber);
if (startinum == 0 ||
inumber < startinum || inumber >= startinum + INOPB(&sblock)) {
iblk = itod(&sblock, inumber);
if (startinum == 0 ||
inumber < startinum || inumber >= startinum + INOPB(&sblock)) {
iblk = itod(&sblock, inumber);
- if ((dp = ginode(idesc->id_number)) == NULL)
- return;
+ dp = ginode(idesc->id_number);
if (flg == 1) {
pwarn("%s %s", s, DIRCT(dp) ? "DIR" : "FILE");
pinode(idesc->id_number);
if (flg == 1) {
pwarn("%s %s", s, DIRCT(dp) ? "DIR" : "FILE");
pinode(idesc->id_number);
char *ctime();
printf(" I=%u ", ino);
char *ctime();
printf(" I=%u ", ino);
- if ((dp = ginode(ino)) == NULL)
+ if (ino < ROOTINO || ino > imax)
printf(" OWNER=");
if (getpw((int)dp->di_uid, uidbuf) == 0) {
for (p = uidbuf; *p != ':'; p++);
printf(" OWNER=");
if (getpw((int)dp->di_uid, uidbuf) == 0) {
for (p = uidbuf; *p != ':'; p++);
-static char version[] = "@(#)pass1.c 3.3 (Berkeley) %G%";
+static char version[] = "@(#)pass1.c 3.4 (Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
if (inumber < ROOTINO)
continue;
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
if (inumber < ROOTINO)
continue;
- if ((dp = ginode(inumber)) == NULL)
- continue;
if (!ALLOC(dp)) {
if (bcmp((char *)dp->di_db, (char *)zino.di_db,
NDADDR * sizeof(daddr_t)) ||
if (!ALLOC(dp)) {
if (bcmp((char *)dp->di_db, (char *)zino.di_db,
NDADDR * sizeof(daddr_t)) ||
-static char version[] = "@(#)pass2.c 3.3 (Berkeley) %G%";
+static char version[] = "@(#)pass2.c 3.4 (Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
case FSTATE:
case FCLEAR:
pfatal("ROOT INODE NOT DIRECTORY");
case FSTATE:
case FCLEAR:
pfatal("ROOT INODE NOT DIRECTORY");
- if (reply("FIX") == 0 || (dp = ginode(ROOTINO)) == NULL)
dp->di_mode &= ~IFMT;
dp->di_mode |= IFDIR;
inodirty();
dp->di_mode &= ~IFMT;
dp->di_mode |= IFDIR;
inodirty();
direrr(dirp->d_ino, "DUP/BAD");
if ((n = reply("REMOVE")) == 1)
break;
direrr(dirp->d_ino, "DUP/BAD");
if ((n = reply("REMOVE")) == 1)
break;
- if ((dp = ginode(dirp->d_ino)) == NULL)
- break;
+ dp = ginode(dirp->d_ino);
statemap[dirp->d_ino] = DIRCT(dp) ? DSTATE : FSTATE;
goto again;
statemap[dirp->d_ino] = DIRCT(dp) ? DSTATE : FSTATE;
goto again;
-static char version[] = "@(#)pass3.c 3.2 (Berkeley) %G%";
+static char version[] = "@(#)pass3.c 3.3 (Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
loopcnt = 0;
do {
orphan = idesc.id_parent;
loopcnt = 0;
do {
orphan = idesc.id_parent;
- if ((dp = ginode(orphan)) == NULL)
+ if (orphan < ROOTINO || orphan > imax)
idesc.id_parent = 0;
idesc.id_filesize = dp->di_size;
idesc.id_number = orphan;
idesc.id_parent = 0;
idesc.id_filesize = dp->di_size;
idesc.id_number = orphan;