Bug 276174 - mkuzip creates images with an invalid startup script
Summary: mkuzip creates images with an invalid startup script
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-07 12:45 UTC by Bill Blake
Modified: 2024-01-12 20:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Blake 2024-01-07 12:45:32 UTC
The mkuzip documentation says that you can just run the script at the start of an image it creates to mdconfig and mount the image.  Those scripts don't work, for two reasons.  First, the /dev/md0.<suffix> are created with a suffix of uzip, which is not what the scripts expect.  Second, the .uzip images are ordinary read-only file systems, mounted with /sbin/mount; the script is trying to mount them using mount_cd9660, which isn't likely to work.
Comment 1 Robert Wing freebsd_committer freebsd_triage 2024-01-07 18:08:37 UTC
(In reply to Bill Blake from comment #0)

Can you give the sequence of commands/configuration you're using?

And demonstrate where it's going wrong and what you expect?
Comment 2 Bill Blake 2024-01-07 20:19:13 UTC
These are the commands and the resulting script that is put at the start of each out.img file:

> mkuzip -A zstd -o out.img in.img
#!/bin/sh
#Z4.0 Format
(kldstat -qm g_uzip||kldload geom_uzip)>&-&&mount_cd9660 /dev/`mdconfig -af $0`.uzip $1
exit $?

> mkuzip -A lzma -o out.img in.img
#!/bin/sh
#L3.0
n=uncompress
m=geom_$n
(kldstat -m $m 2>&-||kldload $m)>&-&&mount_cd9660 /dev/`mdconfig -af $0`.$n $1
exit $?

> mkuzip -A zlib -o out.img in.img
#!/bin/sh
#V2.0 Format
(kldstat -qm g_uzip||kldload geom_uzip)>&-&&mount_cd9660 /dev/`mdconfig -af $0`.uzip $1
exit $?

I can't speak to the kldstat/kldload stuff since I didn't actually run these scripts.  However, look at the second example, which uses lzma.  It tries to mount /dev/md*.uncompress.  However, the mdconfig creates /dev/md*.uzip, so the mount fails. (I did the commands manually to confirm that this sequence doesn't work.)  The other two correctly use the .uzip device.  But in all three cases, the mount is mount_cd9660, which won't work since the file systems actually created are ufs file systems.  They need "mount -o ro" instead.  (Again, manually confirmed.)

Also, a nitpick: The mdconfig calls should have an option "-o ro".  Where it matters is when the config'd image is on a read-only file system; mdconfig will generate an error message without the read-only option, though it still configs the file.
Comment 3 Robert Wing freebsd_committer freebsd_triage 2024-01-10 19:11:58 UTC
(In reply to Bill Blake from comment #2)

Alright, I see what you mean - thanks for the info.

There seems to be a few issues here, I'll check it out.

also, note that mdconfig has a "-o readonly" option
Comment 4 Robert Wing freebsd_committer freebsd_triage 2024-01-12 20:27:24 UTC
proposed fix https://reviews.freebsd.org/D43425