📄 mkisofs.c
字号:
/* @(#)mkisofs.c 1.70 00/07/20 joerg */#ifndef lintstatic char sccsid[] = "@(#)mkisofs.c 1.70 00/07/20 joerg";#endif/* * Program mkisofs.c - generate iso9660 filesystem based upon directory * tree on hard disk. Written by Eric Youngdale (1993). Copyright 1993 Yggdrasil Computing, Incorporated Copyright (c) 1999,2000 J. Schilling This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 22/2/2000 */#include "config.h"#include <errno.h>#include "mkisofs.h"#include "match.h"#ifdef linux#include <getopt.h>#else#include "getopt.h"#endif#include "iso9660.h"#include <ctype.h>#ifndef VMS#include <time.h>#else#include <sys/time.h>#include "vms.h"#endif#include <stdxlib.h>#include <sys/stat.h>#include <unixstd.h>#include <fctldefs.h>#include "exclude.h"#ifdef no_more_needed#ifdef __NetBSD__#include <sys/time.h>#include <sys/resource.h>#endif#endif /* no_more_needed */#include <unls.h> /* For UNICODE translation */#ifdef USE_LIBSCHILY#include <standard.h>#include <schily.h>#endifstruct directory *root = NULL;char version_string[] = "mkisofs 1.13";char *outfile;FILE *discimage;unsigned int next_extent = 0;unsigned int last_extent = 0;unsigned int session_start = 0;unsigned int path_table_size = 0;unsigned int path_table[4] = {0,};unsigned int path_blocks = 0;unsigned int jpath_table_size = 0;unsigned int jpath_table[4] = {0,};unsigned int jpath_blocks = 0;struct iso_directory_record root_record;struct iso_directory_record jroot_record;char *extension_record = NULL;int extension_record_extent = 0;int extension_record_size = 0;/* These variables are associated with command line options */int check_oldnames = 0;int use_eltorito = 0;int hard_disk_boot = 0;int not_bootable = 0;int no_emul_boot = 0;int load_addr = 0;int load_size = 0;int boot_info_table = 0;int use_sparcboot = 0;int use_genboot = 0;int use_RockRidge = 0;int use_Joliet = 0;int verbose = 1;int gui = 0;int all_files = 1; /* New default is to include all files */int follow_links = 0;int rationalize = 0;int generate_tables = 0;int dopad = 0;int print_size = 0;int split_output = 0;char *jcharset = NULL; /* Original charset to convert to UNICODE */char *preparer = PREPARER_DEFAULT;char *publisher = PUBLISHER_DEFAULT;char *appid = APPID_DEFAULT;char *copyright = COPYRIGHT_DEFAULT;char *biblio = BIBLIO_DEFAULT;char *abstract = ABSTRACT_DEFAULT;char *volset_id = VOLSET_ID_DEFAULT;char *volume_id = VOLUME_ID_DEFAULT;char *system_id = SYSTEM_ID_DEFAULT;char *boot_catalog = BOOT_CATALOG_DEFAULT;char *boot_image = BOOT_IMAGE_DEFAULT;char *genboot_image = BOOT_IMAGE_DEFAULT;int ucs_level = 3; /* We now have Unicode tables so use level 3 */int volume_set_size = 1;int volume_sequence_number = 1;struct eltorito_boot_entry_info *first_boot_entry = NULL;struct eltorito_boot_entry_info *last_boot_entry = NULL;struct eltorito_boot_entry_info *current_boot_entry = NULL;int jhide_trans_tbl; /* Hide TRANS.TBL from Joliet tree */int hide_rr_moved; /* Name RR_MOVED .rr_moved in Rock Ridge tree */int omit_period = 0; /* Violates iso9660, but these are a pain */int transparent_compression = 0; /* So far only works with linux */int omit_version_number = 0;/* May violate iso9660, but noone uses vers */int no_rr = 0; /* Do not use RR attributes from old session */int RR_relocation_depth = 6;/* Violates iso9660, but most systems work */int iso9660_level = 1;int iso9660_namelen = LEN_ISONAME; /* 31 characters, may be set to 37 */int full_iso9660_filenames = 0; /* Full 31 character iso9660 filenames */int relaxed_filenames = 0; /* For Amiga. Disc will not work with DOS */int allow_lowercase = 0; /* Allow lower case letters */int allow_multidot = 0; /* Allow more than on dot in filename */int iso_translate = 1; /* 1 == enables '#' and '~' removal */int allow_leading_dots = 0; /* DOS cannot read names with leading dots */#ifdef VMSint use_fileversion = 1; /* Use file version # from filesystem */#elseint use_fileversion = 0; /* Use file version # from filesystem */#endifint split_SL_component = 1; /* circumvent a bug in the SunOS driver */int split_SL_field = 1; /* circumvent a bug in the SunOS */char *trans_tbl = "TRANS.TBL"; /* default name for translation table */#ifdef APPLE_HYBint apple_hyb = 0; /* create HFS hybrid flag */int apple_ext = 0; /* create HFS extensions flag */int apple_both = 0; /* common flag (for above) */int hfs_extra = 0; /* extra HFS blocks added to end of ISO vol */int use_mac_name = 0; /* use Mac name for ISO/Joliet/RR flag */hce_mem *hce; /* libhfs/mkisofs extras */char *hfs_boot_file = 0; /* name of HFS boot file */int gen_pt = 0; /* generate HFS partition table */char *autoname = 0; /* AutoStart filename */char *magic_file = 0; /* name of magic file */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 afe_size = 0; /* Apple File Exchange block size */int hfs_last = MAG_LAST; /* process magic file after map file */char *deftype = APPLE_TYPE_DEFAULT; /* default Apple TYPE */char *defcreator = APPLE_CREATOR_DEFAULT; /* default Apple CREATOR */char *hfs_volume_id = NULL; /* HFS volume ID */int icon_pos = 0; /* Keep icon position */#ifdef PREP_BOOTchar *prep_boot_image[4];int use_prep_boot = 0;#endif /* PREP_BOOT */#endif /* APPLE_HYB */#ifdef SORTINGint do_sort = 0; /* sort file data */#endif /* SORTING */struct nls_table *nls = NULL; /* UNICODE conversion table */struct rcopts { char *tag; char **variable;};struct rcopts rcopt[] = { {"PREP", &preparer}, {"PUBL", &publisher}, {"APPI", &appid}, {"COPY", ©right}, {"BIBL", &biblio}, {"ABST", &abstract}, {"VOLS", &volset_id}, {"VOLI", &volume_id}, {"SYSI", &system_id},#ifdef APPLE_HYB {"HFS_TYPE", &deftype}, {"HFS_CREATOR", &defcreator},#endif /* APPLE_HYB */ {NULL, NULL}};/* * In case it isn't obvious, the option handling code was ripped off * from GNU-ld. */struct ld_option { /* The long option information. */ struct option opt; /* The short option with the same meaning ('\0' if none). */ char shortopt; /* The name of the argument (NULL if none). */ const char *arg; /* * The documentation string. If this is NULL, this is a synonym for * the previous option. */ const char *doc; enum { /* Use one dash before long option name. */ ONE_DASH, /* Use two dashes before long option name. */ TWO_DASHES, /* Don't mention this option in --help output. */ NO_HELP } control;};/* * Codes used for the long options with no short synonyms. 150 isn't * special; it's just an arbitrary non-ASCII char value. */#define OPTION_HELP 150#define OPTION_QUIET 151#define OPTION_NOSPLIT_SL_COMPONENT 152#define OPTION_NOSPLIT_SL_FIELD 153#define OPTION_PRINT_SIZE 154#define OPTION_SPLIT_OUTPUT 155#define OPTION_ABSTRACT 156#define OPTION_BIBLIO 157#define OPTION_COPYRIGHT 158#define OPTION_SYSID 159#define OPTION_VOLSET 160#define OPTION_VOLSET_SIZE 161#define OPTION_VOLSET_SEQ_NUM 162#define OPTION_I_HIDE 163#define OPTION_J_HIDE 164#define OPTION_LOG_FILE 165#define OPTION_PVERSION 166#define OPTION_NOBAK 167#define OPTION_SPARCLABEL 168#define OPTION_HARD_DISK_BOOT 169#define OPTION_NO_EMUL_BOOT 170#define OPTION_NO_BOOT 171#define OPTION_BOOT_LOAD_ADDR 172#define OPTION_BOOT_LOAD_SIZE 173#define OPTION_BOOT_INFO_TABLE 174#define OPTION_HIDE_TRANS_TBL 175#define OPTION_HIDE_RR_MOVED 176#define OPTION_GUI 177#define OPTION_TRANS_TBL 178#define OPTION_P_LIST 179#define OPTION_I_LIST 180#define OPTION_J_LIST 181#define OPTION_X_LIST 182#define OPTION_NO_RR 183#define OPTION_JCHARSET 184#define OPTION_PAD 185#define OPTION_H_HIDE 186#define OPTION_H_LIST 187#define OPTION_CHECK_OLDNAMES 188#ifdef SORTING#define OPTION_SORT 189#endif /* SORTING */#define OPTION_UCS_LEVEL 190#define OPTION_ISO_TRANSLATE 191#define OPTION_ISO_LEVEL 192#define OPTION_RELAXED_FILENAMES 193#define OPTION_ALLOW_LOWERCASE 194#define OPTION_ALLOW_MULTIDOT 195#define OPTION_USE_FILEVERSION 196#define OPTION_MAX_FILENAMES 197#define OPTION_ALT_BOOT 198#define OPTION_USE_GRAFT 199#ifdef APPLE_HYB#define OPTION_CAP 200#define OPTION_NETA 201#define OPTION_DBL 202#define OPTION_ESH 203#define OPTION_FE 204#define OPTION_SGI 205#define OPTION_MBIN 206#define OPTION_SGL 207/* aliases */#define OPTION_USH 208#define OPTION_XIN 209#define OPTION_DAVE 210#define OPTION_SFM 211#define OPTION_PROBE 220#define OPTION_MACNAME 221#define OPTION_NOMACFILES 222#define OPTION_BOOT_HFS_FILE 223#define OPTION_MAGIC_FILE 224#define OPTION_HFS_LIST 225#define OPTION_GEN_PT 226#define OPTION_CREATE_DT 227#define OPTION_HFS_HIDE 228#define OPTION_AUTOSTART 229#define OPTION_BSIZE 230#define OPTION_HFS_VOLID 231#define OPTION_PREP_BOOT 232#define OPTION_ICON_POS 233#define OPTION_HFS_TYPE 234#define OPTION_HFS_CREATOR 235#define OPTION_ROOT_INFO 236#endif /* APPLE_HYB */static int save_pname = 0;static const struct ld_option ld_options[] ={ {{"nobak", no_argument, NULL, OPTION_NOBAK}, '\0', NULL, "Do not include backup files", ONE_DASH}, {{"no-bak", no_argument, NULL, OPTION_NOBAK}, '\0', NULL, "Do not include backup files", ONE_DASH}, {{"abstract", required_argument, NULL, OPTION_ABSTRACT}, '\0', "FILE", "Set Abstract filename", ONE_DASH}, {{"appid", required_argument, NULL, 'A'}, 'A', "ID", "Set Application ID", ONE_DASH}, {{"biblio", required_argument, NULL, OPTION_BIBLIO}, '\0', "FILE", "Set Bibliographic filename", ONE_DASH}, {{"check-oldnames", no_argument, NULL, OPTION_CHECK_OLDNAMES}, '\0', NULL, "Check all imported ISO9660 names from old session", ONE_DASH}, {{"copyright", required_argument, NULL, OPTION_COPYRIGHT}, '\0', "FILE", "Set Copyright filename", ONE_DASH}, {{"eltorito-boot", required_argument, NULL, 'b'}, 'b', "FILE", "Set El Torito boot image name", ONE_DASH}, {{"eltorito-alt-boot", no_argument, NULL, OPTION_ALT_BOOT}, '\0', NULL, "Start specifying alternative El Torito boot parameters", ONE_DASH}, {{"sparc-boot", required_argument, NULL, 'B'}, 'B', "FILES", "Set sparc boot image names", ONE_DASH}, {{"generic-boot", required_argument, NULL, 'G'}, 'G', "FILE", "Set generic boot image name", ONE_DASH}, {{"sparc-label", required_argument, NULL, OPTION_SPARCLABEL}, '\0', "label text", "Set sparc boot disk label", ONE_DASH}, {{"eltorito-catalog", required_argument, NULL, 'c'}, 'c', "FILE", "Set El Torito boot catalog name", ONE_DASH}, {{"cdrecord-params", required_argument, NULL, 'C'}, 'C', "PARAMS", "Magic paramters from cdrecord", ONE_DASH}, {{"omit-period", no_argument, NULL, 'd'}, 'd', NULL, "Omit trailing periods from filenames (violates ISO9660)", ONE_DASH}, {{"disable-deep-relocation", no_argument, NULL, 'D'}, 'D', NULL, "Disable deep directory relocation (violates ISO9660)", ONE_DASH}, {{"follow-links", no_argument, NULL, 'f'}, 'f', NULL, "Follow symbolic links", ONE_DASH}, {{"graft-points", no_argument, NULL, OPTION_USE_GRAFT}, '\0', NULL, "Allow to use graft points for filenames", ONE_DASH}, {{"help", no_argument, NULL, OPTION_HELP}, '\0', NULL, "Print option help", ONE_DASH}, {{"hide", required_argument, NULL, OPTION_I_HIDE}, '\0', "GLOBFILE", "Hide ISO9660/RR file", ONE_DASH}, {{"hide-list", required_argument, NULL, OPTION_I_LIST}, '\0', "FILE", "File with list of ISO9660/RR files to hide", ONE_DASH}, {{"hidden", required_argument, NULL, OPTION_H_HIDE}, '\0', "GLOBFILE", "Set hidden attribute on ISO9660 file", ONE_DASH}, {{"hidden-list", required_argument, NULL, OPTION_H_LIST}, '\0', "FILE", "File with list of ISO9660 files with hidden attribute", ONE_DASH}, {{"hide-joliet", required_argument, NULL, OPTION_J_HIDE}, '\0', "GLOBFILE", "Hide Joliet file", ONE_DASH}, {{"hide-joliet-list", required_argument, NULL, OPTION_J_LIST}, '\0', "FILE", "File with list of Joliet files to hide", ONE_DASH}, {{"hide-joliet-trans-tbl", no_argument, NULL, OPTION_HIDE_TRANS_TBL}, '\0', NULL, "Hide TRANS.TBL from Joliet tree", ONE_DASH}, {{"hide-rr-moved", no_argument, NULL, OPTION_HIDE_RR_MOVED}, '\0', NULL, "Rename RR_MOVED to .rr_moved in Rock Ridge tree", ONE_DASH}, {{"gui", no_argument, NULL, OPTION_GUI}, '\0', NULL, "Switch behaviour for GUI", ONE_DASH}, {{NULL, required_argument, NULL, 'i'}, 'i', "ADD_FILES", "No longer supported", TWO_DASHES}, {{"iso-level", required_argument, NULL, OPTION_ISO_LEVEL}, '\0', "LEVEL", "Set ISO9660 conformance level (1..3)", ONE_DASH}, {{"joliet", no_argument, NULL, 'J'}, 'J', NULL, "Generate Joliet directory information", ONE_DASH}, {{"jcharset", required_argument, NULL, OPTION_JCHARSET}, '\0', "CHARSET", "Local charset for Joliet directory information", ONE_DASH}, {{"full-iso9660-filenames", no_argument, NULL, 'l'}, 'l', NULL, "Allow full 31 character filenames for ISO9660 names", ONE_DASH}, {{"max-iso9660-filenames", no_argument, NULL, OPTION_MAX_FILENAMES}, '\0', NULL, "Allow 37 character filenames for ISO9660 names (violates ISO9660)", ONE_DASH}, {{"allow-leading-dots", no_argument, NULL, 'L'}, 'L', NULL, "Allow ISO9660 filenames to start with '.' (violates ISO9660)", ONE_DASH}, {{"log-file", required_argument, NULL, OPTION_LOG_FILE}, '\0', "LOG_FILE", "Re-direct messages to LOG_FILE", ONE_DASH}, {{"exclude", required_argument, NULL, 'm'}, 'm', "GLOBFILE", "Exclude file name", ONE_DASH}, {{"exclude-list", required_argument, NULL, OPTION_X_LIST}, '\0', "FILE", "File with list of file names to exclude", ONE_DASH}, {{"pad", no_argument, NULL, OPTION_PAD}, 0, NULL, "Pad to a multiple of 32k", ONE_DASH}, {{"prev-session", required_argument, NULL, 'M'}, 'M', "FILE", "Set path to previous session to merge", ONE_DASH}, {{"omit-version-number", no_argument, NULL, 'N'}, 'N', NULL, "Omit version number from ISO9660 filename (violates ISO9660)", ONE_DASH}, {{"no-rr", no_argument, NULL, OPTION_NO_RR}, 0, NULL, "Inhibit reading of Rock Ridge attributes from previous session", ONE_DASH}, {{"no-split-symlink-components", no_argument, NULL, OPTION_NOSPLIT_SL_COMPONENT}, 0, NULL, "Inhibit splitting symlink components", ONE_DASH}, {{"no-split-symlink-fields", no_argument, NULL, OPTION_NOSPLIT_SL_FIELD}, 0, NULL, "Inhibit splitting symlink fields", ONE_DASH}, {{"output", required_argument, NULL, 'o'}, 'o', "FILE", "Set output file name", ONE_DASH}, {{"path-list", required_argument, NULL, OPTION_P_LIST}, '\0', "FILE", "File with list of pathnames to process", ONE_DASH}, {{"preparer", required_argument, NULL, 'p'}, 'p', "PREP", "Set Volume preparer", ONE_DASH}, {{"print-size", no_argument, NULL, OPTION_PRINT_SIZE}, '\0', NULL, "Print estimated filesystem size and exit", ONE_DASH}, {{"publisher", required_argument, NULL, 'P'}, 'P', "PUB", "Set Volume publisher", ONE_DASH}, {{"quiet", no_argument, NULL, OPTION_QUIET}, '\0', NULL, "Run quietly", ONE_DASH}, {{"rational-rock", no_argument, NULL, 'r'}, 'r', NULL, "Generate rationalized Rock Ridge directory information", ONE_DASH}, {{"rock", no_argument, NULL, 'R'}, 'R', NULL, "Generate Rock Ridge directory information", ONE_DASH},#ifdef SORTING { {"sort", required_argument, NULL, OPTION_SORT}, '\0', "FILE", "Sort file content locations according to rules in FILE" , ONE_DASH },#endif /* SORTING */ {{"split-output", no_argument, NULL, OPTION_SPLIT_OUTPUT}, '\0', NULL, "Split output into files of approx. 1GB size", ONE_DASH}, {{"sysid", required_argument, NULL, OPTION_SYSID}, '\0', "ID", "Set System ID", ONE_DASH}, {{"translation-table", no_argument, NULL, 'T'}, 'T', NULL, "Generate translation tables for systems that don't understand long filenames", ONE_DASH}, {{"table-name", required_argument, NULL, OPTION_TRANS_TBL}, '\0', "TABLE_NAME", "Translation table file name", ONE_DASH}, {{"ucs-level", required_argument, NULL, OPTION_UCS_LEVEL}, '\0', "LEVEL", "Set Joliet UCS level (1..3)", ONE_DASH}, {{"untranslated-filenames", no_argument, NULL, 'U'}, 'U', NULL, "Allow Untranslated filenames (for HPUX & AIX - violates ISO9660). Forces -l, -d, -L, -N, -relaxed-filenames, -allow-lowercase, -allow-multidot", ONE_DASH}, {{"relaxed-filenames", no_argument, NULL, OPTION_RELAXED_FILENAMES}, '\0', NULL, "Allow 7 bit ASCII except lower case characters (violates ISO9660)", ONE_DASH}, {{"no-iso-translate", no_argument, NULL, OPTION_ISO_TRANSLATE}, '\0', NULL, "Do not translate illegal ISO chacters '~' and '#' (violates ISO9660)", ONE_DASH}, {{"allow-lowercase", no_argument, NULL, OPTION_ALLOW_LOWERCASE}, '\0', NULL, "Allow lower case characters in addition to the current character set (violates ISO9660)", ONE_DASH}, {{"allow-multidot", no_argument, NULL, OPTION_ALLOW_MULTIDOT}, '\0', NULL, "Allow more than one dot in filenames (e.g. .tar.gz) (violates ISO9660)", ONE_DASH}, {{"use-fileversion", no_argument, NULL, OPTION_USE_FILEVERSION}, '\0', "LEVEL", "Use file version # from filesystem", ONE_DASH}, {{"verbose", no_argument, NULL, 'v'}, 'v', NULL, "Verbose", ONE_DASH}, {{"version", no_argument, NULL, OPTION_PVERSION}, '\0', NULL, "Print the current version", ONE_DASH}, {{"volid", required_argument, NULL, 'V'}, 'V', "ID", "Set Volume ID", ONE_DASH}, {{"volset", required_argument, NULL, OPTION_VOLSET}, '\0', "ID", "Set Volume set ID", ONE_DASH}, {{"volset-size", required_argument, NULL, OPTION_VOLSET_SIZE}, '\0', "#", "Set Volume set size", ONE_DASH}, {{"volset-seqno", required_argument, NULL, OPTION_VOLSET_SEQ_NUM},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -