If anyone is interested here is my branch of mkisofs. I plan to keep Joerg Schilling mkisofs as base.
The fixes in my branch are: mkisofs_noprogdateversioncmdlineversion.diff Do not leak unneeded information about command line used or system used. Many other image creators also don't leak this information. mkisofs_notevenpathtables.diff This saves up to 4 sectors not used. Making images like other image creators. mkisofs_notimezone.diff Do not write timezone information to the image as new and correct filesystems do. mkisofs_correctmtime.diff Set the cd time based on the files that go in the image not the current time. The current code in mkisofs is getting current time from many places and this fixes it. The patches should apply in the order shown. If any of you have problems applying the patches or wants and easier way just contact me.
--- cdrtools-1.10/mkisofs/Makefile Tue Apr 3 20:33:26 2001 +++ cdrtools-1.10/mkisofs/Makefile Wed Nov 14 12:03:44 2001 @@ -28,7 +28,6 @@ CPPOPTS += -DSORTING CPPOPTS += -I../libhfs_iso/ CPPOPTS += -DHAVE_CONFIG_H -DUSE_LIBSCHILY -DUSE_SCG \ - '-DAPPID_DEFAULT="MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"' \ -I../cdrecord CFILES= mkisofs.c tree.c write.c hash.c rock.c multi.c \ joliet.c match.c name.c fnmatch.c eltorito.c boot.c \ --- cdrtools-1.10/mkisofs/defaults.h Tue Apr 3 20:33:26 2001 +++ cdrtools-1.10/mkisofs/defaults.h Wed Nov 14 12:05:39 2001 @@ -8,13 +8,7 @@ #define PREPARER_DEFAULT NULL #define PUBLISHER_DEFAULT NULL -#ifndef APPID_DEFAULT -#ifdef APPLE_HYB -#define APPID_DEFAULT "MKISOFS ISO 9660/HFS FILESYSTEM BUILDER (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING" -#else -#define APPID_DEFAULT "MKISOFS ISO 9660 FILESYSTEM BUILDER (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING" -#endif /* APPLE_HYB */ -#endif +#define APPID_DEFAULT NULL #define COPYRIGHT_DEFAULT NULL #define BIBLIO_DEFAULT NULL #define ABSTRACT_DEFAULT NULL @@ -26,85 +20,3 @@ #define APPLE_TYPE_DEFAULT "TEXT" #define APPLE_CREATOR_DEFAULT "unix" #endif /* APPLE_HYB */ - -#ifdef __QNX__ -#define SYSTEM_ID_DEFAULT "QNX" -#endif - -#ifdef __osf__ -#define SYSTEM_ID_DEFAULT "OSF" -#endif - -#ifdef __sun -#ifdef __SVR4 -#define SYSTEM_ID_DEFAULT "Solaris" -#else -#define SYSTEM_ID_DEFAULT "SunOS" -#endif -#endif - -#ifdef __hpux -#define SYSTEM_ID_DEFAULT "HP-UX" -#endif - -#ifdef __sgi -#define SYSTEM_ID_DEFAULT "SGI" -#endif - -#if defined(_IBMR2) || defined(_AIX) -#define SYSTEM_ID_DEFAULT "AIX" -#endif - -#if defined(_WIN) || defined(__CYGWIN32__) || defined(__CYGWIN__) -#define SYSTEM_ID_DEFAULT "Win32" -#endif /* _WIN */ - -#ifdef __EMX__ -#define SYSTEM_ID_DEFAULT "OS/2" -#endif - -#ifdef __FreeBSD__ -#define SYSTEM_ID_DEFAULT "FreeBSD" -#endif - -#ifdef __NetBSD__ -#define SYSTEM_ID_DEFAULT "NetBSD" -#endif - -#ifdef __OpenBSD__ -#define SYSTEM_ID_DEFAULT "OpenBSD" -#endif - -#ifdef __bsdi__ -#define SYSTEM_ID_DEFAULT "BSD/OS" -#endif - -#ifdef __NeXT__ -#define SYSTEM_ID_DEFAULT "NeXT" -#endif - -#if defined(__NeXT__) && defined(__TARGET_OSNAME) && __TARGET_OSNAME == rhapsody -#undef SYSTEM_ID_DEFAULT -#define SYSTEM_ID_DEFAULT "Rhapsody" -#endif - -#if defined(__APPLE__) && defined(__MACH__) -#undef SYSTEM_ID_DEFAULT -#define SYSTEM_ID_DEFAULT "Mac OS X" -#endif - -#ifdef __BEOS__ -#define SYSTEM_ID_DEFAULT "BeOS" -#endif - -#ifdef __OS2 -#define SYSTEM_ID_DEFAULT "OS/2" -#endif - -#ifdef VMS -#define SYSTEM_ID_DEFAULT "VMS" -#endif - -#ifndef SYSTEM_ID_DEFAULT -#define SYSTEM_ID_DEFAULT "LINUX" -#endif --- cdrtools-1.10/mkisofs/mkisofs.c Fri Apr 20 15:45:50 2001 +++ cdrtools-1.10/mkisofs/mkisofs.c Wed Nov 14 12:02:54 2001 @@ -128,7 +128,7 @@ char *abstract = ABSTRACT_DEFAULT; char *volset_id = VOLSET_ID_DEFAULT; char *volume_id = VOLUME_ID_DEFAULT; -char *system_id = SYSTEM_ID_DEFAULT; +char *system_id = ""; char *boot_catalog = BOOT_CATALOG_DEFAULT; char *boot_image = BOOT_IMAGE_DEFAULT; char *genboot_image = BOOT_IMAGE_DEFAULT; @@ -2775,9 +2775,6 @@ } /* Finally the last volume desctiptor. */ outputlist_insert(&end_vol); - - /* Insert the version desctiptor. */ - outputlist_insert(&version_desc); /* Now start with path tables and directory tree info. */ outputlist_insert(&pathtable_desc); --- cdrtools-1.10/mkisofs/mkisofs.h Mon Apr 2 17:04:36 2001 +++ cdrtools-1.10/mkisofs/mkisofs.h Wed Nov 14 12:02:54 2001 @@ -164,7 +164,6 @@ extern struct output_fragment joliet_desc; extern struct output_fragment torito_desc; extern struct output_fragment end_vol; -extern struct output_fragment version_desc; extern struct output_fragment pathtable_desc; extern struct output_fragment jpathtable_desc; extern struct output_fragment dirtree_desc; --- cdrtools-1.10/mkisofs/write.c Thu Feb 15 22:04:02 2001 +++ cdrtools-1.10/mkisofs/write.c Wed Nov 14 12:02:54 2001 @@ -105,7 +105,6 @@ static int file_write __PR((FILE *outfile)); static int pvd_write __PR((FILE *outfile)); static int evd_write __PR((FILE *outfile)); -static int vers_write __PR((FILE *outfile)); static int pathtab_write __PR((FILE *outfile)); static int exten_write __PR((FILE *outfile)); int oneblock_size __PR((int starting_extent)); @@ -1800,48 +1799,6 @@ } /* - * Function to write the version information for the disc. - */ -static int -vers_write(outfile) - FILE *outfile; -{ - char vers[SECTOR_SIZE]; - int X_ac; - char **X_av; - char *cp; - int i; - int idx = 4; - int len; - extern char version_string[]; - - /* Now write the version descriptor. */ - memset(vers, 0, sizeof(vers)); - strcpy(vers, "MKI "); - - cp = vers; - X_ac = saved_ac(); - X_av = saved_av(); - strcpy(&cp[idx], ctime(&begun)); - idx += 25; - strcpy(&cp[idx], version_string); - idx += strlen(version_string); - for (i = 1; i < X_ac; i++) { - len = strlen(X_av[i]); - if ((idx + len + 1) >= SECTOR_SIZE) - break; - cp[idx++] = ' '; - strcpy(&cp[idx], X_av[i]); - idx += len; - } - - cp[SECTOR_SIZE - 1] = '\0'; - xfwrite(vers, 1, SECTOR_SIZE, outfile); - last_extent_written += 1; - return 0; -} - -/* * Function to write the path table for the disc. */ static int @@ -2432,7 +2389,6 @@ struct output_fragment padblock_desc = {NULL, padblock_size, NULL, padblock_write}; struct output_fragment voldesc_desc = {NULL, oneblock_size, root_gen, pvd_write}; struct output_fragment end_vol = {NULL, oneblock_size, NULL, evd_write}; -struct output_fragment version_desc = {NULL, oneblock_size, NULL, vers_write}; struct output_fragment pathtable_desc = {NULL, pathtab_size, generate_path_tables, pathtab_write}; struct output_fragment dirtree_desc = {NULL, dirtree_size, NULL, dirtree_write}; struct output_fragment dirtree_clean = {NULL, dirtree_fixup, dirtree_dump, dirtree_cleanup};
--- cdrtools-1.10/mkisofs/mkisofs.c Tue Dec 11 21:39:45 2001 +++ cdrtools-1.10/mkisofs/mkisofs.c Tue Dec 11 21:39:56 2001 @@ -2735,14 +2735,8 @@ } /* Now assign addresses on the disc for the path table. */ - path_blocks = (path_table_size + (SECTOR_SIZE - 1)) >> 11; - if (path_blocks & 1) - path_blocks++; - jpath_blocks = (jpath_table_size + (SECTOR_SIZE - 1)) >> 11; - if (jpath_blocks & 1) - jpath_blocks++; /* * Start to set up the linked list that we use to track the contents
--- cdrtools-1.10/mkisofs/mkisofs.c Sun Nov 11 14:29:23 2001 +++ cdrtools-1.10/mkisofs/mkisofs.c Sun Nov 11 14:52:49 2001 @@ -953,46 +953,26 @@ /* * 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). + * We use gmtime as in disk time should always refer to UTC + * If they wouldn't refer to UTC we needed two conversions when + * seeing them. One to translate from in disk timezone to gmt + * and other to translate to local timezone */ int iso9660_date(result, crtime) char *result; time_t crtime; { - struct tm *local; + struct tm *gmt; - 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; + gmt = gmtime(&crtime); + result[0] = gmt->tm_year; + result[1] = gmt->tm_mon + 1; + result[2] = gmt->tm_mday; + result[3] = gmt->tm_hour; + result[4] = gmt->tm_min; + result[5] = gmt->tm_sec; + result[6] = 0; return 0; } --- cdrtools-1.10/mkisofs/write.c Sun Nov 11 14:29:23 2001 +++ cdrtools-1.10/mkisofs/write.c Sun Nov 11 14:51:34 2001 @@ -1667,13 +1667,17 @@ { char iso_time[17]; int should_write; - struct tm local; struct tm gmt; time(&begun); - local = *localtime(&begun); + /* + * We use gmtime as in disk time should always refer to UTC + * If they wouldn't refer to UTC we needed two conversions when + * seeing them. One to translate from in disk timezone to gmt + * and other to translate to local timezone + */ gmt = *gmtime(&begun); /* @@ -1681,15 +1685,11 @@ * That's not true, in 2000 tm_year == 100, so 1900+tm_year == 2000. */ sprintf(iso_time, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d00", - 1900 + local.tm_year, - local.tm_mon + 1, local.tm_mday, - local.tm_hour, local.tm_min, local.tm_sec); + 1900 + gmt.tm_year, + gmt.tm_mon + 1, gmt.tm_mday, + gmt.tm_hour, gmt.tm_min, gmt.tm_sec); - local.tm_min -= gmt.tm_min; - local.tm_hour -= gmt.tm_hour; - local.tm_yday -= gmt.tm_yday; - iso_time[16] = (local.tm_min + 60 * - (local.tm_hour + 24 * local.tm_yday)) / 15; + iso_time[16] = 0; /* Next we write out the primary descriptor for the disc */ memset(&vol_desc, 0, sizeof(vol_desc));
--- cdrtools-1.10/mkisofs/mkisofs.h Mon Dec 24 08:40:47 2001 +++ cdrtools-1.10/mkisofs/mkisofs.h Mon Dec 24 09:24:24 2001 @@ -247,6 +247,7 @@ extern unsigned int last_extent; extern unsigned int last_extent_written; extern unsigned int session_start; +extern time_t cd_time; extern unsigned int path_table_size; extern unsigned int path_table[4]; --- cdrtools-1.10/mkisofs/tree.c Mon Dec 24 08:38:57 2001 +++ cdrtools-1.10/mkisofs/tree.c Mon Dec 24 09:19:26 2001 @@ -762,11 +762,9 @@ static void generate_reloc_directory() { - time_t current_time; struct directory_entry *s_entry; /* Create an entry for our internal tree */ - time(¤t_time); reloc_dir = (struct directory *) e_malloc(sizeof(struct directory)); memset(reloc_dir, 0, sizeof(struct directory)); @@ -806,7 +804,7 @@ root->contents->filedir = root; root->contents->isorec.flags[0] = ISO_DIRECTORY; root->contents->priority = 32768; - iso9660_date(root->contents->isorec.date, current_time); + iso9660_date(root->contents->isorec.date, cd_time); root->contents->inode = UNCACHED_INODE; root->contents->dev = (dev_t) UNCACHED_DEVICE; set_723(root->contents->isorec.volume_sequence_number, @@ -1377,6 +1375,9 @@ #endif return 0; } + + if (statbuf.st_mtime > cd_time) cd_time = statbuf.st_mtime; + if (this_dir == root && strcmp(short_name, ".") == 0) root_statbuf = statbuf; /* Save this for later on */ @@ -2584,10 +2585,7 @@ void init_fstatbuf() { - time_t current_time; - if (fstatbuf.st_ctime == 0) { - time(¤t_time); if (rationalize_uid) fstatbuf.st_uid = uid_to_use; else @@ -2596,8 +2594,8 @@ fstatbuf.st_gid = gid_to_use; else fstatbuf.st_gid = getgid(); - fstatbuf.st_ctime = current_time; - fstatbuf.st_mtime = current_time; - fstatbuf.st_atime = current_time; + fstatbuf.st_ctime = cd_time; + fstatbuf.st_mtime = cd_time; + fstatbuf.st_atime = cd_time; } } --- cdrtools-1.10/mkisofs/write.c Mon Dec 24 08:41:03 2001 +++ cdrtools-1.10/mkisofs/write.c Mon Dec 24 09:24:44 2001 @@ -297,6 +297,7 @@ unsigned int last_extent_written = 0; static Uint path_table_index; static time_t begun; +time_t cd_time = 0; /* * We recursively walk through all of the directories and assign extent @@ -1678,7 +1679,7 @@ * seeing them. One to translate from in disk timezone to gmt * and other to translate to local timezone */ - gmt = *gmtime(&begun); + gmt = *gmtime(&cd_time); /* * There was a comment here about breaking in the year 2000.