From 785d5ade45d5c4273ed022c6e65f4287fd6512b5 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Fri, 31 May 2024 20:23:33 +0000 Subject: [PATCH] Pull changes from mkisofs-1.12.1 to avoid statvfs(2). --- external/gpl2/mkhybrid/dist/apple.c | 34 ++++++--------------------- external/gpl2/mkhybrid/dist/apple.h | 14 ----------- external/gpl2/mkhybrid/dist/mkisofs.c | 14 ++++++++--- external/gpl2/mkhybrid/dist/mkisofs.h | 2 +- 4 files changed, 19 insertions(+), 45 deletions(-) diff --git a/external/gpl2/mkhybrid/dist/apple.c b/external/gpl2/mkhybrid/dist/apple.c index ee332767b0cb..644065d86239 100644 --- a/external/gpl2/mkhybrid/dist/apple.c +++ b/external/gpl2/mkhybrid/dist/apple.c @@ -872,11 +872,6 @@ struct hfs_info * get_hfs_fe_info(struct hfs_info *hfs_info, char *name) { FILE *fp; -#ifdef __svr4__ - struct statvfs fsbuf; -#else - struct statfs fsbuf; -#endif /* __svr4__ */ int fe_num, fe_pad; fe_info info; int c = 0; @@ -889,30 +884,15 @@ get_hfs_fe_info(struct hfs_info *hfs_info, char *name) if ((fp = fopen(name, "rb")) == NULL) return(NULL); - /* The FAT cluster size may have been given on the command line - - if not they try and find *guess* it */ - if (!bsize) { - /* FINDER.DAT layout depends on the FAT cluster size - assume - this is mapped to the "fundamental file system block size" - For SVR4 we use statvfs(), others use statfs() */ -#ifdef __svr4__ - if (statvfs(name, &fsbuf) < 0) - return(NULL); - - bsize = fsbuf.f_frsize; -#else - if (statfs(name, &fsbuf) < 0) - return(NULL); - - bsize = fsbuf.f_bsize; -#endif /* __svr4__ */ - } - - if (bsize <= 0) + /* + * no longer attempt to find out FAT cluster + * - rely on command line parameter + */ + if (afe_size <= 0) return(NULL); - fe_num = bsize/FE_SIZE; - fe_pad = bsize%FE_SIZE; + fe_num = afe_size / FE_SIZE; + fe_pad = afe_size % FE_SIZE; while(fread(&info, 1, FE_SIZE, fp) != 0) { diff --git a/external/gpl2/mkhybrid/dist/apple.h b/external/gpl2/mkhybrid/dist/apple.h index 73de3d5dfd00..e070566838c3 100644 --- a/external/gpl2/mkhybrid/dist/apple.h +++ b/external/gpl2/mkhybrid/dist/apple.h @@ -10,20 +10,6 @@ #define __svr4__ /* maybe there's a "configure" solution ? */ #endif /* __sgi */ -#ifdef __svr4__ -#include -#else -#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__OpenBSD__) -#include -#else -#if defined(_IBMR2) -#include -#else -#include -#endif /* _IBMR2 */ -#endif /* __FreeBSD__ || __bsdi__ */ -#endif /* __svr4__ */ - #ifndef O_BINARY #define O_BINARY 0 #endif /* O_BINARY */ diff --git a/external/gpl2/mkhybrid/dist/mkisofs.c b/external/gpl2/mkhybrid/dist/mkisofs.c index 6de6edf9b5ce..1bbb732ce532 100644 --- a/external/gpl2/mkhybrid/dist/mkisofs.c +++ b/external/gpl2/mkhybrid/dist/mkisofs.c @@ -138,7 +138,7 @@ int probe = 0; /* search files for HFS/Unix type */ int nomacfiles = 0; /* don't look for Mac/Unix files */ int hfs_select = 0; /* Mac/Unix types to select */ int create_dt = 1; /* create the Desktp files */ -int bsize = 0; /* Apple File Exchange block size */ +int afe_size = 0; /* Apple File Exchange block size */ int hfs_last = MAG_LAST; /* process magic file after map file */ char *deftype = DEFTYPE; /* default Apple TYPE */ char *defcreator = DEFCREATOR; /* default Apple CREATOR */ @@ -1068,7 +1068,9 @@ int FDECL2(main, int, argc, char **, argv){ /* gen_pt = 1; */ break; case OPTION_BSIZE: - bsize = atoi(optarg); + afe_size = atoi(optarg); + hfs_select |= DO_FEU; + hfs_select |= DO_FEL; break; case OPTION_HFS_VOLID: hfs_volume_id = optarg; @@ -1164,7 +1166,7 @@ parse_input_files: /* if -probe, -macname, any hfs selection and/or mapping file is given, but no HFS option, then select apple_hyb */ if (!apple_hyb && !apple_ext) { - if (*afpfile || probe || mac_name || nomacfiles || hfs_select || hfs_boot_file || magic_file || hfs_ishidden() || gen_pt || autoname || bsize) + if (*afpfile || probe || mac_name || nomacfiles || hfs_select || hfs_boot_file || magic_file || hfs_ishidden() || gen_pt || autoname || afe_size) apple_hyb = 1; } @@ -1181,6 +1183,12 @@ parse_input_files: if (apple_hyb || apple_ext) apple_both = 1; + if (apple_both && verbose && !afe_size && + (hfs_select & (DO_FEU | DO_FEL))) { + fprintf(stderr, + "Warning: assuming PC Exchange cluster size of 512 bytes\n"); + afe_size = 512; + } if (apple_both) { /* set up the TYPE/CREATOR mappings */ hfs_init(afpfile, 0, probe, nomacfiles, hfs_select); diff --git a/external/gpl2/mkhybrid/dist/mkisofs.h b/external/gpl2/mkhybrid/dist/mkisofs.h index 80d6df04ba9c..18626c524500 100644 --- a/external/gpl2/mkhybrid/dist/mkisofs.h +++ b/external/gpl2/mkhybrid/dist/mkisofs.h @@ -316,7 +316,7 @@ extern char *defcreator; /* default Apple CREATOR */ extern char *trans_tbl; /* translation table name */ extern int gen_pt; /* generate HFS partition table */ extern char *autoname; /* Autostart filename */ -extern int bsize; /* Apple File Exchange block size */ +extern int afe_size; /* Apple File Exchange block size */ extern char *hfs_volume_id; /* HFS volume ID */ #define ASSOC_FLAG 4 /* ISO flag for "associated" file */ #define MAP_LAST 1 /* process magic then map file */