w -> wim
authorEric Biggers <ebiggers3@gmail.com>
Sun, 26 May 2013 03:32:26 +0000 (22:32 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 26 May 2013 03:32:26 +0000 (22:32 -0500)
21 files changed:
include/wimlib/apply.h
include/wimlib/dentry.h
include/wimlib/integrity.h
include/wimlib/lookup_table.h
include/wimlib/metadata.h
include/wimlib/resource.h
include/wimlib/swm.h
include/wimlib/wim.h
include/wimlib/write.h
include/wimlib/xml.h
src/extract.c
src/header.c
src/integrity.c
src/lookup_table.c
src/metadata_resource.c
src/mount_image.c
src/ntfs-3g_apply.c
src/swm.c
src/wim.c
src/write.c
src/xml.c

index becef7a..4fd22f8 100644 (file)
@@ -9,7 +9,7 @@ struct _ntfs_volume;
 #endif
 
 struct apply_args {
-       WIMStruct *w;
+       WIMStruct *wim;
 
        /* Directory to which we're extracting the WIM image or directory tree,
         * in user-specified form (may be slightly altered) */
index a6aa31d..9439366 100644 (file)
@@ -438,10 +438,10 @@ extern int
 set_dentry_name(struct wim_dentry *dentry, const tchar *new_name);
 
 extern struct wim_dentry *
-get_dentry(struct WIMStruct *w, const tchar *path);
+get_dentry(struct WIMStruct *wim, const tchar *path);
 
 extern struct wim_inode *
-wim_pathname_to_inode(struct WIMStruct *w, const tchar *path);
+wim_pathname_to_inode(struct WIMStruct *wim, const tchar *path);
 
 extern struct wim_dentry *
 get_dentry_child_with_name(const struct wim_dentry *dentry,
@@ -453,7 +453,7 @@ get_dentry_child_with_utf16le_name(const struct wim_dentry *dentry,
                                   size_t name_nbytes);
 
 extern struct wim_dentry *
-get_parent_dentry(struct WIMStruct *w, const tchar *path);
+get_parent_dentry(struct WIMStruct *wim, const tchar *path);
 
 extern int
 print_dentry(struct wim_dentry *dentry, void *lookup_table);
index 6d5a16b..aa541f6 100644 (file)
@@ -18,6 +18,6 @@ write_integrity_table(int fd,
                      wimlib_progress_func_t progress_func);
 
 extern int
-check_wim_integrity(WIMStruct *w, wimlib_progress_func_t progress_func);
+check_wim_integrity(WIMStruct *wim, wimlib_progress_func_t progress_func);
 
 #endif /* _WIMLIB_INTEGRITY_H */
index caa24de..ff6a12a 100644 (file)
@@ -301,10 +301,10 @@ extern struct wim_lookup_table *
 new_lookup_table(size_t capacity) _malloc_attribute;
 
 extern int
-read_lookup_table(WIMStruct *w);
+read_lookup_table(WIMStruct *wim);
 
 extern int
-write_lookup_table(WIMStruct *w, int image, struct resource_entry *out_res_entry);
+write_lookup_table(WIMStruct *wim, int image, struct resource_entry *out_res_entry);
 
 extern int
 write_lookup_table_from_stream_list(struct list_head *stream_list,
@@ -363,7 +363,7 @@ extern struct wim_lookup_table_entry *
 __lookup_resource(const struct wim_lookup_table *table, const u8 hash[]);
 
 extern int
-lookup_resource(WIMStruct *w, const tchar *path,
+lookup_resource(WIMStruct *wim, const tchar *path,
                int lookup_flags, struct wim_dentry **dentry_ret,
                struct wim_lookup_table_entry **lte_ret, u16 *stream_idx_ret);
 
index 178c423..31b95ce 100644 (file)
@@ -47,33 +47,33 @@ struct wim_image_metadata {
 };
 
 static inline struct wim_image_metadata *
-wim_get_current_image_metadata(WIMStruct *w)
+wim_get_current_image_metadata(WIMStruct *wim)
 {
-       return w->image_metadata[w->current_image - 1];
+       return wim->image_metadata[wim->current_image - 1];
 }
 
 static inline const struct wim_image_metadata *
-wim_get_const_current_image_metadata(const WIMStruct *w)
+wim_get_const_current_image_metadata(const WIMStruct *wim)
 {
-       return w->image_metadata[w->current_image - 1];
+       return wim->image_metadata[wim->current_image - 1];
 }
 
 static inline struct wim_dentry *
-wim_root_dentry(WIMStruct *w)
+wim_root_dentry(WIMStruct *wim)
 {
-       return wim_get_current_image_metadata(w)->root_dentry;
+       return wim_get_current_image_metadata(wim)->root_dentry;
 }
 
 static inline struct wim_security_data *
-wim_security_data(WIMStruct *w)
+wim_security_data(WIMStruct *wim)
 {
-       return wim_get_current_image_metadata(w)->security_data;
+       return wim_get_current_image_metadata(wim)->security_data;
 }
 
 static inline const struct wim_security_data *
-wim_const_security_data(const WIMStruct *w)
+wim_const_security_data(const WIMStruct *wim)
 {
-       return wim_get_const_current_image_metadata(w)->security_data;
+       return wim_get_const_current_image_metadata(wim)->security_data;
 }
 
 /* Iterate over each inode in a WIM image that has not yet been hashed */
@@ -99,7 +99,7 @@ put_image_metadata(struct wim_image_metadata *imd,
                   struct wim_lookup_table *table);
 
 extern int
-append_image_metadata(WIMStruct *w, struct wim_image_metadata *imd);
+append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
 
 extern struct wim_image_metadata *
 new_image_metadata(void);
index c759861..60da5bf 100644 (file)
@@ -123,13 +123,13 @@ extern int
 sha1_resource(struct wim_lookup_table_entry *lte);
 
 extern int
-copy_resource(struct wim_lookup_table_entry *lte, void *w);
+copy_resource(struct wim_lookup_table_entry *lte, void *wim);
 
 extern int
-read_metadata_resource(WIMStruct *w,
+read_metadata_resource(WIMStruct *wim,
                       struct wim_image_metadata *image_metadata);
 
 extern int
-write_metadata_resource(WIMStruct *w);
+write_metadata_resource(WIMStruct *wim);
 
 #endif /* _WIMLIB_RESOURCE_H */
index 7328165..08a51fc 100644 (file)
@@ -4,11 +4,11 @@
 #include "wimlib/types.h"
 
 extern int
-verify_swm_set(WIMStruct *w,
+verify_swm_set(WIMStruct *wim,
               WIMStruct **additional_swms, unsigned num_additional_swms);
 
 extern void
-merge_lookup_tables(WIMStruct *w,
+merge_lookup_tables(WIMStruct *wim,
                    WIMStruct **additional_swms, unsigned num_additional_swms);
 
 extern void
index 03e0184..1ef55dd 100644 (file)
@@ -82,19 +82,19 @@ extern int
 rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to);
 
 extern int
-select_wim_image(WIMStruct *w, int image);
+select_wim_image(WIMStruct *wim, int image);
 
 extern int
-for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *));
+for_image(WIMStruct *wim, int image, int (*visitor)(WIMStruct *));
 
 extern int
-wim_checksum_unhashed_streams(WIMStruct *w);
+wim_checksum_unhashed_streams(WIMStruct *wim);
 
 extern int
-reopen_wim(WIMStruct *w);
+reopen_wim(WIMStruct *wim);
 
 extern int
-close_wim(WIMStruct *w);
+close_wim(WIMStruct *wim);
 
 extern int
 can_modify_wim(WIMStruct *wim);
index 2cb9a33..1722dab 100644 (file)
 #define WIMLIB_WRITE_MASK_PUBLIC               0x1fffffff
 
 extern int
-begin_write(WIMStruct *w, const tchar *path, int write_flags);
+begin_write(WIMStruct *wim, const tchar *path, int write_flags);
 
 extern void
-close_wim_writable(WIMStruct *w);
+close_wim_writable(WIMStruct *wim);
 
 extern int
-finish_write(WIMStruct *w, int image, int write_flags,
+finish_write(WIMStruct *wim, int image, int write_flags,
             wimlib_progress_func_t progress_func);
 
 #if defined(HAVE_SYS_FILE_H) && defined(HAVE_FLOCK)
 extern int
-lock_wim(WIMStruct *w, int fd);
+lock_wim(WIMStruct *wim, int fd);
 #else
 static inline int
-lock_wim(WIMStruct *w, int fd)
+lock_wim(WIMStruct *wim, int fd)
 {
        return 0;
 }
index 439bd01..0f0d368 100644 (file)
@@ -23,16 +23,16 @@ xml_export_image(const struct wim_info *old_wim_info, int image,
                 const tchar *dest_image_description);
 
 extern size_t
-xml_get_max_image_name_len(const WIMStruct *w);
+xml_get_max_image_name_len(const WIMStruct *wim);
 
 extern void
-xml_update_image_info(WIMStruct *w, int image);
+xml_update_image_info(WIMStruct *wim, int image);
 
 extern void
 xml_delete_image(struct wim_info **wim_info_p, int image);
 
 extern int
-xml_add_image(WIMStruct *w, const tchar *name);
+xml_add_image(WIMStruct *wim, const tchar *name);
 
 extern void
 free_wim_info(struct wim_info *info);
index d6cc9c4..0f5a38d 100644 (file)
@@ -700,7 +700,7 @@ extract_tree(WIMStruct *wim, const tchar *wim_source_path, const tchar *target,
        memset(&args, 0, sizeof(args));
 
 
-       args.w                      = wim;
+       args.wim                    = wim;
        args.target                 = target;
        args.target_nchars          = tstrlen(target);
        args.extract_flags          = extract_flags;
index 5d0b683..6bdf089 100644 (file)
@@ -307,11 +307,11 @@ struct hdr_flag hdr_flags[] = {
        {WIM_HDR_FLAG_COMPRESS_XPRESS,  "COMPRESS_XPRESS"},
 };
 
-/* Prints information from the header of the WIM file associated with @w. */
+/* Prints information from the header of the WIM file associated with @wim. */
 WIMLIBAPI void
-wimlib_print_header(const WIMStruct *w)
+wimlib_print_header(const WIMStruct *wim)
 {
-       const struct wim_header *hdr = &w->hdr;
+       const struct wim_header *hdr = &wim->hdr;
 
        tprintf(T("Magic Characters            = MSWIM\\000\\000\\000\n"));
        tprintf(T("Header Size                 = %u\n"), WIM_HEADER_DISK_SIZE);
@@ -326,8 +326,8 @@ wimlib_print_header(const WIMStruct *w)
        tfputs (T("GUID                        = "), stdout);
        print_byte_field(hdr->guid, WIM_GID_LEN, stdout);
        tputchar(T('\n'));
-       tprintf(T("Part Number                 = %hu\n"), w->hdr.part_number);
-       tprintf(T("Total Parts                 = %hu\n"), w->hdr.total_parts);
+       tprintf(T("Part Number                 = %hu\n"), wim->hdr.part_number);
+       tprintf(T("Total Parts                 = %hu\n"), wim->hdr.total_parts);
        tprintf(T("Image Count                 = %u\n"), hdr->image_count);
        tprintf(T("Lookup Table Size           = %"PRIu64"\n"),
                                (u64)hdr->lookup_table_res_entry.size);
index 1998f6c..fd656a4 100644 (file)
@@ -504,7 +504,7 @@ verify_integrity(int in_fd, const tchar *filename,
  * ~10 MiB chunks of the WIM match up with the values given in the integrity
  * table.
  *
- * @w:
+ * @wim:
  *     The WIM, opened for reading, and with the header already read.
  *
  * @progress_func
@@ -520,20 +520,20 @@ verify_integrity(int in_fd, const tchar *filename,
  *     information.
  */
 int
-check_wim_integrity(WIMStruct *w, wimlib_progress_func_t progress_func)
+check_wim_integrity(WIMStruct *wim, wimlib_progress_func_t progress_func)
 {
        int ret;
        u64 bytes_to_check;
        struct integrity_table *table;
        u64 end_lookup_table_offset;
 
-       if (w->hdr.integrity.offset == 0) {
+       if (wim->hdr.integrity.offset == 0) {
                DEBUG("No integrity information.");
                return WIM_INTEGRITY_NONEXISTENT;
        }
 
-       end_lookup_table_offset = w->hdr.lookup_table_res_entry.offset +
-                                 w->hdr.lookup_table_res_entry.size;
+       end_lookup_table_offset = wim->hdr.lookup_table_res_entry.offset +
+                                 wim->hdr.lookup_table_res_entry.size;
 
        if (end_lookup_table_offset < WIM_HEADER_DISK_SIZE) {
                ERROR("WIM lookup table ends before WIM header ends!");
@@ -542,11 +542,11 @@ check_wim_integrity(WIMStruct *w, wimlib_progress_func_t progress_func)
 
        bytes_to_check = end_lookup_table_offset - WIM_HEADER_DISK_SIZE;
 
-       ret = read_integrity_table(&w->hdr.integrity, w->in_fd,
+       ret = read_integrity_table(&wim->hdr.integrity, wim->in_fd,
                                   bytes_to_check, &table);
        if (ret)
                return ret;
-       ret = verify_integrity(w->in_fd, w->filename, table,
+       ret = verify_integrity(wim->in_fd, wim->filename, table,
                               bytes_to_check, progress_func);
        FREE(table);
        return ret;
index 66ff69d..d155ceb 100644 (file)
@@ -375,7 +375,7 @@ struct wim_lookup_table_entry_disk {
  * image_metadata array).
  */
 int
-read_lookup_table(WIMStruct *w)
+read_lookup_table(WIMStruct *wim)
 {
        int ret;
        size_t num_entries;
@@ -393,16 +393,16 @@ read_lookup_table(WIMStruct *w)
        const struct wim_lookup_table_entry_disk *disk_entry;
 
        DEBUG("Reading lookup table: offset %"PRIu64", size %"PRIu64"",
-             w->hdr.lookup_table_res_entry.offset,
-             w->hdr.lookup_table_res_entry.original_size);
+             wim->hdr.lookup_table_res_entry.offset,
+             wim->hdr.lookup_table_res_entry.original_size);
 
-       if (resource_is_compressed(&w->hdr.lookup_table_res_entry)) {
+       if (resource_is_compressed(&wim->hdr.lookup_table_res_entry)) {
                ERROR("Didn't expect a compressed lookup table!");
                ERROR("Ask the author to implement support for this.");
                return WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE;
        }
 
-       num_entries = w->hdr.lookup_table_res_entry.size /
+       num_entries = wim->hdr.lookup_table_res_entry.size /
                      sizeof(struct wim_lookup_table_entry_disk);
        table = new_lookup_table(num_entries * 2 + 1);
        if (!table) {
@@ -411,8 +411,8 @@ read_lookup_table(WIMStruct *w)
                return WIMLIB_ERR_NOMEM;
        }
 
-       w->current_image = 0;
-       offset = w->hdr.lookup_table_res_entry.offset;
+       wim->current_image = 0;
+       offset = wim->hdr.lookup_table_res_entry.offset;
        buf_entries_remaining = 0;
        for (; num_entries != 0;
             num_entries--, buf_entries_remaining--, disk_entry++)
@@ -422,7 +422,7 @@ read_lookup_table(WIMStruct *w)
 
                        entries_to_read = min(ARRAY_LEN(table_buf), num_entries);
                        bytes_to_read = entries_to_read * sizeof(struct wim_lookup_table_entry_disk);
-                       if (full_pread(w->in_fd, table_buf,
+                       if (full_pread(wim->in_fd, table_buf,
                                       bytes_to_read, offset) != bytes_to_read)
                        {
                                ERROR_WITH_ERRNO("Error reading lookup table "
@@ -440,7 +440,7 @@ read_lookup_table(WIMStruct *w)
                        goto out_free_lookup_table;
                }
 
-               cur_entry->wim = w;
+               cur_entry->wim = wim;
                cur_entry->resource_location = RESOURCE_IN_WIM;
                get_resource_entry(&disk_entry->resource_entry, &cur_entry->resource_entry);
                cur_entry->part_number = le16_to_cpu(disk_entry->part_number);
@@ -448,14 +448,14 @@ read_lookup_table(WIMStruct *w)
                copy_hash(cur_entry->hash, disk_entry->hash);
 
                if (cur_entry->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED)
-                       cur_entry->compression_type = w->compression_type;
+                       cur_entry->compression_type = wim->compression_type;
                else
                        BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_NONE != 0);
 
-               if (cur_entry->part_number != w->hdr.part_number) {
+               if (cur_entry->part_number != wim->hdr.part_number) {
                        WARNING("A lookup table entry in part %hu of the WIM "
                                "points to part %hu (ignoring it)",
-                               w->hdr.part_number, cur_entry->part_number);
+                               wim->hdr.part_number, cur_entry->part_number);
                        free_lookup_table_entry(cur_entry);
                        continue;
                }
@@ -500,17 +500,17 @@ read_lookup_table(WIMStruct *w)
                                goto out_free_cur_entry;
                        }
 
-                       if (w->hdr.part_number != 1) {
+                       if (wim->hdr.part_number != 1) {
                                WARNING("Ignoring metadata resource found in a "
                                        "non-first part of the split WIM");
                                free_lookup_table_entry(cur_entry);
                                continue;
                        }
-                       if (w->current_image == w->hdr.image_count) {
+                       if (wim->current_image == wim->hdr.image_count) {
                                WARNING("The WIM header says there are %u images "
                                        "in the WIM, but we found more metadata "
                                        "resources than this (ignoring the extra)",
-                                       w->hdr.image_count);
+                                       wim->hdr.image_count);
                                free_lookup_table_entry(cur_entry);
                                continue;
                        }
@@ -524,10 +524,10 @@ read_lookup_table(WIMStruct *w)
                         * written in the XML data. */
                        DEBUG("Found metadata resource for image %u at "
                              "offset %"PRIu64".",
-                             w->current_image + 1,
+                             wim->current_image + 1,
                              cur_entry->resource_entry.offset);
-                       w->image_metadata[
-                               w->current_image++]->metadata_lte = cur_entry;
+                       wim->image_metadata[
+                               wim->current_image++]->metadata_lte = cur_entry;
                } else {
                        /* Lookup table entry for a stream that is not a
                         * metadata resource */
@@ -549,18 +549,18 @@ read_lookup_table(WIMStruct *w)
                }
        }
 
-       if (w->hdr.part_number == 1 && w->current_image != w->hdr.image_count) {
+       if (wim->hdr.part_number == 1 && wim->current_image != wim->hdr.image_count) {
                WARNING("The header of \"%"TS"\" says there are %u images in\n"
                        "          the WIM, but we only found %d metadata resources!  Acting as if\n"
                        "          the header specified only %d images instead.",
-                       w->filename, w->hdr.image_count,
-                       w->current_image, w->current_image);
-               for (int i = w->current_image; i < w->hdr.image_count; i++)
-                       put_image_metadata(w->image_metadata[i], NULL);
-               w->hdr.image_count = w->current_image;
+                       wim->filename, wim->hdr.image_count,
+                       wim->current_image, wim->current_image);
+               for (int i = wim->current_image; i < wim->hdr.image_count; i++)
+                       put_image_metadata(wim->image_metadata[i], NULL);
+               wim->hdr.image_count = wim->current_image;
        }
        DEBUG("Done reading lookup table.");
-       w->lookup_table = table;
+       wim->lookup_table = table;
        ret = 0;
        goto out;
 out_free_cur_entry:
@@ -568,7 +568,7 @@ out_free_cur_entry:
 out_free_lookup_table:
        free_lookup_table(table);
 out:
-       w->current_image = 0;
+       wim->current_image = 0;
        return ret;
 }
 
@@ -646,7 +646,7 @@ append_lookup_table_entry(struct wim_lookup_table_entry *lte, void *_list)
 
 /* Writes the WIM lookup table to the output file. */
 int
-write_lookup_table(WIMStruct *w, int image, struct resource_entry *out_res_entry)
+write_lookup_table(WIMStruct *wim, int image, struct resource_entry *out_res_entry)
 {
        LIST_HEAD(stream_list);
        int start_image;
@@ -654,7 +654,7 @@ write_lookup_table(WIMStruct *w, int image, struct resource_entry *out_res_entry
 
        if (image == WIMLIB_ALL_IMAGES) {
                start_image = 1;
-               end_image = w->hdr.image_count;
+               end_image = wim->hdr.image_count;
        } else {
                start_image = image;
                end_image = image;
@@ -663,16 +663,16 @@ write_lookup_table(WIMStruct *w, int image, struct resource_entry *out_res_entry
        for (int i = start_image; i <= end_image; i++) {
                struct wim_lookup_table_entry *metadata_lte;
 
-               metadata_lte = w->image_metadata[i - 1]->metadata_lte;
+               metadata_lte = wim->image_metadata[i - 1]->metadata_lte;
                metadata_lte->out_refcnt = 1;
                metadata_lte->output_resource_entry.flags |= WIM_RESHDR_FLAG_METADATA;
                append_lookup_table_entry(metadata_lte, &stream_list);
        }
-       for_lookup_table_entry(w->lookup_table,
+       for_lookup_table_entry(wim->lookup_table,
                               append_lookup_table_entry,
                               &stream_list);
        return write_lookup_table_from_stream_list(&stream_list,
-                                                  w->out_fd,
+                                                  wim->out_fd,
                                                   out_res_entry);
 }
 
@@ -866,7 +866,7 @@ __lookup_resource(const struct wim_lookup_table *table, const u8 hash[])
  * This is only for pre-resolved inodes.
  */
 int
-lookup_resource(WIMStruct *w,
+lookup_resource(WIMStruct *wim,
                const tchar *path,
                int lookup_flags,
                struct wim_dentry **dentry_ret,
@@ -888,7 +888,7 @@ lookup_resource(WIMStruct *w,
                }
        }
 
-       dentry = get_dentry(w, path);
+       dentry = get_dentry(wim, path);
        if (p)
                *p = T(':');
        if (!dentry)
@@ -897,7 +897,7 @@ lookup_resource(WIMStruct *w,
        inode = dentry->d_inode;
 
        if (!inode->i_resolved)
-               if (inode_resolve_ltes(inode, w->lookup_table))
+               if (inode_resolve_ltes(inode, wim->lookup_table))
                        return -EIO;
 
        if (!(lookup_flags & LOOKUP_FLAG_DIRECTORY_OK)
index d23b6b0..37206d6 100644 (file)
@@ -41,7 +41,7 @@
  * end-of-directory is signaled by a directory entry of length '0', really of
  * length 8, because that's how long the 'length' field is.
  *
- * @w:         Pointer to the WIMStruct for the WIM file.
+ * @wim:               Pointer to the WIMStruct for the WIM file.
  *
  * @imd:       Pointer to the image metadata structure for the image whose
  *             metadata resource we are reading.  Its `metadata_lte' member
@@ -236,7 +236,7 @@ write_wim_resource_from_buffer(const void *buf, size_t buf_size,
 
 /* Write the metadata resource for the current WIM image. */
 int
-write_metadata_resource(WIMStruct *w)
+write_metadata_resource(WIMStruct *wim)
 {
        u8 *buf;
        u8 *p;
@@ -248,13 +248,13 @@ write_metadata_resource(WIMStruct *w)
        struct wim_security_data *sd;
        struct wim_image_metadata *imd;
 
-       wimlib_assert(w->out_fd != -1);
-       wimlib_assert(w->current_image != WIMLIB_NO_IMAGE);
+       wimlib_assert(wim->out_fd != -1);
+       wimlib_assert(wim->current_image != WIMLIB_NO_IMAGE);
 
        DEBUG("Writing metadata resource for image %d (offset = %"PRIu64")",
-             w->current_image, filedes_offset(w->out_fd));
+             wim->current_image, filedes_offset(wim->out_fd));
 
-       imd = w->image_metadata[w->current_image - 1];
+       imd = wim->image_metadata[wim->current_image - 1];
 
        root = imd->root_dentry;
        sd = imd->security_data;
@@ -304,14 +304,14 @@ write_metadata_resource(WIMStruct *w)
 
        /* Get the lookup table entry for the metadata resource so we can update
         * it. */
-       lte = wim_get_current_image_metadata(w)->metadata_lte;
+       lte = wim_get_current_image_metadata(wim)->metadata_lte;
 
        /* Write the metadata resource to the output WIM using the proper
         * compression type.  The lookup table entry for the metadata resource
         * is updated. */
        ret = write_wim_resource_from_buffer(buf, metadata_original_size,
-                                            w->out_fd,
-                                            w->compression_type,
+                                            wim->out_fd,
+                                            wim->compression_type,
                                             &lte->output_resource_entry,
                                             lte->hash);
        /* Note that although the SHA1 message digest of the metadata resource
index ac91461..f1baebb 100644 (file)
@@ -807,7 +807,7 @@ rebuild_wim(struct wimfs_context *ctx, int write_flags,
 {
        int ret;
        struct wim_lookup_table_entry *lte, *tmp;
-       WIMStruct *w = ctx->wim;
+       WIMStruct *wim = ctx->wim;
        struct wim_image_metadata *imd = wim_get_current_image_metadata(ctx->wim);
 
        DEBUG("Closing all staging file descriptors.");
@@ -829,8 +829,8 @@ rebuild_wim(struct wimfs_context *ctx, int write_flags,
                }
        }
 
-       xml_update_image_info(w, w->current_image);
-       ret = wimlib_overwrite(w, write_flags, 0, progress_func);
+       xml_update_image_info(wim, wim->current_image);
+       ret = wimlib_overwrite(wim, write_flags, 0, progress_func);
        if (ret)
                ERROR("Failed to commit changes to mounted WIM image");
        return ret;
@@ -1676,10 +1676,10 @@ wimfs_link(const char *to, const char *from)
        struct wim_dentry *from_dentry, *from_dentry_parent;
        const char *link_name;
        struct wim_inode *inode;
-       WIMStruct *w = wimfs_get_WIMStruct();
+       WIMStruct *wim = wimfs_get_WIMStruct();
        int ret;
 
-       inode = wim_pathname_to_inode(w, to);
+       inode = wim_pathname_to_inode(wim, to);
        if (!inode)
                return -errno;
 
@@ -1687,7 +1687,7 @@ wimfs_link(const char *to, const char *from)
                                   FILE_ATTRIBUTE_REPARSE_POINT))
                return -EPERM;
 
-       from_dentry_parent = get_parent_dentry(w, from);
+       from_dentry_parent = get_parent_dentry(wim, from);
        if (!from_dentry_parent)
                return -errno;
        if (!dentry_is_directory(from_dentry_parent))
@@ -1877,9 +1877,9 @@ wimfs_opendir(const char *path, struct fuse_file_info *fi)
        int ret;
        struct wimfs_fd *fd = NULL;
        struct wimfs_context *ctx = wimfs_get_context();
-       WIMStruct *w = ctx->wim;
+       WIMStruct *wim = ctx->wim;
 
-       inode = wim_pathname_to_inode(w, path);
+       inode = wim_pathname_to_inode(wim, path);
        if (!inode)
                return -errno;
        if (!inode_is_directory(inode))
@@ -2077,9 +2077,9 @@ static int
 wimfs_rmdir(const char *path)
 {
        struct wim_dentry *dentry;
-       WIMStruct *w = wimfs_get_WIMStruct();
+       WIMStruct *wim = wimfs_get_WIMStruct();
 
-       dentry = get_dentry(w, path);
+       dentry = get_dentry(wim, path);
        if (!dentry)
                return -errno;
 
@@ -2089,7 +2089,7 @@ wimfs_rmdir(const char *path)
        if (dentry_has_children(dentry))
                return -ENOTEMPTY;
 
-       remove_dentry(dentry, w->lookup_table);
+       remove_dentry(dentry, wim->lookup_table);
        return 0;
 }
 
@@ -2245,9 +2245,9 @@ wimfs_utimens(const char *path, const struct timespec tv[2])
 {
        struct wim_dentry *dentry;
        struct wim_inode *inode;
-       WIMStruct *w = wimfs_get_WIMStruct();
+       WIMStruct *wim = wimfs_get_WIMStruct();
 
-       dentry = get_dentry(w, path);
+       dentry = get_dentry(wim, path);
        if (!dentry)
                return -errno;
        inode = dentry->d_inode;
@@ -2272,9 +2272,9 @@ wimfs_utime(const char *path, struct utimbuf *times)
 {
        struct wim_dentry *dentry;
        struct wim_inode *inode;
-       WIMStruct *w = wimfs_get_WIMStruct();
+       WIMStruct *wim = wimfs_get_WIMStruct();
 
-       dentry = get_dentry(w, path);
+       dentry = get_dentry(wim, path);
        if (!dentry)
                return -errno;
        inode = dentry->d_inode;
index 4e5926b..a8292c7 100644 (file)
@@ -291,7 +291,7 @@ apply_ntfs_hardlink(struct wim_dentry *from_dentry,
  * @ni:             The NTFS inode to apply the metadata to.
  * @dir_ni:  The NTFS inode for a directory containing @ni.
  * @dentry:  The WIM dentry whose inode contains the metadata to apply.
- * @w:       The WIMStruct for the WIM, through which the table of security
+ * @wim:       The WIMStruct for the WIM, through which the table of security
  *             descriptors can be accessed.
  *
  * Returns 0 on success, nonzero on failure.
@@ -300,7 +300,7 @@ static int
 apply_file_attributes_and_security_data(ntfs_inode *ni,
                                        ntfs_inode *dir_ni,
                                        struct wim_dentry *dentry,
-                                       const WIMStruct *w,
+                                       const WIMStruct *wim,
                                        int extract_flags)
 {
        int ret;
@@ -330,7 +330,7 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
                const char *desc;
                const struct wim_security_data *sd;
 
-               sd = wim_const_security_data(w);
+               sd = wim_const_security_data(wim);
                wimlib_assert(inode->i_security_id < sd->num_entries);
                desc = (const char *)sd->descriptors[inode->i_security_id];
                DEBUG("Applying security descriptor %d to `%s'",
@@ -446,7 +446,7 @@ do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *dir_ni,
        }
 
        ret = apply_file_attributes_and_security_data(ni, dir_ni, dentry,
-                                                     args->w,
+                                                     args->wim,
                                                      args->extract_flags);
        if (ret)
                goto out_close_dir_ni;
@@ -507,7 +507,7 @@ out:
 
 static int
 apply_root_dentry_ntfs(struct wim_dentry *dentry,
-                      ntfs_volume *vol, const WIMStruct *w,
+                      ntfs_volume *vol, const WIMStruct *wim,
                       int extract_flags)
 {
        ntfs_inode *ni;
@@ -522,7 +522,7 @@ apply_root_dentry_ntfs(struct wim_dentry *dentry,
                ERROR_WITH_ERRNO("Could not find root NTFS inode");
                return WIMLIB_ERR_NTFS_3G;
        }
-       ret = apply_file_attributes_and_security_data(ni, ni, dentry, w,
+       ret = apply_file_attributes_and_security_data(ni, ni, dentry, wim,
                                                      extract_flags);
        if (ntfs_inode_close(ni) != 0) {
                ERROR_WITH_ERRNO("Failed to close NTFS inode for root "
@@ -538,14 +538,14 @@ apply_dentry_ntfs(struct wim_dentry *dentry, void *arg)
 {
        struct apply_args *args = arg;
        ntfs_volume *vol = args->vol;
-       WIMStruct *w = args->w;
+       WIMStruct *wim = args->wim;
        struct wim_dentry *orig_dentry;
        struct wim_dentry *other;
        int ret;
 
        /* Treat the root dentry specially. */
        if (dentry_is_root(dentry))
-               return apply_root_dentry_ntfs(dentry, vol, w,
+               return apply_root_dentry_ntfs(dentry, vol, wim,
                                              args->extract_flags);
 
        /* NTFS filename namespaces need careful consideration.  A name for a
index 19452db..5ea5d4f 100644 (file)
--- a/src/swm.c
+++ b/src/swm.c
@@ -51,19 +51,19 @@ lookup_table_join(struct wim_lookup_table *combined_table,
 /*
  * merge_lookup_tables() - Merge lookup tables from the parts of a split WIM.
  *
- * @w specifies the first part, while @additional_swms and @num_additional_swms
+ * @wim specifies the first part, while @additional_swms and @num_additional_swms
  * specify an array of pointers to the WIMStruct's for additional split WIM parts.
  *
  * The reason we join the lookup tables is so we only have to search one lookup
  * table to find the location of a resource in the entire WIM.
  */
 void
-merge_lookup_tables(WIMStruct *w,
+merge_lookup_tables(WIMStruct *wim,
                    WIMStruct **additional_swms,
                    unsigned num_additional_swms)
 {
        for (unsigned i = 0; i < num_additional_swms; i++)
-               lookup_table_join(w->lookup_table, additional_swms[i]->lookup_table);
+               lookup_table_join(wim->lookup_table, additional_swms[i]->lookup_table);
 }
 
 static int
@@ -89,7 +89,7 @@ unmerge_lookup_table(WIMStruct *wim)
  * verify_swm_set: - Sanity checks to make sure a set of WIMs correctly
  *                  correspond to a spanned set.
  *
- * @w:
+ * @wim:
  *     Part 1 of the set.
  *
  * @additional_swms:
@@ -103,25 +103,25 @@ unmerge_lookup_table(WIMStruct *wim)
  *     0 on success; WIMLIB_ERR_SPLIT_INVALID if the set is not valid.
  */
 int
-verify_swm_set(WIMStruct *w, WIMStruct **additional_swms,
+verify_swm_set(WIMStruct *wim, WIMStruct **additional_swms,
               unsigned num_additional_swms)
 {
-       unsigned total_parts = w->hdr.total_parts;
+       unsigned total_parts = wim->hdr.total_parts;
        int ctype;
        const u8 *guid;
 
        if (total_parts != num_additional_swms + 1) {
                ERROR("`%"TS"' says there are %u parts in the spanned set, "
                      "but %"TS"%u part%"TS" provided",
-                     w->filename, total_parts,
+                     wim->filename, total_parts,
                      (num_additional_swms + 1 < total_parts) ? T("only ") : T(""),
                      num_additional_swms + 1,
                      (num_additional_swms) ? T("s were") : T(" was"));
                return WIMLIB_ERR_SPLIT_INVALID;
        }
-       if (w->hdr.part_number != 1) {
+       if (wim->hdr.part_number != 1) {
                ERROR("WIM `%"TS"' is not the first part of the split WIM.",
-                     w->filename);
+                     wim->filename);
                return WIMLIB_ERR_SPLIT_INVALID;
        }
        for (unsigned i = 0; i < num_additional_swms; i++) {
@@ -137,13 +137,13 @@ verify_swm_set(WIMStruct *w, WIMStruct **additional_swms,
 
        /* keep track of ctype and guid just to make sure they are the same for
         * all the WIMs. */
-       ctype = w->compression_type;
-       guid = w->hdr.guid;
+       ctype = wim->compression_type;
+       guid = wim->hdr.guid;
 
        {
                /* parts_to_swms is not allocated at function scope because it
                 * should only be allocated after num_additional_swms was
-                * checked to be the same as w->hdr.total_parts.  Otherwise, it
+                * checked to be the same as wim->hdr.total_parts.  Otherwise, it
                 * could be unexpectedly high and cause a stack overflow. */
                WIMStruct *parts_to_swms[num_additional_swms];
                ZERO_ARRAY(parts_to_swms);
@@ -164,7 +164,7 @@ verify_swm_set(WIMStruct *w, WIMStruct **additional_swms,
                        if (swm->hdr.part_number == 1) {
                                ERROR("WIMs `%"TS"' and `%"TS"' both are marked "
                                      "as the first WIM in the spanned set",
-                                     w->filename, swm->filename);
+                                     wim->filename, swm->filename);
                                return WIMLIB_ERR_SPLIT_INVALID;
                        }
                        if (swm->hdr.part_number == 0 ||
index 73f0060..43a0e34 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
 #include <unistd.h>
 
 static int
-image_print_metadata(WIMStruct *w)
+image_print_metadata(WIMStruct *wim)
 {
-       DEBUG("Printing metadata for image %d", w->current_image);
-       print_wim_security_data(wim_security_data(w));
-       return for_dentry_in_tree(wim_root_dentry(w), print_dentry,
-                                 w->lookup_table);
+       DEBUG("Printing metadata for image %d", wim->current_image);
+       print_wim_security_data(wim_security_data(wim));
+       return for_dentry_in_tree(wim_root_dentry(wim), print_dentry,
+                                 wim->lookup_table);
 }
 
 
 static int
-image_print_files(WIMStruct *w)
+image_print_files(WIMStruct *wim)
 {
-       return for_dentry_in_tree(wim_root_dentry(w), print_dentry_full_path,
+       return for_dentry_in_tree(wim_root_dentry(wim), print_dentry_full_path,
                                  NULL);
 }
 
 static WIMStruct *
 new_wim_struct(void)
 {
-       WIMStruct *w = CALLOC(1, sizeof(WIMStruct));
-       if (w) {
-               w->in_fd = -1;
-               w->out_fd = -1;
+       WIMStruct *wim = CALLOC(1, sizeof(WIMStruct));
+       if (wim) {
+               wim->in_fd = -1;
+               wim->out_fd = -1;
        }
-       return w;
+       return wim;
 }
 
 /*
@@ -88,7 +88,7 @@ new_wim_struct(void)
  * the WIM only once, with that image selected.
  */
 int
-for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *))
+for_image(WIMStruct *wim, int image, int (*visitor)(WIMStruct *))
 {
        int ret;
        int start;
@@ -97,18 +97,18 @@ for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *))
 
        if (image == WIMLIB_ALL_IMAGES) {
                start = 1;
-               end = w->hdr.image_count;
-       } else if (image >= 1 && image <= w->hdr.image_count) {
+               end = wim->hdr.image_count;
+       } else if (image >= 1 && image <= wim->hdr.image_count) {
                start = image;
                end = image;
        } else {
                return WIMLIB_ERR_INVALID_IMAGE;
        }
        for (i = start; i <= end; i++) {
-               ret = select_wim_image(w, i);
+               ret = select_wim_image(wim, i);
                if (ret != 0)
                        return ret;
-               ret = visitor(w);
+               ret = visitor(wim);
                if (ret != 0)
                        return ret;
        }
@@ -119,9 +119,9 @@ for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *))
  * Creates a WIMStruct for a new WIM file.
  */
 WIMLIBAPI int
-wimlib_create_new_wim(int ctype, WIMStruct **w_ret)
+wimlib_create_new_wim(int ctype, WIMStruct **wim_ret)
 {
-       WIMStruct *w;
+       WIMStruct *wim;
        struct wim_lookup_table *table;
        int ret;
 
@@ -131,11 +131,11 @@ wimlib_create_new_wim(int ctype, WIMStruct **w_ret)
              wimlib_get_compression_type_string(ctype));
 
        /* Allocate the WIMStruct. */
-       w = new_wim_struct();
-       if (!w)
+       wim = new_wim_struct();
+       if (!wim)
                return WIMLIB_ERR_NOMEM;
 
-       ret = init_header(&w->hdr, ctype);
+       ret = init_header(&wim->hdr, ctype);
        if (ret != 0)
                goto out_free;
 
@@ -144,18 +144,18 @@ wimlib_create_new_wim(int ctype, WIMStruct **w_ret)
                ret = WIMLIB_ERR_NOMEM;
                goto out_free;
        }
-       w->lookup_table = table;
-       w->refcnts_ok = 1;
-       w->compression_type = ctype;
-       *w_ret = w;
+       wim->lookup_table = table;
+       wim->refcnts_ok = 1;
+       wim->compression_type = ctype;
+       *wim_ret = wim;
        return 0;
 out_free:
-       FREE(w);
+       FREE(wim);
        return ret;
 }
 
 int
-select_wim_image(WIMStruct *w, int image)
+select_wim_image(WIMStruct *wim, int image)
 {
        struct wim_image_metadata *imd;
        int ret;
@@ -167,32 +167,32 @@ select_wim_image(WIMStruct *w, int image)
                return WIMLIB_ERR_INVALID_IMAGE;
        }
 
-       if (image == w->current_image)
+       if (image == wim->current_image)
                return 0;
 
-       if (image < 1 || image > w->hdr.image_count) {
+       if (image < 1 || image > wim->hdr.image_count) {
                ERROR("Cannot select image %d: There are only %u images",
-                     image, w->hdr.image_count);
+                     image, wim->hdr.image_count);
                return WIMLIB_ERR_INVALID_IMAGE;
        }
 
-       if (w->hdr.part_number != 1) {
+       if (wim->hdr.part_number != 1) {
                ERROR("Cannot select an image from a non-first part of a split WIM");
                return WIMLIB_ERR_SPLIT_UNSUPPORTED;
        }
 
        /* If a valid image is currently selected, it can be freed if it is not
         * modified.  */
-       if (w->current_image != WIMLIB_NO_IMAGE) {
-               imd = wim_get_current_image_metadata(w);
+       if (wim->current_image != WIMLIB_NO_IMAGE) {
+               imd = wim_get_current_image_metadata(wim);
                if (!imd->modified) {
                        wimlib_assert(list_empty(&imd->unhashed_streams));
-                       DEBUG("Freeing image %u", w->current_image);
+                       DEBUG("Freeing image %u", wim->current_image);
                        destroy_image_metadata(imd, NULL, false);
                }
        }
-       w->current_image = image;
-       imd = wim_get_current_image_metadata(w);
+       wim->current_image = image;
+       imd = wim_get_current_image_metadata(wim);
        if (imd->root_dentry || imd->modified) {
                ret = 0;
        } else {
@@ -201,9 +201,9 @@ select_wim_image(WIMStruct *w, int image)
                      "lookup table entry:");
                print_lookup_table_entry(imd->metadata_lte, stderr);
                #endif
-               ret = read_metadata_resource(w, imd);
+               ret = read_metadata_resource(wim, imd);
                if (ret)
-                       w->current_image = WIMLIB_NO_IMAGE;
+                       wim->current_image = WIMLIB_NO_IMAGE;
        }
        return ret;
 }
@@ -230,7 +230,7 @@ wimlib_get_compression_type_string(int ctype)
  * starting at 1.
  */
 WIMLIBAPI int
-wimlib_resolve_image(WIMStruct *w, const tchar *image_name_or_num)
+wimlib_resolve_image(WIMStruct *wim, const tchar *image_name_or_num)
 {
        tchar *p;
        long image;
@@ -244,13 +244,13 @@ wimlib_resolve_image(WIMStruct *w, const tchar *image_name_or_num)
                return WIMLIB_ALL_IMAGES;
        image = tstrtol(image_name_or_num, &p, 10);
        if (p != image_name_or_num && *p == T('\0') && image > 0) {
-               if (image > w->hdr.image_count)
+               if (image > wim->hdr.image_count)
                        return WIMLIB_NO_IMAGE;
                return image;
        } else {
-               for (i = 1; i <= w->hdr.image_count; i++) {
+               for (i = 1; i <= wim->hdr.image_count; i++) {
                        if (!tstrcmp(image_name_or_num,
-                                    wimlib_get_image_name(w, i)))
+                                    wimlib_get_image_name(wim, i)))
                                return i;
                }
                return WIMLIB_NO_IMAGE;
@@ -285,7 +285,7 @@ wimlib_print_wim_information(const WIMStruct *wim)
 }
 
 WIMLIBAPI void
-wimlib_print_available_images(const WIMStruct *w, int image)
+wimlib_print_available_images(const WIMStruct *wim, int image)
 {
        int first;
        int last;
@@ -294,8 +294,8 @@ wimlib_print_available_images(const WIMStruct *w, int image)
        if (image == WIMLIB_ALL_IMAGES) {
                n = tprintf(T("Available Images:\n"));
                first = 1;
-               last = w->hdr.image_count;
-       } else if (image >= 1 && image <= w->hdr.image_count) {
+               last = wim->hdr.image_count;
+       } else if (image >= 1 && image <= wim->hdr.image_count) {
                n = tprintf(T("Information for Image %d\n"), image);
                first = image;
                last = image;
@@ -308,34 +308,34 @@ wimlib_print_available_images(const WIMStruct *w, int image)
                tputchar(T('-'));
        tputchar(T('\n'));
        for (i = first; i <= last; i++)
-               print_image_info(w->wim_info, i);
+               print_image_info(wim->wim_info, i);
 }
 
 
 /* Prints the metadata for the specified image, which may be WIMLIB_ALL_IMAGES, but
  * not WIMLIB_NO_IMAGE. */
 WIMLIBAPI int
-wimlib_print_metadata(WIMStruct *w, int image)
+wimlib_print_metadata(WIMStruct *wim, int image)
 {
-       if (w->hdr.part_number != 1) {
+       if (wim->hdr.part_number != 1) {
                ERROR("Cannot show the metadata from part %hu of a %hu-part split WIM!",
-                      w->hdr.part_number, w->hdr.total_parts);
+                      wim->hdr.part_number, wim->hdr.total_parts);
                ERROR("Select the first part of the split WIM to see the metadata.");
                return WIMLIB_ERR_SPLIT_UNSUPPORTED;
        }
-       return for_image(w, image, image_print_metadata);
+       return for_image(wim, image, image_print_metadata);
 }
 
 WIMLIBAPI int
-wimlib_print_files(WIMStruct *w, int image)
+wimlib_print_files(WIMStruct *wim, int image)
 {
-       if (w->hdr.part_number != 1) {
+       if (wim->hdr.part_number != 1) {
                ERROR("Cannot list the files from part %hu of a %hu-part split WIM!",
-                      w->hdr.part_number, w->hdr.total_parts);
+                      wim->hdr.part_number, wim->hdr.total_parts);
                ERROR("Select the first part of the split WIM if you'd like to list the files.");
                return WIMLIB_ERR_SPLIT_UNSUPPORTED;
        }
-       return for_image(w, image, image_print_files);
+       return for_image(wim, image, image_print_files);
 }
 
 WIMLIBAPI int
@@ -487,18 +487,18 @@ do_open_wim(const tchar *filename, int *fd_ret)
 }
 
 int
-reopen_wim(WIMStruct *w)
+reopen_wim(WIMStruct *wim)
 {
-       wimlib_assert(w->in_fd == -1);
-       return do_open_wim(w->filename, &w->in_fd);
+       wimlib_assert(wim->in_fd == -1);
+       return do_open_wim(wim->filename, &wim->in_fd);
 }
 
 int
-close_wim(WIMStruct *w)
+close_wim(WIMStruct *wim)
 {
-       if (w->in_fd != -1) {
-               close(w->in_fd);
-               w->in_fd = -1;
+       if (wim->in_fd != -1) {
+               close(wim->in_fd);
+               wim->in_fd = -1;
        }
        return 0;
 }
@@ -508,7 +508,7 @@ close_wim(WIMStruct *w)
  * lookup table, and optionally checks the integrity.
  */
 static int
-begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
+begin_read(WIMStruct *wim, const tchar *in_wim_path, int open_flags,
           wimlib_progress_func_t progress_func)
 {
        int ret;
@@ -516,7 +516,7 @@ begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
 
        DEBUG("Reading the WIM file `%"TS"'", in_wim_path);
 
-       ret = do_open_wim(in_wim_path, &w->in_fd);
+       ret = do_open_wim(in_wim_path, &wim->in_fd);
        if (ret)
                return ret;
 
@@ -532,8 +532,8 @@ begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
         * Warning: in Windows native builds, realpath() calls the replacement
         * function in win32.c.
         */
-       w->filename = realpath(in_wim_path, NULL);
-       if (!w->filename) {
+       wim->filename = realpath(in_wim_path, NULL);
+       if (!wim->filename) {
                ERROR_WITH_ERRNO("Failed to resolve WIM filename");
                if (errno == ENOMEM)
                        return WIMLIB_ERR_NOMEM;
@@ -541,49 +541,49 @@ begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
                        return WIMLIB_ERR_OPEN;
        }
 
-       ret = read_header(w->filename, w->in_fd, &w->hdr);
+       ret = read_header(wim->filename, wim->in_fd, &wim->hdr);
        if (ret)
                return ret;
 
-       if (w->hdr.flags & WIM_HDR_FLAG_WRITE_IN_PROGRESS) {
+       if (wim->hdr.flags & WIM_HDR_FLAG_WRITE_IN_PROGRESS) {
                WARNING("The WIM_HDR_FLAG_WRITE_IN_PROGRESS is set in the header of \"%"TS"\".\n"
                        "          It may be being changed by another process, or a process\n"
                        "          may have crashed while writing the WIM.", in_wim_path);
        }
 
        if (open_flags & WIMLIB_OPEN_FLAG_WRITE_ACCESS) {
-               ret = can_modify_wim(w);
+               ret = can_modify_wim(wim);
                if (ret)
                        return ret;
        }
 
-       if (w->hdr.total_parts != 1 && !(open_flags & WIMLIB_OPEN_FLAG_SPLIT_OK)) {
+       if (wim->hdr.total_parts != 1 && !(open_flags & WIMLIB_OPEN_FLAG_SPLIT_OK)) {
                ERROR("\"%"TS"\": This WIM is part %u of a %u-part WIM",
-                     in_wim_path, w->hdr.part_number, w->hdr.total_parts);
+                     in_wim_path, wim->hdr.part_number, wim->hdr.total_parts);
                return WIMLIB_ERR_SPLIT_UNSUPPORTED;
        }
 
-       DEBUG("According to header, WIM contains %u images", w->hdr.image_count);
+       DEBUG("According to header, WIM contains %u images", wim->hdr.image_count);
 
        /* If the boot index is invalid, print a warning and set it to 0 */
-       if (w->hdr.boot_idx > w->hdr.image_count) {
+       if (wim->hdr.boot_idx > wim->hdr.image_count) {
                WARNING("In `%"TS"', image %u is marked as bootable, "
                        "but there are only %u images in the WIM",
-                       in_wim_path, w->hdr.boot_idx, w->hdr.image_count);
-               w->hdr.boot_idx = 0;
+                       in_wim_path, wim->hdr.boot_idx, wim->hdr.image_count);
+               wim->hdr.boot_idx = 0;
        }
 
        /* Check and cache the compression type */
-       if (w->hdr.flags & WIM_HDR_FLAG_COMPRESSION) {
-               if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZX) {
-                       if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
+       if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESSION) {
+               if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZX) {
+                       if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
                                ERROR("Multiple compression flags are set in \"%"TS"\"",
                                      in_wim_path);
                                return WIMLIB_ERR_INVALID_COMPRESSION_TYPE;
                        }
-                       w->compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
-               } else if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
-                       w->compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
+                       wim->compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
+               } else if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
+                       wim->compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
                } else {
                        ERROR("The compression flag is set on \"%"TS"\", but "
                              "neither the XPRESS nor LZX flag is set",
@@ -595,7 +595,7 @@ begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
        }
 
        if (open_flags & WIMLIB_OPEN_FLAG_CHECK_INTEGRITY) {
-               ret = check_wim_integrity(w, progress_func);
+               ret = check_wim_integrity(wim, progress_func);
                if (ret == WIM_INTEGRITY_NONEXISTENT) {
                        WARNING("No integrity information for `%"TS"'; skipping "
                                "integrity check.", in_wim_path);
@@ -607,26 +607,26 @@ begin_read(WIMStruct *w, const tchar *in_wim_path, int open_flags,
                }
        }
 
-       if (w->hdr.image_count != 0 && w->hdr.part_number == 1) {
-               w->image_metadata = new_image_metadata_array(w->hdr.image_count);
-               if (!w->image_metadata)
+       if (wim->hdr.image_count != 0 && wim->hdr.part_number == 1) {
+               wim->image_metadata = new_image_metadata_array(wim->hdr.image_count);
+               if (!wim->image_metadata)
                        return WIMLIB_ERR_NOMEM;
        }
 
-       ret = read_lookup_table(w);
+       ret = read_lookup_table(wim);
        if (ret)
                return ret;
 
-       ret = read_xml_data(w->in_fd, &w->hdr.xml_res_entry, &w->wim_info);
+       ret = read_xml_data(wim->in_fd, &wim->hdr.xml_res_entry, &wim->wim_info);
        if (ret)
                return ret;
 
-       xml_num_images = wim_info_get_num_images(w->wim_info);
-       if (xml_num_images != w->hdr.image_count) {
+       xml_num_images = wim_info_get_num_images(wim->wim_info);
+       if (xml_num_images != wim->hdr.image_count) {
                ERROR("In the file `%"TS"', there are %u <IMAGE> elements "
                      "in the XML data,", in_wim_path, xml_num_images);
                ERROR("but %u images in the WIM!  There must be exactly one "
-                     "<IMAGE> element per image.", w->hdr.image_count);
+                     "<IMAGE> element per image.", wim->hdr.image_count);
                return WIMLIB_ERR_IMAGE_COUNT;
        }
 
@@ -711,19 +711,19 @@ put_image_metadata(struct wim_image_metadata *imd,
 /* Appends the specified image metadata structure to the array of image metadata
  * for a WIM, and increments the image count. */
 int
-append_image_metadata(WIMStruct *w, struct wim_image_metadata *imd)
+append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd)
 {
        struct wim_image_metadata **imd_array;
 
        DEBUG("Reallocating image metadata array for image_count = %u",
-             w->hdr.image_count + 1);
-       imd_array = REALLOC(w->image_metadata,
-                           sizeof(w->image_metadata[0]) * (w->hdr.image_count + 1));
+             wim->hdr.image_count + 1);
+       imd_array = REALLOC(wim->image_metadata,
+                           sizeof(wim->image_metadata[0]) * (wim->hdr.image_count + 1));
 
        if (!imd_array)
                return WIMLIB_ERR_NOMEM;
-       w->image_metadata = imd_array;
-       imd_array[w->hdr.image_count++] = imd;
+       wim->image_metadata = imd_array;
+       imd_array[wim->hdr.image_count++] = imd;
        return 0;
 }
 
@@ -777,14 +777,14 @@ new_image_metadata_array(unsigned num_images)
  * library has previously used to add or mount an image using the same
  * WIMStruct. */
 int
-wim_checksum_unhashed_streams(WIMStruct *w)
+wim_checksum_unhashed_streams(WIMStruct *wim)
 {
        int ret;
-       for (int i = 0; i < w->hdr.image_count; i++) {
+       for (int i = 0; i < wim->hdr.image_count; i++) {
                struct wim_lookup_table_entry *lte, *tmp;
-               struct wim_image_metadata *imd = w->image_metadata[i];
+               struct wim_image_metadata *imd = wim->image_metadata[i];
                image_for_each_unhashed_stream_safe(lte, tmp, imd) {
-                       ret = hash_unhashed_stream(lte, w->lookup_table, NULL);
+                       ret = hash_unhashed_stream(lte, wim->lookup_table, NULL);
                        if (ret)
                                return ret;
                }
@@ -851,27 +851,27 @@ can_delete_from_wim(WIMStruct *wim)
 /* Frees the memory for the WIMStruct, including all internal memory; also
  * closes all files associated with the WIMStruct.  */
 WIMLIBAPI void
-wimlib_free(WIMStruct *w)
+wimlib_free(WIMStruct *wim)
 {
        DEBUG("Freeing WIMStruct");
 
-       if (!w)
+       if (!wim)
                return;
-       if (w->in_fd != -1)
-               close(w->in_fd);
-       if (w->out_fd != -1)
-               close(w->out_fd);
+       if (wim->in_fd != -1)
+               close(wim->in_fd);
+       if (wim->out_fd != -1)
+               close(wim->out_fd);
 
-       free_lookup_table(w->lookup_table);
+       free_lookup_table(wim->lookup_table);
 
-       FREE(w->filename);
-       free_wim_info(w->wim_info);
-       if (w->image_metadata) {
-               for (unsigned i = 0; i < w->hdr.image_count; i++)
-                       put_image_metadata(w->image_metadata[i], NULL);
-               FREE(w->image_metadata);
+       FREE(wim->filename);
+       free_wim_info(wim->wim_info);
+       if (wim->image_metadata) {
+               for (unsigned i = 0; i < wim->hdr.image_count; i++)
+                       put_image_metadata(wim->image_metadata[i], NULL);
+               FREE(wim->image_metadata);
        }
-       FREE(w);
+       FREE(wim);
        DEBUG("Freed WIMStruct");
 }
 
index 75193df..3a5ea57 100644 (file)
@@ -1639,15 +1639,15 @@ inode_find_streams_to_write(struct wim_inode *inode,
 }
 
 static int
-image_find_streams_to_write(WIMStruct *w)
+image_find_streams_to_write(WIMStruct *wim)
 {
        struct find_streams_ctx *ctx;
        struct wim_image_metadata *imd;
        struct wim_inode *inode;
        struct wim_lookup_table_entry *lte;
 
-       ctx = w->private;
-       imd = wim_get_current_image_metadata(w);
+       ctx = wim->private;
+       imd = wim_get_current_image_metadata(wim);
 
        image_for_each_unhashed_stream(lte, imd)
                lte->out_refcnt = 0;
@@ -1655,7 +1655,7 @@ image_find_streams_to_write(WIMStruct *w)
        /* Go through this image's inodes to find any streams that have not been
         * found yet. */
        image_for_each_inode(inode, imd) {
-               inode_find_streams_to_write(inode, w->lookup_table,
+               inode_find_streams_to_write(inode, wim->lookup_table,
                                            &ctx->stream_list,
                                            &ctx->stream_size_tab);
        }
@@ -1746,7 +1746,7 @@ write_wim_streams(WIMStruct *wim, int image, int write_flags,
  *
  */
 int
-finish_write(WIMStruct *w, int image, int write_flags,
+finish_write(WIMStruct *wim, int image, int write_flags,
             wimlib_progress_func_t progress_func)
 {
        int ret;
@@ -1756,7 +1756,7 @@ finish_write(WIMStruct *w, int image, int write_flags,
         * from the header in the WIMStruct; then set all the fields that may
         * have changed, including the resource entries, boot index, and image
         * count.  */
-       memcpy(&hdr, &w->hdr, sizeof(struct wim_header));
+       memcpy(&hdr, &wim->hdr, sizeof(struct wim_header));
 
        /* Set image count and boot index correctly for single image writes */
        if (image != WIMLIB_ALL_IMAGES) {
@@ -1776,19 +1776,19 @@ finish_write(WIMStruct *w, int image, int write_flags,
                zero_resource_entry(&hdr.boot_metadata_res_entry);
        } else {
                copy_resource_entry(&hdr.boot_metadata_res_entry,
-                           &w->image_metadata[ hdr.boot_idx- 1
+                           &wim->image_metadata[ hdr.boot_idx- 1
                                        ]->metadata_lte->output_resource_entry);
        }
 
        if (!(write_flags & WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE)) {
-               ret = write_lookup_table(w, image, &hdr.lookup_table_res_entry);
+               ret = write_lookup_table(wim, image, &hdr.lookup_table_res_entry);
                if (ret)
                        goto out_close_wim;
        }
 
-       ret = write_xml_data(w->wim_info, image, w->out_fd,
+       ret = write_xml_data(wim->wim_info, image, wim->out_fd,
                             (write_flags & WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE) ?
-                             wim_info_get_total_bytes(w->wim_info) : 0,
+                             wim_info_get_total_bytes(wim->wim_info) : 0,
                             &hdr.xml_res_entry);
        if (ret)
                goto out_close_wim;
@@ -1799,7 +1799,7 @@ finish_write(WIMStruct *w, int image, int write_flags,
                        memcpy(&checkpoint_hdr, &hdr, sizeof(struct wim_header));
                        zero_resource_entry(&checkpoint_hdr.integrity);
                        checkpoint_hdr.flags |= WIM_HDR_FLAG_WRITE_IN_PROGRESS;
-                       ret = write_header(&checkpoint_hdr, w->out_fd);
+                       ret = write_header(&checkpoint_hdr, wim->out_fd);
                        if (ret)
                                goto out_close_wim;
                }
@@ -1807,15 +1807,15 @@ finish_write(WIMStruct *w, int image, int write_flags,
                off_t old_lookup_table_end;
                off_t new_lookup_table_end;
                if (write_flags & WIMLIB_WRITE_FLAG_REUSE_INTEGRITY_TABLE) {
-                       old_lookup_table_end = w->hdr.lookup_table_res_entry.offset +
-                                              w->hdr.lookup_table_res_entry.size;
+                       old_lookup_table_end = wim->hdr.lookup_table_res_entry.offset +
+                                              wim->hdr.lookup_table_res_entry.size;
                } else {
                        old_lookup_table_end = 0;
                }
                new_lookup_table_end = hdr.lookup_table_res_entry.offset +
                                       hdr.lookup_table_res_entry.size;
 
-               ret = write_integrity_table(w->out_fd,
+               ret = write_integrity_table(wim->out_fd,
                                            &hdr.integrity,
                                            new_lookup_table_end,
                                            old_lookup_table_end,
@@ -1827,46 +1827,46 @@ finish_write(WIMStruct *w, int image, int write_flags,
        }
 
        hdr.flags &= ~WIM_HDR_FLAG_WRITE_IN_PROGRESS;
-       ret = write_header(&hdr, w->out_fd);
+       ret = write_header(&hdr, wim->out_fd);
        if (ret)
                goto out_close_wim;
 
        if (write_flags & WIMLIB_WRITE_FLAG_FSYNC) {
-               if (fsync(w->out_fd)) {
+               if (fsync(wim->out_fd)) {
                        ERROR_WITH_ERRNO("Error syncing data to WIM file");
                        ret = WIMLIB_ERR_WRITE;
                }
        }
 out_close_wim:
-       if (close(w->out_fd)) {
+       if (close(wim->out_fd)) {
                ERROR_WITH_ERRNO("Failed to close the output WIM file");
                if (ret == 0)
                        ret = WIMLIB_ERR_WRITE;
        }
-       w->out_fd = -1;
+       wim->out_fd = -1;
        return ret;
 }
 
 #if defined(HAVE_SYS_FILE_H) && defined(HAVE_FLOCK)
 int
-lock_wim(WIMStruct *w, int fd)
+lock_wim(WIMStruct *wim, int fd)
 {
        int ret = 0;
-       if (fd != -1 && !w->wim_locked) {
+       if (fd != -1 && !wim->wim_locked) {
                ret = flock(fd, LOCK_EX | LOCK_NB);
                if (ret != 0) {
                        if (errno == EWOULDBLOCK) {
                                ERROR("`%"TS"' is already being modified or has been "
                                      "mounted read-write\n"
-                                     "        by another process!", w->filename);
+                                     "        by another process!", wim->filename);
                                ret = WIMLIB_ERR_ALREADY_LOCKED;
                        } else {
                                WARNING_WITH_ERRNO("Failed to lock `%"TS"'",
-                                                  w->filename);
+                                                  wim->filename);
                                ret = 0;
                        }
                } else {
-                       w->wim_locked = 1;
+                       wim->wim_locked = 1;
                }
        }
        return ret;
@@ -1874,10 +1874,10 @@ lock_wim(WIMStruct *w, int fd)
 #endif
 
 static int
-open_wim_writable(WIMStruct *w, const tchar *path, int open_flags)
+open_wim_writable(WIMStruct *wim, const tchar *path, int open_flags)
 {
-       w->out_fd = topen(path, open_flags | O_BINARY, 0644);
-       if (w->out_fd == -1) {
+       wim->out_fd = topen(path, open_flags | O_BINARY, 0644);
+       if (wim->out_fd == -1) {
                ERROR_WITH_ERRNO("Failed to open `%"TS"' for writing", path);
                return WIMLIB_ERR_OPEN;
        }
@@ -1886,18 +1886,18 @@ open_wim_writable(WIMStruct *w, const tchar *path, int open_flags)
 
 
 void
-close_wim_writable(WIMStruct *w)
+close_wim_writable(WIMStruct *wim)
 {
-       if (w->out_fd != -1) {
-               if (close(w->out_fd))
+       if (wim->out_fd != -1) {
+               if (close(wim->out_fd))
                        WARNING_WITH_ERRNO("Failed to close output WIM");
-               w->out_fd = -1;
+               wim->out_fd = -1;
        }
 }
 
 /* Open file stream and write dummy header for WIM. */
 int
-begin_write(WIMStruct *w, const tchar *path, int write_flags)
+begin_write(WIMStruct *wim, const tchar *path, int write_flags)
 {
        int ret;
        int open_flags = O_TRUNC | O_CREAT;
@@ -1905,16 +1905,16 @@ begin_write(WIMStruct *w, const tchar *path, int write_flags)
                open_flags |= O_RDWR;
        else
                open_flags |= O_WRONLY;
-       ret = open_wim_writable(w, path, open_flags);
+       ret = open_wim_writable(wim, path, open_flags);
        if (ret)
                return ret;
        /* Write dummy header. It will be overwritten later. */
-       w->hdr.flags |= WIM_HDR_FLAG_WRITE_IN_PROGRESS;
-       ret = write_header(&w->hdr, w->out_fd);
-       w->hdr.flags &= ~WIM_HDR_FLAG_WRITE_IN_PROGRESS;
+       wim->hdr.flags |= WIM_HDR_FLAG_WRITE_IN_PROGRESS;
+       ret = write_header(&wim->hdr, wim->out_fd);
+       wim->hdr.flags &= ~WIM_HDR_FLAG_WRITE_IN_PROGRESS;
        if (ret)
                return ret;
-       if (lseek(w->out_fd, WIM_HEADER_DISK_SIZE, SEEK_SET) == -1) {
+       if (lseek(wim->out_fd, WIM_HEADER_DISK_SIZE, SEEK_SET) == -1) {
                ERROR_WITH_ERRNO("Failed to seek to end of WIM header");
                return WIMLIB_ERR_WRITE;
        }
@@ -1923,7 +1923,7 @@ begin_write(WIMStruct *w, const tchar *path, int write_flags)
 
 /* Writes a stand-alone WIM to a file.  */
 WIMLIBAPI int
-wimlib_write(WIMStruct *w, const tchar *path,
+wimlib_write(WIMStruct *wim, const tchar *path,
             int image, int write_flags, unsigned num_threads,
             wimlib_progress_func_t progress_func)
 {
@@ -1935,19 +1935,19 @@ wimlib_write(WIMStruct *w, const tchar *path,
        write_flags &= WIMLIB_WRITE_MASK_PUBLIC;
 
        if (image != WIMLIB_ALL_IMAGES &&
-            (image < 1 || image > w->hdr.image_count))
+            (image < 1 || image > wim->hdr.image_count))
                return WIMLIB_ERR_INVALID_IMAGE;
 
-       if (w->hdr.total_parts != 1) {
+       if (wim->hdr.total_parts != 1) {
                ERROR("Cannot call wimlib_write() on part of a split WIM");
                return WIMLIB_ERR_SPLIT_UNSUPPORTED;
        }
 
-       ret = begin_write(w, path, write_flags);
+       ret = begin_write(wim, path, write_flags);
        if (ret)
                goto out_close_wim;
 
-       ret = write_wim_streams(w, image, write_flags, num_threads,
+       ret = write_wim_streams(wim, image, write_flags, num_threads,
                                progress_func);
        if (ret)
                goto out_close_wim;
@@ -1955,28 +1955,28 @@ wimlib_write(WIMStruct *w, const tchar *path,
        if (progress_func)
                progress_func(WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, NULL);
 
-       ret = for_image(w, image, write_metadata_resource);
+       ret = for_image(wim, image, write_metadata_resource);
        if (ret)
                goto out_close_wim;
 
        if (progress_func)
                progress_func(WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, NULL);
 
-       ret = finish_write(w, image, write_flags, progress_func);
+       ret = finish_write(wim, image, write_flags, progress_func);
        /* finish_write() closed the WIM for us */
        goto out;
 out_close_wim:
-       close_wim_writable(w);
+       close_wim_writable(wim);
 out:
        DEBUG("wimlib_write(path=%"TS") = %d", path, ret);
        return ret;
 }
 
 static bool
-any_images_modified(WIMStruct *w)
+any_images_modified(WIMStruct *wim)
 {
-       for (int i = 0; i < w->hdr.image_count; i++)
-               if (w->image_metadata[i]->modified)
+       for (int i = 0; i < wim->hdr.image_count; i++)
+               if (wim->image_metadata[i]->modified)
                        return true;
        return false;
 }
@@ -2039,7 +2039,7 @@ any_images_modified(WIMStruct *w)
  * small amount of space compared to the streams, however.)
  */
 static int
-overwrite_wim_inplace(WIMStruct *w, int write_flags,
+overwrite_wim_inplace(WIMStruct *wim, int write_flags,
                      unsigned num_threads,
                      wimlib_progress_func_t progress_func)
 {
@@ -2049,17 +2049,17 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags,
        u64 old_lookup_table_end, old_xml_begin, old_xml_end;
        int open_flags;
 
-       DEBUG("Overwriting `%"TS"' in-place", w->filename);
+       DEBUG("Overwriting `%"TS"' in-place", wim->filename);
 
        /* Make sure that the integrity table (if present) is after the XML
         * data, and that there are no stream resources, metadata resources, or
         * lookup tables after the XML data.  Otherwise, these data would be
         * overwritten. */
-       old_xml_begin = w->hdr.xml_res_entry.offset;
-       old_xml_end = old_xml_begin + w->hdr.xml_res_entry.size;
-       old_lookup_table_end = w->hdr.lookup_table_res_entry.offset +
-                              w->hdr.lookup_table_res_entry.size;
-       if (w->hdr.integrity.offset != 0 && w->hdr.integrity.offset < old_xml_end) {
+       old_xml_begin = wim->hdr.xml_res_entry.offset;
+       old_xml_end = old_xml_begin + wim->hdr.xml_res_entry.size;
+       old_lookup_table_end = wim->hdr.lookup_table_res_entry.offset +
+                              wim->hdr.lookup_table_res_entry.size;
+       if (wim->hdr.integrity.offset != 0 && wim->hdr.integrity.offset < old_xml_end) {
                ERROR("Didn't expect the integrity table to be before the XML data");
                return WIMLIB_ERR_RESOURCE_ORDER;
        }
@@ -2073,7 +2073,7 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags,
         * allow any file and metadata resources to appear without returning
         * WIMLIB_ERR_RESOURCE_ORDER (due to the fact that we would otherwise
         * overwrite these resources). */
-       if (!w->deletion_occurred && !any_images_modified(w)) {
+       if (!wim->deletion_occurred && !any_images_modified(wim)) {
                /* If no images have been modified and no images have been
                 * deleted, a new lookup table does not need to be written.  We
                 * shall write the new XML data and optional integrity table
@@ -2084,17 +2084,17 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags,
                old_wim_end = old_lookup_table_end;
                write_flags |= WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE |
                               WIMLIB_WRITE_FLAG_CHECKPOINT_AFTER_XML;
-       } else if (w->hdr.integrity.offset) {
+       } else if (wim->hdr.integrity.offset) {
                /* Old WIM has an integrity table; begin writing new streams
                 * after it. */
-               old_wim_end = w->hdr.integrity.offset + w->hdr.integrity.size;
+               old_wim_end = wim->hdr.integrity.offset + wim->hdr.integrity.size;
        } else {
                /* No existing integrity table; begin writing new streams after
                 * the old XML data. */
                old_wim_end = old_xml_end;
        }
 
-       ret = prepare_streams_for_overwrite(w, old_wim_end, &stream_list);
+       ret = prepare_streams_for_overwrite(wim, old_wim_end, &stream_list);
        if (ret)
                return ret;
 
@@ -2103,28 +2103,28 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags,
                open_flags |= O_RDWR;
        else
                open_flags |= O_WRONLY;
-       ret = open_wim_writable(w, w->filename, open_flags);
+       ret = open_wim_writable(wim, wim->filename, open_flags);
        if (ret)
                return ret;
 
-       ret = lock_wim(w, w->out_fd);
+       ret = lock_wim(wim, wim->out_fd);
        if (ret) {
-               close_wim_writable(w);
+               close_wim_writable(wim);
                return ret;
        }
 
        /* Set WIM_HDR_FLAG_WRITE_IN_PROGRESS flag in header. */
-       ret = write_header_flags(w->hdr.flags | WIM_HDR_FLAG_WRITE_IN_PROGRESS,
-                                w->out_fd);
+       ret = write_header_flags(wim->hdr.flags | WIM_HDR_FLAG_WRITE_IN_PROGRESS,
+                                wim->out_fd);
        if (ret) {
                ERROR_WITH_ERRNO("Error updating WIM header flags");
-               close_wim_writable(w);
+               close_wim_writable(wim);
                goto out_unlock_wim;
        }
 
-       if (lseek(w->out_fd, old_wim_end, SEEK_SET) == -1) {
+       if (lseek(wim->out_fd, old_wim_end, SEEK_SET) == -1) {
                ERROR_WITH_ERRNO("Can't seek to end of WIM");
-               close_wim_writable(w);
+               close_wim_writable(wim);
                ret = WIMLIB_ERR_WRITE;
                goto out_unlock_wim;
        }
@@ -2132,59 +2132,59 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags,
        DEBUG("Writing newly added streams (offset = %"PRIu64")",
              old_wim_end);
        ret = write_stream_list(&stream_list,
-                               w->lookup_table,
-                               w->out_fd,
-                               w->compression_type,
+                               wim->lookup_table,
+                               wim->out_fd,
+                               wim->compression_type,
                                write_flags,
                                num_threads,
                                progress_func);
        if (ret)
                goto out_truncate;
 
-       for (int i = 0; i < w->hdr.image_count; i++) {
-               if (w->image_metadata[i]->modified) {
-                       select_wim_image(w, i + 1);
-                       ret = write_metadata_resource(w);
+       for (int i = 0; i < wim->hdr.image_count; i++) {
+               if (wim->image_metadata[i]->modified) {
+                       select_wim_image(wim, i + 1);
+                       ret = write_metadata_resource(wim);
                        if (ret)
                                goto out_truncate;
                }
        }
        write_flags |= WIMLIB_WRITE_FLAG_REUSE_INTEGRITY_TABLE;
-       ret = finish_write(w, WIMLIB_ALL_IMAGES, write_flags,
+       ret = finish_write(wim, WIMLIB_ALL_IMAGES, write_flags,
                           progress_func);
 out_truncate:
-       close_wim_writable(w);
+       close_wim_writable(wim);
        if (ret != 0 && !(write_flags & WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE)) {
                WARNING("Truncating `%"TS"' to its original size (%"PRIu64" bytes)",
-                       w->filename, old_wim_end);
+                       wim->filename, old_wim_end);
                /* Return value of truncate() is ignored because this is already
                 * an error path. */
-               (void)ttruncate(w->filename, old_wim_end);
+               (void)ttruncate(wim->filename, old_wim_end);
        }
 out_unlock_wim:
-       w->wim_locked = 0;
+       wim->wim_locked = 0;
        return ret;
 }
 
 static int
-overwrite_wim_via_tmpfile(WIMStruct *w, int write_flags,
+overwrite_wim_via_tmpfile(WIMStruct *wim, int write_flags,
                          unsigned num_threads,
                          wimlib_progress_func_t progress_func)
 {
        size_t wim_name_len;
        int ret;
 
-       DEBUG("Overwriting `%"TS"' via a temporary file", w->filename);
+       DEBUG("Overwriting `%"TS"' via a temporary file", wim->filename);
 
        /* Write the WIM to a temporary file in the same directory as the
         * original WIM. */
-       wim_name_len = tstrlen(w->filename);
+       wim_name_len = tstrlen(wim->filename);
        tchar tmpfile[wim_name_len + 10];
-       tmemcpy(tmpfile, w->filename, wim_name_len);
+       tmemcpy(tmpfile, wim->filename, wim_name_len);
        randomize_char_array_with_alnum(tmpfile + wim_name_len, 9);
        tmpfile[wim_name_len + 9] = T('\0');
 
-       ret = wimlib_write(w, tmpfile, WIMLIB_ALL_IMAGES,
+       ret = wimlib_write(wim, tmpfile, WIMLIB_ALL_IMAGES,
                           write_flags | WIMLIB_WRITE_FLAG_FSYNC,
                           num_threads, progress_func);
        if (ret) {
@@ -2192,13 +2192,13 @@ overwrite_wim_via_tmpfile(WIMStruct *w, int write_flags,
                goto out_unlink;
        }
 
-       close_wim(w);
+       close_wim(wim);
 
-       DEBUG("Renaming `%"TS"' to `%"TS"'", tmpfile, w->filename);
+       DEBUG("Renaming `%"TS"' to `%"TS"'", tmpfile, wim->filename);
        /* Rename the new file to the old file .*/
-       if (trename(tmpfile, w->filename) != 0) {
+       if (trename(tmpfile, wim->filename) != 0) {
                ERROR_WITH_ERRNO("Failed to rename `%"TS"' to `%"TS"'",
-                                tmpfile, w->filename);
+                                tmpfile, wim->filename);
                ret = WIMLIB_ERR_RENAME;
                goto out_unlink;
        }
@@ -2206,7 +2206,7 @@ overwrite_wim_via_tmpfile(WIMStruct *w, int write_flags,
        if (progress_func) {
                union wimlib_progress_info progress;
                progress.rename.from = tmpfile;
-               progress.rename.to = w->filename;
+               progress.rename.to = wim->filename;
                progress_func(WIMLIB_PROGRESS_MSG_RENAME, &progress);
        }
        goto out;
@@ -2222,7 +2222,7 @@ out:
  * Writes a WIM file to the original file that it was read from, overwriting it.
  */
 WIMLIBAPI int
-wimlib_overwrite(WIMStruct *w, int write_flags,
+wimlib_overwrite(WIMStruct *wim, int write_flags,
                 unsigned num_threads,
                 wimlib_progress_func_t progress_func)
 {
@@ -2231,28 +2231,28 @@ wimlib_overwrite(WIMStruct *w, int write_flags,
 
        write_flags &= WIMLIB_WRITE_MASK_PUBLIC;
 
-       if (!w->filename)
+       if (!wim->filename)
                return WIMLIB_ERR_NO_FILENAME;
 
-       orig_hdr_flags = w->hdr.flags;
+       orig_hdr_flags = wim->hdr.flags;
        if (write_flags & WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG)
-               w->hdr.flags &= ~WIM_HDR_FLAG_READONLY;
-       ret = can_modify_wim(w);
-       w->hdr.flags = orig_hdr_flags;
+               wim->hdr.flags &= ~WIM_HDR_FLAG_READONLY;
+       ret = can_modify_wim(wim);
+       wim->hdr.flags = orig_hdr_flags;
        if (ret)
                return ret;
 
-       if ((!w->deletion_occurred || (write_flags & WIMLIB_WRITE_FLAG_SOFT_DELETE))
+       if ((!wim->deletion_occurred || (write_flags & WIMLIB_WRITE_FLAG_SOFT_DELETE))
            && !(write_flags & WIMLIB_WRITE_FLAG_REBUILD))
        {
                int ret;
-               ret = overwrite_wim_inplace(w, write_flags, num_threads,
+               ret = overwrite_wim_inplace(wim, write_flags, num_threads,
                                            progress_func);
                if (ret == WIMLIB_ERR_RESOURCE_ORDER)
                        WARNING("Falling back to re-building entire WIM");
                else
                        return ret;
        }
-       return overwrite_wim_via_tmpfile(w, write_flags, num_threads,
+       return overwrite_wim_via_tmpfile(wim, write_flags, num_threads,
                                         progress_func);
 }
index 6adba78..db0b3b4 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -1014,12 +1014,12 @@ xml_delete_image(struct wim_info **wim_info_p, int image)
 }
 
 size_t
-xml_get_max_image_name_len(const WIMStruct *w)
+xml_get_max_image_name_len(const WIMStruct *wim)
 {
        size_t max_len = 0;
-       if (w->wim_info) {
-               for (int i = 0; i < w->wim_info->num_images; i++) {
-                       size_t len = tstrlen(w->wim_info->images[i].name);
+       if (wim->wim_info) {
+               for (int i = 0; i < wim->wim_info->num_images; i++) {
+                       size_t len = tstrlen(wim->wim_info->images[i].name);
                        if (len > max_len)
                                max_len = len;
                }
@@ -1116,21 +1116,21 @@ calculate_dentry_statistics(struct wim_dentry *dentry, void *arg)
  * But, see calculate_dentry_statistics().
  */
 void
-xml_update_image_info(WIMStruct *w, int image)
+xml_update_image_info(WIMStruct *wim, int image)
 {
        struct image_info *image_info;
 
        DEBUG("Updating the image info for image %d", image);
 
-       image_info = &w->wim_info->images[image - 1];
+       image_info = &wim->wim_info->images[image - 1];
 
        image_info->file_count      = 0;
        image_info->dir_count       = 0;
        image_info->total_bytes     = 0;
        image_info->hard_link_bytes = 0;
-       image_info->lookup_table = w->lookup_table;
+       image_info->lookup_table = wim->lookup_table;
 
-       for_dentry_in_tree(w->image_metadata[image - 1]->root_dentry,
+       for_dentry_in_tree(wim->image_metadata[image - 1]->root_dentry,
                           calculate_dentry_statistics,
                           image_info);
        image_info->last_modification_time = get_wim_timestamp();
@@ -1138,7 +1138,7 @@ xml_update_image_info(WIMStruct *w, int image)
 
 /* Adds an image to the XML information. */
 int
-xml_add_image(WIMStruct *w, const tchar *name)
+xml_add_image(WIMStruct *wim, const tchar *name)
 {
        struct wim_info *wim_info;
        struct image_info *image_info;
@@ -1147,8 +1147,8 @@ xml_add_image(WIMStruct *w, const tchar *name)
 
        /* If this is the first image, allocate the struct wim_info.  Otherwise
         * use the existing struct wim_info. */
-       if (w->wim_info) {
-               wim_info = w->wim_info;
+       if (wim->wim_info) {
+               wim_info = wim->wim_info;
        } else {
                wim_info = CALLOC(1, sizeof(struct wim_info));
                if (!wim_info)
@@ -1162,17 +1162,17 @@ xml_add_image(WIMStruct *w, const tchar *name)
        if (!(image_info->name = TSTRDUP(name)))
                goto out_destroy_image_info;
 
-       w->wim_info = wim_info;
+       wim->wim_info = wim_info;
        image_info->index = wim_info->num_images;
        image_info->creation_time = get_wim_timestamp();
-       xml_update_image_info(w, image_info->index);
+       xml_update_image_info(wim, image_info->index);
        return 0;
 
 out_destroy_image_info:
        destroy_image_info(image_info);
        wim_info->num_images--;
 out_free_wim_info:
-       if (wim_info != w->wim_info)
+       if (wim_info != wim->wim_info)
                FREE(wim_info);
        return WIMLIB_ERR_NOMEM;
 }
@@ -1469,30 +1469,30 @@ out_write_error:
 
 /* Returns the name of the specified image. */
 WIMLIBAPI const tchar *
-wimlib_get_image_name(const WIMStruct *w, int image)
+wimlib_get_image_name(const WIMStruct *wim, int image)
 {
-       if (image < 1 || image > w->hdr.image_count)
+       if (image < 1 || image > wim->hdr.image_count)
                return NULL;
-       return w->wim_info->images[image - 1].name;
+       return wim->wim_info->images[image - 1].name;
 }
 
 /* Returns the description of the specified image. */
 WIMLIBAPI const tchar *
-wimlib_get_image_description(const WIMStruct *w, int image)
+wimlib_get_image_description(const WIMStruct *wim, int image)
 {
-       if (image < 1 || image > w->hdr.image_count)
+       if (image < 1 || image > wim->hdr.image_count)
                return NULL;
-       return w->wim_info->images[image - 1].description;
+       return wim->wim_info->images[image - 1].description;
 }
 
 /* Determines if an image name is already used by some image in the WIM. */
 WIMLIBAPI bool
-wimlib_image_name_in_use(const WIMStruct *w, const tchar *name)
+wimlib_image_name_in_use(const WIMStruct *wim, const tchar *name)
 {
        if (!name || !*name)
                return false;
-       for (int i = 1; i <= w->hdr.image_count; i++)
-               if (!tstrcmp(w->wim_info->images[i - 1].name, name))
+       for (int i = 1; i <= wim->hdr.image_count; i++)
+               if (!tstrcmp(wim->wim_info->images[i - 1].name, name))
                        return true;
        return false;
 }
@@ -1500,25 +1500,25 @@ wimlib_image_name_in_use(const WIMStruct *w, const tchar *name)
 
 /* Extracts the raw XML data to a file stream. */
 WIMLIBAPI int
-wimlib_extract_xml_data(WIMStruct *w, FILE *fp)
+wimlib_extract_xml_data(WIMStruct *wim, FILE *fp)
 {
        size_t size;
        void *buf;
        int ret;
 
-       size = w->hdr.xml_res_entry.size;
+       size = wim->hdr.xml_res_entry.size;
        if (sizeof(size_t) < sizeof(u64))
-               if (size != w->hdr.xml_res_entry.size)
+               if (size != wim->hdr.xml_res_entry.size)
                        return WIMLIB_ERR_INVALID_PARAM;
 
        buf = MALLOC(size);
        if (!buf)
                return WIMLIB_ERR_NOMEM;
 
-       if (full_pread(w->in_fd,
+       if (full_pread(wim->in_fd,
                       buf,
-                      w->hdr.xml_res_entry.size,
-                      w->hdr.xml_res_entry.offset) != w->hdr.xml_res_entry.size)
+                      wim->hdr.xml_res_entry.size,
+                      wim->hdr.xml_res_entry.offset) != wim->hdr.xml_res_entry.size)
        {
                ERROR_WITH_ERRNO("Error reading XML data");
                ret = WIMLIB_ERR_READ;
@@ -1538,7 +1538,7 @@ out_free_buf:
 
 /* Sets the name of an image in the WIM. */
 WIMLIBAPI int
-wimlib_set_image_name(WIMStruct *w, int image, const tchar *name)
+wimlib_set_image_name(WIMStruct *wim, int image, const tchar *name)
 {
        tchar *p;
        int i;
@@ -1546,22 +1546,22 @@ wimlib_set_image_name(WIMStruct *w, int image, const tchar *name)
 
        DEBUG("Setting the name of image %d to %"TS, image, name);
 
-       ret = can_modify_wim(w);
+       ret = can_modify_wim(wim);
        if (ret)
                return ret;
 
        if (name == NULL)
                name = T("");
 
-       if (image < 1 || image > w->hdr.image_count) {
+       if (image < 1 || image > wim->hdr.image_count) {
                ERROR("%d is not a valid image", image);
                return WIMLIB_ERR_INVALID_IMAGE;
        }
 
-       for (i = 1; i <= w->hdr.image_count; i++) {
+       for (i = 1; i <= wim->hdr.image_count; i++) {
                if (i == image)
                        continue;
-               if (!tstrcmp(w->wim_info->images[i - 1].name, name)) {
+               if (!tstrcmp(wim->wim_info->images[i - 1].name, name)) {
                        ERROR("The name \"%"TS"\" is already in use in the WIM!",
                              name);
                        return WIMLIB_ERR_IMAGE_NAME_COLLISION;
@@ -1572,24 +1572,24 @@ wimlib_set_image_name(WIMStruct *w, int image, const tchar *name)
        if (!p)
                return WIMLIB_ERR_NOMEM;
 
-       FREE(w->wim_info->images[image - 1].name);
-       w->wim_info->images[image - 1].name = p;
+       FREE(wim->wim_info->images[image - 1].name);
+       wim->wim_info->images[image - 1].name = p;
        return 0;
 }
 
 static int
-do_set_image_info_str(WIMStruct *w, int image, const tchar *tstr,
+do_set_image_info_str(WIMStruct *wim, int image, const tchar *tstr,
                      size_t offset)
 {
        tchar *tstr_copy;
        tchar **dest_tstr_p;
        int ret;
 
-       ret = can_modify_wim(w);
+       ret = can_modify_wim(wim);
        if (ret)
                return ret;
 
-       if (image < 1 || image > w->hdr.image_count) {
+       if (image < 1 || image > wim->hdr.image_count) {
                ERROR("%d is not a valid image", image);
                return WIMLIB_ERR_INVALID_IMAGE;
        }
@@ -1600,7 +1600,7 @@ do_set_image_info_str(WIMStruct *w, int image, const tchar *tstr,
        } else {
                tstr_copy = NULL;
        }
-       dest_tstr_p = (tchar**)((void*)&w->wim_info->images[image - 1] + offset);
+       dest_tstr_p = (tchar**)((void*)&wim->wim_info->images[image - 1] + offset);
 
        FREE(*dest_tstr_p);
        *dest_tstr_p = tstr_copy;
@@ -1609,17 +1609,17 @@ do_set_image_info_str(WIMStruct *w, int image, const tchar *tstr,
 
 /* Sets the description of an image in the WIM. */
 WIMLIBAPI int
-wimlib_set_image_descripton(WIMStruct *w, int image,
+wimlib_set_image_descripton(WIMStruct *wim, int image,
                            const tchar *description)
 {
-       return do_set_image_info_str(w, image, description,
+       return do_set_image_info_str(wim, image, description,
                                     offsetof(struct image_info, description));
 }
 
 /* Set the <FLAGS> element of a WIM image */
 WIMLIBAPI int
-wimlib_set_image_flags(WIMStruct *w, int image, const tchar *flags)
+wimlib_set_image_flags(WIMStruct *wim, int image, const tchar *flags)
 {
-       return do_set_image_info_str(w, image, flags,
+       return do_set_image_info_str(wim, image, flags,
                                     offsetof(struct image_info, flags));
 }