Subject: Re: newfs: determining file system parameters
To: Greg 'groggy' Lehey <grog@NetBSD.org>
From: Christian Limpach <chris@pin.lu>
List: tech-kern
Date: 10/11/2003 17:54:11
--1469824295-21717-1065887653=:1952
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Disposition: INLINE
On Sat, 11 Oct 2003 13:53:46 +0930 Greg 'groggy' Lehey <grog@NetBSD.org> wrote:
> I'd suggest that the following method would solve the "problem":
There's a quite simpler solution which only requires changes to newfs and
no new ioctl(s). Using the test suggested by Luke Mewburn on
source-changes, you can detect if the label returned by DIOCGDINFO is real
or fake. If the label is not real, you can then use the RAW_PART entry of
the fake label. The ccd and vnd drivers for instance fill out the RAW_PART
entry with the correct information such that the following works:
# ln /dev/rccd0d /dev/xxx
# ./newfs /dev/xxx
/dev/xxx: 1.2MB (2560 sectors) block size 4096, fragment size 512
using 4 cylinder groups of 0.31MB, 80 blks, 128 inodes.
super-block backups (for fsck -b #) at:
32, 672, 1312, 1952,
As for the ioctl solution:
> - implement an ioctl DIOCGMEDIASIZE to return the size of a special
> device.
Shouldn't this be an ioctl which returns at least as much information as is
available in the disklabel, i.e. at least what's in struct partition?
> - In such a case, newfs should obtain the sector size from the
> DIOCGMEDIASIZE ioctl.
You said the DIOCGMEDIASIZE returns "the size of a special device", how do
you get the sector size from that? Do you intend to also add a
DIOCGSECTORSIZE?
It seems to me that adding ioctl(s) for this information is not a good idea
until we know exactly if, when and how we want to get rid of disklabels and/or
offer a seperate interface.
newfs patch as described above:
--1469824295-21717-1065887653=:1952
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="newfs.txt"
Content-Disposition: INLINE; FILENAME="newfs.txt"
Index: newfs.c
===================================================================
RCS file: /cvs/netbsd/src/sbin/newfs/newfs.c,v
retrieving revision 1.70
diff -u -r1.70 newfs.c
--- newfs.c 11 Sep 2003 12:19:45 -0000 1.70
+++ newfs.c 11 Oct 2003 14:51:09 -0000
@@ -222,7 +222,7 @@
struct disklabel mfsfakelabel;
struct partition oldpartition;
struct statfs *mp;
- int ch, fsi, fso, len, maxpartitions, n, Fflag, Iflag, Zflag;
+ int ch, fsi, fso, len, maxpartitions, n, nolabel, Fflag, Iflag, Zflag;
char *cp, *endp, *s1, *s2, *special;
const char *opstring;
long long llsize;
@@ -239,7 +239,7 @@
cp = NULL;
fsi = fso = -1;
- Fflag = Iflag = Zflag = 0;
+ nolabel = Fflag = Iflag = Zflag = 0;
if (strstr(getprogname(), "mfs")) {
mfs = 1;
mfsmode = 01777; /* default mode for a /tmp-type directory */
@@ -532,19 +532,24 @@
++mp;
}
}
- cp = strchr(argv[0], '\0') - 1;
- if (cp == 0 || ((*cp < 'a' || *cp > ('a' + maxpartitions - 1))
- && !isdigit(*cp)))
- errx(1, "can't figure out file system partition");
#ifdef COMPAT
if (disktype == NULL)
disktype = argv[1];
#endif
lp = getdisklabel(special, fsi);
- if (isdigit(*cp))
- pp = &lp->d_partitions[0];
- else
- pp = &lp->d_partitions[*cp - 'a'];
+ nolabel = lp->d_bbsize == 0 && lp->d_sbsize == 0;
+ if (nolabel)
+ pp = &lp->d_partitions[RAW_PART];
+ else {
+ cp = strchr(argv[0], '\0') - 1;
+ if (cp == 0 || ((*cp < 'a' || *cp > ('a' + maxpartitions - 1))
+ && !isdigit(*cp)))
+ errx(1, "can't figure out file system partition");
+ if (isdigit(*cp))
+ pp = &lp->d_partitions[0];
+ else
+ pp = &lp->d_partitions[*cp - 'a'];
+ }
if (pp->p_size == 0)
errx(1, "`%c' partition is unavailable", *cp);
if (pp->p_fstype == FS_APPLEUFS)
@@ -626,7 +631,7 @@
}
oldpartition = *pp;
mkfs(pp, special, fsi, fso, mfsmode, mfsuid, mfsgid);
- if (!Nflag && memcmp(pp, &oldpartition, sizeof(oldpartition)) && !Fflag)
+ if (!Nflag && memcmp(pp, &oldpartition, sizeof(oldpartition)) && !Fflag && !nolabel)
rewritelabel(special, fso, lp);
if (!Nflag)
close(fso);
--1469824295-21717-1065887653=:1952
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Disposition: INLINE
You'll probably have to fill out the RAW_PART slot in the labels generated
by vinum instead of the LABEL_PART slot. And set its type to FS_BSDFFS,
like ccd and vnd do...
--
Christian Limpach <chris@pin.lu>
--1469824295-21717-1065887653=:1952--