userland|unprivileged file system handling tools
Luigi Rizzo
rizzo at icir.org
Tue Mar 23 16:05:32 PST 2004
On Tue, Mar 23, 2004 at 04:42:48PM -0600, diz at linuxpowered.com wrote:
> hi,
...
> As far as -current goes, mknod is not anything worth mentioning because of
> devfs. My sysgen scripts (wifibsd) are divided into what requires root,
> and what doesn't. My observation is that only mdconfig requires root, and
right now i can produce -current images without root privs
by using makefs (with a bugfix, attached)
and the attached patch to disklabel.
The -stable version still needs a trick for device nodes,
that probably can be handled by makefs itself (which uses
NetBSD's version of mtree which apparently accepts a
device number for device nodes), though I haven't tried it.
cheers
luigi
> -Jon Disnard
> (aka masta)
> irc.freenode.net
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
-------------- next part --------------
Index: disklabel.c
===================================================================
RCS file: /home/ncvs/src/sbin/disklabel/Attic/disklabel.c,v
retrieving revision 1.28.2.15
diff -u -r1.28.2.15 disklabel.c
--- disklabel.c 24 Jan 2003 16:18:16 -0000 1.28.2.15
+++ disklabel.c 23 Mar 2004 16:48:13 -0000
@@ -158,6 +158,9 @@
#define OPTIONS "BNRWb:enrs:w"
#endif
+int is_file; /* use a file, "-f" option */
+
+
int
main(int argc, char *argv[])
{
@@ -166,8 +169,12 @@
int ch, f = 0, flag, error = 0;
char *name = 0;
- while ((ch = getopt(argc, argv, OPTIONS)) != -1)
+ while ((ch = getopt(argc, argv, OPTIONS "f")) != -1)
switch (ch) {
+ case 'f':
+ is_file++;
+ break;
+
#if NUMBOOT > 0
case 'B':
++installboot;
@@ -450,6 +457,7 @@
* disable after writing.
*/
flag = 1;
+ if (!is_file)
if (ioctl(f, DIOCWLABEL, &flag) < 0)
warn("ioctl DIOCWLABEL");
if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) {
@@ -1575,6 +1583,31 @@
char namebuf[BBSIZE];
int f;
+ if (is_file) {
+ struct disklabel *lp = &lab;
+ off_t sz;
+
+ if ((f = open(dkname, O_RDONLY)) == -1) {
+ warn("cannot open %s", namebuf);
+ return (NULL);
+ }
+ sz = lseek(f, (off_t)0, SEEK_END);
+ bzero(lp, sizeof(*lp));
+ lp->d_magic = lp->d_magic2 = DISKMAGIC;
+ lp->d_secsize = DEV_BSIZE;
+ lp->d_bbsize = BBSIZE;
+ lp->d_sbsize = SBSIZE;
+ lp->d_npartitions = 8; /* XXX */
+ lp->d_nsectors = sz/DEV_BSIZE; /* XXX */
+ lp->d_ntracks = 1;
+ lp->d_ncylinders = 1;
+ lp->d_interleave = 1;
+ lp->d_rpm = 3600;
+ lp->d_secpercyl = lp->d_nsectors;
+ lp->d_secperunit = lp->d_nsectors;
+ lp->d_partitions[2].p_size = lp->d_nsectors;
+ goto done;
+ }
if (dkname[0] == '/') {
warnx("\"auto\" requires the usage of a canonical disk name");
return (NULL);
@@ -1596,6 +1630,7 @@
return (NULL);
}
}
+ done:
close(f);
lab.d_boot0 = NULL;
lab.d_boot1 = NULL;
-------------- next part --------------
diff -ubwr work/makefs-20031215/netbsdsrc/usr.sbin/makefs/ffs.c work-luigi/makefs-20031215/netbsdsrc/usr.sbin/makefs/ffs.c
--- work/makefs-20031215/netbsdsrc/usr.sbin/makefs/ffs.c Wed Dec 17 19:53:31 2003
+++ work-luigi/makefs-20031215/netbsdsrc/usr.sbin/makefs/ffs.c Mon Mar 22 23:08:39 2004
@@ -254,7 +254,22 @@
/* write out superblock; image is now complete */
((struct fs *)fsopts->superblock)->fs_fmod = 0;
+ /*
+ * update fs_old_cstotal
+ */
+ ((struct fs *)fsopts->superblock)->fs_old_cstotal.cs_ndir =
+ ((struct fs *)fsopts->superblock)->fs_cstotal.cs_ndir;
+ ((struct fs *)fsopts->superblock)->fs_old_cstotal.cs_nbfree =
+ ((struct fs *)fsopts->superblock)->fs_cstotal.cs_nbfree;
+ ((struct fs *)fsopts->superblock)->fs_old_cstotal.cs_nifree =
+ ((struct fs *)fsopts->superblock)->fs_cstotal.cs_nifree;
+ ((struct fs *)fsopts->superblock)->fs_old_cstotal.cs_nffree =
+ ((struct fs *)fsopts->superblock)->fs_cstotal.cs_nffree;
+
ffs_write_superblock(fsopts->superblock, fsopts);
+ printf("ndir now %d\n",
+ ((struct fs *)fsopts->superblock)->fs_cstotal.cs_ndir);
+
if (close(fsopts->fd) == -1)
err(1, "Closing `%s'", image);
fsopts->fd = -1;
More information about the freebsd-current
mailing list