#include "dentry.h"
#include "lookup_table.h"
#include "xml.h"
+#include "security.h"
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
-
-#if TCHAR_IS_UTF16LE
-# include <wchar.h>
-#else
-# include <string.h>
-#endif
+#include <string.h>
#include <unistd.h>
* These lookup table entries that are added point to the path of
* the file on disk.
*
- * @sd: Ignored. (Security data only captured in NTFS mode.)
+ * @sd_set: Ignored. (Security data only captured in NTFS mode.)
*
* @capture_config:
* Configuration for files to be excluded from capture.
*
* @add_flags: Bitwise or of WIMLIB_ADD_IMAGE_FLAG_*
*
- * @extra_arg: Ignored in UNIX builds; used to pass sd_set pointer in Windows
- * builds.
+ * @extra_arg: Ignored
*
* @return: 0 on success, nonzero on failure. It is a failure if any of
* the files cannot be `stat'ed, or if any of the needed
unix_build_dentry_tree(struct wim_dentry **root_ret,
const char *root_disk_path,
struct wim_lookup_table *lookup_table,
- struct wim_security_data *sd,
+ struct sd_set *sd_set,
const struct capture_config *config,
int add_image_flags,
wimlib_progress_func_t progress_func,
if (*pp == T('\\'))
*pp = T('/');
- /* Remove drive letter
- * XXX maybe keep drive letter on Windows */
+ /* Remove drive letter (UNIX only) */
+ #ifndef __WIN32__
if (eol - p > 2 && istalpha(*p) && *(p + 1) == T(':'))
p += 2;
+ #endif
ret = 0;
- if (tstrcmp(p, T("[ExclusionList]")) == 0)
+ if (!tstrcmp(p, T("[ExclusionList]")))
type = EXCLUSION_LIST;
- else if (tstrcmp(p, T("[ExclusionException]")) == 0)
+ else if (!tstrcmp(p, T("[ExclusionException]")))
type = EXCLUSION_EXCEPTION;
- else if (tstrcmp(p, T("[CompressionExclusionList]")) == 0)
+ else if (!tstrcmp(p, T("[CompressionExclusionList]")))
type = COMPRESSION_EXCLUSION_LIST;
- else if (tstrcmp(p, T("[AlignmentList]")) == 0)
+ else if (!tstrcmp(p, T("[AlignmentList]")))
type = ALIGNMENT_LIST;
else if (p[0] == T('[') && tstrrchr(p, T(']'))) {
ERROR("Unknown capture configuration section \"%"TS"\"", p);
const tchar *basename = path_basename(path);
if (exclude_prefix) {
wimlib_assert(tstrlen(path) >= config->prefix_num_tchars);
- if (tmemcmp(config->prefix, path, config->prefix_num_tchars) == 0
- && path[config->prefix_num_tchars] == T('/'))
+ if (!tmemcmp(config->prefix, path, config->prefix_num_tchars) &&
+ path[config->prefix_num_tchars] == T('/'))
+ {
path += config->prefix_num_tchars;
+ }
}
return match_pattern(path, basename, &config->exclusion_list) &&
!match_pattern(path, basename, &config->exclusion_exception);
break;
}
- p = target_path + tstrlen(target_path) - 1;
+ p = tstrchr(target_path, T('\0')) - 1;
while (*p == T('/'))
*p-- = T('\0');
return target_path;
}
-static void
-zap_backslashes(tchar *s)
-{
- while (*s) {
- if (*s == T('\\'))
- *s = T('/');
- s++;
- }
-}
-
/* Strip leading and trailing slashes from the target paths */
static void
canonicalize_targets(struct wimlib_capture_source *sources, size_t num_sources)
"(the NTFS volume) in NTFS mode!");
return WIMLIB_ERR_INVALID_PARAM;
}
- if (sources[0].wim_target_path[0] != '\0') {
+ if (sources[0].wim_target_path[0] != T('\0')) {
ERROR("In NTFS capture mode the target path inside "
"the image must be the root directory!");
return WIMLIB_ERR_INVALID_PARAM;
* */
parent = *root_p;
while ((slash = tstrchr(target_path, T('/')))) {
- *slash = '\0';
+ *slash = T('\0');
dentry = get_dentry_child_with_name(parent, target_path);
if (!dentry) {
ret = new_filler_directory(target_path, &dentry);
int (*capture_tree)(struct wim_dentry **,
const tchar *,
struct wim_lookup_table *,
- struct wim_security_data *,
+ struct sd_set *,
const struct capture_config *,
int,
wimlib_progress_func_t,
struct capture_config config;
struct wim_image_metadata *imd;
int ret;
+ struct sd_set sd_set;
if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_NTFS) {
#ifdef WITH_NTFS_3G
sd->total_length = 8;
sd->refcnt = 1;
+ sd_set.sd = sd;
+ sd_set.rb_root.rb_node = NULL;
+
DEBUG("Using %zu capture sources", num_sources);
canonicalize_targets(sources, num_sources);
sort_sources(sources, num_sources);
flags = add_image_flags | WIMLIB_ADD_IMAGE_FLAG_SOURCE;
if (!*sources[i].wim_target_path)
flags |= WIMLIB_ADD_IMAGE_FLAG_ROOT;
- ret = (*capture_tree)(&branch, sources[i].fs_source_path,
- w->lookup_table, sd,
+ ret = (*capture_tree)(&branch,
+ sources[i].fs_source_path,
+ w->lookup_table,
+ &sd_set,
&config,
flags,
progress_func, extra_arg);
if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
wimlib_set_boot_idx(w, w->hdr.image_count);
ret = 0;
- goto out_destroy_capture_config;
+ goto out_destroy_sd_set;
out_destroy_imd:
destroy_image_metadata(&w->image_metadata[w->hdr.image_count - 1],
w->lookup_table);
w->hdr.image_count--;
- goto out;
+ goto out_destroy_sd_set;
out_free_branch:
free_dentry_tree(branch, w->lookup_table);
out_free_dentry_tree:
free_dentry_tree(root_dentry, w->lookup_table);
out_free_security_data:
free_security_data(sd);
+out_destroy_sd_set:
+ destroy_sd_set(&sd_set);
out_destroy_capture_config:
destroy_capture_config(&config);
out: