git: afb7a85e52c3 - stable/14 - makefs: Exit with error if writing cd image fails

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 30 Dec 2024 22:20:15 UTC
The branch stable/14 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=afb7a85e52c323aca544f0d235b67123bf87d342

commit afb7a85e52c323aca544f0d235b67123bf87d342
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-23 15:54:32 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-12-30 22:20:04 +0000

    makefs: Exit with error if writing cd image fails
    
    Obtained from:  OpenBSD c8f48d9b1ea9
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b45f84cc6213854ead00a4bfc7973332eda65676)
---
 usr.sbin/makefs/cd9660.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 7ce9a3b6cbb2..bb3a86b7c8b5 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -465,7 +465,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
     fsinfo_t *fsopts)
 {
 	int64_t startoffset;
-	int numDirectories;
+	int ret, numDirectories;
 	uint64_t pathTableSectors;
 	int64_t firstAvailableSector;
 	int64_t totalSpace;
@@ -611,7 +611,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
 	if (diskStructure->include_padding_areas)
 		diskStructure->totalSectors += 150;
 
-	cd9660_write_image(diskStructure, image);
+	ret = cd9660_write_image(diskStructure, image);
 
 	if (diskStructure->verbose_level > 1) {
 		debug_print_volume_descriptor_information(diskStructure);
@@ -623,7 +623,10 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
 	cd9660_free_structure(real_root);
 
 	if (diskStructure->verbose_level > 0)
-		printf("%s: done\n", __func__);
+		printf("%s: done ret = %d\n", __func__, ret);
+
+	if (ret == 0)	/* cd9660_write_image() failed */
+		exit(1);
 }
 
 /* Generic function pointer - implement later */