- p = put_u56(p, entry->size);
- p = put_u8(p, entry->flags);
- p = put_u64(p, entry->offset);
- p = put_u64(p, entry->original_size);
- return p;
-}
-
-static FILE *
-wim_get_fp(WIMStruct *w)
-{
-#ifdef WITH_FUSE
- pthread_mutex_lock(&w->fp_tab_mutex);
- FILE *fp;
-
- wimlib_assert(w->filename != NULL);
-
- for (size_t i = 0; i < w->num_allocated_fps; i++) {
- if (w->fp_tab[i]) {
- fp = w->fp_tab[i];
- w->fp_tab[i] = NULL;
- goto out_unlock;
- }
- }
- DEBUG("Opening extra file descriptor to `%"TS"'", w->filename);
- fp = tfopen(w->filename, T("rb"));
- if (!fp)
- ERROR_WITH_ERRNO("Failed to open `%"TS"'", w->filename);
-out_unlock:
- pthread_mutex_unlock(&w->fp_tab_mutex);
-#else /* WITH_FUSE */
- fp = w->fp;
-#endif /* !WITH_FUSE */
- return fp;
-}
-
-static int
-wim_release_fp(WIMStruct *w, FILE *fp)
-{
- int ret = 0;
-#ifdef WITH_FUSE
- FILE **fp_tab;
-
- pthread_mutex_lock(&w->fp_tab_mutex);
-
- for (size_t i = 0; i < w->num_allocated_fps; i++) {
- if (w->fp_tab[i] == NULL) {
- w->fp_tab[i] = fp;
- goto out_unlock;
- }
- }
-
- fp_tab = REALLOC(w->fp_tab, sizeof(FILE*) * (w->num_allocated_fps + 4));
- if (!fp_tab) {
- ret = WIMLIB_ERR_NOMEM;
- fclose(fp);
- goto out_unlock;
- }
- w->fp_tab = fp_tab;
- memset(&w->fp_tab[w->num_allocated_fps], 0, 4 * sizeof(FILE*));
- w->fp_tab[w->num_allocated_fps] = fp;
- w->num_allocated_fps += 4;
-out_unlock:
- pthread_mutex_unlock(&w->fp_tab_mutex);
-#endif /* WITH_FUSE */
- return ret;
+ /* Note: disk_entry may not be 8 byte aligned--- in that case, the
+ * offset and original_size members will be unaligned. (This should be
+ * okay since `struct resource_entry_disk' is declared as packed.) */
+ u64 size = entry->size;
+
+ disk_entry->size[0] = size >> 0;
+ disk_entry->size[1] = size >> 8;
+ disk_entry->size[2] = size >> 16;
+ disk_entry->size[3] = size >> 24;
+ disk_entry->size[4] = size >> 32;
+ disk_entry->size[5] = size >> 40;
+ disk_entry->size[6] = size >> 48;
+ disk_entry->flags = entry->flags;
+ disk_entry->offset = cpu_to_le64(entry->offset);
+ disk_entry->original_size = cpu_to_le64(entry->original_size);