int ret = 0;
int (*stat_fn)(const char *restrict, struct stat *restrict);
struct dentry *root;
+ const char *filename;
if (exclude_path(root_disk_path, config, true)) {
if (add_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
}
if (!S_ISREG(root_stbuf.st_mode) && !S_ISDIR(root_stbuf.st_mode)
&& !S_ISLNK(root_stbuf.st_mode)) {
- ERROR("`%s' is not a regular file, directory, or symbolic link.");
+ ERROR("`%s' is not a regular file, directory, or symbolic link.",
+ root_disk_path);
return WIMLIB_ERR_SPECIAL_FILE;
}
- root = new_dentry(path_basename(root_disk_path));
+ if (add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT)
+ filename = "";
+ else
+ filename = path_basename(root_disk_path);
+
+ root = new_dentry(filename);
if (!root)
return WIMLIB_ERR_NOMEM;
closedir(dir);
} else if (dentry_is_symlink(root)) {
/* Archiving a symbolic link */
- size_t symlink_buf_len;
char deref_name_buf[4096];
ssize_t deref_name_len;
*
* @w: The WIMStruct for the WIM file.
* @root_dentry: The root of the directory tree for the image.
+ * @sd: The security data for the image.
*/
static int add_new_dentry_tree(WIMStruct *w, struct dentry *root_dentry,
struct wim_security_data *sd)
lgt = new_link_group_table(9001);
if (!lgt)
- goto out_free_security_data;
+ goto out_free_metadata_lte;
metadata_lte->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
random_hash(metadata_lte->hash);
/* Change the current image to the new one. */
return wimlib_select_image(w, w->hdr.image_count);
-out_free_security_data:
- FREE(sd);
out_free_metadata_lte:
FREE(metadata_lte);
out_free_imd:
char *p;
char *eol;
char *next_p;
- size_t next_bytes_remaining;
size_t bytes_remaining;
enum pattern_type type = NONE;
int ret;
if (eol - p > 2 && isalpha(*p) && *(p + 1) == ':')
p += 2;
+ ret = 0;
if (strcmp(p, "[ExclusionList]") == 0)
type = EXCLUSION_LIST;
else if (strcmp(p, "[ExclusionException]") == 0)
type = COMPRESSION_EXCLUSION_LIST;
else if (strcmp(p, "[AlignmentList]") == 0)
type = ALIGNMENT_LIST;
- else switch (type) {
+ else if (p[0] == '[' && strrchr(p, ']')) {
+ ERROR("Unknown capture configuration section `%s'", p);
+ ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
+ goto out_destroy;
+ } else switch (type) {
case EXCLUSION_LIST:
DEBUG("Adding pattern \"%s\" to exclusion list", p);
ret = pattern_list_add_pattern(&config->exclusion_list, p);
void *extra_arg)
{
struct dentry *root_dentry = NULL;
- struct image_metadata *imd;
struct wim_security_data *sd;
struct capture_config config;
+ struct link_group_table *lgt;
int ret;
DEBUG("Adding dentry tree from dir `%s'.", dir);
if (ret != 0)
goto out_free_dentry_tree;
+ lgt = w->image_metadata[w->hdr.image_count - 1].lgt;
DEBUG("Inserting dentries into hard link group table");
- ret = for_dentry_in_tree(root_dentry, link_group_table_insert,
- w->image_metadata[w->hdr.image_count - 1].lgt);
+ ret = for_dentry_in_tree(root_dentry, link_group_table_insert, lgt);
+
if (ret != 0)
goto out_destroy_imd;
- DEBUG("Assigning hard link groups");
- assign_link_groups(w->image_metadata[w->hdr.image_count - 1].lgt);
+
+ DEBUG("Cleanup up the hard link groups");
+ ret = fix_link_groups(lgt);
+ if (ret != 0)
+ goto out_destroy_imd;
+
+ DEBUG("Assigning hard link group IDs");
+ assign_link_group_ids(w->image_metadata[w->hdr.image_count - 1].lgt);
if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
wimlib_set_boot_idx(w, w->hdr.image_count);
return ret;
out_free_dentry_tree:
free_dentry_tree(root_dentry, w->lookup_table);
-out_free_sd:
free_security_data(sd);
out_destroy_config:
destroy_capture_config(&config);