git: 4311c5b3db25 - stable/13 - makefs: #define Apple Partition bits

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 14 Apr 2023 12:52:51 UTC
The branch stable/13 has been updated by emaste:

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

commit 4311c5b3db25c929a2f3d08a8d74d6a08f5cffc0
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-03-30 16:45:18 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-14 12:10:37 +0000

    makefs: #define Apple Partition bits
    
    NetBSD defines these in sys/bootblock.h, which we don't have.  Add local
    defintions in cd9660_eltorito.c (as OpenBSD did) to reduce diffs between
    the three makefs implementations.
    
    Obtained from:  OpenBSD
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit f0bef3d20eb6e28cf66a42c6d34fdfe80a784365)
---
 usr.sbin/makefs/cd9660/cd9660_eltorito.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 0a57c91a659e..6d7a32378b64 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -41,6 +41,14 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+/*
+ * Partition Status Information from Apple Tech Note 1189
+ */
+#define	APPLE_PS_VALID		0x00000001	/* Entry is valid */
+#define	APPLE_PS_ALLOCATED	0x00000002	/* Entry is allocated */
+#define	APPLE_PS_READABLE	0x00000010	/* Entry is readable */
+#define	APPLE_PS_WRITABLE	0x00000020	/* Entry is writable */
+
 #ifdef DEBUG
 #define	ELTORITO_DPRINTF(__x)	printf __x
 #else
@@ -574,15 +582,8 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
 	uint32_t apm32, part_status;
 	uint16_t apm16;
 
-	/* See Apple Tech Note 1189 for the details about the pmPartStatus
-	 * flags.
-	 * Below the flags which are default:
-	 * - IsValid     0x01
-	 * - IsAllocated 0x02
-	 * - IsReadable  0x10
-	 * - IsWritable  0x20
-	 */
-	part_status = 0x01 | 0x02 | 0x10 | 0x20;
+	part_status = APPLE_PS_VALID | APPLE_PS_ALLOCATED | APPLE_PS_READABLE |
+	    APPLE_PS_WRITABLE;
 
 	if (fseeko(fd, (off_t)(idx + 1) * sector_size, SEEK_SET) == -1)
 		err(1, "fseeko");