git: b45f84cc6213 - main - makefs: Exit with error if writing cd image fails

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 23 Dec 2024 16:05:05 UTC
The branch main has been updated by emaste:

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

commit b45f84cc6213854ead00a4bfc7973332eda65676
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-23 15:54:32 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-12-23 16:03:36 +0000

    makefs: Exit with error if writing cd image fails
    
    Obtained from:  OpenBSD c8f48d9b1ea9
    Sponsored by:   The FreeBSD Foundation
---
 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 19bd6e0d21b0..d3baa3b78a6e 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -462,7 +462,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;
@@ -604,7 +604,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);
@@ -616,7 +616,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 */