diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 06a847c..0197837 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -402,7 +402,7 @@ void write_one_dir_record(Ecma119Image *t, Ecma119Node *node, int file_id, rec->len_dr[0] = len_dr + (info != NULL ? info->suf_len : 0); iso_bb(rec->block, block - t->eff_partition_offset, 4); iso_bb(rec->length, len, 4); - if (t->dir_rec_mtime) { + if (t->dir_rec_mtime & 1) { iso= node->node; iso_datetime_7(rec->recording_time, t->replace_timestamps ? t->timestamp : iso->mtime, @@ -2701,7 +2701,13 @@ int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow) if (opts == NULL) { return ISO_NULL_POINTER; } - opts->dir_rec_mtime = allow ? 1 : 0; + if (allow < 0) + allow = 1; + else if (allow & (1 << 14)) + allow &= ~1; + else if (allow & 6) + allow |= 1; + opts->dir_rec_mtime = allow & 7; return ISO_SUCCESS; } diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index 3e59cf7..425db65 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -202,8 +202,9 @@ struct iso_write_opts { * to expect that we do have a creation timestamp with the source. * mkisofs writes mtimes and the result seems more suitable if mounted * without Rock Ridge support.) + * bit0= ECMA-119, bit1= Joliet, bit2= ISO 9660:1999 */ - unsigned int dir_rec_mtime :1; + unsigned int dir_rec_mtime :3; /** * Compute MD5 checksum for the whole session and record it as index 0 of @@ -476,8 +477,10 @@ struct ecma119_image /* Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12. */ unsigned int aaip_susp_1_10 :1; - /* Store in ECMA-119 timestamp mtime of source */ - unsigned int dir_rec_mtime :1; + /* Store in ECMA-119, Joliet, ISO 9660:1999 timestamp the mtime of source + bit0= ECMA-119, bit1= Joliet, bit2= ISO 9660:1999. + */ + unsigned int dir_rec_mtime :3; unsigned int md5_session_checksum :1; unsigned int md5_file_checksums :2; diff --git a/libisofs/iso1999.c b/libisofs/iso1999.c index b83b493..f5a8e0b 100644 --- a/libisofs/iso1999.c +++ b/libisofs/iso1999.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2011 Thomas Schmitt + * Copyright (c) 2011-2012 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -688,6 +688,7 @@ void write_one_dir_record(Ecma119Image *t, Iso1999Node *node, int file_id, : (uint8_t*)node->name; struct ecma119_dir_record *rec = (struct ecma119_dir_record*)buf; + IsoNode *iso; len_dr = 33 + len_fi + ((len_fi % 2) ? 0 : 1); @@ -719,7 +720,15 @@ void write_one_dir_record(Ecma119Image *t, Iso1999Node *node, int file_id, rec->len_dr[0] = len_dr; iso_bb(rec->block, block, 4); iso_bb(rec->length, len, 4); - iso_datetime_7(rec->recording_time, t->now, t->always_gmt); + + /* was: iso_datetime_7(rec->recording_time, t->now, t->always_gmt); + */ + iso= node->node; + iso_datetime_7(rec->recording_time, + (t->dir_rec_mtime & 4) ? ( t->replace_timestamps ? + t->timestamp : iso->mtime ) + : t->now, t->always_gmt); + rec->flags[0] = ((node->type == ISO1999_DIR) ? 2 : 0) | (multi_extend ? 0x80 : 0); iso_bb(rec->vol_seq_number, (uint32_t) 1, 2); rec->len_fi[0] = len_fi; diff --git a/libisofs/joliet.c b/libisofs/joliet.c index 2cd9c20..d820748 100644 --- a/libisofs/joliet.c +++ b/libisofs/joliet.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Mario Danic - * Copyright (c) 2011 Thomas Schmitt + * Copyright (c) 2011-2012 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -758,6 +758,7 @@ void write_one_dir_record(Ecma119Image *t, JolietNode *node, int file_id, : (uint8_t*)node->name; struct ecma119_dir_record *rec = (struct ecma119_dir_record*)buf; + IsoNode *iso; len_dr = 33 + len_fi + ((len_fi % 2) ? 0 : 1); @@ -797,7 +798,15 @@ void write_one_dir_record(Ecma119Image *t, JolietNode *node, int file_id, rec->len_dr[0] = len_dr; iso_bb(rec->block, block - t->eff_partition_offset, 4); iso_bb(rec->length, len, 4); - iso_datetime_7(rec->recording_time, t->now, t->always_gmt); + + /* was: iso_datetime_7(rec->recording_time, t->now, t->always_gmt); + */ + iso= node->node; + iso_datetime_7(rec->recording_time, + (t->dir_rec_mtime & 2) ? ( t->replace_timestamps ? + t->timestamp : iso->mtime ) + : t->now, t->always_gmt); + rec->flags[0] = ((node->type == JOLIET_DIR) ? 2 : 0) | (multi_extend ? 0x80 : 0); iso_bb(rec->vol_seq_number, (uint32_t) 1, 2); rec->len_fi[0] = len_fi; diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 4a92fb3..2b89319 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -4,7 +4,7 @@ /* * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic - * Copyright (c) 2009-2011 Thomas Schmitt + * Copyright (c) 2009-2012 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -1653,9 +1653,35 @@ int iso_write_opts_set_rrip_1_10_px_ino(IsoWriteOpts *opts, int enable); int iso_write_opts_set_aaip_susp_1_10(IsoWriteOpts *opts, int oldvers); /** - * Store as ECMA-119 Directory Record timestamp the mtime of the source + * Store as ECMA-119 Directory Record timestamp the mtime of the source node * rather than the image creation time. + * If storing of mtime is enabled, then the settings of + * iso_write_opts_set_replace_timestamps() apply. (replace==1 will revoke, + * replace==2 will override mtime by iso_write_opts_set_default_timestamp(). * + * Since version 1.2.0 this may apply also to Joliet and ISO 9660:1999. To + * reduce the probability of unwanted behavior changes between pre-1.2.0 and + * post-1.2.0, the bits for Joliet and ISO 9660:1999 also enable ECMA-119. + * The hopefully unlikely bit14 may then be used to disable mtime for ECMA-119. + * + * To enable mtime for all three directory trees, submit 7. + * To disable this feature completely, submit 0. + * + * @param opts + * The option set to be manipulated. + * @param allow + * If this parameter is negative, then mtime is enabled only for ECMA-119. + * With positive numbers, the parameter is interpreted as bit field : + * bit0= enable mtime for ECMA-119 + * bit1= enable mtime for Joliet and ECMA-119 + * bit2= enable mtime for ISO 9660:1999 and ECMA-119 + * bit14= disable mtime for ECMA-119 although some of the other bits + * would enable it + * @since 1.2.0 + * Before version 1.2.0 this applied only to ECMA-119 : + * 0 stored image creation time in ECMA-119 tree. + * Any other value caused storing of mtime. + * Joliet and ISO 9660:1999 always stored the image creation time. * @since 0.6.12 */ int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow); @@ -1783,8 +1809,10 @@ int iso_write_opts_set_default_gid(IsoWriteOpts *opts, gid_t gid); /** * 0 to use IsoNode timestamps, 1 to use recording time, 2 to use - * values from timestamp field. This has only meaning if RR extensions - * are enabled. + * values from timestamp field. This applies to the timestamps of Rock Ridge + * and if the use of mtime is enabled by iso_write_opts_set_dir_rec_mtime(). + * In the latter case, value 1 will revoke the recording of mtime, value + * 2 will override mtime by iso_write_opts_set_default_timestamp(). * * @see iso_write_opts_set_default_timestamp * @since 0.6.2