From: Eric Biggers Date: Sun, 18 Nov 2012 20:44:46 +0000 (-0600) Subject: Various portability fixes X-Git-Tag: v1.1.0~8 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=b61e9afca45dacd9baefbcfa17dbea2af75259b8 Various portability fixes --- diff --git a/config.h.in b/config.h.in index 16781521..05d6092e 100644 --- a/config.h.in +++ b/config.h.in @@ -18,6 +18,9 @@ /* Define to 1 if including even more debug messages. */ #undef ENABLE_MORE_DEBUG +/* Define to 1 if including support for multithreaded compression */ +#undef ENABLE_MULTITHREADED_COMPRESSION + /* Define to 1 if using vectorized implementation of SHA1 */ #undef ENABLE_SSSE3_SHA1 @@ -112,9 +115,6 @@ */ #undef LT_OBJDIR -/* Define to 1 if including support for multithreaded compression */ -#undef MULTITHREADED_COMPRESSION - /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O diff --git a/configure.ac b/configure.ac index cc96b932..63f00975 100644 --- a/configure.ac +++ b/configure.ac @@ -144,7 +144,7 @@ AC_ARG_ENABLE([multithreaded-compression], ) AC_MSG_RESULT([$ENABLE_MULTITHREADED_COMPRESSION]) if test "x$ENABLE_MULTITHREADED_COMPRESSION" = "xyes"; then - AC_DEFINE([MULTITHREADED_COMPRESSION], [1], + AC_DEFINE([ENABLE_MULTITHREADED_COMPRESSION], [1], [Define to 1 if including support for multithreaded compression]) fi diff --git a/debian/changelog b/debian/changelog index a37117c8..bcf014f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wimlib (1.1.0-1) unstable; urgency=low + + * Update to v1.1.0 + + -- Eric Biggers Sun, 18 Nov 2012 13:49:54 -0600 + wimlib (1.0.4-1) unstable; urgency=low * Update to v1.0.4 diff --git a/debian/control b/debian/control index 34510d8b..4b1e6e8f 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Priority: optional Maintainer: Eric Biggers Build-Depends: debhelper (>= 7.0.0), autotools-dev, pkg-config, libfuse-dev, libxml2-dev, libssl-dev, - ntfs-3g-dev (>= 2011.4.12), attr-dev, bash + ntfs-3g-dev (>= 2011.4.12), attr-dev, bash, attr Standards-Version: 3.9.2 Section: libs Homepage: http://sourceforge.net/projects/wimlib diff --git a/programs/mkwinpeimg b/programs/mkwinpeimg index 3e932e74..e3cc1dc5 100755 --- a/programs/mkwinpeimg +++ b/programs/mkwinpeimg @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # This script can make a customized bootable image of Windows PE. # diff --git a/rpm/wimlib-minimal.spec b/rpm/wimlib-minimal.spec index 54dc8c7a..cbd32727 100644 --- a/rpm/wimlib-minimal.spec +++ b/rpm/wimlib-minimal.spec @@ -1,6 +1,6 @@ Summary: Library to extract, create, and modify WIM files Name: wimlib -Version: 1.0.4 +Version: 1.1.0 Release: 1 License: GPLv3+ Group: System/Libraries diff --git a/rpm/wimlib-without-ntfs-3g.spec b/rpm/wimlib-without-ntfs-3g.spec index f9c5637d..01b9ff30 100644 --- a/rpm/wimlib-without-ntfs-3g.spec +++ b/rpm/wimlib-without-ntfs-3g.spec @@ -1,6 +1,6 @@ Summary: Library to extract, create, and modify WIM files Name: wimlib -Version: 1.0.4 +Version: 1.1.0 Release: 1 License: GPLv3+ Group: System/Libraries diff --git a/rpm/wimlib.spec b/rpm/wimlib.spec index 090c7ebb..4ab654dc 100644 --- a/rpm/wimlib.spec +++ b/rpm/wimlib.spec @@ -1,6 +1,6 @@ Summary: Library to extract, create, and modify WIM files Name: wimlib -Version: 1.0.4 +Version: 1.1.0 Release: 1 License: GPLv3+ Group: System/Libraries diff --git a/src/integrity.c b/src/integrity.c index f1e208f1..f9d7aaa5 100644 --- a/src/integrity.c +++ b/src/integrity.c @@ -144,10 +144,12 @@ int check_wim_integrity(WIMStruct *w, int show_progress, int *status) } /* Read the integrity table into memory. */ - buf = MALLOC(res_entry->original_size); - if (!buf) { + if ((sizeof(size_t) < sizeof(u64) + && res_entry->original_size > ~(size_t)0) + || ((buf = MALLOC(res_entry->original_size)) == NULL)) + { ERROR("Out of memory (needed %zu bytes for integrity table)", - res_entry->original_size); + (size_t)res_entry->original_size); ret = WIMLIB_ERR_NOMEM; goto out; } diff --git a/src/lookup_table.c b/src/lookup_table.c index f0da2b42..f320e2dd 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -233,9 +233,10 @@ void lte_decrement_refcnt(struct lookup_table_entry *lte, void lte_decrement_num_opened_fds(struct lookup_table_entry *lte) { wimlib_assert(lte != NULL); - wimlib_assert(lte->num_opened_fds != 0); - if (atomic_dec(<e->num_opened_fds) == 0 && lte->refcnt == 0) - finalize_lte(lte); + if (lte->num_opened_fds != 0) { + if (--lte->num_opened_fds == 0 && lte->refcnt == 0) + finalize_lte(lte); + } } #endif diff --git a/src/mount.c b/src/mount.c index 3c0b9290..8b9cab93 100644 --- a/src/mount.c +++ b/src/mount.c @@ -115,6 +115,11 @@ static inline WIMStruct *wimfs_get_WIMStruct() return wimfs_get_context()->wim; } +static inline bool wimfs_ctx_readonly(const struct wimfs_context *ctx) +{ + return (ctx->mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) == 0; +} + static inline int get_lookup_flags(const struct wimfs_context *ctx) { if (ctx->mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS) @@ -136,13 +141,15 @@ static inline int flags_writable(int open_flags) * @stream_id: ID of the stream we're opening * @lte: Lookup table entry for the stream (may be NULL) * @fd_ret: Return the allocated file descriptor if successful. + * @readonly: True if this is a read-only mount. * * Return 0 iff successful or error code if unsuccessful. */ static int alloc_wimlib_fd(struct inode *inode, u32 stream_id, struct lookup_table_entry *lte, - struct wimlib_fd **fd_ret) + struct wimlib_fd **fd_ret, + bool readonly) { static const u16 fds_per_alloc = 8; static const u16 max_fds = 0xffff; @@ -192,8 +199,8 @@ static int alloc_wimlib_fd(struct inode *inode, *fd_ret = fd; inode->fds[i] = fd; inode->num_opened_fds++; - if (lte) - atomic_inc(<e->num_opened_fds); + if (lte && !readonly) + lte->num_opened_fds++; DEBUG("Allocated fd (idx = %u)", fd->idx); ret = 0; break; @@ -1269,7 +1276,8 @@ static int wimfs_open(const char *path, struct fuse_file_info *fi) return ret; } - ret = alloc_wimlib_fd(inode, stream_id, lte, &fd); + ret = alloc_wimlib_fd(inode, stream_id, lte, &fd, + wimfs_ctx_readonly(ctx)); if (ret != 0) return ret; @@ -1290,14 +1298,15 @@ static int wimfs_opendir(const char *path, struct fuse_file_info *fi) struct inode *inode; int ret; struct wimlib_fd *fd = NULL; - WIMStruct *w = wimfs_get_WIMStruct(); + struct wimfs_context *ctx = wimfs_get_context(); + WIMStruct *w = ctx->wim; inode = wim_pathname_to_inode(w, path); if (!inode) return -ENOENT; if (!inode_is_directory(inode)) return -ENOTDIR; - ret = alloc_wimlib_fd(inode, 0, NULL, &fd); + ret = alloc_wimlib_fd(inode, 0, NULL, &fd, wimfs_ctx_readonly(ctx)); fi->fh = (uintptr_t)fd; return ret; } @@ -1834,9 +1843,13 @@ static struct fuse_operations wimfs_operations = { #endif .write = wimfs_write, +#if FUSE_MAJOR_VERSION > 2 || (FUSE_MAJOR_VERSION == 2 && FUSE_MINOR_VERSION >= 8) .flag_nullpath_ok = 1, +#endif +#if FUSE_MAJOR_VERSION > 2 || (FUSE_MAJOR_VERSION == 2 && FUSE_MINOR_VERSION >= 9) .flag_nopath = 1, .flag_utime_omit_ok = 1, +#endif }; diff --git a/src/ntfs-apply.c b/src/ntfs-apply.c index 9b880a3d..32d98108 100644 --- a/src/ntfs-apply.c +++ b/src/ntfs-apply.c @@ -299,7 +299,7 @@ static int apply_reparse_data(ntfs_inode *ni, const struct dentry *dentry, } if (wim_resource_size(lte) >= 0xffff) { - ERROR("Reparse data of `%s' is too long (%lu bytes)", + ERROR("Reparse data of `%s' is too long (%"PRIu64" bytes)", dentry->full_path_utf8, wim_resource_size(lte)); return WIMLIB_ERR_INVALID_DENTRY; } diff --git a/src/util.h b/src/util.h index 08a661b8..d87a0e82 100644 --- a/src/util.h +++ b/src/util.h @@ -30,6 +30,8 @@ # define HOT #endif /* __GNUC__ */ + +#if 0 #ifdef WITH_FUSE #define atomic_inc(ptr) \ __sync_fetch_and_add(ptr, 1) @@ -37,6 +39,7 @@ #define atomic_dec(ptr) \ __sync_sub_and_fetch(ptr, 1) #endif +#endif #ifndef _NTFS_TYPES_H typedef uint8_t u8; diff --git a/src/write.c b/src/write.c index ef1e02db..b12ec7ac 100644 --- a/src/write.c +++ b/src/write.c @@ -50,9 +50,10 @@ #ifdef HAVE_ALLOCA_H #include +#else +#include #endif - /* Reopens the FILE* for a WIM read-write. */ static int reopen_rw(WIMStruct *w) { @@ -1427,6 +1428,19 @@ out: return ret; } + +static const char *get_data_type(int ctype) +{ + switch (ctype) { + case WIM_COMPRESSION_TYPE_NONE: + return "uncompressed"; + case WIM_COMPRESSION_TYPE_LZX: + return "LZX-compressed"; + case WIM_COMPRESSION_TYPE_XPRESS: + return "XPRESS-compressed"; + } +} + static int write_stream_list_parallel(struct list_head *stream_list, FILE *out_fp, int out_ctype, int write_flags, u64 total_size, @@ -1484,8 +1498,8 @@ static int write_stream_list_parallel(struct list_head *stream_list, } if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) { - printf("Writing compressed data using %u threads...\n", - num_threads); + printf("Writing %s compressed data using %u threads...\n", + get_data_type(out_ctype), num_threads); } ret = main_writer_thread_proc(stream_list, @@ -1561,7 +1575,8 @@ static int write_stream_list(struct list_head *stream_list, FILE *out_fp, const char *reason = ""; if (!compression_needed) reason = " (no compression needed)"; - printf("Writing data using 1 thread%s\n", reason); + printf("Writing %s data using 1 thread%s\n", + get_data_type(out_ctype), reason); } return write_stream_list_serial(stream_list, out_fp, diff --git a/tests/test-imagex b/tests/test-imagex index 2601d876..0ac5fc35 100755 --- a/tests/test-imagex +++ b/tests/test-imagex @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script does some sanity testing of the 'imagex' program. It by no means # tests every aspect of wimlib comprehensively. diff --git a/tests/test-imagex-capture_and_apply b/tests/test-imagex-capture_and_apply index 00090281..caa4d47e 100755 --- a/tests/test-imagex-capture_and_apply +++ b/tests/test-imagex-capture_and_apply @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Test capturing and applying a WIM image in the normal (non-NTFS) capture mode # diff --git a/tests/test-imagex-mount b/tests/test-imagex-mount index 74cff3f7..4f6d1c95 100755 --- a/tests/test-imagex-mount +++ b/tests/test-imagex-mount @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Test WIM mounting @@ -239,7 +239,7 @@ do_test() { fi cd tmp.mnt - if ! tar xf ../test.tar; then + if ! tar xf ../test.tar --no-same-owner; then error "Failed to untar archive on read-write mounted WIM" fi cd .. @@ -254,7 +254,7 @@ do_test() { fi cd tmp.mnt - if ! tar xf ../test.tar; then + if ! tar xf ../test.tar --no-same-owner; then error "Failed to untar archive on read-write mounted WIM" fi cd .. diff --git a/tests/test-imagex-ntfs b/tests/test-imagex-ntfs index 85812baf..c046c2de 100755 --- a/tests/test-imagex-ntfs +++ b/tests/test-imagex-ntfs @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script does some sanity testing of the 'imagex' program, specifically # checking the NTFS capture and apply features.