]> wimlib.net Git - wimlib/commitdiff
Misc. fixes
authorEric Biggers <ebiggers3@gmail.com>
Thu, 21 Mar 2013 03:18:39 +0000 (22:18 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 21 Mar 2013 03:18:39 +0000 (22:18 -0500)
README.WINDOWS
src/encoding.c
src/ntfs-capture.c
src/security.c
src/win32.c
src/write.c
src/xml.c

index ca5195a9b1a7dac6a6959d9b40bdf21292ea4cca..a4968279c2f1e6abeabd9e4c0bfda2550f8600e7 100644 (file)
@@ -59,5 +59,5 @@ Note: zlib and gettext are only necessary when required by the build of libxml2.
 
 Building wimlib using Cygwin is not supported.  I was trying this for a while,
 but I ran into some issues with mixing native Win32 functions and
 
 Building wimlib using Cygwin is not supported.  I was trying this for a while,
 but I ran into some issues with mixing native Win32 functions and
-Cygwin-provided functions, so I just made it possible to do a native Win32 build
+Cygwin-provided functions, so I made it possible to do a native Win32 build
 instead.
 instead.
index 48bad187ff8e21c7df4333e35854aabf75ef6b5d..ec0bc042777b53dd45969ed524e4de9a4fd03617 100644 (file)
@@ -99,7 +99,7 @@ put_iconv(iconv_t *cd)
        int errno_save = errno;
        struct iconv_node *i = container_of(cd, struct iconv_node, cd);
        struct iconv_list_head *head = i->head;
        int errno_save = errno;
        struct iconv_node *i = container_of(cd, struct iconv_node, cd);
        struct iconv_list_head *head = i->head;
-       
+
        pthread_mutex_lock(&head->mutex);
        list_add(&i->list, &head->list);
        pthread_mutex_unlock(&head->mutex);
        pthread_mutex_lock(&head->mutex);
        list_add(&i->list, &head->list);
        pthread_mutex_unlock(&head->mutex);
@@ -247,7 +247,7 @@ iconv_cleanup(struct iconv_list_head *head)
        pthread_mutex_destroy(&head->mutex);
        while (!list_empty(&head->list)) {
                struct iconv_node *i;
        pthread_mutex_destroy(&head->mutex);
        while (!list_empty(&head->list)) {
                struct iconv_node *i;
-               
+
                i = container_of(head->list.next, struct iconv_node, list);
                list_del(&i->list);
                iconv_close(i->cd);
                i = container_of(head->list.next, struct iconv_node, list);
                list_del(&i->list);
                iconv_close(i->cd);
index 7c04e9b85b2410797212fb2aad119acce296eea1..5b6e315c3c913804206af93f64e2ea87eb8ec9ed 100644 (file)
@@ -382,7 +382,7 @@ free_dos_name_tree(struct rb_node *node) {
        }
 }
 
        }
 }
 
-static void 
+static void
 destroy_dos_name_map(struct dos_name_map *map)
 {
        free_dos_name_tree(map->rb_root.rb_node);
 destroy_dos_name_map(struct dos_name_map *map)
 {
        free_dos_name_tree(map->rb_root.rb_node);
@@ -436,12 +436,12 @@ wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
                /* Return now if an error occurred or if this is just a DOS name
                 * and not a Win32+DOS name. */
                if (ret != 0 || name_type == FILE_NAME_DOS)
                /* Return now if an error occurred or if this is just a DOS name
                 * and not a Win32+DOS name. */
                if (ret != 0 || name_type == FILE_NAME_DOS)
-                       return ret;
+                       goto out;
        }
        ret = utf16le_to_mbs(name, name_nbytes,
                             &mbs_name, &mbs_name_nbytes);
        }
        ret = utf16le_to_mbs(name, name_nbytes,
                             &mbs_name, &mbs_name_nbytes);
