Pull changes from mkisofs-1.12.1 to avoid statvfs(2).

This commit is contained in:
tsutsui 2024-05-31 20:23:33 +00:00
parent 29b142dfe2
commit 785d5ade45
4 changed files with 19 additions and 45 deletions

View File

@ -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)
/*
* no longer attempt to find out FAT cluster
* - rely on command line parameter
*/
if (afe_size <= 0)
return(NULL);
bsize = fsbuf.f_frsize;
#else
if (statfs(name, &fsbuf) < 0)
return(NULL);
bsize = fsbuf.f_bsize;
#endif /* __svr4__ */
}
if (bsize <= 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) {

View File

@ -10,20 +10,6 @@
#define __svr4__ /* maybe there's a "configure" solution ? */
#endif /* __sgi */
#ifdef __svr4__
#include <sys/statvfs.h>
#else
#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__OpenBSD__)
#include <sys/mount.h>
#else
#if defined(_IBMR2)
#include <sys/statfs.h>
#else
#include <sys/vfs.h>
#endif /* _IBMR2 */
#endif /* __FreeBSD__ || __bsdi__ */
#endif /* __svr4__ */
#ifndef O_BINARY
#define O_BINARY 0
#endif /* O_BINARY */

View File

@ -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);

View File

@ -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 */