...
 
Commits (2)
......@@ -2418,7 +2418,7 @@ void ecma119_determine_now_time(Ecma119Image *target)
uint8_t time_text[18];
int i;
t0 = time(NULL);
iso_nowtime(&t0, 0);
o = target->opts;
if (o->vol_uuid[0]) {
for(i = 0; i < 16; i++)
......
......@@ -312,7 +312,7 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
node->node.hidden = parent->node.hidden;
/* current time */
now = time(NULL);
iso_nowtime(&now, 0);
node->node.atime = now;
node->node.ctime = now;
node->node.mtime = now;
......
......@@ -1251,6 +1251,27 @@ int iso_set_local_charset(char *name, int flag);
*/
char *iso_get_local_charset(int flag);
/**
* Inquire and maybe define the time which is considered to be "now" and
* used for timestamps of freshly created ISO nodes and as default of
* image timestamps.
* If ever, this should normally be enabled and defined before iso_image_new().
* If it is disabled, time(NULL) is considered to be "now".
*
* @param now
* Returns the "now" value and maybe submits it as definition.
* @param flag
* Bitfield for control purposes
* bit0= *now contains the time to be set as nowtime override.
Enable the override if not bit1 is set, too.
* bit1= Disable the nowtime override
* @return 1= *now is not overridden , 2= *now is overridden
*
* @since 1.5.2
*/
int iso_nowtime(time_t *now, int flag);
/**
* Create a new image, empty.
*
......
......@@ -226,6 +226,7 @@ iso_node_unref;
iso_node_xinfo_get_cloner;
iso_node_xinfo_make_clonable;
iso_node_zf_by_magic;
iso_nowtime;
iso_obtain_msgs;
iso_read_image_features_destroy;
iso_read_image_features_get_size;
......
......@@ -1460,6 +1460,7 @@ void iso_notify_dir_iters(IsoNode *node, int flag)
int iso_node_new_root(IsoDir **root)
{
IsoDir *dir;
time_t now;
dir = calloc(1, sizeof(IsoDir));
if (dir == NULL) {
......@@ -1467,7 +1468,8 @@ int iso_node_new_root(IsoDir **root)
}
dir->node.refcount = 1;
dir->node.type = LIBISO_DIR;
dir->node.atime = dir->node.ctime = dir->node.mtime = time(NULL);
iso_nowtime(&now, 0);
dir->node.atime = dir->node.ctime = dir->node.mtime = now;
dir->node.mode = S_IFDIR | 0555;
/* set parent to itself, to prevent root to be added to another dir */
......
......@@ -2145,7 +2145,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
return ISO_ASSERT_FAILURE;
}
/* This eventually overwrites the non-mbr_req partition table entries
/* This possibly overwrites the non-mbr_req partition table entries
made so far. Overwriting those from t->mbr_req is not allowed.
*/
if (sa_type == 3 || !t->opts->appended_as_gpt) {
......@@ -2175,6 +2175,9 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
if (sa_type == 0 && (t->system_area_options & 0x4000) && !do_isohybrid) {
/* Patch MBR for GRUB2 */
if (t->num_bootsrc <= 0)
return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"No boot image found as jump target for GRUB2 MBR.");
if (t->bootsrc[0] == NULL)
return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Cannot refer by GRUB2 MBR to data outside of ISO 9660 filesystem.");
......
......@@ -87,7 +87,7 @@ int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir)
iso_node_set_hidden((IsoNode*)node, parent->node.hidden);
/* current time */
now = time(NULL);
iso_nowtime(&now, 0);
iso_node_set_atime((IsoNode*)node, now);
iso_node_set_ctime((IsoNode*)node, now);
iso_node_set_mtime((IsoNode*)node, now);
......@@ -175,7 +175,7 @@ int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
iso_node_set_hidden((IsoNode*)node, parent->node.hidden);
/* current time */
now = time(NULL);
iso_nowtime(&now, 0);
iso_node_set_atime((IsoNode*)node, now);
iso_node_set_ctime((IsoNode*)node, now);
iso_node_set_mtime((IsoNode*)node, now);
......@@ -278,7 +278,7 @@ int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
iso_node_set_hidden((IsoNode*)node, parent->node.hidden);
/* current time */
now = time(NULL);
iso_nowtime(&now, 0);
iso_node_set_atime((IsoNode*)node, now);
iso_node_set_ctime((IsoNode*)node, now);
iso_node_set_mtime((IsoNode*)node, now);
......@@ -367,7 +367,7 @@ int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream,
iso_node_set_hidden((IsoNode*)node, parent->node.hidden);
/* current time */
now = time(NULL);
iso_nowtime(&now, 0);
iso_node_set_atime((IsoNode*)node, now);
iso_node_set_ctime((IsoNode*)node, now);
iso_node_set_mtime((IsoNode*)node, now);
......
......@@ -2456,3 +2456,27 @@ int iso_truncate_leaf_name(int mode, int length, char *name, int flag)
return ret;
}
/* API */
/* @param flag bit0= *now contains the time to be set as nowtime override
bit1= disable the nowtime override
@return 1= *now is not overridden , 2= *now is overridden
*/
int iso_nowtime(time_t *now, int flag)
{
static int now_time_overridden = 0;
static time_t now_time_override = 0;
if (flag & 1) {
now_time_overridden = 1;
now_time_override = *now;
}
if (flag & 2) {
now_time_overridden = 0;
}
*now = time(NULL);
if (!now_time_overridden)
return 1;
*now = now_time_override;
return 2;
}