From: Eric Biggers Date: Sun, 18 Nov 2012 21:04:19 +0000 (-0600) Subject: include WIMStruct->fp_tab only if WITH_FUSE X-Git-Tag: v1.1.0~6 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=31fb6f64634dd386a6ba4d4ff0aaade548cddc86 include WIMStruct->fp_tab only if WITH_FUSE --- diff --git a/src/resource.c b/src/resource.c index 01d481df..5ffba67b 100644 --- a/src/resource.c +++ b/src/resource.c @@ -419,6 +419,7 @@ u8 *put_resource_entry(u8 *p, const struct resource_entry *entry) return p; } +#ifdef WITH_FUSE 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; } +#endif /* * 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); + #ifdef WITH_FUSE 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; } @@ -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); + #ifdef WITH_FUSE 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: diff --git a/src/wim.c b/src/wim.c index 3d6febf1..92b59f02 100644 --- 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)); +#ifdef WITH_FUSE if (pthread_mutex_init(&w->fp_tab_mutex, NULL) != 0) { ERROR_WITH_ERRNO("Failed to initialize mutex"); FREE(w); w = NULL; } +#endif return w; } @@ -578,6 +580,7 @@ WIMLIBAPI void wimlib_free(WIMStruct *w) 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]) @@ -585,6 +588,7 @@ WIMLIBAPI void wimlib_free(WIMStruct *w) FREE(w->fp_tab); } pthread_mutex_destroy(&w->fp_tab_mutex); +#endif free_lookup_table(w->lookup_table); diff --git a/src/wimlib_internal.h b/src/wimlib_internal.h index 9af0f336..41028191 100644 --- a/src/wimlib_internal.h +++ b/src/wimlib_internal.h @@ -27,10 +27,13 @@ #ifndef _WIMLIB_INTERNAL_H #define _WIMLIB_INTERNAL_H +#include "config.h" #include "util.h" #include "list.h" +#ifdef WITH_FUSE #include +#endif struct stat; struct dentry; @@ -259,9 +262,11 @@ typedef struct WIMStruct { /* 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; +#endif /* FILE pointer for the WIM file that is being written. */ FILE *out_fp;