From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 30 10:34:36 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38EC816A4CE for ; Thu, 30 Dec 2004 10:34:36 +0000 (GMT) Received: from gandalf.online.bg (gandalf.online.bg [217.75.128.9]) by mx1.FreeBSD.org (Postfix) with SMTP id 1BF1F43D31 for ; Thu, 30 Dec 2004 10:34:35 +0000 (GMT) (envelope-from roam@ringlet.net) Received: (qmail 8331 invoked from network); 30 Dec 2004 10:34:31 -0000 Received: from unknown (HELO straylight.ringlet.net) (213.16.36.84) by gandalf.online.bg with SMTP; 30 Dec 2004 10:34:31 -0000 Received: (qmail 1942 invoked by uid 1000); 30 Dec 2004 10:34:33 -0000 Date: Thu, 30 Dec 2004 12:34:33 +0200 From: Peter Pentchev To: Matteo Riondato Message-ID: <20041230103433.GB830@straylight.m.ringlet.net> Mail-Followup-To: Matteo Riondato , freebsd-hackers@freebsd.org, Maxim Sobolev References: <1104358540.2895.10.camel@kaiser.sig11.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wq9mPyueHGvFACwf" Content-Disposition: inline In-Reply-To: <1104358540.2895.10.camel@kaiser.sig11.org> User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org cc: Maxim Sobolev Subject: Re: Creating Compressed Loop FS from stdin X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2004 10:34:36 -0000 --wq9mPyueHGvFACwf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 29, 2004 at 11:15:40PM +0100, Matteo Riondato wrote: > Hi folks! >=20 > I think you know what FreeSBIE > is and that we use compressed loop filesystems for /usr and /var > directories on our LiveCD.=20 > At the moment, to create compressed filesystems, we rely on > sysutils/cloop-utils, but I know /usr/bin/mkuzip is present in HEAD and > in RELENG_5 and would like to switch to that. However, it seems that I > cannot create valid cloopfs with mkuzip. > To create the cloop image, I use: >=20 > /usr/local/bin/mkisofs -lrJL $FREESBIEBASEDIR/usr | /usr/bin/mkuzip -v \ > -o $FREESBIEBASEDIR/cloop/usr.cloop -s 65536 /dev/stdin Well, as you can see from the very first line output by mkuzip in that case (if -v is indeed specified), it thinks that the input file is 0 bytes long. This is so because the first thing mkuzip does is a stat(2) on the input file descriptor, and when you point it at /dev/stdin, stat() returns a length of 0 bytes since it is impossible to determine beforehand how much data will be produced by the pipe. This could be fixed by the following patch. I'm CC'ing Maxim Sobolev, the author of mkuzip(8); Maxim, do you have any objections to this patch? G'luck, Peter Index: src/usr.bin/mkuzip/mkuzip.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/usr.bin/mkuzip/mkuzip.c,v retrieving revision 1.2 diff -u -r1.2 mkuzip.c --- src/usr.bin/mkuzip/mkuzip.c 10 Sep 2004 23:16:05 -0000 1.2 +++ src/usr.bin/mkuzip/mkuzip.c 30 Dec 2004 10:32:38 -0000 @@ -122,10 +122,23 @@ signal(SIGXFSZ, exit); atexit(cleanup); =20 - if (stat(iname, &sb) !=3D 0) { + fdr =3D open(iname, O_RDONLY); + if (fdr < 0) { err(1, "%s", iname); /* Not reached */ } + + /* Try seeking to the end; if that fails, fall back to fstat() */ + sb.st_size =3D lseek(fdr, 0, SEEK_END); + if (sb.st_size < 1 && fstat(fdr, &sb) !=3D 0) { + err(1, "%s", iname); + /* Not reached */ + } + if (sb.st_size < 1) { + errx(1, "Could not determine the size of %s", iname); + /* Not reached */ + } + lseek(fdr, 0, SEEK_SET); hdr.nblocks =3D sb.st_size / hdr.blksz; if ((sb.st_size % hdr.blksz) !=3D 0) { if (verbose !=3D 0) @@ -135,11 +148,6 @@ } toc =3D safe_malloc((hdr.nblocks + 1) * sizeof(*toc)); =20 - fdr =3D open(iname, O_RDONLY); - if (fdr < 0) { - err(1, "%s", iname); - /* Not reached */ - } fdw =3D open(oname, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fdw < 0) { --=20 Peter Pentchev roam@ringlet.net roam@cnsys.bg roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 This sentence claims to be an Epimenides paradox, but it is lying. --wq9mPyueHGvFACwf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFB09m57Ri2jRYZRVMRAlRcAKCH3qxE19Ay+kvmF0Ot6L/tlXzCEgCeJ7UL bAPkDq8VR/D1OpkMkNEPGag= =Zn97 -----END PGP SIGNATURE----- --wq9mPyueHGvFACwf--