WIM_INTEGRITY_NONEXISTENT,
};
-
-#define RINOK(expr) do { \
- int __ret = (expr); \
- if (__ret != 0) \
- return __ret; \
-} while (0)
-
/* Metadata for a resource in a WIM file. */
struct resource_entry {
/* Size, in bytes, of the resource in the WIM file. */
u8 guid[WIM_GID_LEN];
/* Part number of the WIM file in a spanned set. */
- //u16 part_number;
+ u16 part_number;
/* Total number of parts in a spanned set. */
- //u16 total_parts;
+ u16 total_parts;
/* Number of images in the WIM file. */
u32 image_count;
#define WIM_HDR_FLAG_COMPRESS_LZX 0x00040000
-#if 0
+#ifdef ENABLE_SECURITY_DATA
/* Structure for security data. Each image in the WIM file has its own security
* data. */
-typedef struct WIMSecurityData {
+struct wim_security_data {
/* The total length of the security data, in bytes. A typical size is
* 2048 bytes. If there is no security data, though (as in the WIMs
* that wimlib writes, currently), it will be 8 bytes. */
/* Array of descriptors. */
u8 **descriptors;
+
+ /* keep track of how many WIMs reference this security data (used when
+ * exporting images between WIMs) */
+ u32 refcnt;
} WIMSecurityData;
#endif
/* Metadata resource for an image. */
struct image_metadata {
+ /* Pointer to the root dentry for the image. */
+ struct dentry *root_dentry;
-#if 0
- /* The security data for the image. */
- WIMSecurityData security_data;
+#ifdef ENABLE_SECURITY_DATA
+ /* Pointer to the security data for the image. */
+ struct wim_security_data *security_data;
#endif
-
- /* The root dentry for the image. */
- struct dentry *root_dentry;
+ /* A pointer to the lookup table entry for this image's metadata
+ * resource. */
+ struct lookup_table_entry *lookup_table_entry;
/* True if the filesystem of the image has been modified. If this is
* the case, the memory for the filesystem is not freed when switching
* to a different WIM image. */
bool modified;
- /* A pointer to the lookup table entry for this image's metadata
- * resource. */
- struct lookup_table_entry *lookup_table_entry;
};
/* The opaque structure exposed to the wimlib API. */
typedef struct WIMStruct {
- /* The name of the WIM file that has been opened. */
- char *filename;
/* A pointer to the file indicated by @filename, opened for reading. */
FILE *fp;
- /* The currently selected image, indexed starting at 1. If not 0,
- * subtract 1 from this to get the index of the current image in the
- * image_metadata array. */
- int current_image;
+ /* FILE pointer for the WIM file that is being written. */
+ FILE *out_fp;
+
+ /* The name of the WIM file that has been opened. */
+ char *filename;
/* The lookup table for the WIM file. */
struct lookup_table *lookup_table;
- /* The header of the WIM file. */
- struct wim_header hdr;
-
/* Pointer to the XML data read from the WIM file. */
u8 *xml_data;
* WIM has a image metadata associated with it. */
struct image_metadata *image_metadata;
- /* True if files names are to be printed when doing extraction.
- * May be used for other things later. */
- bool verbose;
+ /* Name of the output directory for extraction. */
+ char *output_dir;
+
+ /* The header of the WIM file. */
+ struct wim_header hdr;
/* The type of links to create when extracting files (hard, symbolic, or
* none.) */
int link_type;
- /* Name of the output directory for extraction. */
- char *output_dir;
+ /* The currently selected image, indexed starting at 1. If not 0,
+ * subtract 1 from this to get the index of the current image in the
+ * image_metadata array. */
+ int current_image;
- /* Set to true when extracting multiple images */
- bool is_multi_image_extraction;
+ /* True if files names are to be printed when doing extraction.
+ * May be used for other things later. */
+ bool verbose;
- /* FILE pointer for the WIM file that is being written. */
- FILE *out_fp;
+ union {
+ /* Set to true when extracting multiple images */
+ bool is_multi_image_extraction;
+
+ bool write_metadata;
+ };
} WIMStruct;
return &w->image_metadata[w->current_image - 1].root_dentry;
}
-#if 0
-static inline WIMSecurityData *wim_security_data(WIMStruct *w)
+#ifdef ENABLE_SECURITY_DATA
+static inline struct wim_security_data *wim_security_data(WIMStruct *w)
{
- return &w->image_metadata[w->current_image - 1].security_data;
+ return w->image_metadata[w->current_image - 1].security_data;
}
#endif
/* header.c */
-extern int read_header(FILE *fp, struct wim_header *hdr);
+extern int read_header(FILE *fp, struct wim_header *hdr, int split_ok);
extern int write_header(const struct wim_header *hdr, FILE *out);
extern int init_header(struct wim_header *hdr, int ctype);
const struct resource_entry *entry,
int fd);
-extern int read_metadata_resource(FILE *fp, const struct resource_entry *metadata,
- int wim_ctype, /* WIMSecurityData *sd, */
- struct dentry **root_dentry_p);
+extern int read_metadata_resource(FILE *fp,
+ const struct resource_entry *metadata,
+ int wim_ctype,
+ struct image_metadata *image_metadata);
extern int resource_compression_type(int wim_ctype, int reshdr_flags);
resource_original_size, 0, contents_ret);
}
-#if 0
-/* security.c */
-bool read_security_data(const u8 metadata_resource[],
- u64 metadata_resource_len, WIMSecurityData *sd);
+extern int write_file_resource(struct dentry *dentry, void *wim_p);
+extern int copy_resource(struct lookup_table_entry *lte, void *w);
+extern int copy_between_files(FILE *in, off_t in_offset, FILE *out, size_t len);
+extern int write_resource_from_memory(const u8 resource[], int out_ctype,
+ u64 resource_original_size, FILE *out,
+ u64 *resource_size_ret);
+extern int write_metadata_resource(WIMStruct *w);
+
+#ifdef ENABLE_SECURITY_DATA
+int read_security_data(const u8 metadata_resource[],
+ u64 metadata_resource_len, struct wim_security_data **sd_p);
-void print_security_data(const WIMSecurityData *sd);
-u8 *write_security_data(const WIMSecurityData *sd, u8 *p);
-void init_security_data(WIMSecurityData *sd);
-void destroy_security_data(WIMSecurityData *sd);
+void print_security_data(const struct wim_security_data *sd);
+u8 *write_security_data(const struct wim_security_data *sd, u8 *p);
+void free_security_data(struct wim_security_data *sd);
#endif
/* wim.c */
+extern WIMStruct *new_wim_struct();
extern int wimlib_select_image(WIMStruct *w, int image);
-extern void wimlib_destroy(WIMStruct *w);
extern int wim_hdr_flags_compression_type(int wim_hdr_flags);
extern int wim_resource_compression_type(const WIMStruct *w,
const struct resource_entry *entry);
extern int for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *));
/* write.c */
-extern int write_resource_from_memory(const u8 resource[], int out_ctype,
- u64 resource_original_size, FILE *out,
- u64 *resource_size_ret);
+extern int finish_write(WIMStruct *w, int image, int flags,
+ int write_lookup_table);
+
+extern int begin_write(WIMStruct *w, const char *path, int flags);
#include "wimlib.h"