X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fextract.c;h=d2f2a3547c1152381f1328e4d1f0189c8e1d691d;hb=5cc26816b770672dbcbf68c07c4aae72d9ac3a32;hp=054984920de7188ea688dd3d075aadafaff3d62a;hpb=302d18acd7ed0423cfd37a9f1a8f5b70a8fe9965;p=wimlib diff --git a/src/extract.c b/src/extract.c index 05498492..d2f2a354 100644 --- a/src/extract.c +++ b/src/extract.c @@ -30,15 +30,21 @@ */ +#include "config.h" + #include #include #include #include #include #include + +#ifdef HAVE_UTIME_H +#include +#endif + #include -#include "config.h" #include "dentry.h" #include "lookup_table.h" #include "timestamp.h" @@ -224,7 +230,8 @@ static int extract_symlink(const struct dentry *dentry, const char *output_path, const WIMStruct *w) { char target[4096]; - ssize_t ret = inode_readlink(dentry->d_inode, target, sizeof(target), w); + ssize_t ret = inode_readlink(dentry->d_inode, target, + sizeof(target), w, 0); if (ret <= 0) { ERROR("Could not read the symbolic link from dentry `%s'", dentry->full_path_utf8); @@ -319,15 +326,32 @@ static int apply_dentry_timestamps(struct dentry *dentry, void *arg) struct extract_args *args = arg; size_t len = strlen(args->output_dir); char output_path[len + dentry->full_path_utf8_len + 1]; + const struct inode *inode = dentry->d_inode; + int ret; memcpy(output_path, args->output_dir, len); memcpy(output_path + len, dentry->full_path_utf8, dentry->full_path_utf8_len); output_path[len + dentry->full_path_utf8_len] = '\0'; struct timeval tv[2]; - wim_timestamp_to_timeval(dentry->d_inode->last_access_time, &tv[0]); - wim_timestamp_to_timeval(dentry->d_inode->last_write_time, &tv[1]); - if (lutimes(output_path, tv) != 0) { + wim_timestamp_to_timeval(inode->last_access_time, &tv[0]); + wim_timestamp_to_timeval(inode->last_write_time, &tv[1]); + #ifdef HAVE_LUTIMES + ret = lutimes(output_path, tv); + #else + ret = -1; + errno = ENOSYS; + #endif + if (ret != 0) { + #ifdef HAVE_UTIME + if (errno == ENOSYS) { + struct utimbuf buf; + buf.actime = wim_timestamp_to_unix(inode->last_access_time); + buf.modtime = wim_timestamp_to_unix(inode->last_write_time); + if (utime(output_path, &buf) == 0) + return 0; + } + #endif if (errno != ENOSYS || args->num_lutimes_warnings < 10) { WARNING("Failed to set timestamp on file `%s': %s", output_path, strerror(errno)); @@ -435,7 +459,7 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w, int image, w->lookup_table = joined_tab; } - for_lookup_table_entry(w->lookup_table, lte_free_extracted_file, NULL); + for_lookup_table_entry(w->lookup_table, lte_zero_extracted_file, NULL); if (image == WIM_ALL_IMAGES) { flags |= WIMLIB_EXTRACT_FLAG_MULTI_IMAGE; @@ -448,6 +472,7 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w, int image, free_lookup_table(w->lookup_table); w->lookup_table = w_tab_save; } + for_lookup_table_entry(w->lookup_table, lte_free_extracted_file, NULL); return ret; }