SCCS-vsn: sbin/newfs/mkfs.c 1.12
SCCS-vsn: sbin/fsck/main.c 1.16
SCCS-vsn: old/dcheck/dcheck.c 1.5
SCCS-vsn: sbin/icheck/icheck.c 1.12
SCCS-vsn: sbin/ncheck/ncheck.c 1.5
SCCS-vsn: sbin/dumpfs/dumpfs.c 1.7
SCCS-vsn: sbin/restore/main.c 1.10
-static char *sccsid = "@(#)dcheck.c 1.4 (Berkeley) %G%";
+static char *sccsid = "@(#)dcheck.c 1.5 (Berkeley) %G%";
/*
* dcheck - check directory consistency
*/
#define NB 10
#define NDIR(fs) ((fs)->fs_bsize/sizeof(struct direct))
#define MAXNDIR (MAXBSIZE/sizeof(struct direct))
/*
* dcheck - check directory consistency
*/
#define NB 10
#define NDIR(fs) ((fs)->fs_bsize/sizeof(struct direct))
#define MAXNDIR (MAXBSIZE/sizeof(struct direct))
-#define MAXNINDIR (MAXBSIZE/sizeof(daddr_t))
+#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
#include <stdio.h>
#include "../h/param.h"
#include <stdio.h>
#include "../h/param.h"
headpr = 0;
printf("%s:\n", file);
sync();
headpr = 0;
printf("%s:\n", file);
sync();
- bread(SBLOCK, (char *)&sblock, MAXBSIZE);
+ bread(SBLOCK, (char *)&sblock, SBSIZE);
if (sblock.fs_magic != FS_MAGIC) {
printf("%s: not a file system\n", file);
nerror++;
if (sblock.fs_magic != FS_MAGIC) {
printf("%s: not a file system\n", file);
nerror++;
-static char *sccsid = "@(#)dumpfs.c 1.6 (Berkeley) %G%";
+static char *sccsid = "@(#)dumpfs.c 1.7 (Berkeley) %G%";
#include "../h/param.h"
#include "../h/fs.h"
#include "../h/param.h"
#include "../h/fs.h"
if (open(argv[1], 0) != 0)
perror(argv[1]), exit(1);
lseek(0, SBLOCK * DEV_BSIZE, 0);
if (open(argv[1], 0) != 0)
perror(argv[1]), exit(1);
lseek(0, SBLOCK * DEV_BSIZE, 0);
- if (read(0, &afs, MAXBSIZE) != MAXBSIZE)
+ if (read(0, &afs, SBSIZE) != SBSIZE)
perror(argv[1]), exit(1);
printf("magic\t%x\n", afs.fs_magic);
printf("sblkno\t%d\n", afs.fs_sblkno);
perror(argv[1]), exit(1);
printf("magic\t%x\n", afs.fs_magic);
printf("sblkno\t%d\n", afs.fs_sblkno);
printf("cgsize\t%d\n", afs.fs_cgsize);
printf("ntrak\t%d\nnsect\t%d\nspc\t%d\nncyl\t%d\n",
afs.fs_ntrak, afs.fs_nsect, afs.fs_spc, afs.fs_ncyl);
printf("cgsize\t%d\n", afs.fs_cgsize);
printf("ntrak\t%d\nnsect\t%d\nspc\t%d\nncyl\t%d\n",
afs.fs_ntrak, afs.fs_nsect, afs.fs_spc, afs.fs_ncyl);
- printf("cpg\t%d\nfpg\t%d\nipg\t%d\n",
- afs.fs_cpg, afs.fs_fpg, afs.fs_ipg);
+ printf("cpg\t%d\nbpg\t%d\nfpg\t%d\nipg\t%d\n",
+ afs.fs_cpg, afs.fs_fpg / afs.fs_frag, afs.fs_fpg, afs.fs_ipg);
printf("ndir\t%d\nnffree\t%d\nnbfree\t%d\nnifree\t%d\n",
afs.fs_cstotal.cs_ndir, afs.fs_cstotal.cs_nffree,
afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_nifree);
printf("ndir\t%d\nnffree\t%d\nnbfree\t%d\nnifree\t%d\n",
afs.fs_cstotal.cs_ndir, afs.fs_cstotal.cs_nffree,
afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_nifree);
- printf("cgrotor\t%d\nblocks available in each rotational position",
- afs.fs_cgrotor);
+ printf("cgrotor\t%d\nfmod\t%d\nronly\t%d\n",
+ afs.fs_cgrotor, afs.fs_fmod, afs.fs_ronly);
+ printf("blocks available in each rotational position");
for (i = 0; i < NRPOS; i++) {
if (afs.fs_postbl[i] > -1)
printf("\nposition %d:\t", i);
for (i = 0; i < NRPOS; i++) {
if (afs.fs_postbl[i] > -1)
printf("\nposition %d:\t", i);
cs->cs_nbfree, cs->cs_ndir, cs->cs_nifree, cs->cs_nffree);
}
printf("\n");
cs->cs_nbfree, cs->cs_ndir, cs->cs_nifree, cs->cs_nffree);
}
printf("\n");
- printf("fmod\t%d\n", afs.fs_fmod);
- printf("ronly\t%d\n", afs.fs_ronly);
+ if (afs.fs_ncyl % afs.fs_cpg) {
+ printf("cylinders in last group %d\n",
+ i = afs.fs_ncyl % afs.fs_cpg);
+ printf("blocks in last group %d\n",
+ i * afs.fs_spc / NSPB(&afs));
+ }
printf("\n");
for (i = 0; i < afs.fs_ncg; i++)
dumpcg(i);
printf("\n");
for (i = 0; i < afs.fs_ncg; i++)
dumpcg(i);
-static char *sccsid = "@(#)main.c 1.15 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c 1.16 (Berkeley) %G%";
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <ctype.h>
#define NDIRECT(fs) ((fs)->fs_bsize / sizeof(struct direct))
#define MAXNDIRECT (MAXBSIZE / sizeof(struct direct))
#define NDIRECT(fs) ((fs)->fs_bsize / sizeof(struct direct))
#define MAXNDIRECT (MAXBSIZE / sizeof(struct direct))
-#define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
-#define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
+#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
+#define MAXINOPB (MAXBSIZE / sizeof (struct dinode))
#define SPERB (MAXBSIZE / sizeof(short))
#define MAXDUP 10 /* limit on dup blks (per inode) */
#define SPERB (MAXBSIZE / sizeof(short))
#define MAXDUP 10 /* limit on dup blks (per inode) */
initbarea(&fileblk);
initbarea(&inoblk);
initbarea(&cgblk);
initbarea(&fileblk);
initbarea(&inoblk);
initbarea(&cgblk);
- if (bread(&dfile, &sblock, super, MAXBSIZE) == 0)
+ if (bread(&dfile, &sblock, super, SBSIZE) == 0)
return (0);
sblk.b_bno = super;
return (0);
sblk.b_bno = super;
- sblk.b_size = MAXBSIZE;
if (sblock.fs_magic != FS_MAGIC)
{ badsb("MAGIC NUMBER WRONG"); return (0); }
if (sblock.fs_ncg < 1)
if (sblock.fs_magic != FS_MAGIC)
{ badsb("MAGIC NUMBER WRONG"); return (0); }
if (sblock.fs_ncg < 1)
if (sblock.fs_spc != sblock.fs_nsect * sblock.fs_ntrak)
{ badsb("SPC DOES NOT JIVE w/NTRAK*NSECT"); return (0); }
if (sblock.fs_cgsize !=
if (sblock.fs_spc != sblock.fs_nsect * sblock.fs_ntrak)
{ badsb("SPC DOES NOT JIVE w/NTRAK*NSECT"); return (0); }
if (sblock.fs_cgsize !=
- sizeof(struct cg) + howmany(sblock.fs_fpg, NBBY))
+ roundup(sizeof(struct cg) + howmany(sblock.fs_fpg, NBBY),
+ sblock.fs_fsize))
{ badsb("CGSIZE INCORRECT"); return (0); }
if (sblock.fs_cssize != sblock.fs_ncg * sizeof(struct csum))
{ badsb("CSSIZE INCORRECT"); return (0); }
{ badsb("CGSIZE INCORRECT"); return (0); }
if (sblock.fs_cssize != sblock.fs_ncg * sizeof(struct csum))
{ badsb("CSSIZE INCORRECT"); return (0); }
-static char *sccsid = "@(#)icheck.c 1.11 (Berkeley) %G%";
+static char *sccsid = "@(#)icheck.c 1.12 (Berkeley) %G%";
/*
* icheck
*/
#define NB 500
#define MAXFN 500
/*
* icheck
*/
#define NB 500
#define MAXFN 500
-#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
+#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
#ifndef STANDALONE
#include <stdio.h>
#ifndef STANDALONE
#include <stdio.h>
}
sblock.fs_ronly = 0;
sblock.fs_fmod = 0;
}
sblock.fs_ronly = 0;
sblock.fs_fmod = 0;
- bwrite(SBLOCK, (char *)&sblock, MAXBSIZE);
+ bwrite(SBLOCK, (char *)&sblock, SBSIZE);
- if (bread(SBLOCK, fs, MAXBSIZE)) {
+ if (bread(SBLOCK, fs, SBSIZE)) {
printf("bad super block");
perror(file);
nerror |= 04;
printf("bad super block");
perror(file);
nerror |= 04;
-static char *sccsid = "@(#)ncheck.c 1.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ncheck.c 1.5 (Berkeley) %G%";
/*
* ncheck -- obtain file names from reading filesystem
*/
/*
* ncheck -- obtain file names from reading filesystem
*/
#define HSIZE 2503
#define NDIR(fs) ((fs)->fs_bsize/sizeof(struct direct))
#define MAXNDIR (MAXBSIZE/sizeof(struct direct))
#define HSIZE 2503
#define NDIR(fs) ((fs)->fs_bsize/sizeof(struct direct))
#define MAXNDIR (MAXBSIZE/sizeof(struct direct))
-#define MAXNINDIR (MAXBSIZE/sizeof(daddr_t))
+#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
#include <stdio.h>
#include "../h/param.h"
#include <stdio.h>
#include "../h/param.h"
nhent = 0;
printf("%s:\n", file);
sync();
nhent = 0;
printf("%s:\n", file);
sync();
- bread(SBLOCK, (char *)&sblock, MAXBSIZE);
+ bread(SBLOCK, (char *)&sblock, SBSIZE);
if (sblock.fs_magic != FS_MAGIC) {
printf("%s: not a file system\n", file);
nerror++;
if (sblock.fs_magic != FS_MAGIC) {
printf("%s: not a file system\n", file);
nerror++;
-static char *sccsid = "@(#)mkfs.c 1.11 (Berkeley) %G%";
+static char *sccsid = "@(#)mkfs.c 1.12 (Berkeley) %G%";
/*
* make file system for cylinder-group style file systems
/*
* make file system for cylinder-group style file systems
#define UMASK 0755
#define MAXNDIR (MAXBSIZE / sizeof(struct direct))
#define UMASK 0755
#define MAXNDIR (MAXBSIZE / sizeof(struct direct))
+#define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
union {
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
union {
printf("Warning, no super-block backups with only one cylinder group\n");
else
printf("\tsuper-block backups (for fsck -b#) at %d+k*%d (%d .. %d)\n",
printf("Warning, no super-block backups with only one cylinder group\n");
else
printf("\tsuper-block backups (for fsck -b#) at %d+k*%d (%d .. %d)\n",
- SBLOCK, fsbtodb(&sblock, sblock.fs_fpg),
- SBLOCK + fsbtodb(&sblock, sblock.fs_fpg),
- SBLOCK + fsbtodb(&sblock, (sblock.fs_ncg - 1) *
- sblock.fs_fpg));
+ SBLOCK, fsbtodb(&sblock, cgsblock(1, &sblock)) - SBLOCK,
+ fsbtodb(&sblock, cgsblock(1, &sblock)),
+ fsbtodb(&sblock, cgsblock(sblock.fs_ncg - 1, &sblock)));
/*
* Now construct the initial file system,
* then write out the super-block.
/*
* Now construct the initial file system,
* then write out the super-block.
- lseek(fsi, bno * DEV_BSIZE, 0);
+ if (lseek(fsi, bno * DEV_BSIZE, 0) < 0) {
+ printf("seek error: %ld\n", bno);
+ perror("rdfs");
+ exit(1);
+ }
n = read(fsi, bf, size);
if(n != size) {
printf("read error: %ld\n", bno);
n = read(fsi, bf, size);
if(n != size) {
printf("read error: %ld\n", bno);
- printf("wtfs: bno %d, size %d, buf %d\n", bno, size, bf);
lseek(fso, bno * DEV_BSIZE, 0);
lseek(fso, bno * DEV_BSIZE, 0);
+ if (lseek(fso, bno * DEV_BSIZE, 0) < 0) {
+ printf("seek error: %ld\n", bno);
+ perror("wtfs");
+ exit(1);
+ }
n = write(fso, bf, size);
if(n != size) {
printf("write error: %D\n", bno);
n = write(fso, bf, size);
if(n != size) {
printf("write error: %D\n", bno);
/* Copyright (c) 1981 Regents of the University of California */
/* Copyright (c) 1981 Regents of the University of California */
-char version[] = "@(#)main.c 1.9 %G%";
+char version[] = "@(#)main.c 1.10 %G%";
/* Modified to include h option (recursively extract all files within
* a subtree) and m option (recreate the heirarchical structure of
/* Modified to include h option (recursively extract all files within
* a subtree) and m option (recreate the heirarchical structure of
*/
if (BIT(ROOTINO, clrimap))
BIS(LOSTFOUNDINO + 1, clrimap);
*/
if (BIT(ROOTINO, clrimap))
BIS(LOSTFOUNDINO + 1, clrimap);
- for (ino = 1; ino <= maxi; ino++)
+ for (ino = ROOTINO; ino <= maxi; ino++)
if (BIT(ino, clrimap) == 0) {
if (!iexist(dev, ino))
continue;
if (BIT(ino, clrimap) == 0) {
if (!iexist(dev, ino))
continue;
for (itp = inotab[INOHASH(odp->d_ino)]; itp; itp = itp->t_next) {
if (itp->t_ino != odp->d_ino)
continue;
for (itp = inotab[INOHASH(odp->d_ino)]; itp; itp = itp->t_next) {
if (itp->t_ino != odp->d_ino)
continue;