};
static const struct option append_options[] = {
- {"boot", no_argument, NULL, 'b'},
- {"check", no_argument, NULL, 'c'},
- {"flags", required_argument, NULL, 'f'},
- {"dereference", no_argument, NULL, 'L'},
- {"config", required_argument, NULL, 'C'},
+ {"boot", no_argument, NULL, 'b'},
+ {"check", no_argument, NULL, 'c'},
+ {"flags", required_argument, NULL, 'f'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"dereference", no_argument, NULL, 'L'},
+ {"config", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0},
};
static const struct option apply_options[] = {
{NULL, 0, NULL, 0},
};
static const struct option capture_options[] = {
- {"boot", no_argument, NULL, 'b'},
- {"check", no_argument, NULL, 'c'},
- {"compress", optional_argument, NULL, 'x'},
- {"flags", required_argument, NULL, 'f'},
- {"verbose", no_argument, NULL,'v'},
- {"dereference", no_argument, NULL, 'L'},
- {"config", required_argument, NULL, 'C'},
+ {"boot", no_argument, NULL, 'b'},
+ {"check", no_argument, NULL, 'c'},
+ {"compress", optional_argument, NULL, 'x'},
+ {"flags", required_argument, NULL, 'f'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"dereference", no_argument, NULL, 'L'},
+ {"config", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0},
};
static const struct option delete_options[] = {
size_t config_len = 0;
WIMStruct *w;
int ret;
+ int cur_image;
for_opt(c, append_options) {
switch (c) {
case 'L':
add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE;
break;
+ case 'v':
+ add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+ break;
default:
usage(APPEND);
return -1;
printf("Capturing WIM image NTFS filesystem on `%s'\n",
ntfs_device);
ret = wimlib_add_image_from_ntfs_volume(w, ntfs_device,
- name, desc,
- flags_element,
+ name,
config_str,
config_len,
add_image_flags);
imagex_error_with_errno("Failed to stat `%s'", dir);
}
#endif
- ret = wimlib_add_image(w, dir, name, desc,
- flags_element, config_str, config_len,
+ ret = wimlib_add_image(w, dir, name, config_str, config_len,
add_image_flags);
out_write:
if (ret != 0)
goto out;
+ cur_image = wimlib_get_num_images(w);
+ if (desc) {
+ ret = wimlib_set_image_descripton(w, cur_image, desc);
+ if (ret != 0)
+ goto out;
+ }
+ if (flags_element) {
+ ret = wimlib_set_image_flags(w, cur_image, flags_element);
+ if (ret != 0)
+ goto out;
+ }
ret = wimlib_overwrite(w, write_flags);
out:
wimlib_free(w);
const char *config_str = NULL;
size_t config_len = 0;
WIMStruct *w;
+ int cur_image;
int ret;
for_opt(c, capture_options) {
printf("Capturing WIM image NTFS filesystem on `%s'\n",
ntfs_device);
ret = wimlib_add_image_from_ntfs_volume(w, ntfs_device,
- name, desc,
- flags_element,
+ name,
config_str,
config_len,
add_image_flags);
imagex_error_with_errno("Failed to stat `%s'", dir);
}
#endif
- ret = wimlib_add_image(w, dir, name, desc, flags_element, config_str,
+ ret = wimlib_add_image(w, dir, name, config_str,
config_len, add_image_flags);
out_write:
imagex_error("Failed to add the image `%s'", dir);
goto out;
}
+ cur_image = wimlib_get_num_images(w);
+ if (desc) {
+ ret = wimlib_set_image_descripton(w, cur_image, desc);
+ if (ret != 0)
+ goto out;
+ }
+ if (flags_element) {
+ ret = wimlib_set_image_flags(w, cur_image, flags_element);
+ if (ret != 0)
+ goto out;
+ }
ret = wimlib_write(w, wimfile, WIM_ALL_IMAGES, write_flags);
if (ret != 0)
int do_add_image(WIMStruct *w, const char *dir, const char *name,
- const char *description, const char *flags_element,
const char *config_str, size_t config_len,
int flags,
int (*capture_tree)(struct dentry **, const char *,
if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
wimlib_set_boot_idx(w, w->hdr.image_count);
- ret = xml_add_image(w, root_dentry, name, description, flags_element);
+ ret = xml_add_image(w, root_dentry, name);
if (ret != 0)
goto out_destroy_imd;
* Adds an image to a WIM file from a directory tree on disk.
*/
WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *dir,
- const char *name, const char *description,
- const char *flags_element,
- const char *config_str,
+ const char *name, const char *config_str,
size_t config_len, int flags)
{
- return do_add_image(w, dir, name, description, flags_element,
- config_str, config_len, flags,
+ return do_add_image(w, dir, name, config_str, config_len, flags,
build_dentry_tree, NULL);
}
WIMLIBAPI int wimlib_add_image_from_ntfs_volume(WIMStruct *w,
const char *device,
const char *name,
- const char *description,
- const char *flags_element,
const char *config_str,
size_t config_len,
int flags)
ERROR("Cannot dereference files when capturing directly from NTFS");
return WIMLIB_ERR_INVALID_PARAM;
}
- return do_add_image(w, device, name, description, flags_element,
- config_str, config_len, flags, build_dentry_tree_ntfs,
- &w->ntfs_vol);
+ return do_add_image(w, device, name, config_str, config_len, flags,
+ build_dentry_tree_ntfs, &w->ntfs_vol);
}
#else /* WITH_NTFS_3G */
*
*/
extern int wimlib_add_image(WIMStruct *wim, const char *dir,
- const char *name, const char *description,
- const char *flags_element,
- const char *config, size_t config_len,
- int flags);
+ const char *name, const char *config,
+ size_t config_len, int flags);
extern int wimlib_add_image_from_ntfs_volume(WIMStruct *w, const char *device,
const char *name,
- const char *description,
- const char *flags_element,
const char *config,
size_t config_len,
int flags);
extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
const char *description);
+extern int wimlib_set_image_flags(WIMStruct *w, int image,
+ const char *flags);
+
/**
* Changes the name of an image in the WIM.
*
const struct capture_config *config,
bool exclude_prefix);
extern int do_add_image(WIMStruct *w, const char *dir, const char *name,
- const char *description, const char *flags_element,
const char *config_str, size_t config_len,
int flags,
int (*capture_tree)(struct dentry **, const char *,
}
/* Adds an image to the XML information. */
-int xml_add_image(WIMStruct *w, struct dentry *root_dentry, const char *name,
- const char *description, const char *flags_element)
+int xml_add_image(WIMStruct *w, struct dentry *root_dentry, const char *name)
{
struct wim_info *wim_info;
struct image_info *image_info;
wimlib_assert(name);
- DEBUG("Adding image: name = %s, description = %s, flags_element = %s",
- name, description, flags_element);
+ DEBUG("Adding image: name = %s", name);
/* If this is the first image, allocate the struct wim_info. Otherwise
* use the existing struct wim_info. */
if (!(image_info->name = STRDUP(name)))
goto out_destroy_image_info;
- if (description && !(image_info->description = STRDUP(description)))
- goto out_destroy_image_info;
- if (flags_element && !(image_info->flags = STRDUP(flags_element)))
- goto out_destroy_image_info;
-
w->wim_info = wim_info;
image_info->index = wim_info->num_images;
image_info->creation_time = get_wim_timestamp();
w->wim_info->images[image - 1].description = p;
return 0;
}
+
+WIMLIBAPI int wimlib_set_image_flags(WIMStruct *w, int image,
+ const char *flags)
+{
+ char *p;
+
+ DEBUG("Setting the flags of image %d to %s", image, flags);
+
+ if (image < 1 || image > w->hdr.image_count) {
+ ERROR("%d is not a valid image", image);
+ return WIMLIB_ERR_INVALID_IMAGE;
+ }
+ if (flags) {
+ p = STRDUP(flags);
+ if (!p) {
+ ERROR("Out of memory");
+ return WIMLIB_ERR_NOMEM;
+ }
+ } else {
+ p = NULL;
+ }
+ FREE(w->wim_info->images[image - 1].flags);
+ w->wim_info->images[image - 1].flags = p;
+ return 0;
+}
extern void xml_delete_image(struct wim_info **wim_info_p, int image);
extern int xml_add_image(WIMStruct *w, struct dentry *root_dentry,
- const char *name, const char *description,
- const char *flags);
+ const char *name);
extern void free_wim_info(struct wim_info *info);