Various portability fixes
authorEric Biggers <ebiggers3@gmail.com>
Sun, 18 Nov 2012 20:44:46 +0000 (14:44 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 18 Nov 2012 20:44:46 +0000 (14:44 -0600)
18 files changed:
config.h.in
configure.ac
debian/changelog
debian/control
programs/mkwinpeimg
rpm/wimlib-minimal.spec
rpm/wimlib-without-ntfs-3g.spec
rpm/wimlib.spec
src/integrity.c
src/lookup_table.c
src/mount.c
src/ntfs-apply.c
src/util.h
src/write.c
tests/test-imagex
tests/test-imagex-capture_and_apply
tests/test-imagex-mount
tests/test-imagex-ntfs

index 1678152..05d6092 100644 (file)
@@ -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
 
    */
 #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
 
index cc96b93..63f0097 100644 (file)
@@ -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
index a37117c..bcf014f 100644 (file)
@@ -1,3 +1,9 @@
+wimlib (1.1.0-1) unstable; urgency=low
+
+  * Update to v1.1.0
+
+ -- Eric Biggers <ebiggers3@gmail.com>  Sun, 18 Nov 2012 13:49:54 -0600
+
 wimlib (1.0.4-1) unstable; urgency=low
 
   * Update to v1.0.4
index 34510d8..4b1e6e8 100644 (file)
@@ -3,7 +3,7 @@ Priority: optional
 Maintainer: Eric Biggers <ebiggers3@gmail.com>
 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
index 3e932e7..e3cc1dc 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # This script can make a customized bootable image of Windows PE.
 #
index 54dc8c7..cbd3272 100644 (file)
@@ -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
index f9c5637..01b9ff3 100644 (file)
@@ -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
index 090c7eb..4ab654d 100644 (file)
@@ -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
index f1e208f..f9d7aaa 100644 (file)
@@ -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;
        }
index f0da2b4..f320e2d 100644 (file)
@@ -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(&lte->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
 
index 3c0b929..8b9cab9 100644 (file)
@@ -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(&lte->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
 };
 
 
index 9b880a3..32d9810 100644 (file)
@@ -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;
        }
index 08a661b..d87a0e8 100644 (file)
@@ -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;
index ef1e02d..b12ec7a 100644 (file)
 
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
+#else
+#include <stdlib.h>
 #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,
index 2601d87..0ac5fc3 100755 (executable)
@@ -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.
index 0009028..caa4d47 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Test capturing and applying a WIM image in the normal (non-NTFS) capture mode
 #
index 74cff3f..4f6d1c9 100755 (executable)
@@ -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 ..
index 85812ba..c046c2d 100755 (executable)
@@ -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.