]> wimlib.net Git - wimlib/blobdiff - src/win32_capture.c
Remove buffer_io.h
[wimlib] / src / win32_capture.c
index e3072494b96718488cdc1f38f2cb3cee4ad0bb63..c05eb192b4105a86c2c90f7652320fe232f056a4 100644 (file)
@@ -1,10 +1,40 @@
+/*
+ * win32_capture.c - Windows-specific code for capturing files into a WIM image.
+ */
+
+/*
+ * Copyright (C) 2013 Eric Biggers
+ *
+ * This file is part of wimlib, a library for working with WIM files.
+ *
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ */
+
 #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
@@ -231,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)
@@ -394,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
@@ -523,7 +519,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];
@@ -616,7 +612,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))
@@ -1007,7 +1003,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
         * only 1 link and refuse to hard link them.  This is because Windows
         * has a bug where it can return duplicate File IDs for files and
         * directories on the FAT filesystem. */
-       ret = inode_table_new_dentry(params->inode_table,
+       ret = inode_table_new_dentry(&params->inode_table,
                                     path_basename_with_len(path, path_num_chars),
                                     ((u64)file_info.nFileIndexHigh << 32) |
                                         (u64)file_info.nFileIndexLow,
@@ -1038,7 +1034,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        if (!(params->add_flags & WIMLIB_ADD_FLAG_NO_ACLS)
            && (vol_flags & FILE_PERSISTENT_ACLS))
        {
-               ret = win32_get_security_descriptor(root, params->sd_set,
+               ret = win32_get_security_descriptor(root, &params->sd_set,
                                                    path, state,
                                                    params->add_flags);
                if (ret)
@@ -1065,7 +1061,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) {
@@ -1115,8 +1111,7 @@ win32_do_capture_warnings(const struct win32_capture_state *state,
 "          nothing more needs to be done%ls\n",
        (add_flags & WIMLIB_ADD_FLAG_NO_ACLS) ? L"." :
          L", although you might consider\n"
-"          passing the --no-acls flag to `wimlib-imagex capture' or\n"
-"          `wimlib-imagex append' to explicitly capture no security\n"
+"          using the --no-acls option to explicitly capture no security\n"
 "          descriptors.\n");
 }
 
@@ -1132,6 +1127,10 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
        struct win32_capture_state state;
        unsigned vol_flags;
 
+       if (!win32func_FindFirstStreamW) {
+               WARNING("Running on Windows XP or earlier; "
+                       "alternate data streams will not be captured.");
+       }
 
        path_nchars = wcslen(root_disk_path);
        if (path_nchars > 32767)