mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-26 20:12:44 +00:00
mkimg(1): process non-seekable output gracefully
mkimg may make severe load only to fail in the end if output is non-seekable pipe, socket or FIFO unless output format is raw disk image. Check it out and fail early. Make it clear in the manual. MFC after: 1 week
This commit is contained in:
parent
5b35479e3e
commit
7f0dc6e2cd
@ -22,7 +22,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd February 28, 2024
|
||||
.Dd March 12, 2024
|
||||
.Dt MKIMG 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -64,6 +64,7 @@ The image file is a raw disk image by default, but the format of the
|
||||
image file can be specified with the
|
||||
.Ar format
|
||||
argument.
|
||||
Most formats require seekable output, except of raw disk image.
|
||||
.Pp
|
||||
The disk image can be made bootable by specifying the scheme-specific boot
|
||||
block contents with the
|
||||
|
@ -555,6 +555,7 @@ mkimg(void)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const char *format_name;
|
||||
int bcfd, outfd;
|
||||
int c, error;
|
||||
|
||||
@ -699,6 +700,7 @@ main(int argc, char *argv[])
|
||||
errc(EX_DATAERR, error, "boot code");
|
||||
}
|
||||
|
||||
format_name = format_selected()->name;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Logical sector size: %u\n", secsz);
|
||||
fprintf(stderr, "Physical block size: %u\n", blksz);
|
||||
@ -709,10 +711,20 @@ main(int argc, char *argv[])
|
||||
fprintf(stderr, "Partitioning scheme: %s\n",
|
||||
scheme_selected()->name);
|
||||
fprintf(stderr, "Output file format: %s\n",
|
||||
format_selected()->name);
|
||||
format_name);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
#if defined(SPARSE_WRITE)
|
||||
/*
|
||||
* sparse_write() fails if output is not seekable so fail early
|
||||
* not wasting some load unless output format is raw
|
||||
*/
|
||||
if (strcmp("raw", format_name) &&
|
||||
lseek(outfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
|
||||
errx(EX_USAGE, "%s: output must be seekable", format_name);
|
||||
#endif
|
||||
|
||||
error = image_init();
|
||||
if (error)
|
||||
errc(EX_OSERR, error, "cannot initialize");
|
||||
|
Loading…
Reference in New Issue
Block a user