mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 04:22:44 +00:00
mkuzip: drop support for executable uzip images
A uzip image has a 128-byte header, historically, this header could be executed as a shell script to mount the uzip image to a user provided mountpoint. The embedded shell commands only work for uzip images that were created with zlib or zstd compression that contained an ISO-9660 file system. Given the limited space available in the uzip header, it is not practical to extend this feature to include other file systems or to provide sensible error handling and error messages to the user. For these reasons, abandon the embedded shell script in the uzip image header. To maintain backwards compatibility, the shebang and shell must reside in the 128-byte header. This change of behavior is documented in mkuzip(8) and an example has been provided for creating/mounting uzip images. PR: 276174
This commit is contained in:
parent
d2d0d6cb47
commit
525a177c16
@ -25,17 +25,11 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Format L3.0, since we move to XZ API */
|
|
||||||
#define CLOOP_MAGIC_LZMA \
|
|
||||||
"#!/bin/sh\n" \
|
|
||||||
"#L3.0\n" \
|
|
||||||
"n=uncompress\n" \
|
|
||||||
"m=geom_$n\n" \
|
|
||||||
"(kldstat -m $m 2>&-||kldload $m)>&-&&" \
|
|
||||||
"mount_cd9660 /dev/`mdconfig -af $0`.$n $1\n" \
|
|
||||||
"exit $?\n"
|
|
||||||
#define DEFAULT_SUFX_LZMA ".ulzma"
|
#define DEFAULT_SUFX_LZMA ".ulzma"
|
||||||
|
|
||||||
|
/* Format L3.0, since we move to XZ API */
|
||||||
|
#define CLOOP_MAGIC_LZMA "#!/bin/sh\n#L3.0\n"
|
||||||
|
|
||||||
size_t mkuz_lzma_cbound(size_t);
|
size_t mkuz_lzma_cbound(size_t);
|
||||||
void *mkuz_lzma_init(int *);
|
void *mkuz_lzma_init(int *);
|
||||||
void mkuz_lzma_compress(void *, const struct mkuz_blk *, struct mkuz_blk *);
|
void mkuz_lzma_compress(void *, const struct mkuz_blk *, struct mkuz_blk *);
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_SUFX_ZLIB ".uzip"
|
#define DEFAULT_SUFX_ZLIB ".uzip"
|
||||||
|
|
||||||
#define CLOOP_MAGIC_ZLIB "#!/bin/sh\n#V2.0 Format\n" \
|
#define CLOOP_MAGIC_ZLIB "#!/bin/sh\n#V2.0 Format\n"
|
||||||
"(kldstat -qm g_uzip||kldload geom_uzip)>&-&&" \
|
|
||||||
"mount_cd9660 /dev/`mdconfig -af $0`.uzip $1\nexit $?\n"
|
|
||||||
|
|
||||||
size_t mkuz_zlib_cbound(size_t);
|
size_t mkuz_zlib_cbound(size_t);
|
||||||
void *mkuz_zlib_init(int *);
|
void *mkuz_zlib_init(int *);
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_SUFX_ZSTD ".uzst"
|
#define DEFAULT_SUFX_ZSTD ".uzst"
|
||||||
|
|
||||||
#define CLOOP_MAGIC_ZSTD "#!/bin/sh\n#Z4.0 Format\n" \
|
#define CLOOP_MAGIC_ZSTD "#!/bin/sh\n#Z4.0 Format\n"
|
||||||
"(kldstat -qm g_uzip||kldload geom_uzip)>&-&&" \
|
|
||||||
"mount_cd9660 /dev/`mdconfig -af $0`.uzip $1\nexit $?\n"
|
|
||||||
|
|
||||||
size_t mkuz_zstd_cbound(size_t);
|
size_t mkuz_zstd_cbound(size_t);
|
||||||
void *mkuz_zstd_init(int *);
|
void *mkuz_zstd_init(int *);
|
||||||
|
@ -207,23 +207,6 @@ The same tradeoff continues to apply: reads in
|
|||||||
.Xr geom_uzip 4
|
.Xr geom_uzip 4
|
||||||
become more expensive the greater the cluster size.
|
become more expensive the greater the cluster size.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
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.
|
|
||||||
The script tries to load the
|
|
||||||
.Xr geom_uzip 4
|
|
||||||
class if it is not loaded, configure the image as an
|
|
||||||
.Xr md 4
|
|
||||||
disk device using
|
|
||||||
.Xr mdconfig 8 ,
|
|
||||||
and automatically mount it using
|
|
||||||
.Xr mount_cd9660 8
|
|
||||||
on the mount point provided as the first argument to the script.
|
|
||||||
.Pp
|
|
||||||
The de-duplication is a
|
The de-duplication is a
|
||||||
.Fx
|
.Fx
|
||||||
specific feature and while it does not require any changes to on-disk
|
specific feature and while it does not require any changes to on-disk
|
||||||
@ -247,6 +230,34 @@ for
|
|||||||
.Dq 1 .
|
.Dq 1 .
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Ex -std
|
.Ex -std
|
||||||
|
.Sh EXAMPLES
|
||||||
|
.Pp
|
||||||
|
The following describes how to create and mount a uzip image.
|
||||||
|
.Pp
|
||||||
|
Create a file system image:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
makefs /src.img /usr/src
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Create the uzip image, the output file will be named src.img.uzip:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
mkuzip /src.img
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Ensure geom_uzip is loaded:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
kldload geom_uzip
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Create an MD device backed by the uzip image:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
mdconfig -f /src.img.uzip
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Mount the uzip image:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
mount -o ro /dev/md0.uzip /mnt
|
||||||
|
.Ed
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr gzip 1 ,
|
.Xr gzip 1 ,
|
||||||
.Xr xz 1 ,
|
.Xr xz 1 ,
|
||||||
|
@ -298,7 +298,7 @@ int main(int argc, char **argv)
|
|||||||
toc[hdr.nblocks] = 0;
|
toc[hdr.nblocks] = 0;
|
||||||
|
|
||||||
cfs.fdw = open(oname, (cfs.en_dedup ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT,
|
cfs.fdw = open(oname, (cfs.en_dedup ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT,
|
||||||
S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
if (cfs.fdw < 0) {
|
if (cfs.fdw < 0) {
|
||||||
err(1, "open(%s)", oname);
|
err(1, "open(%s)", oname);
|
||||||
/* Not reached */
|
/* Not reached */
|
||||||
|
Loading…
Reference in New Issue
Block a user