]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.c
execute_add_command(): Handle NULL config correctly
[wimlib] / src / lookup_table.c
index e2ca5920745f84b733bdfb794928c4f5a516e821..2a313060ef357717af18ed8f7087209e34d43a41 100644 (file)
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include "wimlib_internal.h"
-#include "lookup_table.h"
-#include "buffer_io.h"
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "wimlib/buffer_io.h"
+#include "wimlib/error.h"
+#include "wimlib/file_io.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/metadata.h"
+#include "wimlib/paths.h"
+#include "wimlib/resource.h"
+#include "wimlib/util.h"
+
 #include <errno.h>
 #include <stdlib.h>
-
 #ifdef WITH_FUSE
-#include <unistd.h>
+#  include <unistd.h> /* for unlink() */
 #endif
 
+/* Size of each lookup table entry in the WIM file. */
+#define WIM_LOOKUP_TABLE_ENTRY_DISK_SIZE 50
+
 struct wim_lookup_table *
 new_lookup_table(size_t capacity)
 {
@@ -58,7 +70,7 @@ new_lookup_table(size_t capacity)
 }
 
 struct wim_lookup_table_entry *
-new_lookup_table_entry()
+new_lookup_table_entry(void)
 {
        struct wim_lookup_table_entry *lte;
 
@@ -240,7 +252,9 @@ lte_decrement_refcnt(struct wim_lookup_table_entry *lte,
        wimlib_assert(lte != NULL);
        wimlib_assert(lte->refcnt != 0);
        if (--lte->refcnt == 0) {
-               if (!lte->unhashed)
+               if (lte->unhashed)
+                       list_del(&lte->unhashed_list);
+               else
                        lookup_table_unlink(table, lte);
        #ifdef WITH_FUSE
                if (lte->num_opened_fds == 0)
@@ -523,7 +537,7 @@ out:
 
 
 static u8 *
-write_lookup_table_entry(struct wim_lookup_table_entry *lte, u8 *buf_p)
+write_lookup_table_entry(const struct wim_lookup_table_entry *lte, u8 *buf_p)
 {
        buf_p = put_resource_entry(buf_p, &lte->output_resource_entry);
        buf_p = put_u16(buf_p, lte->part_number);
@@ -822,6 +836,19 @@ out:
 }
 #endif
 
+/*
+ * XXX Probably should store the compression type directly in the lookup table
+ * entry
+ */
+int
+wim_resource_compression_type(const struct wim_lookup_table_entry *lte)
+{
+       if (!(lte->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED)
+           || lte->resource_location != RESOURCE_IN_WIM)
+               return WIMLIB_COMPRESSION_TYPE_NONE;
+       return wimlib_get_compression_type(lte->wim);
+}
+
 /* Resolve an inode's lookup table entries
  *
  * This replaces the SHA1 hash fields (which are used to lookup an entry in the