X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fiterate_dir.c;h=e4eb87d7875d0c92dcbf02bdb064997df19f4240;hp=7dc63486618d4f93065c251ca7387829abdb8084;hb=088dff37aa334c218e1cac96cc847f5dd14f7124;hpb=3de1ec66f778edda19865482d685bc6f4e17faf7 diff --git a/src/iterate_dir.c b/src/iterate_dir.c index 7dc63486..e4eb87d7 100644 --- a/src/iterate_dir.c +++ b/src/iterate_dir.c @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2013, 2015 Eric Biggers + * Copyright (C) 2013-2016 Eric Biggers * * This file is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -31,6 +31,7 @@ #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/metadata.h" +#include "wimlib/object_id.h" #include "wimlib/paths.h" #include "wimlib/security.h" #include "wimlib/timestamp.h" @@ -49,12 +50,11 @@ stream_to_wimlib_stream_entry(const struct wim_inode *inode, const u8 *hash; if (stream_is_named(strm)) { - size_t dummy; int ret; ret = utf16le_get_tstr(strm->stream_name, utf16le_len_bytes(strm->stream_name), - &wstream->stream_name, &dummy); + &wstream->stream_name, NULL); if (ret) return ret; } @@ -86,30 +86,31 @@ init_wimlib_dentry(struct wimlib_dir_entry *wdentry, struct wim_dentry *dentry, WIMStruct *wim, int flags) { int ret; - size_t dummy; const struct wim_inode *inode = dentry->d_inode; const struct wim_inode_stream *strm; struct wimlib_unix_data unix_data; + const void *object_id; + u32 object_id_len; - ret = utf16le_get_tstr(dentry->file_name, dentry->file_name_nbytes, - &wdentry->filename, &dummy); + ret = utf16le_get_tstr(dentry->d_name, dentry->d_name_nbytes, + &wdentry->filename, NULL); if (ret) return ret; - ret = utf16le_get_tstr(dentry->short_name, dentry->short_name_nbytes, - &wdentry->dos_name, &dummy); + ret = utf16le_get_tstr(dentry->d_short_name, dentry->d_short_name_nbytes, + &wdentry->dos_name, NULL); if (ret) return ret; ret = calculate_dentry_full_path(dentry); if (ret) return ret; - wdentry->full_path = dentry->_full_path; + wdentry->full_path = dentry->d_full_path; for (struct wim_dentry *d = dentry; !dentry_is_root(d); d = d->d_parent) wdentry->depth++; - if (inode->i_security_id >= 0) { + if (inode_has_security_descriptor(inode)) { struct wim_security_data *sd; sd = wim_get_current_security_data(wim); @@ -120,15 +121,30 @@ init_wimlib_dentry(struct wimlib_dir_entry *wdentry, struct wim_dentry *dentry, wdentry->num_links = inode->i_nlink; wdentry->attributes = inode->i_attributes; wdentry->hard_link_group_id = inode->i_ino; + + /* For Windows builds, to maintain ABI compatibility with previous + * versions of the DLLs, double-check that we're using the expected size + * for 'struct timespec'. */ +#ifdef _WIN64 + STATIC_ASSERT(sizeof(struct timespec) == 16); +#elif defined(_WIN32) + STATIC_ASSERT(sizeof(struct timespec) == 8); +#endif wdentry->creation_time = wim_timestamp_to_timespec(inode->i_creation_time); wdentry->last_write_time = wim_timestamp_to_timespec(inode->i_last_write_time); wdentry->last_access_time = wim_timestamp_to_timespec(inode->i_last_access_time); + if (inode_get_unix_data(inode, &unix_data)) { wdentry->unix_uid = unix_data.uid; wdentry->unix_gid = unix_data.gid; wdentry->unix_mode = unix_data.mode; wdentry->unix_rdev = unix_data.rdev; } + object_id = inode_get_object_id(inode, &object_id_len); + if (unlikely(object_id != NULL)) { + memcpy(&wdentry->object_id, object_id, + min(object_id_len, sizeof(wdentry->object_id))); + } strm = inode_get_unnamed_stream(inode, get_default_stream_type(inode)); if (strm) { @@ -200,25 +216,17 @@ do_iterate_dir_tree(WIMStruct *wim, struct wim_dentry *child; ret = 0; - if (default_ignore_case) { - for_dentry_child_case_insensitive(child, dentry) { - ret = do_iterate_dir_tree(wim, child, - flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN, - cb, user_ctx); - if (ret) - break; - } - } else { - for_dentry_child(child, dentry) { - ret = do_iterate_dir_tree(wim, child, - flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN, - cb, user_ctx); - if (ret) - break; - } + for_dentry_child(child, dentry) { + ret = do_iterate_dir_tree(wim, child, + flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN, + cb, user_ctx); + if (ret) + break; } } out_free_wimlib_dentry: + FREE(dentry->d_full_path); + dentry->d_full_path = NULL; free_wimlib_dentry(wdentry); out: return ret; @@ -261,6 +269,11 @@ wimlib_iterate_dir_tree(WIMStruct *wim, int image, const tchar *_path, path = canonicalize_wim_path(_path); if (path == NULL) return WIMLIB_ERR_NOMEM; + + ret = wim_checksum_unhashed_blobs(wim); + if (ret) + return ret; + struct image_iterate_dir_tree_ctx ctx = { .path = path, .flags = flags,