summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbenno <benno@FreeBSD.org>2018-04-25 01:12:40 +0000
committerbenno <benno@FreeBSD.org>2018-04-25 01:12:40 +0000
commit84210c92cdf6e89644eeb912a3b4009f098149c9 (patch)
treec12277d5ddce641469376e52217eb9e931aecb5f /usr.sbin
parent26bdcfd01a2a20c834daa12856cbd6de7118c4ae (diff)
downloadFreeBSD-src-84210c92cdf6e89644eeb912a3b4009f098149c9.zip
FreeBSD-src-84210c92cdf6e89644eeb912a3b4009f098149c9.tar.gz
MFC r314117
makefs: eliminate global cd9660 structure For diff reduction with NetBSD NetBSD file versions: cd9660.c 1.39 cd9660.h 1.19 cd9660/cd9660_debug.c 1.12 cd9660/cd9660_eltorito.c 1.20 cd9660/cd9660_write.c 1.16 cd9660/iso9660_rrip.c 1.12 cd9660/iso9660_rrip.h 1.6 Sponsored by: iXsystems, Inc.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/makefs/cd9660.c624
-rw-r--r--usr.sbin/makefs/cd9660.h27
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_debug.c10
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.c102
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_write.c134
-rw-r--r--usr.sbin/makefs/cd9660/iso9660_rrip.c58
-rw-r--r--usr.sbin/makefs/cd9660/iso9660_rrip.h12
7 files changed, 506 insertions, 461 deletions
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 946ef2e..d7c8c75 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -110,58 +110,59 @@ __FBSDID("$FreeBSD$");
#include "cd9660/iso9660_rrip.h"
#include "cd9660/cd9660_archimedes.h"
-/*
- * Global variables
- */
-iso9660_disk diskStructure;
-
-static void cd9660_finalize_PVD(void);
+static void cd9660_finalize_PVD(iso9660_disk *);
static cd9660node *cd9660_allocate_cd9660node(void);
-static void cd9660_set_defaults(void);
+static void cd9660_set_defaults(iso9660_disk *);
static int cd9660_arguments_set_string(const char *, const char *, int,
char, char *);
static void cd9660_populate_iso_dir_record(
struct _iso_directory_record_cd9660 *, u_char, u_char, u_char,
const char *);
-static void cd9660_setup_root_node(void);
-static int cd9660_setup_volume_descriptors(void);
+static void cd9660_setup_root_node(iso9660_disk *);
+static int cd9660_setup_volume_descriptors(iso9660_disk *);
#if 0
static int cd9660_fill_extended_attribute_record(cd9660node *);
#endif
static void cd9660_sort_nodes(cd9660node *);
-static int cd9660_translate_node_common(cd9660node *);
-static int cd9660_translate_node(fsnode *, cd9660node *);
+static int cd9660_translate_node_common(iso9660_disk *, cd9660node *);
+static int cd9660_translate_node(iso9660_disk *, fsnode *, cd9660node *);
static int cd9660_compare_filename(const char *, const char *);
static void cd9660_sorted_child_insert(cd9660node *, cd9660node *);
-static int cd9660_handle_collisions(cd9660node *, int);
-static cd9660node *cd9660_rename_filename(cd9660node *, int, int);
-static void cd9660_copy_filenames(cd9660node *);
+static int cd9660_handle_collisions(iso9660_disk *, cd9660node *, int);
+static cd9660node *cd9660_rename_filename(iso9660_disk *, cd9660node *, int,
+ int);
+static void cd9660_copy_filenames(iso9660_disk *, cd9660node *);
static void cd9660_sorting_nodes(cd9660node *);
static int cd9660_count_collisions(cd9660node *);
-static cd9660node *cd9660_rrip_move_directory(cd9660node *);
-static int cd9660_add_dot_records(cd9660node *);
+static cd9660node *cd9660_rrip_move_directory(iso9660_disk *, cd9660node *);
+static int cd9660_add_dot_records(iso9660_disk *, cd9660node *);
-static void cd9660_convert_structure(fsnode *, cd9660node *, int,
+static void cd9660_convert_structure(iso9660_disk *, fsnode *, cd9660node *, int,
int *, int *);
static void cd9660_free_structure(cd9660node *);
-static int cd9660_generate_path_table(void);
-static int cd9660_level1_convert_filename(const char *, char *, int);
-static int cd9660_level2_convert_filename(const char *, char *, int);
+static int cd9660_generate_path_table(iso9660_disk *);
+static int cd9660_level1_convert_filename(iso9660_disk *, const char *, char *,
+ int);
+static int cd9660_level2_convert_filename(iso9660_disk *, const char *, char *,
+ int);
#if 0
-static int cd9660_joliet_convert_filename(const char *, char *, int);
+static int cd9660_joliet_convert_filename(iso9660_disk *, const char *, char *,
+ int);
#endif
-static int cd9660_convert_filename(const char *, char *, int);
-static void cd9660_populate_dot_records(cd9660node *);
-static int64_t cd9660_compute_offsets(cd9660node *, int64_t);
+static int cd9660_convert_filename(iso9660_disk *, const char *, char *, int);
+static void cd9660_populate_dot_records(iso9660_disk *, cd9660node *);
+static int64_t cd9660_compute_offsets(iso9660_disk *, cd9660node *, int64_t);
#if 0
static int cd9660_copy_stat_info(cd9660node *, cd9660node *, int);
#endif
-static cd9660node *cd9660_create_virtual_entry(const char *, cd9660node *, int,
- int);
-static cd9660node *cd9660_create_file(const char *, cd9660node *, cd9660node *);
-static cd9660node *cd9660_create_directory(const char *, cd9660node *,
+static cd9660node *cd9660_create_virtual_entry(iso9660_disk *, const char *,
+ cd9660node *, int, int);
+static cd9660node *cd9660_create_file(iso9660_disk *, const char *,
+ cd9660node *, cd9660node *);
+static cd9660node *cd9660_create_directory(iso9660_disk *, const char *,
+ cd9660node *, cd9660node *);
+static cd9660node *cd9660_create_special_directory(iso9660_disk *, u_char,
cd9660node *);
-static cd9660node *cd9660_create_special_directory(u_char, cd9660node *);
/*
@@ -192,72 +193,79 @@ int cd9660_defaults_set = 0;
* Set default values for cd9660 extension to makefs
*/
static void
-cd9660_set_defaults(void)
+cd9660_set_defaults(iso9660_disk *diskStructure)
{
/*Fix the sector size for now, though the spec allows for other sizes*/
- diskStructure.sectorSize = 2048;
+ diskStructure->sectorSize = 2048;
/* Set up defaults in our own structure */
- diskStructure.verbose_level = 0;
- diskStructure.keep_bad_images = 0;
- diskStructure.follow_sym_links = 0;
- diskStructure.isoLevel = 2;
+ diskStructure->verbose_level = 0;
+ diskStructure->keep_bad_images = 0;
+ diskStructure->follow_sym_links = 0;
+ diskStructure->isoLevel = 2;
- diskStructure.rock_ridge_enabled = 0;
- diskStructure.rock_ridge_renamed_dir_name = 0;
- diskStructure.rock_ridge_move_count = 0;
- diskStructure.rr_moved_dir = 0;
+ diskStructure->rock_ridge_enabled = 0;
+ diskStructure->rock_ridge_renamed_dir_name = 0;
+ diskStructure->rock_ridge_move_count = 0;
+ diskStructure->rr_moved_dir = 0;
- diskStructure.archimedes_enabled = 0;
- diskStructure.chrp_boot = 0;
+ diskStructure->archimedes_enabled = 0;
+ diskStructure->chrp_boot = 0;
- diskStructure.include_padding_areas = 1;
+ diskStructure->include_padding_areas = 1;
/* Spec breaking functionality */
- diskStructure.allow_deep_trees =
- diskStructure.allow_start_dot =
- diskStructure.allow_max_name =
- diskStructure.allow_illegal_chars =
- diskStructure.allow_lowercase =
- diskStructure.allow_multidot =
- diskStructure.omit_trailing_period = 0;
+ diskStructure->allow_deep_trees =
+ diskStructure->allow_start_dot =
+ diskStructure->allow_max_name =
+ diskStructure->allow_illegal_chars =
+ diskStructure->allow_lowercase =
+ diskStructure->allow_multidot =
+ diskStructure->omit_trailing_period = 0;
/* Make sure the PVD is clear */
- memset(&diskStructure.primaryDescriptor, 0, 2048);
+ memset(&diskStructure->primaryDescriptor, 0, 2048);
- memset(diskStructure.primaryDescriptor.publisher_id, 0x20,128);
- memset(diskStructure.primaryDescriptor.preparer_id, 0x20,128);
- memset(diskStructure.primaryDescriptor.application_id, 0x20,128);
- memset(diskStructure.primaryDescriptor.copyright_file_id, 0x20,37);
- memset(diskStructure.primaryDescriptor.abstract_file_id, 0x20,37);
- memset(diskStructure.primaryDescriptor.bibliographic_file_id, 0x20,37);
+ memset(diskStructure->primaryDescriptor.publisher_id, 0x20,128);
+ memset(diskStructure->primaryDescriptor.preparer_id, 0x20,128);
+ memset(diskStructure->primaryDescriptor.application_id, 0x20,128);
+ memset(diskStructure->primaryDescriptor.copyright_file_id, 0x20,37);
+ memset(diskStructure->primaryDescriptor.abstract_file_id, 0x20,37);
+ memset(diskStructure->primaryDescriptor.bibliographic_file_id, 0x20,37);
- strcpy(diskStructure.primaryDescriptor.system_id, "FreeBSD");
+ strcpy(diskStructure->primaryDescriptor.system_id, "FreeBSD");
cd9660_defaults_set = 1;
/* Boot support: Initially disabled */
- diskStructure.has_generic_bootimage = 0;
- diskStructure.generic_bootimage = NULL;
+ diskStructure->has_generic_bootimage = 0;
+ diskStructure->generic_bootimage = NULL;
- diskStructure.boot_image_directory = 0;
- /*memset(diskStructure.boot_descriptor, 0, 2048);*/
+ diskStructure->boot_image_directory = 0;
+ /*memset(diskStructure->boot_descriptor, 0, 2048);*/
- diskStructure.is_bootable = 0;
- TAILQ_INIT(&diskStructure.boot_images);
- LIST_INIT(&diskStructure.boot_entries);
+ diskStructure->is_bootable = 0;
+ TAILQ_INIT(&diskStructure->boot_images);
+ LIST_INIT(&diskStructure->boot_entries);
}
void
-cd9660_prep_opts(fsinfo_t *fsopts __unused)
+cd9660_prep_opts(fsinfo_t *fsopts)
{
- cd9660_set_defaults();
+ iso9660_disk *diskStructure;
+
+ if ((diskStructure = calloc(1, sizeof(*diskStructure))) == NULL)
+ err(EXIT_FAILURE, "%s: calloc", __func__);
+
+ fsopts->fs_specific = diskStructure;
+
+ cd9660_set_defaults(diskStructure);
}
void
-cd9660_cleanup_opts(fsinfo_t *fsopts __unused)
+cd9660_cleanup_opts(fsinfo_t *fsopts)
{
-
+ free(fsopts->fs_specific);
}
static int
@@ -296,20 +304,19 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
{
char *var, *val;
int rv;
+ iso9660_disk *diskStructure = fsopts->fs_specific;
+
/* Set up allowed options - integer options ONLY */
option_t cd9660_options[] = {
- { "l", &diskStructure.isoLevel, 1, 2, "ISO Level" },
- { "isolevel", &diskStructure.isoLevel, 1, 2, "ISO Level" },
- { "verbose", &diskStructure.verbose_level, 0, 2,
+ { "l", &diskStructure->isoLevel, 1, 2, "ISO Level" },
+ { "isolevel", &diskStructure->isoLevel, 1, 2, "ISO Level" },
+ { "verbose", &diskStructure->verbose_level, 0, 2,
"Turns on verbose output" },
- { "v", &diskStructure.verbose_level, 0 , 2,
+ { "v", &diskStructure->verbose_level, 0 , 2,
"Turns on verbose output"},
{ .name = NULL }
};
- if (cd9660_defaults_set == 0)
- cd9660_set_defaults();
-
/*
* Todo : finish implementing this, and make a function that
* parses them
@@ -336,33 +343,33 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
/* First handle options with no parameters */
if (strcmp(var, "h") == 0) {
- diskStructure.displayHelp = 1;
+ diskStructure->displayHelp = 1;
rv = 1;
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "S", "follow-symlinks")) {
/* this is not handled yet */
- diskStructure.follow_sym_links = 1;
+ diskStructure->follow_sym_links = 1;
rv = 1;
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "L", "label")) {
rv = cd9660_arguments_set_string(val, "Disk Label", 32, 'd',
- diskStructure.primaryDescriptor.volume_id);
+ diskStructure->primaryDescriptor.volume_id);
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "applicationid")) {
rv = cd9660_arguments_set_string(val, "Application Identifier", 128, 'a',
- diskStructure.primaryDescriptor.application_id);
+ diskStructure->primaryDescriptor.application_id);
} else if(CD9660_IS_COMMAND_ARG_DUAL(var, "P", "publisher")) {
rv = cd9660_arguments_set_string(val, "Publisher Identifier",
- 128, 'a', diskStructure.primaryDescriptor.publisher_id);
+ 128, 'a', diskStructure->primaryDescriptor.publisher_id);
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "p", "preparer")) {
rv = cd9660_arguments_set_string(val, "Preparer Identifier",
- 128, 'a', diskStructure.primaryDescriptor.preparer_id);
+ 128, 'a', diskStructure->primaryDescriptor.preparer_id);
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "V", "volumeid")) {
rv = cd9660_arguments_set_string(val, "Volume Set Identifier",
- 128, 'a', diskStructure.primaryDescriptor.volume_set_id);
+ 128, 'a', diskStructure->primaryDescriptor.volume_set_id);
/* Boot options */
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "B", "bootimage")) {
if (val == NULL)
warnx("error: The Boot Image parameter requires a valid boot information string");
else
- rv = cd9660_add_boot_disk(val);
+ rv = cd9660_add_boot_disk(diskStructure, val);
} else if (CD9660_IS_COMMAND_ARG(var, "bootimagedir")) {
/*
* XXXfvdl this is unused.
@@ -371,7 +378,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
errx(1, "error: The Boot Image Directory parameter"
" requires a directory name\n");
else {
- if ((diskStructure.boot_image_directory =
+ if ((diskStructure->boot_image_directory =
malloc(strlen(val) + 1)) == NULL) {
CD9660_MEM_ALLOC_ERROR("cd9660_parse_opts");
exit(1);
@@ -379,40 +386,40 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
/* BIG TODO: Add the max length function here */
cd9660_arguments_set_string(val, "Boot Image Directory",
- 12 , 'd', diskStructure.boot_image_directory);
+ 12 , 'd', diskStructure->boot_image_directory);
}
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "G", "generic-bootimage")) {
if (val == NULL)
warnx("error: The Boot Image parameter requires a valid boot information string");
else
- rv = cd9660_add_generic_bootimage(val);
+ rv = cd9660_add_generic_bootimage(diskStructure, val);
} else if (CD9660_IS_COMMAND_ARG(var, "no-trailing-padding"))
- diskStructure.include_padding_areas = 0;
+ diskStructure->include_padding_areas = 0;
/* RRIP */
else if (CD9660_IS_COMMAND_ARG_DUAL(var, "R", "rockridge"))
- diskStructure.rock_ridge_enabled = 1;
+ diskStructure->rock_ridge_enabled = 1;
else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "archimedes"))
- diskStructure.archimedes_enabled = 1;
+ diskStructure->archimedes_enabled = 1;
else if (CD9660_IS_COMMAND_ARG(var, "chrp-boot"))
- diskStructure.chrp_boot = 1;
+ diskStructure->chrp_boot = 1;
else if (CD9660_IS_COMMAND_ARG_DUAL(var, "K", "keep-bad-images"))
- diskStructure.keep_bad_images = 1;
+ diskStructure->keep_bad_images = 1;
else if (CD9660_IS_COMMAND_ARG(var, "allow-deep-trees"))
- diskStructure.allow_deep_trees = 1;
+ diskStructure->allow_deep_trees = 1;
else if (CD9660_IS_COMMAND_ARG(var, "allow-max-name"))
- diskStructure.allow_max_name = 1;
+ diskStructure->allow_max_name = 1;
else if (CD9660_IS_COMMAND_ARG(var, "allow-illegal-chars"))
- diskStructure.allow_illegal_chars = 1;
+ diskStructure->allow_illegal_chars = 1;
else if (CD9660_IS_COMMAND_ARG(var, "allow-lowercase"))
- diskStructure.allow_lowercase = 1;
+ diskStructure->allow_lowercase = 1;
else if (CD9660_IS_COMMAND_ARG(var,"allow-multidot"))
- diskStructure.allow_multidot = 1;
+ diskStructure->allow_multidot = 1;
else if (CD9660_IS_COMMAND_ARG(var, "omit-trailing-period"))
- diskStructure.omit_trailing_period = 1;
+ diskStructure->omit_trailing_period = 1;
else if (CD9660_IS_COMMAND_ARG(var, "no-emul-boot") ||
CD9660_IS_COMMAND_ARG(var, "no-boot") ||
CD9660_IS_COMMAND_ARG(var, "hard-disk-boot")) {
- cd9660_eltorito_add_boot_option(var, 0);
+ cd9660_eltorito_add_boot_option(diskStructure, var, 0);
/* End of flag variables */
} else if (CD9660_IS_COMMAND_ARG(var, "boot-load-segment")) {
@@ -420,7 +427,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
warnx("Option `%s' doesn't contain a value", var);
rv = 0;
} else {
- cd9660_eltorito_add_boot_option(var, val);
+ cd9660_eltorito_add_boot_option(diskStructure, var,
+ val);
}
} else {
if (val == NULL) {
@@ -453,19 +461,20 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
int64_t totalSpace;
int error;
cd9660node *real_root;
+ iso9660_disk *diskStructure = fsopts->fs_specific;
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: ISO level is %i\n",
- diskStructure.isoLevel);
- if (diskStructure.isoLevel < 2 &&
- diskStructure.allow_multidot)
+ diskStructure->isoLevel);
+ if (diskStructure->isoLevel < 2 &&
+ diskStructure->allow_multidot)
errx(1, "allow-multidot requires iso level of 2\n");
assert(image != NULL);
assert(dir != NULL);
assert(root != NULL);
- if (diskStructure.displayHelp) {
+ if (diskStructure->displayHelp) {
/*
* Display help here - probably want to put it in
* a separate function
@@ -473,7 +482,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
return;
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: image %s directory %s root %p\n",
image, dir, root);
@@ -497,11 +506,12 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
ISO_FILENAME_MAXLENGTH_WITH_PADDING);
real_root->level = 0;
- diskStructure.rootNode = real_root;
+ diskStructure->rootNode = real_root;
real_root->type = CD9660_TYPE_DIR;
error = 0;
real_root->node = root;
- cd9660_convert_structure(root, real_root, 1, &numDirectories, &error);
+ cd9660_convert_structure(diskStructure, root, real_root, 1,
+ &numDirectories, &error);
if (TAILQ_EMPTY(&real_root->cn_children)) {
errx(1, "cd9660_makefs: converted directory is empty. "
@@ -509,109 +519,111 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
} else if (error != 0) {
errx(1, "cd9660_makefs: tree conversion failed\n");
} else {
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: tree converted\n");
}
/* Add the dot and dot dot records */
- cd9660_add_dot_records(real_root);
+ cd9660_add_dot_records(diskStructure, real_root);
- cd9660_setup_root_node();
+ cd9660_setup_root_node(diskStructure);
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: done converting tree\n");
/* non-SUSP extensions */
- if (diskStructure.archimedes_enabled)
- archimedes_convert_tree(diskStructure.rootNode);
+ if (diskStructure->archimedes_enabled)
+ archimedes_convert_tree(diskStructure->rootNode);
/* Rock ridge / SUSP init pass */
- if (diskStructure.rock_ridge_enabled) {
- cd9660_susp_initialize(diskStructure.rootNode,
- diskStructure.rootNode, NULL);
+ if (diskStructure->rock_ridge_enabled) {
+ cd9660_susp_initialize(diskStructure, diskStructure->rootNode,
+ diskStructure->rootNode, NULL);
}
/* Build path table structure */
- diskStructure.pathTableLength = cd9660_generate_path_table();
+ diskStructure->pathTableLength = cd9660_generate_path_table(
+ diskStructure);
- pathTableSectors = CD9660_BLOCKS(diskStructure.sectorSize,
- diskStructure.pathTableLength);
+ pathTableSectors = CD9660_BLOCKS(diskStructure->sectorSize,
+ diskStructure->pathTableLength);
- firstAvailableSector = cd9660_setup_volume_descriptors();
- if (diskStructure.is_bootable) {
- firstAvailableSector = cd9660_setup_boot(firstAvailableSector);
+ firstAvailableSector = cd9660_setup_volume_descriptors(diskStructure);
+ if (diskStructure->is_bootable) {
+ firstAvailableSector = cd9660_setup_boot(diskStructure,
+ firstAvailableSector);
if (firstAvailableSector < 0)
errx(1, "setup_boot failed");
}
/* LE first, then BE */
- diskStructure.primaryLittleEndianTableSector = firstAvailableSector;
- diskStructure.primaryBigEndianTableSector =
- diskStructure.primaryLittleEndianTableSector + pathTableSectors;
+ diskStructure->primaryLittleEndianTableSector = firstAvailableSector;
+ diskStructure->primaryBigEndianTableSector =
+ diskStructure->primaryLittleEndianTableSector + pathTableSectors;
/* Set the secondary ones to -1, not going to use them for now */
- diskStructure.secondaryBigEndianTableSector = -1;
- diskStructure.secondaryLittleEndianTableSector = -1;
+ diskStructure->secondaryBigEndianTableSector = -1;
+ diskStructure->secondaryLittleEndianTableSector = -1;
- diskStructure.dataFirstSector =
- diskStructure.primaryBigEndianTableSector + pathTableSectors;
- if (diskStructure.verbose_level > 0)
+ diskStructure->dataFirstSector =
+ diskStructure->primaryBigEndianTableSector + pathTableSectors;
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: Path table conversion complete. "
"Each table is %i bytes, or %" PRIu64 " sectors.\n",
- diskStructure.pathTableLength, pathTableSectors);
+ diskStructure->pathTableLength, pathTableSectors);
- startoffset = diskStructure.sectorSize*diskStructure.dataFirstSector;
+ startoffset = diskStructure->sectorSize*diskStructure->dataFirstSector;
- totalSpace = cd9660_compute_offsets(real_root, startoffset);
+ totalSpace = cd9660_compute_offsets(diskStructure, real_root, startoffset);
- diskStructure.totalSectors = diskStructure.dataFirstSector +
- CD9660_BLOCKS(diskStructure.sectorSize, totalSpace);
+ diskStructure->totalSectors = diskStructure->dataFirstSector +
+ CD9660_BLOCKS(diskStructure->sectorSize, totalSpace);
/* Disabled until pass 1 is done */
- if (diskStructure.rock_ridge_enabled) {
- diskStructure.susp_continuation_area_start_sector =
- diskStructure.totalSectors;
- diskStructure.totalSectors +=
- CD9660_BLOCKS(diskStructure.sectorSize,
- diskStructure.susp_continuation_area_size);
- cd9660_susp_finalize(diskStructure.rootNode);
+ if (diskStructure->rock_ridge_enabled) {
+ diskStructure->susp_continuation_area_start_sector =
+ diskStructure->totalSectors;
+ diskStructure->totalSectors +=
+ CD9660_BLOCKS(diskStructure->sectorSize,
+ diskStructure->susp_continuation_area_size);
+ cd9660_susp_finalize(diskStructure, diskStructure->rootNode);
}
- cd9660_finalize_PVD();
+ cd9660_finalize_PVD(diskStructure);
/* Add padding sectors, just for testing purposes right now */
- /* diskStructure.totalSectors+=150; */
+ /* diskStructure->totalSectors+=150; */
/* Debugging output */
- if (diskStructure.verbose_level > 0) {
+ if (diskStructure->verbose_level > 0) {
printf("cd9660_makefs: Sectors 0-15 reserved\n");
printf("cd9660_makefs: Primary path tables starts in sector %"
- PRId64 "\n", diskStructure.primaryLittleEndianTableSector);
+ PRId64 "\n", diskStructure->primaryLittleEndianTableSector);
printf("cd9660_makefs: File data starts in sector %"
- PRId64 "\n", diskStructure.dataFirstSector);
+ PRId64 "\n", diskStructure->dataFirstSector);
printf("cd9660_makefs: Total sectors: %"
- PRId64 "\n", diskStructure.totalSectors);
+ PRId64 "\n", diskStructure->totalSectors);
}
/*
* Add padding sectors at the end
* TODO: Clean this up and separate padding
*/
- if (diskStructure.include_padding_areas)
- diskStructure.totalSectors += 150;
+ if (diskStructure->include_padding_areas)
+ diskStructure->totalSectors += 150;
- cd9660_write_image(image);
+ cd9660_write_image(diskStructure, image);
- if (diskStructure.verbose_level > 1) {
- debug_print_volume_descriptor_information();
- debug_print_tree(real_root,0);
+ if (diskStructure->verbose_level > 1) {
+ debug_print_volume_descriptor_information(diskStructure);
+ debug_print_tree(diskStructure, real_root, 0);
debug_print_path_tree(real_root);
}
/* Clean up data structures */
cd9660_free_structure(real_root);
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_makefs: done\n");
}
@@ -619,76 +631,77 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
typedef int (*cd9660node_func)(cd9660node *);
static void
-cd9660_finalize_PVD(void)
+cd9660_finalize_PVD(iso9660_disk *diskStructure)
{
time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
/* root should be a fixed size of 34 bytes since it has no name */
- memcpy(diskStructure.primaryDescriptor.root_directory_record,
- diskStructure.rootNode->dot_record->isoDirRecord, 34);
+ memcpy(diskStructure->primaryDescriptor.root_directory_record,
+ diskStructure->rootNode->dot_record->isoDirRecord, 34);
/* In RRIP, this might be longer than 34 */
- diskStructure.primaryDescriptor.root_directory_record[0] = 34;
+ diskStructure->primaryDescriptor.root_directory_record[0] = 34;
/* Set up all the important numbers in the PVD */
- cd9660_bothendian_dword(diskStructure.totalSectors,
- (unsigned char *)diskStructure.primaryDescriptor.volume_space_size);
+ cd9660_bothendian_dword(diskStructure->totalSectors,
+ (unsigned char *)diskStructure->primaryDescriptor.volume_space_size);
cd9660_bothendian_word(1,
- (unsigned char *)diskStructure.primaryDescriptor.volume_set_size);
+ (unsigned char *)diskStructure->primaryDescriptor.volume_set_size);
cd9660_bothendian_word(1,
(unsigned char *)
- diskStructure.primaryDescriptor.volume_sequence_number);
- cd9660_bothendian_word(diskStructure.sectorSize,
+ diskStructure->primaryDescriptor.volume_sequence_number);
+ cd9660_bothendian_word(diskStructure->sectorSize,
(unsigned char *)
- diskStructure.primaryDescriptor.logical_block_size);
- cd9660_bothendian_dword(diskStructure.pathTableLength,
- (unsigned char *)diskStructure.primaryDescriptor.path_table_size);
+ diskStructure->primaryDescriptor.logical_block_size);
+ cd9660_bothendian_dword(diskStructure->pathTableLength,
+ (unsigned char *)diskStructure->primaryDescriptor.path_table_size);
- cd9660_731(diskStructure.primaryLittleEndianTableSector,
- (u_char *)diskStructure.primaryDescriptor.type_l_path_table);
- cd9660_732(diskStructure.primaryBigEndianTableSector,
- (u_char *)diskStructure.primaryDescriptor.type_m_path_table);
+ cd9660_731(diskStructure->primaryLittleEndianTableSector,
+ (u_char *)diskStructure->primaryDescriptor.type_l_path_table);
+ cd9660_732(diskStructure->primaryBigEndianTableSector,
+ (u_char *)diskStructure->primaryDescriptor.type_m_path_table);
- diskStructure.primaryDescriptor.file_structure_version[0] = 1;
+ diskStructure->primaryDescriptor.file_structure_version[0] = 1;
/* Pad all strings with spaces instead of nulls */
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.volume_id, 32);
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.system_id, 32);
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.volume_set_id,
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.volume_id, 32);
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.system_id, 32);
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.volume_set_id,
128);
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.publisher_id,
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.publisher_id,
128);
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.preparer_id,
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.preparer_id,
128);
- cd9660_pad_string_spaces(diskStructure.primaryDescriptor.application_id,
+ cd9660_pad_string_spaces(diskStructure->primaryDescriptor.application_id,
128);
cd9660_pad_string_spaces(
- diskStructure.primaryDescriptor.copyright_file_id, 37);
+ diskStructure->primaryDescriptor.copyright_file_id, 37);
cd9660_pad_string_spaces(
- diskStructure.primaryDescriptor.abstract_file_id, 37);
+ diskStructure->primaryDescriptor.abstract_file_id, 37);
cd9660_pad_string_spaces(
- diskStructure.primaryDescriptor.bibliographic_file_id, 37);
+ diskStructure->primaryDescriptor.bibliographic_file_id, 37);
/* Setup dates */
cd9660_time_8426(
- (unsigned char *)diskStructure.primaryDescriptor.creation_date,
+ (unsigned char *)diskStructure->primaryDescriptor.creation_date,
tstamp);
cd9660_time_8426(
- (unsigned char *)diskStructure.primaryDescriptor.modification_date,
+ (unsigned char *)diskStructure->primaryDescriptor.modification_date,
tstamp);
#if 0
- cd9660_set_date(diskStructure.primaryDescriptor.expiration_date,
+ cd9660_set_date(diskStructure->primaryDescriptor.expiration_date,
tstamp);
#endif
- memset(diskStructure.primaryDescriptor.expiration_date, '0', 16);
- diskStructure.primaryDescriptor.expiration_date[16] = 0;
+ memset(diskStructure->primaryDescriptor.expiration_date, '0', 16);
+ diskStructure->primaryDescriptor.expiration_date[16] = 0;
+
cd9660_time_8426(
- (unsigned char *)diskStructure.primaryDescriptor.effective_date,
+ (unsigned char *)diskStructure->primaryDescriptor.effective_date,
tstamp);
/* make this sane */
- cd9660_time_915(diskStructure.rootNode->dot_record->isoDirRecord->date,
+ cd9660_time_915(diskStructure->rootNode->dot_record->isoDirRecord->date,
tstamp);
}
@@ -712,16 +725,16 @@ cd9660_populate_iso_dir_record(struct _iso_directory_record_cd9660 *record,
}
static void
-cd9660_setup_root_node(void)
+cd9660_setup_root_node(iso9660_disk *diskStructure)
{
- cd9660_populate_iso_dir_record(diskStructure.rootNode->isoDirRecord,
+ cd9660_populate_iso_dir_record(diskStructure->rootNode->isoDirRecord,
0, ISO_FLAG_DIRECTORY, 1, "\0");
}
/*********** SUPPORT FUNCTIONS ***********/
static int
-cd9660_setup_volume_descriptors(void)
+cd9660_setup_volume_descriptors(iso9660_disk *diskStructure)
{
/* Boot volume descriptor should come second */
int sector = 16;
@@ -735,17 +748,17 @@ cd9660_setup_volume_descriptors(void)
}
temp->volumeDescriptorData =
- (unsigned char *)&diskStructure.primaryDescriptor;
+ (unsigned char *)&diskStructure->primaryDescriptor;
temp->volumeDescriptorData[0] = ISO_VOLUME_DESCRIPTOR_PVD;
temp->volumeDescriptorData[6] = 1;
temp->sector = sector;
memcpy(temp->volumeDescriptorData + 1,
ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5);
- diskStructure.firstVolumeDescriptor = temp;
+ diskStructure->firstVolumeDescriptor = temp;
sector++;
/* Set up boot support if enabled. BVD must reside in sector 17 */
- if (diskStructure.is_bootable) {
+ if (diskStructure->is_bootable) {
if ((t = malloc(sizeof(volume_descriptor))) == NULL) {
CD9660_MEM_ALLOC_ERROR(
"cd9660_setup_volume_descriptors");
@@ -760,9 +773,9 @@ cd9660_setup_volume_descriptors(void)
temp = t;
memset(t->volumeDescriptorData, 0, 2048);
t->sector = 17;
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Setting up boot volume descriptor\n");
- cd9660_setup_boot_volume_descriptor(t);
+ cd9660_setup_boot_volume_descriptor(diskStructure, t);
sector++;
}
@@ -808,7 +821,7 @@ cd9660_fill_extended_attribute_record(cd9660node *node)
#endif
static int
-cd9660_translate_node_common(cd9660node *newnode)
+cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
{
time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
int test;
@@ -818,7 +831,7 @@ cd9660_translate_node_common(cd9660node *newnode)
/* Now populate the isoDirRecord structure */
memset(temp, 0, ISO_FILENAME_MAXLENGTH_WITH_PADDING);
- test = cd9660_convert_filename(newnode->node->name,
+ test = cd9660_convert_filename(diskStructure, newnode->node->name,
temp, !(S_ISDIR(newnode->node->type)));
flag = ISO_FLAG_CLEAR;
@@ -852,10 +865,11 @@ cd9660_translate_node_common(cd9660node *newnode)
* @returns int 0 on failure, 1 on success
*/
static int
-cd9660_translate_node(fsnode *node, cd9660node *newnode)
+cd9660_translate_node(iso9660_disk *diskStructure, fsnode *node,
+ cd9660node *newnode)
{
if (node == NULL) {
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("cd9660_translate_node: NULL node passed, "
"returning\n");
return 0;
@@ -873,7 +887,7 @@ cd9660_translate_node(fsnode *node, cd9660node *newnode)
if (!(S_ISDIR(node->type)))
newnode->fileDataLength = node->inode->st.st_size;
- if (cd9660_translate_node_common(newnode) == 0)
+ if (cd9660_translate_node_common(diskStructure, newnode) == 0)
return 0;
/* Finally, overwrite some of the values that are set by default */
@@ -1007,7 +1021,8 @@ cd9660_sorted_child_insert(cd9660node *parent, cd9660node *cn_new)
* where n represents the files respective place in the ordering
*/
static int
-cd9660_handle_collisions(cd9660node *colliding, int past)
+cd9660_handle_collisions(iso9660_disk *diskStructure, cd9660node *colliding,
+ int past)
{
cd9660node *iter, *next, *prev;
int skip;
@@ -1042,14 +1057,16 @@ cd9660_handle_collisions(cd9660node *colliding, int past)
temp_past--;
}
skip += past;
- iter = cd9660_rename_filename(iter, skip, delete_chars);
+ iter = cd9660_rename_filename(diskStructure, iter, skip,
+ delete_chars);
}
return flag;
}
static cd9660node *
-cd9660_rename_filename(cd9660node *iter, int num, int delete_chars)
+cd9660_rename_filename(iso9660_disk *diskStructure, cd9660node *iter, int num,
+ int delete_chars)
{
int i = 0;
int numbts, digit, digits, temp, powers, count;
@@ -1057,14 +1074,14 @@ cd9660_rename_filename(cd9660node *iter, int num, int delete_chars)
int maxlength;
char *tmp;
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Rename_filename called\n");
- assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
+ assert(1 <= diskStructure->isoLevel && diskStructure->isoLevel <= 2);
/* TODO : A LOT of chanes regarding 8.3 filenames */
- if (diskStructure.isoLevel == 1)
+ if (diskStructure->isoLevel == 1)
maxlength = 8;
- else if (diskStructure.isoLevel == 2)
+ else if (diskStructure->isoLevel == 2)
maxlength = 31;
else
maxlength = ISO_FILENAME_MAXLENGTH_BEFORE_VERSION;
@@ -1110,7 +1127,7 @@ cd9660_rename_filename(cd9660node *iter, int num, int delete_chars)
*/
/*
- if (diskStructure.isoLevel == 1) {
+ if (diskStructure->isoLevel == 1) {
numbts = 8 - digits - delete_chars;
if (dot < 0) {
@@ -1162,7 +1179,7 @@ cd9660_rename_filename(cd9660node *iter, int num, int delete_chars)
/* Todo: Figure out why these functions are nec. */
static void
-cd9660_copy_filenames(cd9660node *node)
+cd9660_copy_filenames(iso9660_disk *diskStructure, cd9660node *node)
{
cd9660node *cn;
@@ -1170,12 +1187,12 @@ cd9660_copy_filenames(cd9660node *node)
return;
if (TAILQ_FIRST(&node->cn_children)->isoDirRecord == NULL) {
- debug_print_tree(diskStructure.rootNode, 0);
+ debug_print_tree(diskStructure, diskStructure->rootNode, 0);
exit(1);
}
TAILQ_FOREACH(cn, &node->cn_children, cn_next_child) {
- cd9660_copy_filenames(cn);
+ cd9660_copy_filenames(diskStructure, cn);
memcpy(cn->o_name, cn->isoDirRecord->name,
ISO_FILENAME_MAXLENGTH_WITH_PADDING);
}
@@ -1242,7 +1259,7 @@ cd9660_count_collisions(cd9660node *copy)
}
static cd9660node *
-cd9660_rrip_move_directory(cd9660node *dir)
+cd9660_rrip_move_directory(iso9660_disk *diskStructure, cd9660node *dir)
{
char newname[9];
cd9660node *tfile;
@@ -1253,28 +1270,29 @@ cd9660_rrip_move_directory(cd9660node *dir)
* 2) Point the virtual file to the new directory
* 3) Point the relocated directory to its old parent
* 4) Move the directory specified by dir into rr_moved_dir,
- * and rename it to "diskStructure.rock_ridge_move_count" (as a string)
+ * and rename it to "diskStructure->rock_ridge_move_count" (as a string)
*/
/* First see if the moved directory even exists */
- if (diskStructure.rr_moved_dir == NULL) {
- diskStructure.rr_moved_dir =
- cd9660_create_directory(ISO_RRIP_DEFAULT_MOVE_DIR_NAME,
- diskStructure.rootNode, dir);
- if (diskStructure.rr_moved_dir == NULL)
+ if (diskStructure->rr_moved_dir == NULL) {
+ diskStructure->rr_moved_dir = cd9660_create_directory(
+ diskStructure, ISO_RRIP_DEFAULT_MOVE_DIR_NAME,
+ diskStructure->rootNode, dir);
+ if (diskStructure->rr_moved_dir == NULL)
return 0;
- cd9660_time_915(diskStructure.rr_moved_dir->isoDirRecord->date,
+ cd9660_time_915(diskStructure->rr_moved_dir->isoDirRecord->date,
stampst.st_ino ? stampst.st_mtime : start_time.tv_sec);
}
/* Create a file with the same ORIGINAL name */
- tfile = cd9660_create_file(dir->node->name, dir->parent, dir);
+ tfile = cd9660_create_file(diskStructure, dir->node->name, dir->parent,
+ dir);
if (tfile == NULL)
return NULL;
- diskStructure.rock_ridge_move_count++;
+ diskStructure->rock_ridge_move_count++;
snprintf(newname, sizeof(newname), "%08i",
- diskStructure.rock_ridge_move_count);
+ diskStructure->rock_ridge_move_count);
/* Point to old parent */
dir->rr_real_parent = dir->parent;
@@ -1288,13 +1306,13 @@ cd9660_rrip_move_directory(cd9660node *dir)
}
/* Point to new parent */
- dir->parent = diskStructure.rr_moved_dir;
+ dir->parent = diskStructure->rr_moved_dir;
/* Point the file to the moved directory */
tfile->rr_relocated = dir;
/* Actually move the directory */
- cd9660_sorted_child_insert(diskStructure.rr_moved_dir, dir);
+ cd9660_sorted_child_insert(diskStructure->rr_moved_dir, dir);
/* TODO: Inherit permissions / ownership (basically the entire inode) */
@@ -1308,7 +1326,7 @@ cd9660_rrip_move_directory(cd9660node *dir)
}
static int
-cd9660_add_dot_records(cd9660node *root)
+cd9660_add_dot_records(iso9660_disk *diskStructure, cd9660node *root)
{
struct cd9660_children_head *head = &root->cn_children;
cd9660node *cn;
@@ -1317,10 +1335,11 @@ cd9660_add_dot_records(cd9660node *root)
if ((cn->type & CD9660_TYPE_DIR) == 0)
continue;
/* Recursion first */
- cd9660_add_dot_records(cn);
+ cd9660_add_dot_records(diskStructure, cn);
}
- cd9660_create_special_directory(CD9660_TYPE_DOT, root);
- cd9660_create_special_directory(CD9660_TYPE_DOTDOT, root);
+ cd9660_create_special_directory(diskStructure, CD9660_TYPE_DOT, root);
+ cd9660_create_special_directory(diskStructure, CD9660_TYPE_DOTDOT,
+ root);
return 1;
}
@@ -1335,8 +1354,8 @@ cd9660_add_dot_records(cd9660node *root)
* @param int* Running count of the number of directories that are being created
*/
static void
-cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
- int *numDirectories, int *error)
+cd9660_convert_structure(iso9660_disk *diskStructure, fsnode *root,
+ cd9660node *parent_node, int level, int *numDirectories, int *error)
{
fsnode *iterator = root;
cd9660node *this_node;
@@ -1379,7 +1398,8 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
/* Translate the node, including its filename */
this_node->parent = parent_node;
- cd9660_translate_node(iterator, this_node);
+ cd9660_translate_node(diskStructure, iterator,
+ this_node);
this_node->level = level;
if (S_ISDIR(iterator->type)) {
@@ -1393,14 +1413,14 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
* allowed as per ISO spec
*/
if (level == 8) {
- if ((!diskStructure.allow_deep_trees) &&
- (!diskStructure.rock_ridge_enabled)) {
+ if ((!diskStructure->allow_deep_trees) &&
+ (!diskStructure->rock_ridge_enabled)) {
warnx("error: found entry "
"with depth greater "
"than 8.");
(*error) = 1;
return;
- } else if (diskStructure.
+ } else if (diskStructure->
rock_ridge_enabled) {
working_level = 3;
/*
@@ -1410,6 +1430,7 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
this_node->level =
working_level - 1;
if (cd9660_rrip_move_directory(
+ diskStructure,
this_node) == NULL) {
warnx("Failure in "
"cd9660_rrip_"
@@ -1424,8 +1445,8 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
/* Do the recursive call on the children */
if (iterator->child != NULL) {
- cd9660_convert_structure(
- iterator->child, this_node,
+ cd9660_convert_structure(diskStructure,
+ iterator->child, this_node,
working_level,
numDirectories, error);
@@ -1464,10 +1485,11 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
/* cd9660_handle_collisions(first_node); */
/* TODO: need cleanup */
- cd9660_copy_filenames(parent_node);
+ cd9660_copy_filenames(diskStructure, parent_node);
do {
- flag = cd9660_handle_collisions(parent_node, counter);
+ flag = cd9660_handle_collisions(diskStructure, parent_node,
+ counter);
counter++;
cd9660_sorting_nodes(parent_node);
} while ((flag == 1) && (counter < 100));
@@ -1518,9 +1540,9 @@ struct ptq_entry
* @returns int The number of built path tables (between 1 and 4), 0 on failure
*/
static int
-cd9660_generate_path_table(void)
+cd9660_generate_path_table(iso9660_disk *diskStructure)
{
- cd9660node *cn, *dirNode = diskStructure.rootNode;
+ cd9660node *cn, *dirNode = diskStructure->rootNode;
cd9660node *last = dirNode;
int pathTableSize = 0; /* computed as we go */
int counter = 1; /* root gets a count of 0 */
@@ -1528,7 +1550,7 @@ cd9660_generate_path_table(void)
TAILQ_HEAD(cd9660_pt_head, ptq_entry) pt_head;
TAILQ_INIT(&pt_head);
- PTQUEUE_NEW(n, ptq_entry, -1, diskStructure.rootNode);
+ PTQUEUE_NEW(n, ptq_entry, -1, diskStructure->rootNode);
/* Push the root node */
TAILQ_INSERT_HEAD(&pt_head, n, ptq);
@@ -1586,7 +1608,8 @@ cd9660_compute_full_filename(cd9660node *node, char *buf)
}
/* NEW filename conversion method */
-typedef int(*cd9660_filename_conversion_functor)(const char *, char *, int);
+typedef int(*cd9660_filename_conversion_functor)(iso9660_disk *, const char *,
+ char *, int);
/*
@@ -1596,7 +1619,8 @@ typedef int(*cd9660_filename_conversion_functor)(const char *, char *, int);
* XXX bounds checking!
*/
static int
-cd9660_level1_convert_filename(const char *oldname, char *newname, int is_file)
+cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname,
+ char *newname, int is_file)
{
/*
* ISO 9660 : 10.1
@@ -1621,7 +1645,7 @@ cd9660_level1_convert_filename(const char *oldname, char *newname, int is_file)
}
} else {
/* cut RISC OS file type off ISO name */
- if (diskStructure.archimedes_enabled &&
+ if (diskStructure->archimedes_enabled &&
*oldname == ',' && strlen(oldname) == 4)
break;
@@ -1645,7 +1669,7 @@ cd9660_level1_convert_filename(const char *oldname, char *newname, int is_file)
oldname++;
}
if (is_file) {
- if (!found_ext && !diskStructure.omit_trailing_period)
+ if (!found_ext && !diskStructure->omit_trailing_period)
*newname++ = '.';
/* Add version */
sprintf(newname, ";%i", 1);
@@ -1655,7 +1679,8 @@ cd9660_level1_convert_filename(const char *oldname, char *newname, int is_file)
/* XXX bounds checking! */
static int
-cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
+cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname,
+ char *newname, int is_file)
{
/*
* ISO 9660 : 7.5.1
@@ -1674,7 +1699,7 @@ cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
/* Handle period first, as it is special */
if (*oldname == '.') {
if (found_ext) {
- if (diskStructure.allow_multidot) {
+ if (diskStructure->allow_multidot) {
*newname++ = '.';
} else {
*newname++ = '_';
@@ -1687,7 +1712,7 @@ cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
}
} else {
/* cut RISC OS file type off ISO name */
- if (diskStructure.archimedes_enabled &&
+ if (diskStructure->archimedes_enabled &&
*oldname == ',' && strlen(oldname) == 4)
break;
@@ -1696,7 +1721,7 @@ cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
else if (isupper((unsigned char)*oldname) ||
isdigit((unsigned char)*oldname))
*newname++ = *oldname;
- else if (diskStructure.allow_multidot &&
+ else if (diskStructure->allow_multidot &&
*oldname == '.') {
*newname++ = '.';
} else {
@@ -1711,7 +1736,7 @@ cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
oldname ++;
}
if (is_file) {
- if (!found_ext && !diskStructure.omit_trailing_period)
+ if (!found_ext && !diskStructure->omit_trailing_period)
*newname++ = '.';
/* Add version */
sprintf(newname, ";%i", 1);
@@ -1721,7 +1746,8 @@ cd9660_level2_convert_filename(const char *oldname, char *newname, int is_file)
#if 0
static int
-cd9660_joliet_convert_filename(const char *oldname, char *newname, int is_file)
+cd9660_joliet_convert_filename(iso9660_disk *diskStructure, const char *oldname,
+ char *newname, int is_file)
{
/* TODO: implement later, move to cd9660_joliet.c ?? */
}
@@ -1737,24 +1763,25 @@ cd9660_joliet_convert_filename(const char *oldname, char *newname, int is_file)
* @returns int The length of the new string
*/
static int
-cd9660_convert_filename(const char *oldname, char *newname, int is_file)
+cd9660_convert_filename(iso9660_disk *diskStructure, const char *oldname,
+ char *newname, int is_file)
{
- assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
+ assert(1 <= diskStructure->isoLevel && diskStructure->isoLevel <= 2);
/* NEW */
cd9660_filename_conversion_functor conversion_function = NULL;
- if (diskStructure.isoLevel == 1)
+ if (diskStructure->isoLevel == 1)
conversion_function = &cd9660_level1_convert_filename;
- else if (diskStructure.isoLevel == 2)
+ else if (diskStructure->isoLevel == 2)
conversion_function = &cd9660_level2_convert_filename;
- return (*conversion_function)(oldname, newname, is_file);
+ return (*conversion_function)(diskStructure, oldname, newname, is_file);
}
int
-cd9660_compute_record_size(cd9660node *node)
+cd9660_compute_record_size(iso9660_disk *diskStructure, cd9660node *node)
{
int size = node->isoDirRecord->length[0];
- if (diskStructure.rock_ridge_enabled)
+ if (diskStructure->rock_ridge_enabled)
size += node->susp_entry_size;
size += node->su_tail_size;
size += size & 1; /* Ensure length of record is even. */
@@ -1763,7 +1790,7 @@ cd9660_compute_record_size(cd9660node *node)
}
static void
-cd9660_populate_dot_records(cd9660node *node)
+cd9660_populate_dot_records(iso9660_disk *diskStructure, cd9660node *node)
{
node->dot_record->fileDataSector = node->fileDataSector;
memcpy(node->dot_record->isoDirRecord,node->isoDirRecord, 34);
@@ -1772,9 +1799,9 @@ cd9660_populate_dot_records(cd9660node *node)
node->dot_record->isoDirRecord->name[1] = 0;
node->dot_record->isoDirRecord->length[0] = 34;
node->dot_record->fileRecordSize =
- cd9660_compute_record_size(node->dot_record);
+ cd9660_compute_record_size(diskStructure, node->dot_record);
- if (node == diskStructure.rootNode) {
+ if (node == diskStructure->rootNode) {
node->dot_dot_record->fileDataSector = node->fileDataSector;
memcpy(node->dot_dot_record->isoDirRecord,node->isoDirRecord,
34);
@@ -1789,7 +1816,7 @@ cd9660_populate_dot_records(cd9660node *node)
node->dot_dot_record->isoDirRecord->name[1] = 0;
node->dot_dot_record->isoDirRecord->length[0] = 34;
node->dot_dot_record->fileRecordSize =
- cd9660_compute_record_size(node->dot_dot_record);
+ cd9660_compute_record_size(diskStructure, node->dot_dot_record);
}
/*
@@ -1799,7 +1826,8 @@ cd9660_populate_dot_records(cd9660node *node)
* a multiple of sector size)
*/
static int64_t
-cd9660_compute_offsets(cd9660node *node, int64_t startOffset)
+cd9660_compute_offsets(iso9660_disk *diskStructure, cd9660node *node,
+ int64_t startOffset)
{
/*
* This function needs to compute the size of directory records and
@@ -1823,10 +1851,11 @@ cd9660_compute_offsets(cd9660node *node, int64_t startOffset)
node->fileDataSector = -1;
if (node->type & CD9660_TYPE_DIR) {
- node->fileRecordSize = cd9660_compute_record_size(node);
+ node->fileRecordSize = cd9660_compute_record_size(
+ diskStructure, node);
/*Set what sector this directory starts in*/
node->fileDataSector =
- CD9660_BLOCKS(diskStructure.sectorSize,startOffset);
+ CD9660_BLOCKS(diskStructure->sectorSize,startOffset);
cd9660_bothendian_dword(node->fileDataSector,
node->isoDirRecord->extent);
@@ -1838,32 +1867,32 @@ cd9660_compute_offsets(cd9660node *node, int64_t startOffset)
node->fileSectorsUsed = 1;
TAILQ_FOREACH(child, &node->cn_children, cn_next_child) {
node->fileDataLength +=
- cd9660_compute_record_size(child);
- if ((cd9660_compute_record_size(child) +
+ cd9660_compute_record_size(diskStructure, child);
+ if ((cd9660_compute_record_size(diskStructure, child) +
current_sector_usage) >=
- diskStructure.sectorSize) {
+ diskStructure->sectorSize) {
current_sector_usage = 0;
node->fileSectorsUsed++;
}
current_sector_usage +=
- cd9660_compute_record_size(child);
+ cd9660_compute_record_size(diskStructure, child);
}
cd9660_bothendian_dword(node->fileSectorsUsed *
- diskStructure.sectorSize,node->isoDirRecord->size);
+ diskStructure->sectorSize,node->isoDirRecord->size);
/*
* This should point to the sector after the directory
* record (or, the first byte in that sector)
*/
- used_bytes += node->fileSectorsUsed * diskStructure.sectorSize;
+ used_bytes += node->fileSectorsUsed * diskStructure->sectorSize;
for (child = TAILQ_NEXT(node->dot_dot_record, cn_next_child);
child != NULL; child = TAILQ_NEXT(child, cn_next_child)) {
/* Directories need recursive call */
if (S_ISDIR(child->node->type)) {
- r = cd9660_compute_offsets(child,
+ r = cd9660_compute_offsets(diskStructure, child,
used_bytes + startOffset);
if (r != -1)
@@ -1874,7 +1903,7 @@ cd9660_compute_offsets(cd9660node *node, int64_t startOffset)
}
/* Explicitly set the . and .. records */
- cd9660_populate_dot_records(node);
+ cd9660_populate_dot_records(diskStructure, node);
/* Finally, do another iteration to write the file data*/
for (child = TAILQ_NEXT(node->dot_dot_record, cn_next_child);
@@ -1884,20 +1913,20 @@ cd9660_compute_offsets(cd9660node *node, int64_t startOffset)
if (S_ISDIR(child->node->type))
continue;
child->fileRecordSize =
- cd9660_compute_record_size(child);
+ cd9660_compute_record_size(diskStructure, child);
child->fileSectorsUsed =
- CD9660_BLOCKS(diskStructure.sectorSize,
+ CD9660_BLOCKS(diskStructure->sectorSize,
child->fileDataLength);
inode = child->node->inode;
if ((inode->flags & FI_ALLOCATED) == 0) {
inode->ino =
- CD9660_BLOCKS(diskStructure.sectorSize,
+ CD9660_BLOCKS(diskStructure->sectorSize,
used_bytes + startOffset);
inode->flags |= FI_ALLOCATED;
used_bytes += child->fileSectorsUsed *
- diskStructure.sectorSize;
+ diskStructure->sectorSize;
} else {
INODE_WARNX(("%s: already allocated inode %d "
"data sectors at %" PRIu32, __func__,
@@ -1938,8 +1967,8 @@ cd9660_copy_stat_info(cd9660node *from, cd9660node *to, int file)
#endif
static cd9660node *
-cd9660_create_virtual_entry(const char *name, cd9660node *parent, int file,
- int insert)
+cd9660_create_virtual_entry(iso9660_disk *diskStructure, const char *name,
+ cd9660node *parent, int file, int insert)
{
cd9660node *temp;
fsnode * tfsnode;
@@ -1969,7 +1998,8 @@ cd9660_create_virtual_entry(const char *name, cd9660node *parent, int file,
strcpy(tfsnode->name, name);
- cd9660_convert_filename(tfsnode->name, temp->isoDirRecord->name, file);
+ cd9660_convert_filename(diskStructure, tfsnode->name,
+ temp->isoDirRecord->name, file);
temp->node = tfsnode;
temp->parent = parent;
@@ -2005,11 +2035,12 @@ cd9660_create_virtual_entry(const char *name, cd9660node *parent, int file,
}
static cd9660node *
-cd9660_create_file(const char * name, cd9660node *parent, cd9660node *me)
+cd9660_create_file(iso9660_disk *diskStructure, const char *name,
+ cd9660node *parent, cd9660node *me)
{
cd9660node *temp;
- temp = cd9660_create_virtual_entry(name,parent,1,1);
+ temp = cd9660_create_virtual_entry(diskStructure, name, parent, 1, 1);
if (temp == NULL)
return NULL;
@@ -2021,7 +2052,7 @@ cd9660_create_file(const char * name, cd9660node *parent, cd9660node *me)
return NULL;
*temp->node->inode = *me->node->inode;
- if (cd9660_translate_node_common(temp) == 0)
+ if (cd9660_translate_node_common(diskStructure, temp) == 0)
return NULL;
return temp;
}
@@ -2033,11 +2064,12 @@ cd9660_create_file(const char * name, cd9660node *parent, cd9660node *me)
* @returns cd9660node * Pointer to the new directory
*/
static cd9660node *
-cd9660_create_directory(const char *name, cd9660node *parent, cd9660node *me)
+cd9660_create_directory(iso9660_disk *diskStructure, const char *name,
+ cd9660node *parent, cd9660node *me)
{
cd9660node *temp;
- temp = cd9660_create_virtual_entry(name,parent,0,1);
+ temp = cd9660_create_virtual_entry(diskStructure, name, parent, 0, 1);
if (temp == NULL)
return NULL;
temp->node->type |= S_IFDIR;
@@ -2048,13 +2080,14 @@ cd9660_create_directory(const char *name, cd9660node *parent, cd9660node *me)
return NULL;
*temp->node->inode = *me->node->inode;
- if (cd9660_translate_node_common(temp) == 0)
+ if (cd9660_translate_node_common(diskStructure, temp) == 0)
return NULL;
return temp;
}
static cd9660node *
-cd9660_create_special_directory(u_char type, cd9660node *parent)
+cd9660_create_special_directory(iso9660_disk *diskStructure, u_char type,
+ cd9660node *parent)
{
cd9660node *temp, *first;
char na[2];
@@ -2069,7 +2102,8 @@ cd9660_create_special_directory(u_char type, cd9660node *parent)
return 0;
na[1] = 0;
- if ((temp = cd9660_create_virtual_entry(na, parent, 0, 0)) == NULL)
+ if ((temp = cd9660_create_virtual_entry(diskStructure, na, parent,
+ 0, 0)) == NULL)
return NULL;
temp->parent = parent;
@@ -2100,7 +2134,7 @@ cd9660_create_special_directory(u_char type, cd9660node *parent)
}
int
-cd9660_add_generic_bootimage(const char *bootimage)
+cd9660_add_generic_bootimage(iso9660_disk *diskStructure, const char *bootimage)
{
struct stat stbuf;
@@ -2111,27 +2145,27 @@ cd9660_add_generic_bootimage(const char *bootimage)
return 0;
}
- if ((diskStructure.generic_bootimage = strdup(bootimage)) == NULL) {
+ if ((diskStructure->generic_bootimage = strdup(bootimage)) == NULL) {
warn("%s: strdup", __func__);
return 0;
}
/* Get information about the file */
- if (lstat(diskStructure.generic_bootimage, &stbuf) == -1)
+ if (lstat(diskStructure->generic_bootimage, &stbuf) == -1)
err(EXIT_FAILURE, "%s: lstat(\"%s\")", __func__,
- diskStructure.generic_bootimage);
+ diskStructure->generic_bootimage);
if (stbuf.st_size > 32768) {
warnx("Error: Boot image must be no greater than 32768 bytes");
return 0;
}
- if (diskStructure.verbose_level > 0) {
+ if (diskStructure->verbose_level > 0) {
printf("Generic boot image image has size %lld\n",
(long long)stbuf.st_size);
}
- diskStructure.has_generic_bootimage = 1;
+ diskStructure->has_generic_bootimage = 1;
return 1;
}
diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h
index 370acdf..a996d25 100644
--- a/usr.sbin/makefs/cd9660.h
+++ b/usr.sbin/makefs/cd9660.h
@@ -312,9 +312,6 @@ typedef struct _iso9660_disk {
} iso9660_disk;
-/******** GLOBAL VARIABLES ***********/
-extern iso9660_disk diskStructure;
-
/************ FUNCTIONS **************/
int cd9660_valid_a_chars(const char *);
int cd9660_valid_d_chars(const char *);
@@ -333,25 +330,27 @@ void cd9660_time_915(unsigned char *, time_t);
/*** Boot Functions ***/
int cd9660_write_generic_bootimage(FILE *);
-int cd9660_add_generic_bootimage(const char *);
-int cd9660_write_boot(FILE *);
-int cd9660_add_boot_disk(const char *);
-int cd9660_eltorito_add_boot_option(const char *, const char *);
-int cd9660_setup_boot(int);
-int cd9660_setup_boot_volume_descriptor(volume_descriptor *);
+int cd9660_add_generic_bootimage(iso9660_disk *, const char *);
+int cd9660_write_boot(iso9660_disk *, FILE *);
+int cd9660_add_boot_disk(iso9660_disk *, const char *);
+int cd9660_eltorito_add_boot_option(iso9660_disk *, const char *,
+ const char *);
+int cd9660_setup_boot(iso9660_disk *, int);
+int cd9660_setup_boot_volume_descriptor(iso9660_disk *,
+ volume_descriptor *);
/*** Write Functions ***/
-int cd9660_write_image(const char *image);
-int cd9660_copy_file(FILE *, off_t, const char *);
+int cd9660_write_image(iso9660_disk *, const char *image);
+int cd9660_copy_file(iso9660_disk *, FILE *, off_t, const char *);
void cd9660_compute_full_filename(cd9660node *, char *);
-int cd9660_compute_record_size(cd9660node *);
+int cd9660_compute_record_size(iso9660_disk *, cd9660node *);
/* Debugging functions */
-void debug_print_tree(cd9660node *,int);
+void debug_print_tree(iso9660_disk *, cd9660node *,int);
void debug_print_path_tree(cd9660node *);
-void debug_print_volume_descriptor_information(void);
+void debug_print_volume_descriptor_information(iso9660_disk *);
void debug_dump_to_xml_ptentry(path_table_entry *,int, int);
void debug_dump_to_xml_path_table(FILE *, off_t, int, int);
void debug_dump_to_xml(FILE *);
diff --git a/usr.sbin/makefs/cd9660/cd9660_debug.c b/usr.sbin/makefs/cd9660/cd9660_debug.c
index 11f8fd0..0b2a649 100644
--- a/usr.sbin/makefs/cd9660/cd9660_debug.c
+++ b/usr.sbin/makefs/cd9660/cd9660_debug.c
@@ -85,7 +85,7 @@ debug_print_susp_attrs(cd9660node *n, int indent)
}
void
-debug_print_tree(cd9660node *node, int level)
+debug_print_tree(iso9660_disk *diskStructure, cd9660node *node, int level)
{
#if !HAVE_NBTOOL_CONFIG_H
cd9660node *cn;
@@ -113,10 +113,10 @@ debug_print_tree(cd9660node *node, int level)
node->fileDataSector
+ node->fileSectorsUsed - 1);
}
- if (diskStructure.rock_ridge_enabled)
+ if (diskStructure->rock_ridge_enabled)
debug_print_susp_attrs(node, level + 1);
TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
- debug_print_tree(cn, level + 1);
+ debug_print_tree(diskStructure, cn, level + 1);
#else
printf("Sorry, debugging is not supported in host-tools mode.\n");
#endif
@@ -143,9 +143,9 @@ debug_print_path_tree(cd9660node *n)
}
void
-debug_print_volume_descriptor_information(void)
+debug_print_volume_descriptor_information(iso9660_disk *diskStructure)
{
- volume_descriptor *tmp = diskStructure.firstVolumeDescriptor;
+ volume_descriptor *tmp = diskStructure->firstVolumeDescriptor;
char temp[CD9660_SECTOR_SIZE];
printf("==Listing Volume Descriptors==\n");
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 7a14eaf..a91a5c8 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -57,7 +57,7 @@ static u_char cd9660_boot_get_system_type(struct cd9660_boot_image *);
#endif
int
-cd9660_add_boot_disk(const char *boot_info)
+cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info)
{
struct stat stbuf;
const char *mode_msg;
@@ -91,7 +91,7 @@ cd9660_add_boot_disk(const char *boot_info)
*filename++ = '\0';
- if (diskStructure.verbose_level > 0) {
+ if (diskStructure->verbose_level > 0) {
printf("Found bootdisk with system %s, and filename %s\n",
sysname, filename);
}
@@ -153,14 +153,14 @@ cd9660_add_boot_disk(const char *boot_info)
break;
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("%s\n", mode_msg);
new_image->size = stbuf.st_size;
new_image->num_sectors =
- howmany(new_image->size, diskStructure.sectorSize) *
- howmany(diskStructure.sectorSize, 512);
- if (diskStructure.verbose_level > 0) {
+ howmany(new_image->size, diskStructure->sectorSize) *
+ howmany(diskStructure->sectorSize, 512);
+ if (diskStructure->verbose_level > 0) {
printf("New image has size %d, uses %d 512-byte sectors\n",
new_image->size, new_image->num_sectors);
}
@@ -170,27 +170,28 @@ cd9660_add_boot_disk(const char *boot_info)
/* Add boot disk */
/* Group images for the same platform together. */
- TAILQ_FOREACH(tmp_image, &diskStructure.boot_images, image_list) {
+ TAILQ_FOREACH(tmp_image, &diskStructure->boot_images, image_list) {
if (tmp_image->system != new_image->system)
break;
}
if (tmp_image == NULL) {
- TAILQ_INSERT_HEAD(&diskStructure.boot_images, new_image,
+ TAILQ_INSERT_HEAD(&diskStructure->boot_images, new_image,
image_list);
} else
TAILQ_INSERT_BEFORE(tmp_image, new_image, image_list);
- new_image->serialno = diskStructure.image_serialno++;
+ new_image->serialno = diskStructure->image_serialno++;
/* TODO : Need to do anything about the boot image in the tree? */
- diskStructure.is_bootable = 1;
+ diskStructure->is_bootable = 1;
return 1;
}
int
-cd9660_eltorito_add_boot_option(const char *option_string, const char *value)
+cd9660_eltorito_add_boot_option(iso9660_disk *diskStructure,
+ const char *option_string, const char *value)
{
char *eptr;
struct cd9660_boot_image *image;
@@ -198,8 +199,8 @@ cd9660_eltorito_add_boot_option(const char *option_string, const char *value)
assert(option_string != NULL);
/* Find the last image added */
- TAILQ_FOREACH(image, &diskStructure.boot_images, image_list) {
- if (image->serialno + 1 == diskStructure.image_serialno)
+ TAILQ_FOREACH(image, &diskStructure->boot_images, image_list) {
+ if (image->serialno + 1 == diskStructure->image_serialno)
break;
}
if (image == NULL)
@@ -353,7 +354,7 @@ cd9660_boot_get_system_type(struct cd9660_boot_image *disk)
* Set up the BVD, Boot catalog, and the boot entries, but do no writing
*/
int
-cd9660_setup_boot(int first_sector)
+cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
{
int sector;
int used_sectors;
@@ -367,14 +368,14 @@ cd9660_setup_boot(int first_sector)
x86_head = mac_head = ppc_head = NULL;
/* If there are no boot disks, don't bother building boot information */
- if (TAILQ_EMPTY(&diskStructure.boot_images))
+ if (TAILQ_EMPTY(&diskStructure->boot_images))
return 0;
/* Point to catalog: For now assume it consumes one sector */
ELTORITO_DPRINTF(("Boot catalog will go in sector %d\n", first_sector));
- diskStructure.boot_catalog_sector = first_sector;
+ diskStructure->boot_catalog_sector = first_sector;
cd9660_bothendian_dword(first_sector,
- diskStructure.boot_descriptor->boot_catalog_pointer);
+ diskStructure->boot_descriptor->boot_catalog_pointer);
/* Step 1: Generate boot catalog */
/* Step 1a: Validation entry */
@@ -389,16 +390,16 @@ cd9660_setup_boot(int first_sector)
num_entries = 1;
used_sectors = 0;
- TAILQ_FOREACH(tmp_disk, &diskStructure.boot_images, image_list) {
+ TAILQ_FOREACH(tmp_disk, &diskStructure->boot_images, image_list) {
used_sectors += tmp_disk->num_sectors;
/* One default entry per image */
num_entries++;
}
- catalog_sectors = howmany(num_entries * 0x20, diskStructure.sectorSize);
+ catalog_sectors = howmany(num_entries * 0x20, diskStructure->sectorSize);
used_sectors += catalog_sectors;
- if (diskStructure.verbose_level > 0) {
+ if (diskStructure->verbose_level > 0) {
printf("%s: there will be %i entries consuming %i sectors. "
"Catalog is %i sectors\n", __func__, num_entries,
used_sectors, catalog_sectors);
@@ -406,16 +407,16 @@ cd9660_setup_boot(int first_sector)
/* Populate sector numbers */
sector = first_sector + catalog_sectors;
- TAILQ_FOREACH(tmp_disk, &diskStructure.boot_images, image_list) {
+ TAILQ_FOREACH(tmp_disk, &diskStructure->boot_images, image_list) {
tmp_disk->sector = sector;
sector += tmp_disk->num_sectors;
}
- LIST_INSERT_HEAD(&diskStructure.boot_entries, valid_entry, ll_struct);
+ LIST_INSERT_HEAD(&diskStructure->boot_entries, valid_entry, ll_struct);
/* Step 1b: Initial/default entry */
/* TODO : PARAM */
- tmp_disk = TAILQ_FIRST(&diskStructure.boot_images);
+ tmp_disk = TAILQ_FIRST(&diskStructure->boot_images);
default_entry = cd9660_boot_setup_default_entry(tmp_disk);
if (default_entry == NULL) {
warnx("Error: memory allocation failed in cd9660_setup_boot");
@@ -485,7 +486,8 @@ cd9660_setup_boot(int first_sector)
}
int
-cd9660_setup_boot_volume_descriptor(volume_descriptor *bvd)
+cd9660_setup_boot_volume_descriptor(iso9660_disk *diskStructure,
+ volume_descriptor *bvd)
{
boot_volume_descriptor *bvdData =
(boot_volume_descriptor*)bvd->volumeDescriptorData;
@@ -495,7 +497,7 @@ cd9660_setup_boot_volume_descriptor(volume_descriptor *bvd)
bvdData->version[0] = 1;
memcpy(bvdData->boot_system_identifier, ET_ID, 23);
memcpy(bvdData->identifier, ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5);
- diskStructure.boot_descriptor =
+ diskStructure->boot_descriptor =
(boot_volume_descriptor*) bvd->volumeDescriptorData;
return 1;
}
@@ -590,7 +592,7 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
}
int
-cd9660_write_boot(FILE *fd)
+cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
{
struct boot_catalog_entry *e;
struct cd9660_boot_image *t;
@@ -598,16 +600,16 @@ cd9660_write_boot(FILE *fd)
int mbr_partitions = 0;
/* write boot catalog */
- if (fseeko(fd, (off_t)diskStructure.boot_catalog_sector *
- diskStructure.sectorSize, SEEK_SET) == -1)
+ if (fseeko(fd, (off_t)diskStructure->boot_catalog_sector *
+ diskStructure->sectorSize, SEEK_SET) == -1)
err(1, "fseeko");
- if (diskStructure.verbose_level > 0) {
+ if (diskStructure->verbose_level > 0) {
printf("Writing boot catalog to sector %" PRId64 "\n",
- diskStructure.boot_catalog_sector);
+ diskStructure->boot_catalog_sector);
}
- LIST_FOREACH(e, &diskStructure.boot_entries, ll_struct) {
- if (diskStructure.verbose_level > 0) {
+ LIST_FOREACH(e, &diskStructure->boot_entries, ll_struct) {
+ if (diskStructure->verbose_level > 0) {
printf("Writing catalog entry of type %d\n",
e->entry_type);
}
@@ -617,16 +619,16 @@ cd9660_write_boot(FILE *fd)
*/
fwrite(&(e->entry_data.VE), 1, 32, fd);
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Finished writing boot catalog\n");
/* copy boot images */
- TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) {
- if (diskStructure.verbose_level > 0) {
+ TAILQ_FOREACH(t, &diskStructure->boot_images, image_list) {
+ if (diskStructure->verbose_level > 0) {
printf("Writing boot image from %s to sectors %d\n",
t->filename, t->sector);
}
- cd9660_copy_file(fd, t->sector, t->filename);
+ cd9660_copy_file(diskStructure, fd, t->sector, t->filename);
if (t->system == ET_SYS_MAC)
apm_partitions++;
@@ -635,7 +637,7 @@ cd9660_write_boot(FILE *fd)
}
/* some systems need partition tables as well */
- if (mbr_partitions > 0 || diskStructure.chrp_boot) {
+ if (mbr_partitions > 0 || diskStructure->chrp_boot) {
uint16_t sig;
fseek(fd, 0x1fe, SEEK_SET);
@@ -645,18 +647,18 @@ cd9660_write_boot(FILE *fd)
mbr_partitions = 0;
/* Write ISO9660 descriptor, enclosing the whole disk */
- if (diskStructure.chrp_boot)
+ if (diskStructure->chrp_boot)
cd9660_write_mbr_partition_entry(fd, mbr_partitions++,
- 0, diskStructure.totalSectors *
- (diskStructure.sectorSize / 512), 0x96);
+ 0, diskStructure->totalSectors *
+ (diskStructure->sectorSize / 512), 0x96);
/* Write all partition entries */
- TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) {
+ TAILQ_FOREACH(t, &diskStructure->boot_images, image_list) {
if (t->system != ET_SYS_PPC)
continue;
cd9660_write_mbr_partition_entry(fd, mbr_partitions++,
- t->sector * (diskStructure.sectorSize / 512),
- t->num_sectors * (diskStructure.sectorSize / 512),
+ t->sector * (diskStructure->sectorSize / 512),
+ t->num_sectors * (diskStructure->sectorSize / 512),
0x41 /* PReP Boot */);
}
}
@@ -674,8 +676,8 @@ cd9660_write_boot(FILE *fd)
apm16 = htobe16(512);
fwrite(&apm16, sizeof(apm16), 1, fd);
/* Device block count */
- apm32 = htobe32(diskStructure.totalSectors *
- (diskStructure.sectorSize / 512));
+ apm32 = htobe32(diskStructure->totalSectors *
+ (diskStructure->sectorSize / 512));
fwrite(&apm32, sizeof(apm32), 1, fd);
/* Device type/id */
apm16 = htobe16(1);
@@ -691,20 +693,20 @@ cd9660_write_boot(FILE *fd)
/* Write all partition entries */
apm_partitions = 0;
- TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) {
+ TAILQ_FOREACH(t, &diskStructure->boot_images, image_list) {
if (t->system != ET_SYS_MAC)
continue;
cd9660_write_apm_partition_entry(fd,
1 + apm_partitions++, total_parts,
- t->sector * (diskStructure.sectorSize / 512),
- t->num_sectors * (diskStructure.sectorSize / 512),
+ t->sector * (diskStructure->sectorSize / 512),
+ t->num_sectors * (diskStructure->sectorSize / 512),
512, "CD Boot", "Apple_Bootstrap");
}
/* Write ISO9660 descriptor, enclosing the whole disk */
cd9660_write_apm_partition_entry(fd, 2 + apm_partitions,
- total_parts, 0, diskStructure.totalSectors *
- (diskStructure.sectorSize / 512), 512, "ISO9660",
+ total_parts, 0, diskStructure->totalSectors *
+ (diskStructure->sectorSize / 512), 512, "ISO9660",
"CD_ROM_Mode_1");
}
diff --git a/usr.sbin/makefs/cd9660/cd9660_write.c b/usr.sbin/makefs/cd9660/cd9660_write.c
index 333b632..9d29986 100644
--- a/usr.sbin/makefs/cd9660/cd9660_write.c
+++ b/usr.sbin/makefs/cd9660/cd9660_write.c
@@ -40,15 +40,16 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-static int cd9660_write_volume_descriptors(FILE *);
-static int cd9660_write_path_table(FILE *, off_t, int);
-static int cd9660_write_path_tables(FILE *);
-static int cd9660_write_file(FILE *, cd9660node *);
-static int cd9660_write_filedata(FILE *, off_t, const unsigned char *, int);
+static int cd9660_write_volume_descriptors(iso9660_disk *, FILE *);
+static int cd9660_write_path_table(iso9660_disk *, FILE *, off_t, int);
+static int cd9660_write_path_tables(iso9660_disk *, FILE *);
+static int cd9660_write_file(iso9660_disk *, FILE *, cd9660node *);
+static int cd9660_write_filedata(iso9660_disk *, FILE *, off_t,
+ const unsigned char *, int);
#if 0
static int cd9660_write_buffered(FILE *, off_t, int, const unsigned char *);
#endif
-static void cd9660_write_rr(FILE *, cd9660node *, off_t, off_t);
+static void cd9660_write_rr(iso9660_disk *, FILE *, cd9660node *, off_t, off_t);
/*
* Write the image
@@ -57,7 +58,7 @@ static void cd9660_write_rr(FILE *, cd9660node *, off_t, off_t);
* @returns int 1 on success, 0 on failure
*/
int
-cd9660_write_image(const char* image)
+cd9660_write_image(iso9660_disk *diskStructure, const char* image)
{
FILE *fd;
int status;
@@ -68,12 +69,12 @@ cd9660_write_image(const char* image)
image);
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Writing image\n");
- if (diskStructure.has_generic_bootimage) {
- status = cd9660_copy_file(fd, 0,
- diskStructure.generic_bootimage);
+ if (diskStructure->has_generic_bootimage) {
+ status = cd9660_copy_file(diskStructure, fd, 0,
+ diskStructure->generic_bootimage);
if (status == 0) {
warnx("%s: Error writing generic boot image",
__func__);
@@ -82,70 +83,71 @@ cd9660_write_image(const char* image)
}
/* Write the volume descriptors */
- status = cd9660_write_volume_descriptors(fd);
+ status = cd9660_write_volume_descriptors(diskStructure, fd);
if (status == 0) {
warnx("%s: Error writing volume descriptors to image",
__func__);
goto cleanup_bad_image;
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Volume descriptors written\n");
/*
* Write the path tables: there are actually four, but right
* now we are only concearned with two.
*/
- status = cd9660_write_path_tables(fd);
+ status = cd9660_write_path_tables(diskStructure, fd);
if (status == 0) {
warnx("%s: Error writing path tables to image", __func__);
goto cleanup_bad_image;
}
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Path tables written\n");
/* Write the directories and files */
- status = cd9660_write_file(fd, diskStructure.rootNode);
+ status = cd9660_write_file(diskStructure, fd, diskStructure->rootNode);
if (status == 0) {
warnx("%s: Error writing files to image", __func__);
goto cleanup_bad_image;
}
- if (diskStructure.is_bootable) {
- cd9660_write_boot(fd);
+ if (diskStructure->is_bootable) {
+ cd9660_write_boot(diskStructure, fd);
}
/* Write padding bits. This is temporary */
memset(buf, 0, CD9660_SECTOR_SIZE);
- cd9660_write_filedata(fd, diskStructure.totalSectors - 1, buf, 1);
+ cd9660_write_filedata(diskStructure, fd,
+ diskStructure->totalSectors - 1, buf, 1);
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Files written\n");
fclose(fd);
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Image closed\n");
return 1;
cleanup_bad_image:
fclose(fd);
- if (!diskStructure.keep_bad_images)
+ if (!diskStructure->keep_bad_images)
unlink(image);
- if (diskStructure.verbose_level > 0)
+ if (diskStructure->verbose_level > 0)
printf("Bad image cleaned up\n");
return 0;
}
static int
-cd9660_write_volume_descriptors(FILE *fd)
+cd9660_write_volume_descriptors(iso9660_disk *diskStructure, FILE *fd)
{
- volume_descriptor *vd_temp = diskStructure.firstVolumeDescriptor;
+ volume_descriptor *vd_temp = diskStructure->firstVolumeDescriptor;
int pos;
while (vd_temp != NULL) {
- pos = vd_temp->sector * diskStructure.sectorSize;
- cd9660_write_filedata(fd, vd_temp->sector,
+ pos = vd_temp->sector * diskStructure->sectorSize;
+ cd9660_write_filedata(diskStructure, fd, vd_temp->sector,
vd_temp->volumeDescriptorData, 1);
vd_temp = vd_temp->next;
}
@@ -161,26 +163,27 @@ cd9660_write_volume_descriptors(FILE *fd)
* @returns int 1 on success, 0 on failure
*/
static int
-cd9660_write_path_table(FILE *fd, off_t sector, int mode)
+cd9660_write_path_table(iso9660_disk *diskStructure, FILE *fd, off_t sector,
+ int mode)
{
- int path_table_sectors = CD9660_BLOCKS(diskStructure.sectorSize,
- diskStructure.pathTableLength);
+ int path_table_sectors = CD9660_BLOCKS(diskStructure->sectorSize,
+ diskStructure->pathTableLength);
unsigned char *buffer;
unsigned char *buffer_head;
int len, ret;
path_table_entry temp_entry;
cd9660node *ptcur;
- buffer = malloc(diskStructure.sectorSize * path_table_sectors);
+ buffer = malloc(diskStructure->sectorSize * path_table_sectors);
if (buffer == NULL) {
warnx("%s: Memory allocation error allocating buffer",
__func__);
return 0;
}
buffer_head = buffer;
- memset(buffer, 0, diskStructure.sectorSize * path_table_sectors);
+ memset(buffer, 0, diskStructure->sectorSize * path_table_sectors);
- ptcur = diskStructure.rootNode;
+ ptcur = diskStructure->rootNode;
while (ptcur != NULL) {
memset(&temp_entry, 0, sizeof(path_table_entry));
@@ -215,7 +218,7 @@ cd9660_write_path_table(FILE *fd, off_t sector, int mode)
ptcur = ptcur->ptnext;
}
- ret = cd9660_write_filedata(fd, sector, buffer_head,
+ ret = cd9660_write_filedata(diskStructure, fd, sector, buffer_head,
path_table_sectors);
free(buffer_head);
return ret;
@@ -237,14 +240,14 @@ cd9660_write_path_table(FILE *fd, off_t sector, int mode)
* @returns int 0 on failure, 1 on success
*/
static int
-cd9660_write_path_tables(FILE *fd)
+cd9660_write_path_tables(iso9660_disk *diskStructure, FILE *fd)
{
- if (cd9660_write_path_table(fd,
- diskStructure.primaryLittleEndianTableSector, LITTLE_ENDIAN) == 0)
+ if (cd9660_write_path_table(diskStructure, fd,
+ diskStructure->primaryLittleEndianTableSector, LITTLE_ENDIAN) == 0)
return 0;
- if (cd9660_write_path_table(fd,
- diskStructure.primaryBigEndianTableSector, BIG_ENDIAN) == 0)
+ if (cd9660_write_path_table(diskStructure, fd,
+ diskStructure->primaryBigEndianTableSector, BIG_ENDIAN) == 0)
return 0;
/* @TODO: handle remaining two path tables */
@@ -263,7 +266,7 @@ cd9660_write_path_tables(FILE *fd)
* @returns int 0 on failure, 1 on success
*/
static int
-cd9660_write_file(FILE *fd, cd9660node *writenode)
+cd9660_write_file(iso9660_disk *diskStructure, FILE *fd, cd9660node *writenode)
{
char *buf;
char *temp_file_name;
@@ -283,7 +286,7 @@ cd9660_write_file(FILE *fd, cd9660node *writenode)
memset(temp_file_name, 0, CD9660MAXPATH + 1);
- buf = malloc(diskStructure.sectorSize);
+ buf = malloc(diskStructure->sectorSize);
if (buf == NULL)
err(EXIT_FAILURE, "%s: malloc", __func__);
@@ -301,7 +304,8 @@ cd9660_write_file(FILE *fd, cd9660node *writenode)
if (writenode->node->contents == NULL)
cd9660_compute_full_filename(writenode,
temp_file_name);
- ret = cd9660_copy_file(fd, writenode->fileDataSector,
+ ret = cd9660_copy_file(diskStructure, fd,
+ writenode->fileDataSector,
(writenode->node->contents != NULL) ?
writenode->node->contents : temp_file_name);
if (ret == 0)
@@ -320,7 +324,7 @@ cd9660_write_file(FILE *fd, cd9660node *writenode)
*/
cur_sector_offset = 0;
working_sector = writenode->fileDataSector;
- if (fseeko(fd, working_sector * diskStructure.sectorSize,
+ if (fseeko(fd, working_sector * diskStructure->sectorSize,
SEEK_SET) == -1)
err(1, "fseeko");
@@ -337,27 +341,27 @@ cd9660_write_file(FILE *fd, cd9660node *writenode)
sizeof(iso_directory_record_cd9660));
temp_record.length[0] =
- cd9660_compute_record_size(temp);
+ cd9660_compute_record_size(diskStructure, temp);
if (temp_record.length[0] + cur_sector_offset >=
- diskStructure.sectorSize) {
+ diskStructure->sectorSize) {
cur_sector_offset = 0;
working_sector++;
/* Seek to the next sector. */
if (fseeko(fd, working_sector *
- diskStructure.sectorSize, SEEK_SET) == -1)
+ diskStructure->sectorSize, SEEK_SET) == -1)
err(1, "fseeko");
}
/* Write out the basic ISO directory record */
written = fwrite(&temp_record, 1,
temp->isoDirRecord->length[0], fd);
- if (diskStructure.rock_ridge_enabled) {
- cd9660_write_rr(fd, temp,
+ if (diskStructure->rock_ridge_enabled) {
+ cd9660_write_rr(diskStructure, fd, temp,
cur_sector_offset, working_sector);
}
if (fseeko(fd, working_sector *
- diskStructure.sectorSize + cur_sector_offset +
+ diskStructure->sectorSize + cur_sector_offset +
temp_record.length[0] - temp->su_tail_size,
SEEK_SET) == -1)
err(1, "fseeko");
@@ -376,7 +380,7 @@ cd9660_write_file(FILE *fd, cd9660node *writenode)
* Recurse on children.
*/
TAILQ_FOREACH(temp, &writenode->cn_children, cn_next_child) {
- if ((ret = cd9660_write_file(fd, temp)) == 0)
+ if ((ret = cd9660_write_file(diskStructure, fd, temp)) == 0)
goto out;
}
}
@@ -401,24 +405,24 @@ out:
* is written, the rest should be set to 0.
*/
static int
-cd9660_write_filedata(FILE *fd, off_t sector, const unsigned char *buf,
- int numsecs)
+cd9660_write_filedata(iso9660_disk *diskStructure, FILE *fd, off_t sector,
+ const unsigned char *buf, int numsecs)
{
off_t curpos;
size_t success;
curpos = ftello(fd);
- if (fseeko(fd, sector * diskStructure.sectorSize, SEEK_SET) == -1)
+ if (fseeko(fd, sector * diskStructure->sectorSize, SEEK_SET) == -1)
err(1, "fseeko");
- success = fwrite(buf, diskStructure.sectorSize * numsecs, 1, fd);
+ success = fwrite(buf, diskStructure->sectorSize * numsecs, 1, fd);
if (fseeko(fd, curpos, SEEK_SET) == -1)
err(1, "fseeko");
if (success == 1)
- success = diskStructure.sectorSize * numsecs;
+ success = diskStructure->sectorSize * numsecs;
return success;
}
@@ -435,12 +439,13 @@ cd9660_write_buffered(FILE *fd, off_t offset, int buff_len,
#endif
int
-cd9660_copy_file(FILE *fd, off_t start_sector, const char *filename)
+cd9660_copy_file(iso9660_disk *diskStructure, FILE *fd, off_t start_sector,
+ const char *filename)
{
FILE *rf;
int bytes_read;
off_t sector = start_sector;
- int buf_size = diskStructure.sectorSize;
+ int buf_size = diskStructure->sectorSize;
char *buf;
buf = malloc(buf_size);
@@ -453,10 +458,10 @@ cd9660_copy_file(FILE *fd, off_t start_sector, const char *filename)
return 0;
}
- if (diskStructure.verbose_level > 1)
+ if (diskStructure->verbose_level > 1)
printf("Writing file: %s\n",filename);
- if (fseeko(fd, start_sector * diskStructure.sectorSize, SEEK_SET) == -1)
+ if (fseeko(fd, start_sector * diskStructure->sectorSize, SEEK_SET) == -1)
err(1, "fseeko");
while (!feof(rf)) {
@@ -484,13 +489,14 @@ cd9660_copy_file(FILE *fd, off_t start_sector, const char *filename)
}
static void
-cd9660_write_rr(FILE *fd, cd9660node *writenode, off_t offset, off_t sector)
+cd9660_write_rr(iso9660_disk *diskStructure, FILE *fd, cd9660node *writenode,
+ off_t offset, off_t sector)
{
int in_ca = 0;
struct ISO_SUSP_ATTRIBUTES *myattr;
offset += writenode->isoDirRecord->length[0];
- if (fseeko(fd, sector * diskStructure.sectorSize + offset, SEEK_SET) ==
+ if (fseeko(fd, sector * diskStructure->sectorSize + offset, SEEK_SET) ==
-1)
err(1, "fseeko");
/* Offset now points at the end of the record */
@@ -504,9 +510,9 @@ cd9660_write_rr(FILE *fd, cd9660node *writenode, off_t offset, off_t sector)
* Point the offset to the start of this
* record's CE area
*/
- if (fseeko(fd, ((off_t)diskStructure.
+ if (fseeko(fd, ((off_t)diskStructure->
susp_continuation_area_start_sector *
- diskStructure.sectorSize)
+ diskStructure->sectorSize)
+ writenode->susp_entry_ce_start,
SEEK_SET) == -1)
err(1, "fseeko");
@@ -520,7 +526,7 @@ cd9660_write_rr(FILE *fd, cd9660node *writenode, off_t offset, off_t sector)
* where we should be.
*/
if (in_ca)
- if (fseeko(fd, sector * diskStructure.sectorSize + offset,
+ if (fseeko(fd, sector * diskStructure->sectorSize + offset,
SEEK_SET) == -1)
err(1, "fseeko");
}
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.c b/usr.sbin/makefs/cd9660/iso9660_rrip.c
index ef1ee56..5008d73 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.c
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.c
@@ -47,12 +47,13 @@
__FBSDID("$FreeBSD$");
static void cd9660_rrip_initialize_inode(cd9660node *);
-static int cd9660_susp_handle_continuation(cd9660node *);
-static int cd9660_susp_handle_continuation_common(cd9660node *, int);
+static int cd9660_susp_handle_continuation(iso9660_disk *, cd9660node *);
+static int cd9660_susp_handle_continuation_common(iso9660_disk *, cd9660node *,
+ int);
int
-cd9660_susp_initialize(cd9660node *node, cd9660node *parent,
- cd9660node *grandparent)
+cd9660_susp_initialize(iso9660_disk *diskStructure, cd9660node *node,
+ cd9660node *parent, cd9660node *grandparent)
{
cd9660node *cn;
int r;
@@ -69,11 +70,11 @@ cd9660_susp_initialize(cd9660node *node, cd9660node *parent,
TAILQ_INIT(&(node->dot_dot_record->head));
/* SUSP specific entries here */
- if ((r = cd9660_susp_initialize_node(node)) < 0)
+ if ((r = cd9660_susp_initialize_node(diskStructure, node)) < 0)
return r;
/* currently called cd9660node_rrip_init_links */
- r = cd9660_rrip_initialize_node(node, parent, grandparent);
+ r = cd9660_rrip_initialize_node(diskStructure, node, parent, grandparent);
if (r < 0)
return r;
@@ -84,35 +85,35 @@ cd9660_susp_initialize(cd9660node *node, cd9660node *parent,
* This should be called after all extensions. After
* this is called, no new records should be added.
*/
- if ((r = cd9660_susp_handle_continuation(node)) < 0)
+ if ((r = cd9660_susp_handle_continuation(diskStructure, node)) < 0)
return r;
/* Recurse on children. */
TAILQ_FOREACH(cn, &node->cn_children, cn_next_child) {
- if ((r = cd9660_susp_initialize(cn, node, parent)) < 0)
+ if ((r = cd9660_susp_initialize(diskStructure, cn, node, parent)) < 0)
return 0;
}
return 1;
}
int
-cd9660_susp_finalize(cd9660node *node)
+cd9660_susp_finalize(iso9660_disk *diskStructure, cd9660node *node)
{
cd9660node *temp;
int r;
assert(node != NULL);
- if (node == diskStructure.rootNode)
- diskStructure.susp_continuation_area_current_free = 0;
+ if (node == diskStructure->rootNode)
+ diskStructure->susp_continuation_area_current_free = 0;
- if ((r = cd9660_susp_finalize_node(node)) < 0)
+ if ((r = cd9660_susp_finalize_node(diskStructure, node)) < 0)
return r;
if ((r = cd9660_rrip_finalize_node(node)) < 0)
return r;
TAILQ_FOREACH(temp, &node->cn_children, cn_next_child) {
- if ((r = cd9660_susp_finalize(temp)) < 0)
+ if ((r = cd9660_susp_finalize(diskStructure, temp)) < 0)
return r;
}
return 1;
@@ -132,15 +133,15 @@ cd9660_susp_finalize(cd9660node *node)
* CE (continuation area)
*/
int
-cd9660_susp_finalize_node(cd9660node *node)
+cd9660_susp_finalize_node(iso9660_disk *diskStructure, cd9660node *node)
{
struct ISO_SUSP_ATTRIBUTES *t;
/* Handle CE counters */
if (node->susp_entry_ce_length > 0) {
node->susp_entry_ce_start =
- diskStructure.susp_continuation_area_current_free;
- diskStructure.susp_continuation_area_current_free +=
+ diskStructure->susp_continuation_area_current_free;
+ diskStructure->susp_continuation_area_current_free +=
node->susp_entry_ce_length;
}
@@ -149,12 +150,12 @@ cd9660_susp_finalize_node(cd9660node *node)
t->entry_type != SUSP_ENTRY_SUSP_CE)
continue;
cd9660_bothendian_dword(
- diskStructure.
+ diskStructure->
susp_continuation_area_start_sector,
t->attr.su_entry.CE.ca_sector);
cd9660_bothendian_dword(
- diskStructure.
+ diskStructure->
susp_continuation_area_start_sector,
t->attr.su_entry.CE.ca_sector);
cd9660_bothendian_dword(node->susp_entry_ce_start,
@@ -199,7 +200,8 @@ cd9660_rrip_finalize_node(cd9660node *node)
}
static int
-cd9660_susp_handle_continuation_common(cd9660node *node, int space)
+cd9660_susp_handle_continuation_common(iso9660_disk *diskStructure,
+ cd9660node *node, int space)
{
int ca_used, susp_used, susp_used_pre_ce, working;
struct ISO_SUSP_ATTRIBUTES *temp, *pre_ce, *last, *CE, *ST;
@@ -272,18 +274,18 @@ cd9660_susp_handle_continuation_common(cd9660node *node, int space)
node->susp_entry_size = susp_used;
node->susp_entry_ce_length = ca_used;
- diskStructure.susp_continuation_area_size += ca_used;
+ diskStructure->susp_continuation_area_size += ca_used;
return 1;
}
/* See if a continuation entry is needed for each of the different types */
static int
-cd9660_susp_handle_continuation(cd9660node *node)
+cd9660_susp_handle_continuation(iso9660_disk *diskStructure, cd9660node *node)
{
assert (node != NULL);
/* Entry */
- if (cd9660_susp_handle_continuation_common(
+ if (cd9660_susp_handle_continuation_common(diskStructure,
node,(int)(node->isoDirRecord->length[0])) < 0)
return 0;
@@ -291,7 +293,7 @@ cd9660_susp_handle_continuation(cd9660node *node)
}
int
-cd9660_susp_initialize_node(cd9660node *node)
+cd9660_susp_initialize_node(iso9660_disk *diskStructure, cd9660node *node)
{
struct ISO_SUSP_ATTRIBUTES *temp;
@@ -307,7 +309,7 @@ cd9660_susp_initialize_node(cd9660node *node)
/* Check for root directory, add SP and ER if needed. */
if (node->type & CD9660_TYPE_DOT) {
- if (node->parent == diskStructure.rootNode) {
+ if (node->parent == diskStructure->rootNode) {
temp = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
SUSP_ENTRY_SUSP_SP, "SP", SUSP_LOC_DOT);
cd9660_susp_sp(temp, node);
@@ -366,8 +368,8 @@ cd9660_rrip_initialize_inode(cd9660node *node)
}
int
-cd9660_rrip_initialize_node(cd9660node *node, cd9660node *parent,
- cd9660node *grandparent)
+cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node,
+ cd9660node *parent, cd9660node *grandparent)
{
struct ISO_SUSP_ATTRIBUTES *current = NULL;
@@ -378,7 +380,7 @@ cd9660_rrip_initialize_node(cd9660node *node, cd9660node *parent,
* Handle ER - should be the only entry to appear on
* a "." record
*/
- if (node->parent == diskStructure.rootNode) {
+ if (node->parent == diskStructure->rootNode) {
cd9660_susp_ER(node, 1, SUSP_RRIP_ER_EXT_ID,
SUSP_RRIP_ER_EXT_DES, SUSP_RRIP_ER_EXT_SRC);
}
@@ -416,7 +418,7 @@ cd9660_rrip_initialize_node(cd9660node *node, cd9660node *parent,
*
* The rr_moved_dir needs to be assigned a NM record as well.
*/
- if (node == diskStructure.rr_moved_dir) {
+ if (node == diskStructure->rr_moved_dir) {
cd9660_rrip_add_NM(node, RRIP_DEFAULT_MOVE_DIR_NAME);
}
else if ((node->node != NULL) &&
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.h b/usr.sbin/makefs/cd9660/iso9660_rrip.h
index 04acf03..0c7b89e 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.h
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.h
@@ -219,10 +219,10 @@ struct ISO_SUSP_ATTRIBUTES {
((int) ((entry)->attr.su_entry.SP.h.length[0]))
/* Recursive function - move later to func pointer code*/
-int cd9660_susp_finalize(cd9660node *);
+int cd9660_susp_finalize(iso9660_disk *, cd9660node *);
/* These two operate on single nodes */
-int cd9660_susp_finalize_node(cd9660node *);
+int cd9660_susp_finalize_node(iso9660_disk *, cd9660node *);
int cd9660_rrip_finalize_node(cd9660node *);
/* POSIX File attribute */
@@ -274,15 +274,17 @@ struct ISO_SUSP_ATTRIBUTES *cd9660_susp_ES(struct ISO_SUSP_ATTRIBUTES*,
/* Helper functions */
/* Common SUSP/RRIP functions */
-int cd9660_susp_initialize(cd9660node *, cd9660node *, cd9660node *);
-int cd9660_susp_initialize_node(cd9660node *);
+int cd9660_susp_initialize(iso9660_disk *, cd9660node *, cd9660node *,
+ cd9660node *);
+int cd9660_susp_initialize_node(iso9660_disk *, cd9660node *);
struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_create_node(int, int, const char *,
int);
struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_add_entry(cd9660node *,
struct ISO_SUSP_ATTRIBUTES *, struct ISO_SUSP_ATTRIBUTES *, int);
/* RRIP specific functions */
-int cd9660_rrip_initialize_node(cd9660node *, cd9660node *, cd9660node *);
+int cd9660_rrip_initialize_node(iso9660_disk *, cd9660node *, cd9660node *,
+ cd9660node *);
void cd9660_createSL(cd9660node *);
/* Functions that probably can be removed */
OpenPOWER on IntegriCloud