[Midnightbsd-cvs] src: usr.bin/mkuzip:
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Mar 25 18:15:55 EDT 2009
Log Message:
-----------
Modified Files:
--------------
src/usr.bin/mkuzip:
mkuzip.8 (r1.1.1.1 -> r1.2)
mkuzip.c (r1.1.1.1 -> r1.2)
-------------- next part --------------
Index: mkuzip.8
===================================================================
RCS file: /home/cvs/src/usr.bin/mkuzip/mkuzip.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/mkuzip/mkuzip.8 -L usr.bin/mkuzip/mkuzip.8 -u -r1.1.1.1 -r1.2
--- usr.bin/mkuzip/mkuzip.8
+++ usr.bin/mkuzip/mkuzip.8
@@ -5,9 +5,9 @@
.\" this stuff is worth it, you can buy me a beer in return. Maxim Sobolev
.\" ----------------------------------------------------------------------------
.\"
-.\" $FreeBSD: src/usr.bin/mkuzip/mkuzip.8,v 1.5 2005/01/18 13:43:51 ru Exp $
+.\" $FreeBSD: src/usr.bin/mkuzip/mkuzip.8,v 1.7 2006/09/29 15:20:46 ru Exp $
.\"
-.Dd September 10, 2004
+.Dd March 17, 2006
.Dt MKUZIP 8
.Os
.Sh NAME
@@ -24,37 +24,38 @@
.Sh DESCRIPTION
The
.Nm
-utility compresses a disk image file in such a way that the
+utility compresses a disk image file so that the
.Xr geom_uzip 4
-class will be able to decompress resulting image in run-time.
-This allows for significant reduction of size of disk image at
+class will be able to decompress the resulting image at run-time.
+This allows for a significant reduction of size of disk image at
the expense of some CPU time required to decompress the data each
time it is read.
-Internally, operation is done in two phases as follows:
+The
+.Nm
+utility
+works in two phases:
.Bl -enum
.It
An
.Ar infile
-image is split into clusters and each cluster compressed using
+image is split into clusters; each cluster is compressed using
.Xr zlib 3 .
.It
-Resulting set of compressed clusters along with headers allowing to
-independently locate each individual cluster is written into
-output file.
+The resulting set of compressed clusters along with headers that allow
+locating each individual cluster is written to the output file.
.El
.Pp
The options are:
.Bl -tag -width indent
.It Fl o Ar outfile
-Name the output file
+Name of the output file
.Ar outfile .
The default is to use the input name with the suffix
.Pa .uzip .
.It Fl s Ar cluster_size
-Use
+Split the image into clusters of
.Ar cluster_size
-as the size of chunks the file being split up into.
-Default value is 16384 bytes.
+bytes, 16384 bytes by default.
The
.Ar cluster_size
should be a multiple of 512 bytes.
@@ -62,33 +63,35 @@
Display verbose messages.
.El
.Sh NOTES
-Compression ratio largely depends on the cluster size used.
+The compression ratio largely depends on the cluster size used.
+.\" The following two sentences are unclear: how can gzip(1) be
+.\" used in a comparable fashion, and wouldn't a gzip-compressed
+.\" image suffer from larger cluster sizes as well?
For large cluster sizes (16K and higher), typical compression ratios
-are only 1-2% less than those achieved with the
-.Xr gzip 1
-utlity.
+are only 1-2% less than those achieved with
+.Xr gzip 1 .
However, it should be kept in mind that larger cluster
sizes lead to higher overhead in the
.Xr geom_uzip 4
class, as the class has to decompress the whole cluster even if
-only several bytes from that cluster have to be read.
+only a few bytes from that cluster have to be read.
.Pp
The
.Nm
-inserts tiny shell script at the beginning of the generated image,
+utility
+inserts a short shell script at the beginning of the generated image,
which makes it possible to
.Dq run
the image just like any other shell script.
-This script tries
-to load
+The script tries to load the
.Xr geom_uzip 4
-class if it is not loaded, configure image as an
+class if it is not loaded, configure the image as an
.Xr md 4
disk device using
-.Xr mdconfig 8
-utility, and automatically mount it using
+.Xr mdconfig 8 ,
+and automatically mount it using
.Xr mount_cd9660 8
-utility to the mount point provided as a first argument.
+on the mount point provided as the first argument to the script.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
Index: mkuzip.c
===================================================================
RCS file: /home/cvs/src/usr.bin/mkuzip/mkuzip.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/mkuzip/mkuzip.c -L usr.bin/mkuzip/mkuzip.c -u -r1.1.1.1 -r1.2
--- usr.bin/mkuzip/mkuzip.c
+++ usr.bin/mkuzip/mkuzip.c
@@ -6,11 +6,12 @@
* this stuff is worth it, you can buy me a beer in return. Maxim Sobolev
* ----------------------------------------------------------------------------
*
- * $FreeBSD: src/usr.bin/mkuzip/mkuzip.c,v 1.4 2005/05/11 17:02:38 fjoe Exp $
+ * $FreeBSD: src/usr.bin/mkuzip/mkuzip.c,v 1.6 2007/03/06 17:04:15 fjoe Exp $
*
*/
#include <sys/types.h>
+#include <sys/disk.h>
#include <sys/endian.h>
#include <sys/param.h>
#include <sys/stat.h>
@@ -122,10 +123,28 @@
signal(SIGXFSZ, exit);
atexit(cleanup);
- if (stat(iname, &sb) != 0) {
- err(1, "%s", iname);
+ fdr = open(iname, O_RDONLY);
+ if (fdr < 0) {
+ err(1, "open(%s)", iname);
+ /* Not reached */
+ }
+ if (fstat(fdr, &sb) != 0) {
+ err(1, "fstat(%s)", iname);
/* Not reached */
}
+ if (S_ISCHR(sb.st_mode)) {
+ off_t ms;
+
+ if (ioctl(fdr, DIOCGMEDIASIZE, &ms) < 0) {
+ err(1, "ioctl(DIOCGMEDIASIZE)");
+ /* Not reached */
+ }
+ sb.st_size = ms;
+ } else if (!S_ISREG(sb.st_mode)) {
+ fprintf(stderr, "%s: not a character device or regular file\n",
+ iname);
+ exit(1);
+ }
hdr.nblocks = sb.st_size / hdr.blksz;
if ((sb.st_size % hdr.blksz) != 0) {
if (verbose != 0)
@@ -135,15 +154,10 @@
}
toc = safe_malloc((hdr.nblocks + 1) * sizeof(*toc));
- fdr = open(iname, O_RDONLY);
- if (fdr < 0) {
- err(1, "%s", iname);
- /* Not reached */
- }
fdw = open(oname, O_WRONLY | O_TRUNC | O_CREAT,
S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (fdw < 0) {
- err(1, "%s", oname);
+ err(1, "open(%s)", oname);
/* Not reached */
}
cleanfile = oname;
@@ -185,7 +199,7 @@
DEV_BSIZE);
}
if (write(fdw, obuf, destlen) < 0) {
- err(1, "%s", oname);
+ err(1, "write(%s)", oname);
/* Not reached */
}
toc[i] = htobe64(offset);
@@ -204,7 +218,7 @@
/* Write headers into pre-allocated space */
lseek(fdw, 0, SEEK_SET);
if (writev(fdw, iov, 2) < 0) {
- err(1, "%s", oname);
+ err(1, "writev(%s)", oname);
/* Not reached */
}
cleanfile = NULL;
More information about the Midnightbsd-cvs
mailing list