summaryrefslogtreecommitdiffstats
path: root/sbin/newfs/mkfs.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-04-24 11:44:02 +0000
committerphk <phk@FreeBSD.org>2002-04-24 11:44:02 +0000
commit0f040bcefc6089fa617085e2f285bd8a94b2ce81 (patch)
tree2587dfad5420ee43da47ccb65c3280a1bb0e6035 /sbin/newfs/mkfs.c
parentf92f3e5ed1e887f7f2afc3733747f62b2b781b2e (diff)
downloadFreeBSD-src-0f040bcefc6089fa617085e2f285bd8a94b2ce81.zip
FreeBSD-src-0f040bcefc6089fa617085e2f285bd8a94b2ce81.tar.gz
Continue the cleanup preparations for UFS2 (& GEOM):
Use only one filedescriptor. Open in R/O or R/W based in the '-N' option. Make the filedescriptor a global variable instead of passing it around as semi-global variable(s). Remove the undocumented ability to specify type without '-T' option. Replace fatal() with straight err(3)/errx(3). Save calls to strerror() where applicable. Loose the progname variable. Get the sense of the cpgflag test correct so we only issue warnings if people specify cpg and can't get that. It can be argued that this should be an error. Remove the check to see if the disk is mounted: Open for writing would fail if it were mounted. Attempt to get the sectorsize and mediasize with the generic disk ioctls, fall back to disklabel and /etc/disktab as we can. Notice that on-disk labels still take precedence over /etc/disktab, this is probably wrong, but not as wrong as the entire concept of /etc/disktab is. Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sbin/newfs/mkfs.c')
-rw-r--r--sbin/newfs/mkfs.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 6887069..b0bbcb9 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -92,7 +92,6 @@ static union {
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 lcpg, long bpcg, off_t *usedbp);
@@ -110,7 +109,7 @@ static void wtfs(daddr_t, int, char *);
static void wtfsflush(void);
void
-mkfs(struct partition *pp, char *fsys, int fi, int fo)
+mkfs(struct partition *pp, char *fsys)
{
long i, mincpc, mincpg, inospercg;
long cylno, j, lwarn = 0;
@@ -130,8 +129,6 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
randinit = 1;
srandomdev();
}
- fsi = fi;
- fso = fo;
sblock.fs_inodefmt = FS_44INODEFMT;
sblock.fs_maxsymlinklen = MAXSYMLINKLEN;
if (Uflag)
@@ -372,10 +369,8 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
printf("cylinder groups must have at least %ld cylinders\n",
mincpg);
exit(25);
- } else if (sblock.fs_cpg != cpg) {
- if (!cpgflg)
- printf("Warning: ");
- else if (!mapcramped && !inodecramped)
+ } else if (cpgflg && sblock.fs_cpg != cpg) {
+ if (!mapcramped && !inodecramped)
exit(26);
if (mapcramped && inodecramped)
printf("Block size and bytes per inode restrict");
@@ -562,10 +557,12 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo)
* Update information about this partion in pack
* label, to that it may be updated on disk.
*/
- pp->p_fstype = FS_BSDFFS;
- pp->p_fsize = sblock.fs_fsize;
- pp->p_frag = sblock.fs_frag;
- pp->p_cpg = sblock.fs_cpg;
+ if (pp != NULL) {
+ pp->p_fstype = FS_BSDFFS;
+ pp->p_fsize = sblock.fs_fsize;
+ pp->p_frag = sblock.fs_frag;
+ pp->p_cpg = sblock.fs_cpg;
+ }
}
/*
@@ -918,11 +915,11 @@ rdfs(daddr_t bno, int size, char *bf)
int n;
wtfsflush();
- if (lseek(fsi, (off_t)bno * sectorsize, 0) < 0) {
+ if (lseek(fso, (off_t)bno * sectorsize, 0) < 0) {
printf("seek error: %ld\n", (long)bno);
err(33, "rdfs");
}
- n = read(fsi, bf, size);
+ n = read(fso, bf, size);
if (n != size) {
printf("read error: %ld\n", (long)bno);
err(34, "rdfs");
OpenPOWER on IntegriCloud