Mostly sync with CSRG.

This commit is contained in:
mycroft 1994-12-28 00:03:49 +00:00
parent d966913f57
commit 0826920c54
12 changed files with 152 additions and 82 deletions

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: dir.c,v 1.15 1994/12/05 20:15:44 cgd Exp $";
/*static char sccsid[] = "from: @(#)dir.c 8.5 (Berkeley) 12/8/94";*/
static char *rcsid = "$Id: dir.c,v 1.16 1994/12/28 00:03:49 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -348,11 +348,11 @@ mkentry(idesc)
dirp->d_reclen = oldlen;
dirp = (struct direct *)(((char *)dirp) + oldlen);
dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
dirp->d_reclen = newent.d_reclen;
if (newinofmt)
dirp->d_type = typemap[idesc->id_parent];
else
dirp->d_type = 0;
dirp->d_reclen = newent.d_reclen;
dirp->d_namlen = newent.d_namlen;
memcpy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1);
# if (BYTE_ORDER == LITTLE_ENDIAN)

View File

@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fsck.8 8.2 (Berkeley) 12/11/93
.\" $Id: fsck.8,v 1.7 1994/06/08 19:00:20 mycroft Exp $
.\" from: @(#)fsck.8 8.3 (Berkeley) 11/29/94
.\" $Id: fsck.8,v 1.8 1994/12/28 00:03:51 mycroft Exp $
.\"
.Dd December 11, 1993
.Dd November 29, 1994
.Dt FSCK 8
.Os BSD 4
.Sh NAME
@ -182,7 +182,7 @@ do not open the filesystem for writing.
Convert the filesystem to the specified level.
Note that the level of a filesystem can only be raised.
.Bl -tag -width indent
There are currently three levels defined:
There are currently four levels defined:
.It 0
The filesystem is in the old (static table) format.
.It 1
@ -191,6 +191,10 @@ The filesystem is in the new (dynamic table) format.
The filesystem supports 32-bit uid's and gid's,
short symbolic links are stored in the inode,
and directories have an added field showing the file type.
.It 3
If maxcontig is greater than one,
build the free segment maps to aid in finding contiguous sets of blocks.
If maxcontig is equal to one, delete any existing segment maps.
.El
.Pp
In interactive mode,

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)pass2.c 8.2 (Berkeley) 2/27/94";*/
static char *rcsid = "$Id: pass2.c,v 1.9 1994/12/05 20:15:59 cgd Exp $";
/*static char sccsid[] = "from: @(#)pass2.c 8.6 (Berkeley) 10/27/94";*/
static char *rcsid = "$Id: pass2.c,v 1.10 1994/12/28 00:03:53 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -108,6 +108,10 @@ pass2()
errexit("BAD STATE %d FOR ROOT INODE", statemap[ROOTINO]);
}
statemap[ROOTINO] = DFOUND;
if (newinofmt) {
statemap[WINO] = FSTATE;
typemap[WINO] = DT_WHT;
}
/*
* Sort the directory list into disk block order.
*/
@ -241,15 +245,15 @@ pass2check(idesc)
proto.d_type = 0;
proto.d_namlen = 1;
(void)strcpy(proto.d_name, ".");
#if BYTE_ORDER == LITTLE_ENDIAN
if (!newinofmt) {
u_char tmp;
# if BYTE_ORDER == LITTLE_ENDIAN
if (!newinofmt) {
u_char tmp;
tmp = proto.d_type;
proto.d_type = proto.d_namlen;
proto.d_namlen = tmp;
}
#endif
tmp = proto.d_type;
proto.d_type = proto.d_namlen;
proto.d_namlen = tmp;
}
# endif
entrysize = DIRSIZ(0, &proto);
if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
@ -366,6 +370,14 @@ chk2:
if (dirp->d_ino > maxino) {
fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
n = reply("REMOVE");
} else if (newinofmt &&
((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
(dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
dirp->d_ino = WINO;
dirp->d_type = DT_WHT;
if (reply("FIX") == 1)
ret |= ALTERED;
} else {
again:
switch (statemap[dirp->d_ino]) {

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)pass5.c 8.2 (Berkeley) 2/2/94";*/
static char *rcsid = "$Id: pass5.c,v 1.11 1994/12/18 15:55:41 cgd Exp $";
/*static char sccsid[] = "from: @(#)pass5.c 8.6 (Berkeley) 11/30/94";*/
static char *rcsid = "$Id: pass5.c,v 1.12 1994/12/28 00:03:54 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -60,9 +60,10 @@ pass5()
register struct cg *newcg = (struct cg *)buf;
struct ocg *ocg = (struct ocg *)buf;
statemap[WINO] = USTATE;
memset(newcg, 0, (size_t)fs->fs_cgsize);
newcg->cg_niblk = fs->fs_ipg;
if (cvtlevel > 3) {
if (cvtlevel >= 3) {
if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
if (preen)
pwarn("DELETING CLUSTERING MAPS\n");
@ -106,8 +107,7 @@ pass5()
case FS_42POSTBLFMT:
basesize = (char *)(&ocg->cg_btot[0]) -
(char *)(&ocg->cg_firstfield);
sumsize = (char *)&ocg->cg_iused[0] -
(char *)(&ocg->cg_btot[0]);
sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
(u_char *)&ocg->cg_iused[0];
ocg->cg_magic = CG_MAGIC;

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)preen.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: preen.c,v 1.9 1994/12/05 20:16:04 cgd Exp $";
/*static char sccsid[] = "from: @(#)preen.c 8.3 (Berkeley) 12/6/94";*/
static char *rcsid = "$Id: preen.c,v 1.10 1994/12/28 00:03:55 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -281,47 +281,51 @@ startdisk(dk, checkit)
}
char *
blockcheck(name)
char *name;
blockcheck(origname)
char *origname;
{
struct stat stslash, stblock, stchar;
char *raw;
char *newname, *raw;
int retried = 0;
hotroot = 0;
if (stat("/", &stslash) < 0) {
perror("/");
printf("Can't stat root\n");
return (0);
return (origname);
}
newname = origname;
retry:
if (stat(name, &stblock) < 0) {
perror(name);
printf("Can't stat %s\n", name);
return (0);
if (stat(newname, &stblock) < 0) {
perror(newname);
printf("Can't stat %s\n", newname);
return (origname);
}
if (S_ISBLK(stblock.st_mode)) {
if (stslash.st_dev == stblock.st_rdev)
hotroot++;
raw = rawname(name);
raw = rawname(newname);
if (stat(raw, &stchar) < 0) {
perror(raw);
printf("Can't stat %s\n", raw);
return (name);
return (origname);
}
if (S_ISCHR(stchar.st_mode)) {
return (raw);
} else {
printf("%s is not a character device\n", raw);
return (name);
return (origname);
}
} else if (S_ISCHR(stblock.st_mode) && !retried) {
name = unrawname(name);
newname = unrawname(newname);
retried++;
goto retry;
}
printf("Can't make sense out of name %s\n", name);
return (0);
/*
* Not a block or character device, just return name and
* let the user decide whether to use it.
*/
return (origname);
}
char *

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)setup.c 8.2 (Berkeley) 2/21/94";*/
static char *rcsid = "$Id: setup.c,v 1.17 1994/12/27 19:26:57 mycroft Exp $";
/*static char sccsid[] = "from: @(#)setup.c 8.5 (Berkeley) 11/23/94";*/
static char *rcsid = "$Id: setup.c,v 1.18 1994/12/28 00:03:57 mycroft Exp $";
#endif /* not lint */
#define DKTYPENAMES
@ -360,9 +360,9 @@ readsb(listerr)
altsblock.fs_optim = sblock.fs_optim;
altsblock.fs_rotdelay = sblock.fs_rotdelay;
altsblock.fs_maxbpg = sblock.fs_maxbpg;
altsblock.fs_maxcluster = sblock.fs_maxcluster;
memcpy(altsblock.fs_csp, sblock.fs_csp,
sizeof sblock.fs_csp);
altsblock.fs_maxcluster = sblock.fs_maxcluster;
memcpy(altsblock.fs_fsmnt, sblock.fs_fsmnt,
sizeof sblock.fs_fsmnt);
memcpy(altsblock.fs_sparecon, sblock.fs_sparecon,
@ -374,11 +374,26 @@ readsb(listerr)
altsblock.fs_interleave = sblock.fs_interleave;
altsblock.fs_npsect = sblock.fs_npsect;
altsblock.fs_nrpos = sblock.fs_nrpos;
altsblock.fs_state = sblock.fs_state;
altsblock.fs_qbmask = sblock.fs_qbmask;
altsblock.fs_qfmask = sblock.fs_qfmask;
altsblock.fs_state = sblock.fs_state;
altsblock.fs_maxfilesize = sblock.fs_maxfilesize;
if (memcmp(&sblock, &altsblock, (int)sblock.fs_sbsize)) {
if (debug) {
long *nlp, *olp, *endlp;
printf("superblock mismatches\n");
nlp = (long *)&altsblock;
olp = (long *)&sblock;
endlp = olp + (sblock.fs_sbsize / sizeof *olp);
for ( ; olp < endlp; olp++, nlp++) {
if (*olp == *nlp)
continue;
printf("offset %d, original %d, alternate %d\n",
olp - (long *)&sblock, *olp, *nlp);
}
}
badsb(listerr,
"VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE");
return (0);

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: dir.c,v 1.15 1994/12/05 20:15:44 cgd Exp $";
/*static char sccsid[] = "from: @(#)dir.c 8.5 (Berkeley) 12/8/94";*/
static char *rcsid = "$Id: dir.c,v 1.16 1994/12/28 00:03:49 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -348,11 +348,11 @@ mkentry(idesc)
dirp->d_reclen = oldlen;
dirp = (struct direct *)(((char *)dirp) + oldlen);
dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
dirp->d_reclen = newent.d_reclen;
if (newinofmt)
dirp->d_type = typemap[idesc->id_parent];
else
dirp->d_type = 0;
dirp->d_reclen = newent.d_reclen;
dirp->d_namlen = newent.d_namlen;
memcpy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1);
# if (BYTE_ORDER == LITTLE_ENDIAN)

View File

@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fsck.8 8.2 (Berkeley) 12/11/93
.\" $Id: fsck_ffs.8,v 1.7 1994/06/08 19:00:20 mycroft Exp $
.\" from: @(#)fsck.8 8.3 (Berkeley) 11/29/94
.\" $Id: fsck_ffs.8,v 1.8 1994/12/28 00:03:51 mycroft Exp $
.\"
.Dd December 11, 1993
.Dd November 29, 1994
.Dt FSCK 8
.Os BSD 4
.Sh NAME
@ -182,7 +182,7 @@ do not open the filesystem for writing.
Convert the filesystem to the specified level.
Note that the level of a filesystem can only be raised.
.Bl -tag -width indent
There are currently three levels defined:
There are currently four levels defined:
.It 0
The filesystem is in the old (static table) format.
.It 1
@ -191,6 +191,10 @@ The filesystem is in the new (dynamic table) format.
The filesystem supports 32-bit uid's and gid's,
short symbolic links are stored in the inode,
and directories have an added field showing the file type.
.It 3
If maxcontig is greater than one,
build the free segment maps to aid in finding contiguous sets of blocks.
If maxcontig is equal to one, delete any existing segment maps.
.El
.Pp
In interactive mode,

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)pass2.c 8.2 (Berkeley) 2/27/94";*/
static char *rcsid = "$Id: pass2.c,v 1.9 1994/12/05 20:15:59 cgd Exp $";
/*static char sccsid[] = "from: @(#)pass2.c 8.6 (Berkeley) 10/27/94";*/
static char *rcsid = "$Id: pass2.c,v 1.10 1994/12/28 00:03:53 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -108,6 +108,10 @@ pass2()
errexit("BAD STATE %d FOR ROOT INODE", statemap[ROOTINO]);
}
statemap[ROOTINO] = DFOUND;
if (newinofmt) {
statemap[WINO] = FSTATE;
typemap[WINO] = DT_WHT;
}
/*
* Sort the directory list into disk block order.
*/
@ -241,15 +245,15 @@ pass2check(idesc)
proto.d_type = 0;
proto.d_namlen = 1;
(void)strcpy(proto.d_name, ".");
#if BYTE_ORDER == LITTLE_ENDIAN
if (!newinofmt) {
u_char tmp;
# if BYTE_ORDER == LITTLE_ENDIAN
if (!newinofmt) {
u_char tmp;
tmp = proto.d_type;
proto.d_type = proto.d_namlen;
proto.d_namlen = tmp;
}
#endif
tmp = proto.d_type;
proto.d_type = proto.d_namlen;
proto.d_namlen = tmp;
}
# endif
entrysize = DIRSIZ(0, &proto);
if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
@ -366,6 +370,14 @@ chk2:
if (dirp->d_ino > maxino) {
fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
n = reply("REMOVE");
} else if (newinofmt &&
((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
(dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
dirp->d_ino = WINO;
dirp->d_type = DT_WHT;
if (reply("FIX") == 1)
ret |= ALTERED;
} else {
again:
switch (statemap[dirp->d_ino]) {

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)pass5.c 8.2 (Berkeley) 2/2/94";*/
static char *rcsid = "$Id: pass5.c,v 1.11 1994/12/18 15:55:41 cgd Exp $";
/*static char sccsid[] = "from: @(#)pass5.c 8.6 (Berkeley) 11/30/94";*/
static char *rcsid = "$Id: pass5.c,v 1.12 1994/12/28 00:03:54 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -60,9 +60,10 @@ pass5()
register struct cg *newcg = (struct cg *)buf;
struct ocg *ocg = (struct ocg *)buf;
statemap[WINO] = USTATE;
memset(newcg, 0, (size_t)fs->fs_cgsize);
newcg->cg_niblk = fs->fs_ipg;
if (cvtlevel > 3) {
if (cvtlevel >= 3) {
if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
if (preen)
pwarn("DELETING CLUSTERING MAPS\n");
@ -106,8 +107,7 @@ pass5()
case FS_42POSTBLFMT:
basesize = (char *)(&ocg->cg_btot[0]) -
(char *)(&ocg->cg_firstfield);
sumsize = (char *)&ocg->cg_iused[0] -
(char *)(&ocg->cg_btot[0]);
sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
(u_char *)&ocg->cg_iused[0];
ocg->cg_magic = CG_MAGIC;

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)preen.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: preen.c,v 1.9 1994/12/05 20:16:04 cgd Exp $";
/*static char sccsid[] = "from: @(#)preen.c 8.3 (Berkeley) 12/6/94";*/
static char *rcsid = "$Id: preen.c,v 1.10 1994/12/28 00:03:55 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -281,47 +281,51 @@ startdisk(dk, checkit)
}
char *
blockcheck(name)
char *name;
blockcheck(origname)
char *origname;
{
struct stat stslash, stblock, stchar;
char *raw;
char *newname, *raw;
int retried = 0;
hotroot = 0;
if (stat("/", &stslash) < 0) {
perror("/");
printf("Can't stat root\n");
return (0);
return (origname);
}
newname = origname;
retry:
if (stat(name, &stblock) < 0) {
perror(name);
printf("Can't stat %s\n", name);
return (0);
if (stat(newname, &stblock) < 0) {
perror(newname);
printf("Can't stat %s\n", newname);
return (origname);
}
if (S_ISBLK(stblock.st_mode)) {
if (stslash.st_dev == stblock.st_rdev)
hotroot++;
raw = rawname(name);
raw = rawname(newname);
if (stat(raw, &stchar) < 0) {
perror(raw);
printf("Can't stat %s\n", raw);
return (name);
return (origname);
}
if (S_ISCHR(stchar.st_mode)) {
return (raw);
} else {
printf("%s is not a character device\n", raw);
return (name);
return (origname);
}
} else if (S_ISCHR(stblock.st_mode) && !retried) {
name = unrawname(name);
newname = unrawname(newname);
retried++;
goto retry;
}
printf("Can't make sense out of name %s\n", name);
return (0);
/*
* Not a block or character device, just return name and
* let the user decide whether to use it.
*/
return (origname);
}
char *

View File

@ -32,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)setup.c 8.2 (Berkeley) 2/21/94";*/
static char *rcsid = "$Id: setup.c,v 1.17 1994/12/27 19:26:57 mycroft Exp $";
/*static char sccsid[] = "from: @(#)setup.c 8.5 (Berkeley) 11/23/94";*/
static char *rcsid = "$Id: setup.c,v 1.18 1994/12/28 00:03:57 mycroft Exp $";
#endif /* not lint */
#define DKTYPENAMES
@ -360,9 +360,9 @@ readsb(listerr)
altsblock.fs_optim = sblock.fs_optim;
altsblock.fs_rotdelay = sblock.fs_rotdelay;
altsblock.fs_maxbpg = sblock.fs_maxbpg;
altsblock.fs_maxcluster = sblock.fs_maxcluster;
memcpy(altsblock.fs_csp, sblock.fs_csp,
sizeof sblock.fs_csp);
altsblock.fs_maxcluster = sblock.fs_maxcluster;
memcpy(altsblock.fs_fsmnt, sblock.fs_fsmnt,
sizeof sblock.fs_fsmnt);
memcpy(altsblock.fs_sparecon, sblock.fs_sparecon,
@ -374,11 +374,26 @@ readsb(listerr)
altsblock.fs_interleave = sblock.fs_interleave;
altsblock.fs_npsect = sblock.fs_npsect;
altsblock.fs_nrpos = sblock.fs_nrpos;
altsblock.fs_state = sblock.fs_state;
altsblock.fs_qbmask = sblock.fs_qbmask;
altsblock.fs_qfmask = sblock.fs_qfmask;
altsblock.fs_state = sblock.fs_state;
altsblock.fs_maxfilesize = sblock.fs_maxfilesize;
if (memcmp(&sblock, &altsblock, (int)sblock.fs_sbsize)) {
if (debug) {
long *nlp, *olp, *endlp;
printf("superblock mismatches\n");
nlp = (long *)&altsblock;
olp = (long *)&sblock;
endlp = olp + (sblock.fs_sbsize / sizeof *olp);
for ( ; olp < endlp; olp++, nlp++) {
if (*olp == *nlp)
continue;
printf("offset %d, original %d, alternate %d\n",
olp - (long *)&sblock, *olp, *nlp);
}
}
badsb(listerr,
"VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE");
return (0);