📄 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 <errno.h>#include "config.h"#include "mkisofs.h"#include "match.h"#include "foolhash.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 __NetBSD__#include <sys/time.h>#include <sys/resource.h>#endifstruct directory * root = NULL;static char version_string[] = "mkisofs 1.12b5";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 use_RockRidge = 0;int use_Joliet = 0;int do_fileopt = 0;int verbose = 1;int all_files = 0;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;int volume_set_size = 1;int volume_sequence_number = 1;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 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_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 */struct rcopts{ char * tag; char ** variable;};struct hash_table *md5_hash=NULL;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 165static const struct ld_option ld_options[] ={ { {"all-files", no_argument, NULL, 'a'}, 'a', NULL, "Process all files (don't skip 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 }, { {"eltorito-catalog", required_argument, NULL, 'c'}, 'c', "FILE", "Set El Torito boot catalog name" , ONE_DASH }, { {"cdwrite-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-joliet", required_argument, NULL, OPTION_J_HIDE}, '\0', "GLOBFILE", "Hide Joliet file" , 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 }, { {"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-split-symlink-components", no_argument, NULL, 0}, 0, NULL, "Inhibit splitting symlink components" , ONE_DASH }, { {"no-split-symlink-fields", no_argument, NULL, 0}, 0, NULL, "Inhibit splitting symlink fields" , ONE_DASH }, { {"output", required_argument, NULL, 'o'}, 'o', "FILE", "Set output file name" , ONE_DASH }, { {"optimize", no_argument, NULL, 'O'}, 'O', NULL, "Optimize for file space", 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 }, { {"verbose", no_argument, NULL, 'v'}, 'v', NULL, "Verbose", 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 }#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((void));static void hide_reloc_dir __PR((void));void FDECL1(read_rcfile, char *, appname){ FILE * rcfile; struct rcopts * rco; char * pnt, *pnt1; char linebuffer[256]; static char rcfn[] = ".mkisofsrc"; char filename[1000]; int linum; strcpy(filename, rcfn); rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT) perror(filename); if (!rcfile) { pnt = getenv("MKISOFSRC"); if (pnt && strlen(pnt) <= sizeof(filename)) { strcpy(filename, pnt); rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT) perror(filename); } } if (!rcfile) { pnt = getenv("HOME"); if (pnt && strlen(pnt) + strlen(rcfn) + 2 <= sizeof(filename)) { strcpy(filename, pnt); strcat(filename, "/"); strcat(filename, rcfn); rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT) perror(filename); } } if (!rcfile && strlen(appname)+sizeof(rcfn)+2 <= sizeof(filename)) { strcpy(filename, appname); pnt = strrchr(filename, '/'); if (pnt) { strcpy(pnt + 1, rcfn); rcfile = fopen(filename, "r"); if (!rcfile && errno != ENOENT) perror(filename); } } if (!rcfile) return; if ( verbose > 0 ) { fprintf(stderr, "Using \"%s\"\n", filename); } /* OK, we got it. Now read in the lines and parse them */ linum = 0; while (fgets(linebuffer, sizeof(linebuffer), rcfile)) { char *name; char *name_end; ++linum; /* skip any leading white space */ pnt = linebuffer; while (*pnt == ' ' || *pnt == '\t') ++pnt; /* If we are looking at a # character, this line is a comment. */ if (*pnt == '#') continue; /* The name should begin in the left margin. Make sure it is in upper case. Stop when we see white space or a comment. */ name = pnt; while (*pnt && isalpha((unsigned char)*pnt)) { if(islower((unsigned char)*pnt)) *pnt = toupper((unsigned char)*pnt); pnt++; } if (name == pnt) { fprintf(stderr, "%s:%d: name required\n", filename, linum); continue; } name_end = pnt; /* Skip past white space after the name */ while (*pnt == ' ' || *pnt == '\t') pnt++; /* silently ignore errors in the rc file. */ if (*pnt != '=') { fprintf(stderr, "%s:%d: equals sign required\n", filename, linum); continue; } /* Skip pas the = sign, and any white space following it */ pnt++; /* Skip past '=' sign */ while (*pnt == ' ' || *pnt == '\t') pnt++; /* now it is safe to NUL terminate the name */ *name_end = 0; /* Now get rid of trailing newline */ pnt1 = pnt; while (*pnt1) { if (*pnt1 == '\n') { *pnt1 = 0; break; } pnt1++; }; /* OK, now figure out which option we have */ for(rco = rcopt; rco->tag; rco++) { if(strcmp(rco->tag, name) == 0) { *rco->variable = strdup(pnt); break; }; } if (rco->tag == NULL) { fprintf(stderr, "%s:%d: field name \"%s\" unknown\n", filename, linum, name); } } if (ferror(rcfile)) perror(filename); fclose(rcfile);}char * path_table_l = NULL;char * path_table_m = NULL;char * jpath_table_l = NULL;char * jpath_table_m = NULL;int goof = 0;#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endifvoid usage(){ const char * program_name = "mkisofs";#if 0 fprintf(stderr,"Usage:\n"); fprintf(stderr,"mkisofs [-o outfile] [-R] [-V volid] [-v] [-a] \[-T]\n [-l] [-d] [-V] [-D] [-L] [-p preparer]""[-P publisher] [ -A app_id ] [-z] \n \[-b boot_image_name] [-c boot_catalog-name] \[-x path -x path ...] path\n");#endif int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -