]> wimlib.net Git - wimlib/commitdiff
include WIMStruct->fp_tab only if WITH_FUSE
authorEric Biggers <ebiggers3@gmail.com>
Sun, 18 Nov 2012 21:04:19 +0000 (15:04 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 18 Nov 2012 21:04:19 +0000 (15:04 -0600)
src/resource.c
src/wim.c
src/wimlib_internal.h

index 01d481df0f97057a074e7168270e0616e9359c2e..5ffba67bb61d4de3c5ad17d30aba7b2eebc52c68 100644 (file)
@@ -419,6 +419,7 @@ u8 *put_resource_entry(u8 *p, const struct resource_entry *entry)
        return p;
 }
 
        return p;
 }
 
+#ifdef WITH_FUSE
 static FILE *wim_get_fp(WIMStruct *w)
 {
        pthread_mutex_lock(&w->fp_tab_mutex);
 static FILE *wim_get_fp(WIMStruct *w)
 {
        pthread_mutex_lock(&w->fp_tab_mutex);
@@ -469,6 +470,7 @@ out:
        pthread_mutex_unlock(&w->fp_tab_mutex);
        return ret;
 }
        pthread_mutex_unlock(&w->fp_tab_mutex);
        return ret;
 }
+#endif
 
 /*
  * Reads some data from the resource corresponding to a WIM lookup table entry.
 
 /*
  * Reads some data from the resource corresponding to a WIM lookup table entry.
@@ -501,11 +503,15 @@ int read_wim_resource(const struct lookup_table_entry *lte, u8 buf[],
                 * or uncompressed. */
                wimlib_assert(lte->wim != NULL);
 
                 * or uncompressed. */
                wimlib_assert(lte->wim != NULL);
 
+               #ifdef WITH_FUSE
                if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
                        fp = wim_get_fp(lte->wim);
                        if (!fp)
                                return WIMLIB_ERR_OPEN;
                if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
                        fp = wim_get_fp(lte->wim);
                        if (!fp)
                                return WIMLIB_ERR_OPEN;
-               } else {
+               } else
+               #endif
+               {
+                       wimlib_assert(!(flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED));
                        wimlib_assert(lte->wim->fp != NULL);
                        fp = lte->wim->fp;
                }
                        wimlib_assert(lte->wim->fp != NULL);
                        fp = lte->wim->fp;
                }
@@ -527,11 +533,13 @@ int read_wim_resource(const struct lookup_table_entry *lte, u8 buf[],
                                                       lte->resource_entry.original_size,
                                                       lte->resource_entry.offset,
                                                       ctype, size, offset, buf);
                                                       lte->resource_entry.original_size,
                                                       lte->resource_entry.offset,
                                                       ctype, size, offset, buf);
+       #ifdef WITH_FUSE
                if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
                        int ret2 = wim_release_fp(lte->wim, fp);
                        if (ret == 0)
                                ret = ret2;
                }
                if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
                        int ret2 = wim_release_fp(lte->wim, fp);
                        if (ret == 0)
                                ret = ret2;
                }
+       #endif
                break;
        case RESOURCE_IN_STAGING_FILE:
        case RESOURCE_IN_FILE_ON_DISK:
                break;
        case RESOURCE_IN_STAGING_FILE:
        case RESOURCE_IN_FILE_ON_DISK:
index 3d6febf1ee7898a96a96a65e0941fa09bab27c2b..92b59f02335cddb071a5e404e27f7cac1726c5c3 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -60,11 +60,13 @@ static int print_files(WIMStruct *w)
 WIMStruct *new_wim_struct()
 {
        WIMStruct *w = CALLOC(1, sizeof(WIMStruct));
 WIMStruct *new_wim_struct()
 {
        WIMStruct *w = CALLOC(1, sizeof(WIMStruct));
+#ifdef WITH_FUSE
        if (pthread_mutex_init(&w->fp_tab_mutex, NULL) != 0) {
                ERROR_WITH_ERRNO("Failed to initialize mutex");
                FREE(w);
                w = NULL;
        }
        if (pthread_mutex_init(&w->fp_tab_mutex, NULL) != 0) {
                ERROR_WITH_ERRNO("Failed to initialize mutex");
                FREE(w);
                w = NULL;
        }
+#endif
        return w;
 
 }
        return w;
 
 }
@@ -578,6 +580,7 @@ WIMLIBAPI void wimlib_free(WIMStruct *w)
        if (w->out_fp)
                fclose(w->out_fp);
 
        if (w->out_fp)
                fclose(w->out_fp);
 
+#ifdef WITH_FUSE
        if (w->fp_tab) {
                for (size_t i = 0; i < w->num_allocated_fps; i++)
                        if (w->fp_tab[i])
        if (w->fp_tab) {
                for (size_t i = 0; i < w->num_allocated_fps; i++)
                        if (w->fp_tab[i])
@@ -585,6 +588,7 @@ WIMLIBAPI void wimlib_free(WIMStruct *w)
                FREE(w->fp_tab);
        }
        pthread_mutex_destroy(&w->fp_tab_mutex);
                FREE(w->fp_tab);
        }
        pthread_mutex_destroy(&w->fp_tab_mutex);
+#endif
 
        free_lookup_table(w->lookup_table);
 
 
        free_lookup_table(w->lookup_table);
 
index 9af0f3360255571a07aaf8de40712d0207733a5d..410281913c103431636feebaf9be3621e1dc2518 100644 (file)
 #ifndef _WIMLIB_INTERNAL_H
 #define _WIMLIB_INTERNAL_H
 
 #ifndef _WIMLIB_INTERNAL_H
 #define _WIMLIB_INTERNAL_H
 
+#include "config.h"
 #include "util.h"
 #include "list.h"
 
 #include "util.h"
 #include "list.h"
 
+#ifdef WITH_FUSE
 #include <pthread.h>
 #include <pthread.h>
+#endif
 
 struct stat;
 struct dentry;
 
 struct stat;
 struct dentry;
@@ -259,9 +262,11 @@ typedef struct WIMStruct {
        /* A pointer to the file indicated by @filename, opened for reading. */
        FILE  *fp;
 
        /* A pointer to the file indicated by @filename, opened for reading. */
        FILE  *fp;
 
+#ifdef WITH_FUSE
        FILE **fp_tab;
        size_t num_allocated_fps;
        pthread_mutex_t fp_tab_mutex;
        FILE **fp_tab;
        size_t num_allocated_fps;
        pthread_mutex_t fp_tab_mutex;
+#endif
 
        /* FILE pointer for the WIM file that is being written. */
        FILE  *out_fp;
 
        /* FILE pointer for the WIM file that is being written. */
        FILE  *out_fp;