📄 mkisofs.c
字号:
/* * Program mkisofs.c - generate iso9660 filesystem based upon directory * tree on hard disk. Written by Eric Youngdale (1993). Copyright 1993 Yggdrasil Computing, Incorporated 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. */static char rcsid[] ="$Id: mkisofs.c,v 1.32 1999/03/07 21:48:49 eric Exp $";#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 <stdlib.h>#include <sys/stat.h>#ifndef VMS#ifdef HAVE_UNISTD_H#include <unistd.h>#endif#endif#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 */#ifdef USE_LIBSCHILY#include <standard.h>#endifstruct directory * root = NULL;static char version_string[] = "mkisofs 1.12";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 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 print_size = 0;int split_output = 0;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 volume_set_size = 1;int volume_sequence_number = 1;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 full_iso9660_filenames = 0; /* Used with Amiga. Disc will not work with DOS */int allow_untranslated = 0; /* Minimal (only truncation of 30+ characters) translation of filenames. This is for HP-UX, which does not recognize ANY extentions (Rock Ridge, Joliet), causing pain when loading software. pfs_mount can be used to read the extensions, but the untranslated filenames can be read by the "native" cdfs mounter. Completely violates iso9660. */int allow_leading_dots = 0; /* DOS cannot read names with leading dots */int 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 */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}, {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 183static const struct ld_option ld_options[] ={ { {"all-files", no_argument, NULL, 'a'}, 'a', NULL, "Process all files (don't skip backup files)", ONE_DASH }, { {"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 }, { {"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 }, { {"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", ONE_DASH }, { {"disable-deep-relocation", no_argument, NULL, 'D'}, 'D', NULL, "Disable deep directory relocation", ONE_DASH }, { {"follow-links", no_argument, NULL, 'f'}, 'f', NULL, "Follow symbolic links", 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 }, { {"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 }, { {"joliet", no_argument, NULL, 'J'}, 'J', NULL, "Generate Joliet directory information", ONE_DASH }, { {"full-iso9660-filenames", no_argument, NULL, 'l'}, 'l', NULL, "Allow full 32 character filenames for iso9660 names", ONE_DASH }, { {"allow-leading-dots", no_argument, NULL, 'L'}, 'L', NULL, "Allow iso9660 filenames to start with '.'", 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 }, { {"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", 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 }, { {"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 }, { {"untranslated-filenames", no_argument, NULL, 'U'}, 'U', NULL, "Allow Untranslated filenames (for HPUX & AIX). Forces on -d, -l, -L, -N", 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}, '\0', "#", "Set Volume set sequence number" , ONE_DASH }, { {"old-exclude", required_argument, NULL, 'x'}, 'x', "FILE", "Exclude file name(depreciated)" , ONE_DASH }, { {"hard-disk-boot", no_argument, NULL, OPTION_HARD_DISK_BOOT}, '\0', NULL, "Boot image is a hard disk image", ONE_DASH }, { {"no-emul-boot", no_argument, NULL, OPTION_NO_EMUL_BOOT}, '\0', NULL, "Boot image is 'no emulation' image", ONE_DASH }, { {"no-boot", no_argument, NULL, OPTION_NO_BOOT}, '\0', NULL, "Boot image is not bootable", ONE_DASH }, { {"boot-load-seg", required_argument, NULL, OPTION_BOOT_LOAD_ADDR}, '\0', "#", "Set load segment for boot image" , ONE_DASH }, { {"boot-load-size", required_argument, NULL, OPTION_BOOT_LOAD_SIZE}, '\0', "#", "Set numbers of load sectors", ONE_DASH }, { {"boot-info-table", no_argument, NULL, OPTION_BOOT_INFO_TABLE}, '\0', NULL, "Patch boot image with info table", ONE_DASH },#ifdef ERIC_neverdef { {"transparent-compression", no_argument, NULL, 'z'}, 'z', NULL, "Enable transparent compression of files", ONE_DASH },#endif};#define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])#if defined(ultrix) || defined(_AUX_SOURCE)char *strdup(s)char *s;{char *c;if(c=(char *)malloc(strlen(s)+1))strcpy(c,s);return c;}#endif void read_rcfile __PR((char * appname)); void usage __PR((int excode));static void hide_reloc_dir __PR((void));void FDECL1(read_rcfile, char *, appname){ FILE * rcfile = (FILE *)NULL; struct rcopts * rco; char * pnt, *pnt1; char linebuffer[256]; static char rcfn[] = ".mkisofsrc"; char filename[1000]; int linum; strcpy(filename, rcfn); if (access(filename, R_OK) == 0) rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT)#ifdef USE_LIBSCHILY errmsg("Cannot open '%s'.\n", filename);#else perror(filename);#endif if (!rcfile) { pnt = getenv("MKISOFSRC"); if (pnt && strlen(pnt) <= sizeof(filename)) { strcpy(filename, pnt); if (access(filename, R_OK) == 0) rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT)#ifdef USE_LIBSCHILY errmsg("Cannot open '%s'.\n", filename);#else perror(filename);#endif } } if (!rcfile) { pnt = getenv("HOME"); if (pnt && strlen(pnt) + strlen(rcfn) + 2 <= sizeof(filename)) { strcpy(filename, pnt); strcat(filename, "/"); strcat(filename, rcfn); if (access(filename, R_OK) == 0) rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT)#ifdef USE_LIBSCHILY errmsg("Cannot open '%s'.\n", filename);#else perror(filename);#endif } } if (!rcfile && strlen(appname)+sizeof(rcfn)+2 <= sizeof(filename)) { strcpy(filename, appname); pnt = strrchr(filename, '/'); if (pnt) { strcpy(pnt + 1, rcfn); if (access(filename, R_OK) == 0) rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT)#ifdef USE_LIBSCHILY errmsg("Cannot open '%s'.\n", filename);#else perror(filename);#endif } } if (!rcfile) return; if ( verbose > 0 ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -