X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_capture.c;h=a2d67976bc4ab5e3fcf6f979345dd880d654afd5;hp=aeabfa91ae8f2a9a4d6994f0ef33b3bd843fee78;hb=2412c8ed80e1283657c97d156061beac04849eb5;hpb=726f9bbd0bd664294fce8a50be1d5b6881df8d16;ds=sidebyside diff --git a/src/win32_capture.c b/src/win32_capture.c index aeabfa91..a2d67976 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -23,11 +23,18 @@ #ifdef __WIN32__ -#include "win32_common.h" -#include "wimlib_internal.h" -#include "lookup_table.h" -#include "security.h" -#include "endianness.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "wimlib/win32_common.h" + +#include "wimlib/capture.h" +#include "wimlib/endianness.h" +#include "wimlib/error.h" +#include "wimlib/lookup_table.h" +#include "wimlib/paths.h" +#include "wimlib/reparse.h" #define MAX_GET_SD_ACCESS_DENIED_WARNINGS 1 #define MAX_GET_SACL_PRIV_NOTHELD_WARNINGS 1 @@ -254,7 +261,7 @@ win32_get_short_name(struct wim_dentry *dentry, const wchar_t *path) static int win32_get_security_descriptor(struct wim_dentry *dentry, - struct sd_set *sd_set, + struct wim_sd_set *sd_set, const wchar_t *path, struct win32_capture_state *state, int add_flags) @@ -417,40 +424,6 @@ out_find_close: return ret; } -int -win32_get_file_and_vol_ids(const wchar_t *path, u64 *ino_ret, u64 *dev_ret) -{ - HANDLE hFile; - DWORD err; - BY_HANDLE_FILE_INFORMATION file_info; - int ret; - - hFile = win32_open_existing_file(path, FILE_READ_ATTRIBUTES); - if (hFile == INVALID_HANDLE_VALUE) { - err = GetLastError(); - if (err != ERROR_FILE_NOT_FOUND) { - WARNING("Failed to open \"%ls\" to get file " - "and volume IDs", path); - win32_error(err); - } - return WIMLIB_ERR_OPEN; - } - - if (!GetFileInformationByHandle(hFile, &file_info)) { - err = GetLastError(); - ERROR("Failed to get file information for \"%ls\"", path); - win32_error(err); - ret = WIMLIB_ERR_STAT; - } else { - *ino_ret = ((u64)file_info.nFileIndexHigh << 32) | - (u64)file_info.nFileIndexLow; - *dev_ret = file_info.dwVolumeSerialNumber; - ret = 0; - } - CloseHandle(hFile); - return ret; -} - /* Reparse point fixup status code */ enum rp_status { /* Reparse point corresponded to an absolute symbolic link or junction @@ -533,12 +506,10 @@ win32_capture_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p, const wchar_t *path) { struct reparse_data rpdata; - DWORD rpbuflen; int ret; enum rp_status rp_status; - rpbuflen = *rpbuflen_p; - ret = parse_reparse_data(rpbuf, rpbuflen, &rpdata); + ret = parse_reparse_data(rpbuf, *rpbuflen_p, &rpdata); if (ret) return -ret; @@ -546,7 +517,7 @@ win32_capture_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p, &rpdata.substitute_name_nbytes, capture_root_ino, capture_root_dev, - le32_to_cpu(*(u32*)rpbuf)); + le32_to_cpu(*(le32*)rpbuf)); if (rp_status & RP_FIXED) { wimlib_assert(rpdata.substitute_name_nbytes % 2 == 0); utf16lechar substitute_name_copy[rpdata.substitute_name_nbytes / 2]; @@ -562,7 +533,7 @@ win32_capture_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p, rpdata.print_name += 4; rpdata.print_name_nbytes -= 8; } - ret = make_reparse_buffer(&rpdata, rpbuf); + ret = make_reparse_buffer(&rpdata, rpbuf, rpbuflen_p); if (ret == 0) ret = rp_status; else @@ -639,7 +610,7 @@ win32_get_reparse_data(HANDLE hFile, const wchar_t *path, } rpbuflen = bytesReturned; - reparse_tag = le32_to_cpu(*(u32*)rpbuf); + reparse_tag = le32_to_cpu(*(le32*)rpbuf); if (params->add_flags & WIMLIB_ADD_FLAG_RPFIX && (reparse_tag == WIM_IO_REPARSE_TAG_SYMLINK || reparse_tag == WIM_IO_REPARSE_TAG_MOUNT_POINT)) @@ -1088,7 +1059,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret, /* Reparse point: set the reparse data (which we read already) * */ inode->i_not_rpfixed = not_rpfixed; - inode->i_reparse_tag = le32_to_cpu(*(u32*)rpbuf); + inode->i_reparse_tag = le32_to_cpu(*(le32*)rpbuf); ret = inode_set_unnamed_stream(inode, rpbuf + 8, rpbuflen - 8, params->lookup_table); } else if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) {