From: Eric Biggers Date: Thu, 21 Mar 2013 03:18:39 +0000 (-0500) Subject: Misc. fixes X-Git-Tag: v1.3.0~3 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=118cdc5cac01aad79e3314bf92cbbd924d48860c Misc. fixes --- diff --git a/README.WINDOWS b/README.WINDOWS index ca5195a9..a4968279 100644 --- a/README.WINDOWS +++ b/README.WINDOWS @@ -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 -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. diff --git a/src/encoding.c b/src/encoding.c index 48bad187..ec0bc042 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -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; - + 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; - + i = container_of(head->list.next, struct iconv_node, list); list_del(&i->list); iconv_close(i->cd); diff --git a/src/ntfs-capture.c b/src/ntfs-capture.c index 7c04e9b8..5b6e315c 100644 --- a/src/ntfs-capture.c +++ b/src/ntfs-capture.c @@ -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); @@ -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 ret; + goto out; } 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' || @@ -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"); + ret = -1; 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); +out: return ret; } diff --git a/src/security.c b/src/security.c index ae71c5dd..9b1ea218 100644 --- a/src/security.c +++ b/src/security.c @@ -258,6 +258,9 @@ typedef struct { 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); @@ -266,6 +269,7 @@ empty_sacl_fixup(u8 *descr, u64 *size_p) *size_p -= sizeof(ACL); } } +#endif } /* diff --git a/src/win32.c b/src/win32.c index fb30b5f0..12d0afee 100644 --- a/src/win32.c +++ b/src/win32.c @@ -44,6 +44,12 @@ #include +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) @@ -171,10 +177,17 @@ win32_get_security_descriptor(struct wim_dentry *dentry, 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 @@ -514,10 +527,17 @@ win32_capture_streams(const wchar_t *path_utf16, { 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 { diff --git a/src/write.c b/src/write.c index 139ecdab..27b1dbbe 100644 --- a/src/write.c +++ b/src/write.c @@ -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. */ -static void +static void end_wim_resource_read(struct wim_lookup_table_entry *lte #ifdef WITH_NTFS_3G , ntfs_inode *ni diff --git a/src/xml.c b/src/xml.c index 0ea13f83..79d6b3e6 100644 --- a/src/xml.c +++ b/src/xml.c @@ -490,7 +490,7 @@ err: 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. */