Swing the axe and remove some archaic features from newfs which modern
diskdrives do neither need nor want: -O create a 4.3BSD format filesystem -d rotational delay between contiguous blocks -k sector 0 skew, per track -l hardware sector interleave -n number of distinguished rotational positions -p spare sectors per track -r revolutions/minute -t tracks/cylinder -x spare sectors per cylinder No change in the produced filesystem image unless one or more of these options were used. Approved by: mckusick
This commit is contained in:
parent
e57574233a
commit
5dccd5c649
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=92763
@ -95,7 +95,7 @@ static struct dinode zino[MAXBSIZE / sizeof(struct dinode)];
|
||||
static int fsi, fso;
|
||||
static int randinit;
|
||||
static daddr_t alloc(int size, int mode);
|
||||
static long calcipg(long cpg, long bpcg, off_t *usedbp);
|
||||
static long calcipg(long lcpg, long bpcg, off_t *usedbp);
|
||||
static int charsperline(void);
|
||||
static void clrblock (struct fs *, unsigned char *, int);
|
||||
static void fsinit (time_t);
|
||||
@ -113,11 +113,10 @@ void
|
||||
mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
{
|
||||
long i, mincpc, mincpg, inospercg;
|
||||
long cylno, rpos, blk, j, warn = 0;
|
||||
long cylno, j, lwarn = 0;
|
||||
long used, mincpgcnt, bpcg;
|
||||
off_t usedb;
|
||||
long mapcramped, inodecramped;
|
||||
long postblsize, rotblsize, totalsbsize;
|
||||
time_t utime;
|
||||
quad_t sizepb;
|
||||
int width;
|
||||
@ -133,13 +132,8 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
}
|
||||
fsi = fi;
|
||||
fso = fo;
|
||||
if (Oflag) {
|
||||
sblock.fs_inodefmt = FS_42INODEFMT;
|
||||
sblock.fs_maxsymlinklen = 0;
|
||||
} else {
|
||||
sblock.fs_inodefmt = FS_44INODEFMT;
|
||||
sblock.fs_maxsymlinklen = MAXSYMLINKLEN;
|
||||
}
|
||||
if (Uflag)
|
||||
sblock.fs_flags |= FS_DOSOFTDEP;
|
||||
/*
|
||||
@ -153,10 +147,8 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
/*
|
||||
* collect and verify the sector and track info
|
||||
*/
|
||||
sblock.fs_nsect = nsectors;
|
||||
sblock.fs_ntrak = ntracks;
|
||||
if (sblock.fs_ntrak <= 0)
|
||||
printf("preposterous ntrak %d\n", sblock.fs_ntrak), exit(14);
|
||||
sblock.fs_nsect = secpercyl;
|
||||
sblock.fs_ntrak = 1;
|
||||
if (sblock.fs_nsect <= 0)
|
||||
printf("preposterous nsect %d\n", sblock.fs_nsect), exit(15);
|
||||
/*
|
||||
@ -216,7 +208,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
sblock.fs_bsize / MAXFRAG);
|
||||
exit(21);
|
||||
}
|
||||
sblock.fs_nrpos = nrpos;
|
||||
sblock.fs_nrpos = 1;
|
||||
sblock.fs_nindir = sblock.fs_bsize / sizeof(daddr_t);
|
||||
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct dinode);
|
||||
sblock.fs_nspf = sblock.fs_fsize / sectorsize;
|
||||
@ -228,10 +220,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag;
|
||||
sblock.fs_cgoffset =
|
||||
roundup(howmany(sblock.fs_nsect, NSPF(&sblock)), sblock.fs_frag);
|
||||
for (sblock.fs_cgmask = 0xffffffff, i = sblock.fs_ntrak; i > 1; i >>= 1)
|
||||
sblock.fs_cgmask <<= 1;
|
||||
if (!POWEROF2(sblock.fs_ntrak))
|
||||
sblock.fs_cgmask <<= 1;
|
||||
sblock.fs_cgmask = 0xffffffff;
|
||||
sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1;
|
||||
for (sizepb = sblock.fs_bsize, i = 0; i < NIADDR; i++) {
|
||||
sizepb *= NINDIR(&sblock);
|
||||
@ -404,7 +393,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
sblock.fs_ncyl = fssize * NSPF(&sblock) / sblock.fs_spc;
|
||||
if (fssize * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) {
|
||||
sblock.fs_ncyl++;
|
||||
warn = 1;
|
||||
lwarn = 1;
|
||||
}
|
||||
if (sblock.fs_ncyl < 1) {
|
||||
printf("file systems must have at least one cylinder\n");
|
||||
@ -421,65 +410,14 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
* are not powers of two, because more cylinders must be described
|
||||
* by the tables before the rotational pattern repeats (fs_cpc).
|
||||
*/
|
||||
sblock.fs_interleave = interleave;
|
||||
sblock.fs_trackskew = trackskew;
|
||||
sblock.fs_npsect = nphyssectors;
|
||||
sblock.fs_interleave = 1;
|
||||
sblock.fs_trackskew = 0;
|
||||
sblock.fs_npsect = secpercyl;
|
||||
sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT;
|
||||
sblock.fs_sbsize = fragroundup(&sblock, sizeof(struct fs));
|
||||
if (sblock.fs_sbsize > SBSIZE)
|
||||
sblock.fs_sbsize = SBSIZE;
|
||||
if (sblock.fs_ntrak == 1) {
|
||||
sblock.fs_cpc = 0;
|
||||
goto next;
|
||||
}
|
||||
postblsize = sblock.fs_nrpos * sblock.fs_cpc * sizeof(int16_t);
|
||||
rotblsize = sblock.fs_cpc * sblock.fs_spc / NSPB(&sblock);
|
||||
totalsbsize = sizeof(struct fs) + rotblsize;
|
||||
if (sblock.fs_nrpos == 8 && sblock.fs_cpc <= 16) {
|
||||
/* use old static table space */
|
||||
sblock.fs_postbloff = (char *)(&sblock.fs_opostbl[0][0]) -
|
||||
(char *)(&sblock.fs_firstfield);
|
||||
sblock.fs_rotbloff = &sblock.fs_space[0] -
|
||||
(u_char *)(&sblock.fs_firstfield);
|
||||
} else {
|
||||
/* use dynamic table space */
|
||||
sblock.fs_postbloff = &sblock.fs_space[0] -
|
||||
(u_char *)(&sblock.fs_firstfield);
|
||||
sblock.fs_rotbloff = sblock.fs_postbloff + postblsize;
|
||||
totalsbsize += postblsize;
|
||||
}
|
||||
if (totalsbsize > SBSIZE ||
|
||||
sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) {
|
||||
printf("%s %s %d %s %d.%s",
|
||||
"Warning: insufficient space in super block for\n",
|
||||
"rotational layout tables with nsect", sblock.fs_nsect,
|
||||
"and ntrak", sblock.fs_ntrak,
|
||||
"\nFile system performance may be impaired.\n");
|
||||
sblock.fs_cpc = 0;
|
||||
goto next;
|
||||
}
|
||||
sblock.fs_sbsize = fragroundup(&sblock, totalsbsize);
|
||||
if (sblock.fs_sbsize > SBSIZE)
|
||||
sblock.fs_sbsize = SBSIZE;
|
||||
/*
|
||||
* calculate the available blocks for each rotational position
|
||||
*/
|
||||
for (cylno = 0; cylno < sblock.fs_cpc; cylno++)
|
||||
for (rpos = 0; rpos < sblock.fs_nrpos; rpos++)
|
||||
fs_postbl(&sblock, cylno)[rpos] = -1;
|
||||
for (i = (rotblsize - 1) * sblock.fs_frag;
|
||||
i >= 0; i -= sblock.fs_frag) {
|
||||
cylno = cbtocylno(&sblock, i);
|
||||
rpos = cbtorpos(&sblock, i);
|
||||
blk = fragstoblks(&sblock, i);
|
||||
if (fs_postbl(&sblock, cylno)[rpos] == -1)
|
||||
fs_rotbl(&sblock)[blk] = 0;
|
||||
else
|
||||
fs_rotbl(&sblock)[blk] =
|
||||
fs_postbl(&sblock, cylno)[rpos] - blk;
|
||||
fs_postbl(&sblock, cylno)[rpos] = blk;
|
||||
}
|
||||
next:
|
||||
/*
|
||||
* Compute/validate number of cylinder groups.
|
||||
*/
|
||||
@ -516,9 +454,9 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg;
|
||||
sblock.fs_size = fssize = sblock.fs_ncyl * sblock.fs_spc /
|
||||
NSPF(&sblock);
|
||||
warn = 0;
|
||||
lwarn = 0;
|
||||
}
|
||||
if (warn) {
|
||||
if (lwarn) {
|
||||
printf("Warning: %d sector(s) in last cylinder unallocated\n",
|
||||
sblock.fs_spc -
|
||||
(fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1) *
|
||||
@ -542,11 +480,11 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
|
||||
if (fscs == NULL)
|
||||
errx(31, "calloc failed");
|
||||
sblock.fs_magic = FS_MAGIC;
|
||||
sblock.fs_rotdelay = rotdelay;
|
||||
sblock.fs_rotdelay = 0;
|
||||
sblock.fs_minfree = minfree;
|
||||
sblock.fs_maxcontig = maxcontig;
|
||||
sblock.fs_maxbpg = maxbpg;
|
||||
sblock.fs_rps = rpm / 60;
|
||||
sblock.fs_rps = 60;
|
||||
sblock.fs_optim = opt;
|
||||
sblock.fs_cgrotor = 0;
|
||||
sblock.fs_cstotal.cs_ndir = 0;
|
||||
@ -666,7 +604,7 @@ initcg(int cylno, time_t utime)
|
||||
acg.cg_btotoff = &acg.cg_space[0] - (u_char *)(&acg.cg_firstfield);
|
||||
acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(int32_t);
|
||||
acg.cg_iusedoff = acg.cg_boff +
|
||||
sblock.fs_cpg * sblock.fs_nrpos * sizeof(u_int16_t);
|
||||
sblock.fs_cpg * sizeof(u_int16_t);
|
||||
acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, NBBY);
|
||||
if (sblock.fs_contigsumsize <= 0) {
|
||||
acg.cg_nextfreeoff = acg.cg_freeoff +
|
||||
@ -842,17 +780,10 @@ fsinit(time_t utime)
|
||||
/*
|
||||
* create the lost+found directory
|
||||
*/
|
||||
if (Oflag) {
|
||||
(void)makedir((struct direct *)olost_found_dir, 2);
|
||||
for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ)
|
||||
memmove(&buf[i], &olost_found_dir[2],
|
||||
DIRSIZ(0, &olost_found_dir[2]));
|
||||
} else {
|
||||
(void)makedir(lost_found_dir, 2);
|
||||
for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ)
|
||||
memmove(&buf[i], &lost_found_dir[2],
|
||||
DIRSIZ(0, &lost_found_dir[2]));
|
||||
}
|
||||
node.di_mode = IFDIR | UMASK;
|
||||
node.di_nlink = 2;
|
||||
node.di_size = sblock.fs_bsize;
|
||||
@ -866,9 +797,6 @@ fsinit(time_t utime)
|
||||
*/
|
||||
node.di_mode = IFDIR | UMASK;
|
||||
node.di_nlink = PREDEFDIR;
|
||||
if (Oflag)
|
||||
node.di_size = makedir((struct direct *)oroot_dir, PREDEFDIR);
|
||||
else
|
||||
node.di_size = makedir(root_dir, PREDEFDIR);
|
||||
node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode);
|
||||
node.di_blocks = btodb(fragroundup(&sblock, node.di_size));
|
||||
@ -955,7 +883,7 @@ alloc(int size, int mode)
|
||||
* Calculate number of inodes per group.
|
||||
*/
|
||||
long
|
||||
calcipg(long cpg, long bpcg, off_t *usedbp)
|
||||
calcipg(long lcpg, long bpcg, off_t *usedbp)
|
||||
{
|
||||
int i;
|
||||
long ipg, new_ipg, ncg, ncyl;
|
||||
@ -966,7 +894,7 @@ calcipg(long cpg, long bpcg, off_t *usedbp)
|
||||
* Note that fssize is still in sectors, not filesystem blocks.
|
||||
*/
|
||||
ncyl = howmany(fssize, (u_int)secpercyl);
|
||||
ncg = howmany(ncyl, cpg);
|
||||
ncg = howmany(ncyl, lcpg);
|
||||
/*
|
||||
* Iterate a few times to allow for ipg depending on itself.
|
||||
*/
|
||||
@ -974,8 +902,8 @@ calcipg(long cpg, long bpcg, off_t *usedbp)
|
||||
for (i = 0; i < 10; i++) {
|
||||
usedb = (sblock.fs_iblkno + ipg / INOPF(&sblock)) *
|
||||
NSPF(&sblock) * (off_t)sectorsize;
|
||||
new_ipg = (cpg * (quad_t)bpcg - usedb) / density *
|
||||
fssize / ncg / secpercyl / cpg;
|
||||
new_ipg = (lcpg * (quad_t)bpcg - usedb) / density *
|
||||
fssize / ncg / secpercyl / lcpg;
|
||||
new_ipg = roundup(new_ipg, INOPB(&sblock));
|
||||
if (new_ipg == ipg)
|
||||
break;
|
||||
@ -991,7 +919,7 @@ calcipg(long cpg, long bpcg, off_t *usedbp)
|
||||
void
|
||||
iput(struct dinode *ip, ino_t ino)
|
||||
{
|
||||
struct dinode buf[MAXINOPB];
|
||||
struct dinode lbuf[MAXINOPB];
|
||||
daddr_t d;
|
||||
int c;
|
||||
|
||||
@ -1014,9 +942,9 @@ iput(struct dinode *ip, ino_t ino)
|
||||
exit(32);
|
||||
}
|
||||
d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino));
|
||||
rdfs(d, sblock.fs_bsize, (char *)buf);
|
||||
buf[ino_to_fsbo(&sblock, ino)] = *ip;
|
||||
wtfs(d, sblock.fs_bsize, (char *)buf);
|
||||
rdfs(d, sblock.fs_bsize, (char *)lbuf);
|
||||
lbuf[ino_to_fsbo(&sblock, ino)] = *ip;
|
||||
wtfs(d, sblock.fs_bsize, (char *)lbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1207,7 +1135,7 @@ charsperline(void)
|
||||
static int
|
||||
ilog2(int val)
|
||||
{
|
||||
int n;
|
||||
u_int n;
|
||||
|
||||
for (n = 0; n < sizeof(n) * NBBY; n++)
|
||||
if (1 << n == val)
|
||||
|
@ -46,24 +46,16 @@
|
||||
.Op Fl a Ar maxcontig
|
||||
.Op Fl b Ar block-size
|
||||
.Op Fl c Ar cylinders
|
||||
.Op Fl d Ar rotdelay
|
||||
.Op Fl e Ar maxbpg
|
||||
.Op Fl f Ar frag-size
|
||||
.Op Fl g Ar avgfilesize
|
||||
.Op Fl h Ar avfpdir
|
||||
.Op Fl i Ar bytes
|
||||
.Op Fl k Ar skew
|
||||
.Op Fl l Ar interleave
|
||||
.Op Fl m Ar free space
|
||||
.Op Fl n Ar rotational positions
|
||||
.Op Fl o Ar optimization
|
||||
.Op Fl p Ar sectors
|
||||
.Op Fl r Ar revolutions
|
||||
.Op Fl s Ar size
|
||||
.Op Fl t Ar tracks
|
||||
.Op Fl u Ar sectors
|
||||
.Op Fl v
|
||||
.Op Fl x Ar sectors
|
||||
.Ar special
|
||||
.Sh DESCRIPTION
|
||||
.Nm Newfs
|
||||
@ -91,19 +83,11 @@ For backward compatibility.
|
||||
.It Fl N
|
||||
Cause the file system parameters to be printed out
|
||||
without really creating the file system.
|
||||
.It Fl O
|
||||
Create a
|
||||
.Bx 4.3
|
||||
format filesystem.
|
||||
This options is primarily used to build root filesystems
|
||||
that can be understood by older boot ROMs.
|
||||
.It Fl U
|
||||
Enables soft updates on the new filesystem.
|
||||
.It Fl a Ar maxcontig
|
||||
Specify the maximum number of contiguous blocks that will be
|
||||
laid out before forcing a rotational delay (see the
|
||||
.Fl d
|
||||
option).
|
||||
laid out before forcing a rotational delay.
|
||||
The default value is 1.
|
||||
See
|
||||
.Xr tunefs 8
|
||||
@ -119,14 +103,6 @@ The number of cylinders per cylinder group in a file system. The default
|
||||
is to compute the maximum allowed by the other parameters. This value is
|
||||
dependent on a number of other parameters, in particular the block size
|
||||
and the number of bytes per inode.
|
||||
.It Fl d Ar rotdelay
|
||||
This parameter once specified the minimum time in milliseconds required to
|
||||
initiate another disk transfer on the same cylinder. It was used in determining
|
||||
the rotationally optimal layout for disk blocks within a file. Modern disks
|
||||
with read/write-behind achieve higher performance with this feature disabled, so
|
||||
this value should be left at the default value of 0 milliseconds. See
|
||||
.Xr tunefs 8
|
||||
for more details on how to set this option.
|
||||
.It Fl e Ar maxbpg
|
||||
Indicate the maximum number of blocks any single file can
|
||||
allocate out of a cylinder group before it is forced to begin
|
||||
@ -167,15 +143,6 @@ currently 8%.
|
||||
See
|
||||
.Xr tunefs 8
|
||||
for more details on how to set this option.
|
||||
.It Fl n Ar number of distinguished rotational positions
|
||||
UFS has the ability to keep track of the availability of blocks at different
|
||||
rotational positions, so that it could lay out the data to be picked up with
|
||||
minimum rotational latency. This parameter specifies the default number of
|
||||
rotational positions to distinguish.
|
||||
.Pp
|
||||
Nowadays this value should be set to 1 (which essentially disables the
|
||||
rotational position table) because modern drives with read-ahead and
|
||||
write-behind do better without the rotational position table.
|
||||
.It Fl o Ar optimization\ preference
|
||||
.Pq Ar space No or Ar time .
|
||||
The file system can either be instructed to try to minimize the time spent
|
||||
@ -218,57 +185,11 @@ to find the alternate superblocks if the standard superblock is lost.
|
||||
.Bl -tag -width indent
|
||||
.It Fl S Ar sector-size
|
||||
The size of a sector in bytes (almost never anything but 512).
|
||||
.It Fl k Ar sector \&0 skew , per track
|
||||
Used to describe perturbations in the media format to compensate for
|
||||
a slow controller.
|
||||
Track skew is the offset of sector 0 on track N relative to sector 0
|
||||
on track N-1 on the same cylinder.
|
||||
This option is of historical importance only; modern controllers are always fast
|
||||
enough to handle operations back-to-back.
|
||||
.It Fl l Ar hardware sector interleave
|
||||
Used to describe perturbations in the media format to compensate for
|
||||
a slow controller.
|
||||
Interleave is physical sector interleave on each track,
|
||||
specified as the denominator of the ratio:
|
||||
.Dl sectors read/sectors passed over
|
||||
Thus an interleave of 1/1 implies contiguous layout, while 1/2 implies
|
||||
logical sector 0 is separated by one sector from logical sector 1.
|
||||
This option is of historical importance only; the physical sector layout of
|
||||
modern disks is not visible from outside.
|
||||
.It Fl p Ar spare sectors per track
|
||||
Spare sectors (bad sector replacements) are physical sectors that occupy
|
||||
space at the end of each track.
|
||||
They are not counted as part of the sectors/track
|
||||
.Pq Fl u
|
||||
since they are not available to the file system for data allocation.
|
||||
This option is of historical importance only. Modern disks perform their own
|
||||
bad sector allocation.
|
||||
.It Fl r Ar revolutions/minute
|
||||
The speed of the disk in revolutions per minute. This value is no longer of
|
||||
interest, since all the parameters which depend on it are usually disabled.
|
||||
.It Fl t Ar #tracks/cylinder
|
||||
The number of tracks/cylinder available for data allocation by the file
|
||||
system.
|
||||
The default is 1.
|
||||
If zero is specified, the value from the disklabel will be used.
|
||||
.It Fl u Ar sectors/track
|
||||
The number of sectors per track available for data allocation by the file
|
||||
.It Fl u Ar sectors/cylinders
|
||||
The number of sectors per cylinder available for data allocation by the file
|
||||
system.
|
||||
The default is 4096.
|
||||
If zero is specified, the value from the disklabel will be used.
|
||||
This does not include sectors reserved at the end of each track for bad
|
||||
block replacement (see the
|
||||
.Fl p
|
||||
option).
|
||||
.It Fl x Ar spare sectors per cylinder
|
||||
Spare sectors (bad sector replacements) are physical sectors that occupy
|
||||
space at the end of the last track in the cylinder.
|
||||
They are deducted from the sectors/track
|
||||
.Pq Fl u
|
||||
of the last track of each cylinder since they are not available to the file
|
||||
system for data allocation.
|
||||
This option is of historical importance only. Modern disks perform their own
|
||||
bad sector allocation.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Dl newfs /dev/ad3s1a
|
||||
|
@ -95,19 +95,6 @@ static struct disklabel *getdisklabel(char *s, int fd);
|
||||
*/
|
||||
#define DESCPG 65536 /* desired fs_cpg ("infinity") */
|
||||
|
||||
/*
|
||||
* Once upon a time...
|
||||
* ROTDELAY gives the minimum number of milliseconds to initiate
|
||||
* another disk transfer on the same cylinder. It is used in
|
||||
* determining the rotationally optimal layout for disk blocks
|
||||
* within a file; the default of fs_rotdelay is 4ms.
|
||||
*
|
||||
* ...but now we make this 0 to disable the rotdelay delay because
|
||||
* modern drives with read/write-behind achieve higher performance
|
||||
* without the delay.
|
||||
*/
|
||||
#define ROTDELAY 0
|
||||
|
||||
/*
|
||||
* MAXBLKPG determines the maximum number of data blocks which are
|
||||
* placed in a single cylinder group. The default is one indirect
|
||||
@ -122,20 +109,6 @@ static struct disklabel *getdisklabel(char *s, int fd);
|
||||
*/
|
||||
#define NFPI 4
|
||||
|
||||
/*
|
||||
* Once upon a time...
|
||||
* For each cylinder we keep track of the availability of blocks at different
|
||||
* rotational positions, so that we can lay out the data to be picked
|
||||
* up with minimum rotational latency. NRPOS is the default number of
|
||||
* rotational positions that we distinguish. With NRPOS of 8 the resolution
|
||||
* of our summary information is 2ms for a typical 3600 rpm drive.
|
||||
*
|
||||
* ...but now we make this 1 (which essentially disables the rotational
|
||||
* position table because modern drives with read-ahead and write-behind do
|
||||
* better without the rotational position table.
|
||||
*/
|
||||
#define NRPOS 1 /* number distinct rotational positions */
|
||||
|
||||
/*
|
||||
* About the same time as the above, we knew what went where on the disks.
|
||||
* no longer so, so kill the code which finds the different platters too...
|
||||
@ -143,27 +116,15 @@ static struct disklabel *getdisklabel(char *s, int fd);
|
||||
* The number of sectors are used to determine the size of a cyl-group.
|
||||
* Kirk suggested one or two meg per "cylinder" so we say two.
|
||||
*/
|
||||
#define NTRACKS 1 /* number of heads */
|
||||
#define NSECTORS 4096 /* number of sectors */
|
||||
|
||||
int Nflag; /* run without writing file system */
|
||||
int Oflag; /* format as an 4.3BSD file system */
|
||||
int Rflag; /* regression test */
|
||||
int Uflag; /* enable soft updates for file system */
|
||||
int fssize; /* file system size */
|
||||
int ntracks = NTRACKS; /* # tracks/cylinder */
|
||||
int nsectors = NSECTORS; /* # sectors/track */
|
||||
int nphyssectors; /* # sectors/track including spares */
|
||||
int secpercyl; /* sectors per cylinder */
|
||||
int trackspares = -1; /* spare sectors per track */
|
||||
int cylspares = -1; /* spare sectors per cylinder */
|
||||
u_int fssize; /* file system size */
|
||||
u_int secpercyl = NSECTORS; /* sectors per cylinder */
|
||||
int sectorsize; /* bytes/sector */
|
||||
int realsectorsize; /* bytes/sector in hardware */
|
||||
int rpm; /* revolutions/minute of drive */
|
||||
int interleave; /* hardware sector interleave */
|
||||
int trackskew = -1; /* sector 0 skew, per track */
|
||||
int headswitch; /* head switch time, usec */
|
||||
int trackseek; /* track-to-track seek, usec */
|
||||
int fsize = 0; /* fragment size */
|
||||
int bsize = 0; /* block size */
|
||||
int cpg = DESCPG; /* cylinders/cylinder group */
|
||||
@ -172,23 +133,20 @@ int minfree = MINFREE; /* free space threshold */
|
||||
int opt = DEFAULTOPT; /* optimization preference (space or time) */
|
||||
int density; /* number of bytes per inode */
|
||||
int maxcontig = 0; /* max contiguous blocks to allocate */
|
||||
int rotdelay = ROTDELAY; /* rotational delay between blocks */
|
||||
int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
int nrpos = NRPOS; /* # of distinguished rotational positions */
|
||||
int avgfilesize = AVFILESIZ;/* expected average file size */
|
||||
int avgfilesperdir = AFPDIR;/* expected number of files per directory */
|
||||
int bbsize = BBSIZE; /* boot block size */
|
||||
int sbsize = SBSIZE; /* superblock size */
|
||||
int t_or_u_flag = 0; /* user has specified -t or -u */
|
||||
static int t_or_u_flag = 0; /* user has specified -t or -u */
|
||||
#ifdef COMPAT
|
||||
char *disktype;
|
||||
int unlabeled;
|
||||
static char *disktype;
|
||||
static int unlabeled;
|
||||
#endif
|
||||
|
||||
char device[MAXPATHLEN];
|
||||
char *progname;
|
||||
static char device[MAXPATHLEN];
|
||||
static char *progname;
|
||||
|
||||
extern void mkfs (struct partition *, char *, int, int);
|
||||
static void rewritelabel (char *s, int fd, register struct disklabel *lp);
|
||||
static void usage (void);
|
||||
|
||||
@ -210,14 +168,11 @@ main(int argc, char *argv[])
|
||||
progname = *argv;
|
||||
|
||||
while ((ch = getopt(argc, argv,
|
||||
"NORS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:")) != -1)
|
||||
"NRS:T:Ua:b:c:e:f:g:h:i:m:o:s:u:v:")) != -1)
|
||||
switch (ch) {
|
||||
case 'N':
|
||||
Nflag = 1;
|
||||
break;
|
||||
case 'O':
|
||||
Oflag = 1;
|
||||
break;
|
||||
case 'R':
|
||||
Rflag = 1;
|
||||
break;
|
||||
@ -247,10 +202,6 @@ main(int argc, char *argv[])
|
||||
fatal("%s: bad cylinders/group", optarg);
|
||||
cpgflg++;
|
||||
break;
|
||||
case 'd':
|
||||
if ((rotdelay = atoi(optarg)) < 0)
|
||||
fatal("%s: bad rotational delay", optarg);
|
||||
break;
|
||||
case 'e':
|
||||
if ((maxbpg = atoi(optarg)) <= 0)
|
||||
fatal("%s: bad blocks per file in a cylinder group",
|
||||
@ -272,25 +223,10 @@ main(int argc, char *argv[])
|
||||
if ((density = atoi(optarg)) <= 0)
|
||||
fatal("%s: bad bytes per inode", optarg);
|
||||
break;
|
||||
case 'k':
|
||||
if ((trackskew = atoi(optarg)) < 0)
|
||||
fatal("%s: bad track skew", optarg);
|
||||
break;
|
||||
case 'l':
|
||||
if ((interleave = atoi(optarg)) <= 0)
|
||||
fatal("%s: bad interleave", optarg);
|
||||
break;
|
||||
case 'm':
|
||||
if ((minfree = atoi(optarg)) < 0 || minfree > 99)
|
||||
fatal("%s: bad free space %%", optarg);
|
||||
break;
|
||||
case 'n':
|
||||
if ((nrpos = atoi(optarg)) < 0)
|
||||
fatal("%s: bad rotational layout count",
|
||||
optarg);
|
||||
if (nrpos == 0)
|
||||
nrpos = 1;
|
||||
break;
|
||||
case 'o':
|
||||
if (strcmp(optarg, "space") == 0)
|
||||
opt = FS_OPTSPACE;
|
||||
@ -301,37 +237,19 @@ main(int argc, char *argv[])
|
||||
"%s: unknown optimization preference: use `space' or `time'",
|
||||
optarg);
|
||||
break;
|
||||
case 'p':
|
||||
if ((trackspares = atoi(optarg)) < 0)
|
||||
fatal("%s: bad spare sectors per track",
|
||||
optarg);
|
||||
break;
|
||||
case 'r':
|
||||
if ((rpm = atoi(optarg)) <= 0)
|
||||
fatal("%s: bad revolutions/minute", optarg);
|
||||
break;
|
||||
case 's':
|
||||
if ((fssize = atoi(optarg)) <= 0)
|
||||
fatal("%s: bad file system size", optarg);
|
||||
break;
|
||||
case 't':
|
||||
t_or_u_flag++;
|
||||
if ((ntracks = atoi(optarg)) < 0)
|
||||
fatal("%s: bad total tracks", optarg);
|
||||
break;
|
||||
case 'u':
|
||||
t_or_u_flag++;
|
||||
if ((nsectors = atoi(optarg)) < 0)
|
||||
if ((n = atoi(optarg)) < 0)
|
||||
fatal("%s: bad sectors/track", optarg);
|
||||
secpercyl = n;
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
case 'x':
|
||||
if ((cylspares = atoi(optarg)) < 0)
|
||||
fatal("%s: bad spare sectors per cylinder",
|
||||
optarg);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -416,19 +334,9 @@ main(int argc, char *argv[])
|
||||
fatal(
|
||||
"%s: maximum file system size on the `%c' partition is %d",
|
||||
argv[0], *cp, pp->p_size);
|
||||
if (rpm == 0) {
|
||||
rpm = lp->d_rpm;
|
||||
if (rpm <= 0)
|
||||
rpm = 3600;
|
||||
}
|
||||
if (ntracks == 0) {
|
||||
ntracks = lp->d_ntracks;
|
||||
if (ntracks <= 0)
|
||||
fatal("%s: no default #tracks", argv[0]);
|
||||
}
|
||||
if (nsectors == 0) {
|
||||
nsectors = lp->d_nsectors;
|
||||
if (nsectors <= 0)
|
||||
if (secpercyl == 0) {
|
||||
secpercyl = lp->d_nsectors;
|
||||
if (secpercyl <= 0)
|
||||
fatal("%s: no default #sectors/track", argv[0]);
|
||||
}
|
||||
if (sectorsize == 0) {
|
||||
@ -436,16 +344,6 @@ main(int argc, char *argv[])
|
||||
if (sectorsize <= 0)
|
||||
fatal("%s: no default sector size", argv[0]);
|
||||
}
|
||||
if (trackskew == -1) {
|
||||
trackskew = lp->d_trackskew;
|
||||
if (trackskew < 0)
|
||||
trackskew = 0;
|
||||
}
|
||||
if (interleave == 0) {
|
||||
interleave = lp->d_interleave;
|
||||
if (interleave <= 0)
|
||||
interleave = 1;
|
||||
}
|
||||
if (fsize == 0) {
|
||||
fsize = pp->p_fsize;
|
||||
if (fsize <= 0)
|
||||
@ -471,18 +369,6 @@ main(int argc, char *argv[])
|
||||
fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
|
||||
opt = FS_OPTSPACE;
|
||||
}
|
||||
if (trackspares == -1) {
|
||||
trackspares = lp->d_sparespertrack;
|
||||
if (trackspares < 0)
|
||||
trackspares = 0;
|
||||
}
|
||||
nphyssectors = nsectors + trackspares;
|
||||
if (cylspares == -1) {
|
||||
cylspares = lp->d_sparespercyl;
|
||||
if (cylspares < 0)
|
||||
cylspares = 0;
|
||||
}
|
||||
secpercyl = nsectors * ntracks - cylspares;
|
||||
/*
|
||||
* Only complain if -t or -u have been specified; the default
|
||||
* case (4096 sectors per cylinder) is intended to disagree
|
||||
@ -494,8 +380,6 @@ main(int argc, char *argv[])
|
||||
"disagrees with disk label", (u_long)lp->d_secpercyl);
|
||||
if (maxbpg == 0)
|
||||
maxbpg = MAXBLKPG(bsize);
|
||||
headswitch = lp->d_headswitch;
|
||||
trackseek = lp->d_trkseek;
|
||||
#ifdef notdef /* label may be 0 if faked up by kernel */
|
||||
bbsize = lp->d_bbsize;
|
||||
sbsize = lp->d_sbsize;
|
||||
@ -506,8 +390,6 @@ main(int argc, char *argv[])
|
||||
int secperblk = sectorsize / DEV_BSIZE;
|
||||
|
||||
sectorsize = DEV_BSIZE;
|
||||
nsectors *= secperblk;
|
||||
nphyssectors *= secperblk;
|
||||
secpercyl *= secperblk;
|
||||
fssize *= secperblk;
|
||||
pp->p_size *= secperblk;
|
||||
@ -599,7 +481,6 @@ usage()
|
||||
fprintf(stderr, "where fsoptions are:\n");
|
||||
fprintf(stderr,
|
||||
"\t-N do not create file system, just print out parameters\n");
|
||||
fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n");
|
||||
fprintf(stderr, "\t-R regression test, supress random factors\n");
|
||||
fprintf(stderr, "\t-S sector size\n");
|
||||
#ifdef COMPAT
|
||||
@ -609,24 +490,16 @@ usage()
|
||||
fprintf(stderr, "\t-a maximum contiguous blocks\n");
|
||||
fprintf(stderr, "\t-b block size\n");
|
||||
fprintf(stderr, "\t-c cylinders/group\n");
|
||||
fprintf(stderr, "\t-d rotational delay between contiguous blocks\n");
|
||||
fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n");
|
||||
fprintf(stderr, "\t-f frag size\n");
|
||||
fprintf(stderr, "\t-g average file size\n");
|
||||
fprintf(stderr, "\t-h average files per directory\n");
|
||||
fprintf(stderr, "\t-i number of bytes per inode\n");
|
||||
fprintf(stderr, "\t-k sector 0 skew, per track\n");
|
||||
fprintf(stderr, "\t-l hardware sector interleave\n");
|
||||
fprintf(stderr, "\t-m minimum free space %%\n");
|
||||
fprintf(stderr, "\t-n number of distinguished rotational positions\n");
|
||||
fprintf(stderr, "\t-o optimization preference (`space' or `time')\n");
|
||||
fprintf(stderr, "\t-p spare sectors per track\n");
|
||||
fprintf(stderr, "\t-s file system size (sectors)\n");
|
||||
fprintf(stderr, "\t-r revolutions/minute\n");
|
||||
fprintf(stderr, "\t-t tracks/cylinder\n");
|
||||
fprintf(stderr, "\t-u sectors/track\n");
|
||||
fprintf(stderr, "\t-u sectors/cylinder\n");
|
||||
fprintf(stderr,
|
||||
"\t-v do not attempt to determine partition name from device name\n");
|
||||
fprintf(stderr, "\t-x spare sectors per cylinder\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -38,19 +38,12 @@
|
||||
* variables set up by front end.
|
||||
*/
|
||||
extern int Nflag; /* run mkfs without writing file system */
|
||||
extern int Oflag; /* format as an 4.3BSD file system */
|
||||
extern int Rflag; /* regression test */
|
||||
extern int Uflag; /* enable soft updates for file system */
|
||||
extern int fssize; /* file system size */
|
||||
extern int ntracks; /* # tracks/cylinder */
|
||||
extern int nsectors; /* # sectors/track */
|
||||
extern int nphyssectors; /* # sectors/track including spares */
|
||||
extern int secpercyl; /* sectors per cylinder */
|
||||
extern u_int fssize; /* file system size */
|
||||
extern u_int secpercyl; /* sectors per cylinder */
|
||||
extern int sectorsize; /* bytes/sector */
|
||||
extern int realsectorsize; /* bytes/sector in hardware*/
|
||||
extern int rpm; /* revolutions/minute of drive */
|
||||
extern int interleave; /* hardware sector interleave */
|
||||
extern int trackskew; /* sector 0 skew, per track */
|
||||
extern int fsize; /* fragment size */
|
||||
extern int bsize; /* block size */
|
||||
extern int cpg; /* cylinders/cylinder group */
|
||||
@ -59,11 +52,9 @@ extern int minfree; /* free space threshold */
|
||||
extern int opt; /* optimization preference (space or time) */
|
||||
extern int density; /* number of bytes per inode */
|
||||
extern int maxcontig; /* max contiguous blocks to allocate */
|
||||
extern int rotdelay; /* rotational delay between blocks */
|
||||
extern int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
extern int nrpos; /* # of distinguished rotational positions */
|
||||
extern int bbsize; /* boot block size */
|
||||
extern int sbsize; /* superblock size */
|
||||
extern int avgfilesize; /* expected average file size */
|
||||
extern int avgfilesperdir; /* expected number of files per directory */
|
||||
|
||||
void mkfs (struct partition *, char *, int, int);
|
||||
|
Loading…
Reference in New Issue
Block a user