⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkisofs.c

📁 创建一个符合iso-9660标准的iso文件系统
💻 C
📖 第 1 页 / 共 5 页
字号:
	'\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#ifdef APPLE_HYB	{{"hfs-type", required_argument, NULL, OPTION_HFS_TYPE},	'\0', "TYPE", "Set HFS default TYPE", ONE_DASH},	{{"hfs-creator", required_argument, NULL, OPTION_HFS_CREATOR},	'\0', "CREATOR", "Set HFS default CREATOR", ONE_DASH},	{{"apple", no_argument, NULL, 'g'},	'g', NULL, "Add Apple ISO9660 extensions", ONE_DASH},	{{"hfs", no_argument, NULL, 'h'},	'h', NULL, "Create ISO9660/HFS hybrid", ONE_DASH},	{{"map", required_argument, NULL, 'H'},	'H', "MAPPING_FILE", "Map file extensions to HFS TYPE/CREATOR", ONE_DASH},	{{"magic", required_argument, NULL, OPTION_MAGIC_FILE},	'\0', "FILE", "Magic file for HFS TYPE/CREATOR", ONE_DASH},	{{"probe", no_argument, NULL, OPTION_PROBE},	'\0', NULL, "Probe all files for Apple/Unix file types", ONE_DASH},	{{"mac-name", no_argument, NULL, OPTION_MACNAME},	'\0', NULL, "Use Macintosh name for ISO9660/Joliet/RockRidge file name",	ONE_DASH},	{{"no-mac-files", no_argument, NULL, OPTION_NOMACFILES},	'\0', NULL, "Do not look for Unix/Mac files (depreciated)", ONE_DASH},	{{"boot-hfs-file", required_argument, NULL, OPTION_BOOT_HFS_FILE},	'\0', "FILE", "Set HFS boot image name", ONE_DASH},	{{"part", no_argument, NULL, OPTION_GEN_PT},	'\0', NULL, "Generate HFS partition table", ONE_DASH},	{{"cluster-size", required_argument, NULL, OPTION_BSIZE},	'\0', "SIZE", "Cluster size for PC Exchange Macintosh files", ONE_DASH},	{{"auto", required_argument, NULL, OPTION_AUTOSTART},	'\0', "FILE", "Set HFS AutoStart file name", ONE_DASH},	{{"no-desktop", no_argument, NULL, OPTION_CREATE_DT},	'\0', NULL, "Do not create the HFS (empty) Desktop files", ONE_DASH},	{{"hide-hfs", required_argument, NULL, OPTION_HFS_HIDE},	'\0', "GLOBFILE", "Hide HFS file", ONE_DASH},	{{"hide-hfs-list", required_argument, NULL, OPTION_HFS_LIST},	'\0', "FILE", "List of HFS files to hide", ONE_DASH},	{{"hfs-volid", required_argument, NULL, OPTION_HFS_VOLID},	'\0', "HFS_VOLID", "Volume name for the HFS partition", ONE_DASH},	{{"icon-position", no_argument, NULL, OPTION_ICON_POS},	'\0', NULL, "Keep HFS icon position", ONE_DASH},	{{"root-info", required_argument, NULL, OPTION_ROOT_INFO},	'\0', "FILE", "finderinfo for root folder", ONE_DASH},#ifdef PREP_BOOT	{{"prep-boot", required_argument, NULL, OPTION_PREP_BOOT},	'\0', "FILE", "PReP boot image file -- up to 4 are allowed", ONE_DASH},#endif	/* PREP_BOOT */	{{"cap", no_argument, NULL, OPTION_CAP},	'\0', NULL, "Look for AUFS CAP Macintosh files", TWO_DASHES},	{{"netatalk", no_argument, NULL, OPTION_NETA},	'\0', NULL, "Look for NETATALK Macintosh files", TWO_DASHES},	{{"double", no_argument, NULL, OPTION_DBL},	'\0', NULL, "Look for AppleDouble Macintosh files", TWO_DASHES},	{{"ethershare", no_argument, NULL, OPTION_ESH},	'\0', NULL, "Look for Helios EtherShare Macintosh files", TWO_DASHES},	{{"exchange", no_argument, NULL, OPTION_FE},	'\0', NULL, "Look for PC Exchange Macintosh files", TWO_DASHES},	{{"sgi", no_argument, NULL, OPTION_SGI},	'\0', NULL, "Look for SGI Macintosh files", TWO_DASHES},	{{"macbin", no_argument, NULL, OPTION_MBIN},	'\0', NULL, "Look for MacBinary Macintosh files", TWO_DASHES},	{{"single", no_argument, NULL, OPTION_SGL},	'\0', NULL, "Look for AppleSingle Macintosh files", TWO_DASHES},	{{"ushare", no_argument, NULL, OPTION_USH},	'\0', NULL, "Look for IPT UShare Macintosh files", TWO_DASHES},	{{"xinet", no_argument, NULL, OPTION_XIN},	'\0', NULL, "Look for XINET Macintosh files", TWO_DASHES},	{{"dave", no_argument, NULL, OPTION_DAVE},	'\0', NULL, "Look for DAVE Macintosh files", TWO_DASHES},	{{"sfm", no_argument, NULL, OPTION_SFM},	'\0', NULL, "Look for SFM Macintosh files", TWO_DASHES},#endif	/* APPLE_HYB */};#define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])#if defined(ultrix) || defined(_AUX_SOURCE)	char    *strdup		__PR((char *s));#endif	void	read_rcfile	__PR((char *appname));	void	usage		__PR((int excode));	int	iso9660_date	__PR((char *result, time_t crtime));static	void	hide_reloc_dir	__PR((void));static	char *	get_pnames	__PR((int argc, char **argv, int opt,					char *pname, int pnsize, FILE * fp));	int	main		__PR((int argc, char **argv));	char *	findequal	__PR((char *s));	char *	escstrcpy	__PR((char *to, char *from));	void *	e_malloc	__PR((size_t size));#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;}#endifvoidread_rcfile(appname)	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) {		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))#ifdef	USE_LIBSCHILY		errmsg("Read error on '%s'.\n", filename);#else		perror(filename);#endif	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#endifvoidusage(excode)	int		excode;{	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;/*	const char **targets, **pp;*/	fprintf(stderr, "Usage: %s [options] file...\n", program_name);	fprintf(stderr, "Options:\n");	for (i = 0; i < OPTION_COUNT; i++) {		if (ld_options[i].doc != NULL) {			int	comma;			int	len;			int	j;			fprintf(stderr, "  ");			comma = FALSE;			len = 2;			j = i;			do {				if (ld_options[j].shortopt != '\0'					&& ld_options[j].control != NO_HELP) {					fprintf(stderr, "%s-%c",						comma ? ", " : "",						ld_options[j].shortopt);					len += (comma ? 2 : 0) + 2;					if (ld_options[j].arg != NULL) {						if (ld_options[j].opt.has_arg != optional_argument) {							fprintf(stderr, " ");							++len;						}						fprintf(stderr, "%s",							ld_options[j].arg);						len += strlen(ld_options[j].arg);					}					comma = TRUE;				}				++j;			}			while (j < OPTION_COUNT && ld_options[j].doc == NULL);			j = i;			do {				if (ld_options[j].opt.name != NULL					&& ld_options[j].control != NO_HELP) {					fprintf(stderr, "%s-%s%s",						comma ? ", " : "",						ld_options[j].control == TWO_DASHES ? "-" : "",						ld_options[j].opt.name);					len += ((comma ? 2 : 0)						+ 1						+ (ld_options[j].control == TWO_DASHES ? 1 : 0)						+ strlen(ld_options[j].opt.name));					if (ld_options[j].arg != NULL) {						fprintf(stderr, " %s",							ld_options[j].arg);						len += 1 +						    strlen(ld_options[j].arg);					}					comma = TRUE;				}				++j;			}			while (j < OPTION_COUNT && ld_options[j].doc == NULL);			if (len >= 30) {				fprintf(stderr, "\n");				len = 0;			}			for (; len < 30; len++)				fputc(' ', stderr);			fprintf(stderr, "%s\n", ld_options[i].doc);		}	}	exit(excode);}/* * Fill in date in the iso9660 format * * The standards  state that the timezone offset is in multiples of 15 * minutes, and is what you add to GMT to get the localtime.  The U.S. * is always at a negative offset, from -5h to -8h (can vary a little * with DST,  I guess).  The Linux iso9660 filesystem has had the sign * of this wrong for ages (mkisofs had it wrong too for the longest time). */intiso9660_date(result, crtime)	char	*result;	time_t	crtime;{	struct tm	*local;	local = localtime(&crtime);	result[0] = local->tm_year;	result[1] = local->tm_mon + 1;	result[2] = local->tm_mday;	result[3] = local->tm_hour;	result[4] = local->tm_min;	result[5] = local->tm_sec;	/*	 * Must recalculate proper timezone offset each time, as some files use	 * daylight savings time and some don't...	 */	result[6] = local->tm_yday;	/* save yday 'cause gmtime zaps it */	local = gmtime(&crtime);	local->tm_year -= result[0];	local->tm_yday -= result[6];	local->tm_hour -= result[3];	local->tm_min -= result[4];	if (local->tm_year < 0) {		local->tm_yday = -1;	} else {		if (local->tm_year > 0)			local->tm_yday = 1;	}	result[6] = -(local->tm_min + 60 *			(local->tm_hour + 24 * local->tm_yday)) / 15;	return 0;}/* hide "./rr_moved" if all its contents are hidden */static voidhide_reloc_dir(){	struct directory_entry *s_entry;	for (s_entry = reloc_dir->contents; s_entry; s_entry = s_entry->next) {		if (strcmp(s_entry->name, ".") == 0 ||				strcmp(s_entry->name, "..") == 0)			continue;		if ((s_entry->de_flags & INHIBIT_ISO9660_ENTRY) == 0)			return;	}	/* all entries are hidden, so hide this directory */	reloc_dir->dir_flags |= INHIBIT_ISO9660_ENTRY;	reloc_dir->self->de_flags |= INHIBIT_ISO9660_ENTRY;}/* * get pathnames from the command line, and then from given file */static char *get_pnames(argc, argv, opt, pname, pnsize, fp)	int	argc;	char	**argv;	int	opt;	char	*pname;	int	pnsize;	FILE	*fp;{	/* we may of already read the first line from the pathnames file */	if (save_pname) {		save_pname = 0;		return (pname);	}	if (opt < argc)		return (argv[opt]);	if (fp == NULL)		return ((char *) 0);	if (fgets(pname, pnsize, fp)) {		pname[strlen(pname) - 1] = '\0';	/* Discard newline */		return (pname);	}	return ((char *) 0);}extern char	*cdrecord_data;intmain(argc, argv)	int		argc;	char		**argv;{	struct directory_entry de;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -