]> wimlib.net Git - wimlib/commitdiff
resource code fixes/cleanup
authorEric Biggers <ebiggers3@gmail.com>
Sun, 7 Apr 2013 02:13:06 +0000 (21:13 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 7 Apr 2013 02:13:06 +0000 (21:13 -0500)
src/mount_image.c
src/resource.c
src/wimlib_internal.h

index a2e09b435e43a60a72db289e0839c747315ceeaa..a83c6ba239552ca7f6ada629236073c65668d247 100644 (file)
@@ -2559,10 +2559,8 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
 #endif
 
        /* Mark dentry tree as modified if read-write mount. */
 #endif
 
        /* Mark dentry tree as modified if read-write mount. */
-       if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
+       if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE)
                imd->modified = 1;
                imd->modified = 1;
-               imd->has_been_mounted_rw = 1;
-       }
 
        /* Resolve the lookup table entries for every inode in the image, and
         * assign inode numbers */
 
        /* Resolve the lookup table entries for every inode in the image, and
         * assign inode numbers */
index a7a831980b562e3915721ff62044d08e1da4ecb5..73f860eb4d4bd559de6fc6be70dc4cc5585729a2 100644 (file)
@@ -320,11 +320,11 @@ read_compressed_resource(FILE *fp,
                 * is equal to the uncompressed chunk size. */
                if (compressed_chunk_size == uncompressed_chunk_size) {
                        /* Uncompressed chunk */
                 * is equal to the uncompressed chunk size. */
                if (compressed_chunk_size == uncompressed_chunk_size) {
                        /* Uncompressed chunk */
-
                        if (start_offset != 0)
                                if (fseeko(fp, start_offset, SEEK_CUR))
                                        goto read_error;
                        if (start_offset != 0)
                                if (fseeko(fp, start_offset, SEEK_CUR))
                                        goto read_error;
-                       if (fread(out_p, 1, partial_chunk_size, fp) != partial_chunk_size)
+                       if (fread(cb ? out_p + start_offset : out_p,
+                                 1, partial_chunk_size, fp) != partial_chunk_size)
                                goto read_error;
                } else {
                        /* Compressed chunk */
                                goto read_error;
                } else {
                        /* Compressed chunk */
@@ -533,22 +533,18 @@ read_partial_wim_resource(const struct wim_lookup_table_entry *lte,
        int ret;
 
        wimlib_assert(lte->resource_location == RESOURCE_IN_WIM);
        int ret;
 
        wimlib_assert(lte->resource_location == RESOURCE_IN_WIM);
-       wimlib_assert(offset + size <= lte->resource_entry.original_size);
 
        wim = lte->wim;
 
        wim = lte->wim;
-
        if (flags & WIMLIB_RESOURCE_FLAG_THREADSAFE_READ) {
                wim_fp = wim_get_fp(wim);
                if (!wim_fp) {
        if (flags & WIMLIB_RESOURCE_FLAG_THREADSAFE_READ) {
                wim_fp = wim_get_fp(wim);
                if (!wim_fp) {
-                       ret = -1;
+                       ret = WIMLIB_ERR_READ;
                        goto out;
                }
        } else {
                wim_fp = lte->wim->fp;
        }
 
                        goto out;
                }
        } else {
                wim_fp = lte->wim->fp;
        }
 
-       wimlib_assert(wim_fp != NULL);
-
        if (lte->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED &&
            !(flags & WIMLIB_RESOURCE_FLAG_RAW))
        {
        if (lte->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED &&
            !(flags & WIMLIB_RESOURCE_FLAG_RAW))
        {
@@ -593,15 +589,17 @@ read_partial_wim_resource(const struct wim_lookup_table_entry *lte,
        }
        goto out_release_fp;
 read_error:
        }
        goto out_release_fp;
 read_error:
-       if (ferror(wim_fp)) {
+       if (ferror(wim_fp))
                ERROR_WITH_ERRNO("Error reading data from WIM");
                ERROR_WITH_ERRNO("Error reading data from WIM");
-       } else {
+       else
                ERROR("Unexpected EOF in WIM!");
                ERROR("Unexpected EOF in WIM!");
-       }
        ret = WIMLIB_ERR_READ;
 out_release_fp:
        ret = WIMLIB_ERR_READ;
 out_release_fp:
-       if (flags & WIMLIB_RESOURCE_FLAG_THREADSAFE_READ)
-               ret |= wim_release_fp(wim, wim_fp);
+       if (flags & WIMLIB_RESOURCE_FLAG_THREADSAFE_READ) {
+               int ret2 = wim_release_fp(wim, wim_fp);
+               if (ret == 0)
+                       ret = ret2;
+       }
 out:
        if (ret) {
                if (errno == 0)
 out:
        if (ret) {
                if (errno == 0)
index 0442aaaca4b78ca20ae332f2eca268ca7a326225..e94fab9ba719fcab55f0cf2f62c1a12008729fa5 100644 (file)
@@ -268,9 +268,6 @@ struct wim_image_metadata {
         * different WIM image. */
        u8 modified : 1;
 
         * different WIM image. */
        u8 modified : 1;
 
-       /* 1 iff this image has been mounted read-write */
-       u8 has_been_mounted_rw : 1;
-
 #ifdef WITH_NTFS_3G
        struct _ntfs_volume *ntfs_vol;
 #endif
 #ifdef WITH_NTFS_3G
        struct _ntfs_volume *ntfs_vol;
 #endif
@@ -573,7 +570,6 @@ do_ntfs_umount(struct _ntfs_volume *vol);
 #define WIMLIB_RESOURCE_FLAG_RAW               0x1
 #define WIMLIB_RESOURCE_FLAG_THREADSAFE_READ   0x2
 #define WIMLIB_RESOURCE_FLAG_RECOMPRESS                0x4
 #define WIMLIB_RESOURCE_FLAG_RAW               0x1
 #define WIMLIB_RESOURCE_FLAG_THREADSAFE_READ   0x2
 #define WIMLIB_RESOURCE_FLAG_RECOMPRESS                0x4
-//#define WIMLIB_RESOURCE_FLAG_OVERWRITE_INPLACE       0x8
 
 extern int
 read_resource_prefix(const struct wim_lookup_table_entry *lte,
 
 extern int
 read_resource_prefix(const struct wim_lookup_table_entry *lte,