-       if (ret != 0)
-               return -1;
+       if (ret)
+               goto out;
 
        if (mbs_name[0] == '.' &&
             (mbs_name[1] == '\0' ||
 
        if (mbs_name[0] == '.' &&
             (mbs_name[1] == '\0' ||
@@ -459,6 +459,7 @@ wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
        ntfs_inode *ni = ntfs_inode_open(ctx->dir_ni->vol, mref);
        if (!ni) {
                ERROR_WITH_ERRNO("Failed to open NTFS inode");
        ntfs_inode *ni = ntfs_inode_open(ctx->dir_ni->vol, mref);
        if (!ni) {
                ERROR_WITH_ERRNO("Failed to open NTFS inode");
+               ret = -1;
                goto out_free_mbs_name;
        }
        path_len = ctx->path_len;
                goto out_free_mbs_name;
        }
        path_len = ctx->path_len;
@@ -478,6 +479,7 @@ wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
        ntfs_inode_close(ni);
 out_free_mbs_name:
        FREE(mbs_name);
        ntfs_inode_close(ni);
 out_free_mbs_name:
        FREE(mbs_name);
+out:
        return ret;
 }
 
        return ret;
 }
 
index ae71c5dd938c58104af62189454d1708a1c7a701..9b1ea21811485f64183a65a996ab7da6e3c3c894 100644 (file)
@@ -258,6 +258,9 @@ typedef struct {
 static void
 empty_sacl_fixup(u8 *descr, u64 *size_p)
 {
 static void
 empty_sacl_fixup(u8 *descr, u64 *size_p)
 {
+       /* No-op if no NTFS-3g support, or if NTFS-3g is version 2013 or later
+        * */
+#if defined(WITH_NTFS_3G) && !defined(HAVE_NTFS_MNT_RDONLY)
        if (*size_p >= sizeof(SecurityDescriptor)) {
                SecurityDescriptor *sd = (SecurityDescriptor*)descr;
                u32 sacl_offset = le32_to_cpu(sd->sacl_offset);
        if (*size_p >= sizeof(SecurityDescriptor)) {
                SecurityDescriptor *sd = (SecurityDescriptor*)descr;
                u32 sacl_offset = le32_to_cpu(sd->sacl_offset);
@@ -266,6 +269,7 @@ empty_sacl_fixup(u8 *descr, u64 *size_p)
                        *size_p -= sizeof(ACL);
                }
        }
                        *size_p -= sizeof(ACL);
                }
        }
+#endif
 }
 
 /*
 }
 
 /*
index fb30b5f08d3f29e9577bb05ef29578e92e91e3c2..12d0afeef3d7583daffad4e69284a4f01ad26f89 100644 (file)
 
 #include <errno.h>
 
 
 #include <errno.h>
 
+static const char *access_denied_msg =
+"         If you are not running this program as the administrator, you may\n"
+"         need to do so, so that all data and metadata can be backed up.\n"
+"         Otherwise, there may be no way to access the desired data or\n"
+"         metadata without taking ownership of the file or directory.\n";
+
 #ifdef ENABLE_ERROR_MESSAGES
 void
 win32_error(u32 err_code)
 #ifdef ENABLE_ERROR_MESSAGES
 void
 win32_error(u32 err_code)
@@ -171,10 +177,17 @@ win32_get_security_descriptor(struct wim_dentry *dentry,
                        err = GetLastError();
                }
        }
                        err = GetLastError();
                }
        }
-       ERROR("Win32 API: Failed to read security descriptor of \"%ls\"",
-             path_utf16);
-       win32_error(err);
-       return WIMLIB_ERR_READ;
+
+       if (err == ERROR_ACCESS_DENIED) {
+               WARNING("Failed to read security descriptor of \"%ls\": "
+                       "Access denied!\n%s", path_utf16, access_denied_msg);
+               return 0;
+       } else {
+               ERROR("Win32 API: Failed to read security descriptor of \"%ls\"",
+                     path_utf16);
+               win32_error(err);
+               return WIMLIB_ERR_READ;
+       }
 }
 
 /* Reads the directory entries of directory using a Win32 API and recursively
 }
 
 /* Reads the directory entries of directory using a Win32 API and recursively
@@ -514,10 +527,17 @@ win32_capture_streams(const wchar_t *path_utf16,
                {
                        return 0;
                } else {
                {
                        return 0;
                } else {
-                       ERROR("Win32 API: Failed to look up data streams of \"%ls\"",
-                             path_utf16);
-                       win32_error(err);
-                       return WIMLIB_ERR_READ;
+                       if (err == ERROR_ACCESS_DENIED) {
+                               WARNING("Failed to look up data streams of \"%ls\": "
+                                       "Access denied!\n%s", path_utf16,
+                                       access_denied_msg);
+                               return 0;
+                       } else {
+                               ERROR("Win32 API: Failed to look up data streams of \"%ls\"",
+                                     path_utf16);
+                               win32_error(err);
+                               return WIMLIB_ERR_READ;
+                       }
                }
        }
        do {
                }
        }
        do {
index 139ecdabc73dd74da20fc45cfaaa772dd8478e59..27b1dbbebf57001031c7eb6289f189bdf192d761 100644 (file)
@@ -329,7 +329,7 @@ prepare_resource_for_read(struct wim_lookup_table_entry *lte
 
 /* Undo prepare_resource_for_read() by closing the cached FILE * or NTFS
  * attribute. */
 
 /* Undo prepare_resource_for_read() by closing the cached FILE * or NTFS
  * attribute. */
-static void 
+static void
 end_wim_resource_read(struct wim_lookup_table_entry *lte
                        #ifdef WITH_NTFS_3G
                                , ntfs_inode *ni
 end_wim_resource_read(struct wim_lookup_table_entry *lte
                        #ifdef WITH_NTFS_3G
                                , ntfs_inode *ni
index 0ea13f83b044037458c09cc577e08e253e10c1fa..79d6b3e6e376c51430031f215b2931a93d32678e 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -490,7 +490,7 @@ err:
        return ret;
 }
 
        return ret;
 }
 
-/* Prints the information contained in a `struct windows_info'. 
+/* Prints the information contained in a `struct windows_info'.
  *
  * Warning: any strings printed here are in UTF-8 encoding.  If the locale
  * character encoding is not UTF-8, the printed strings may be garbled. */
  *
  * Warning: any strings printed here are in UTF-8 encoding.  If the locale
  * character encoding is not UTF-8, the printed strings may be garbled. */