* fixups can be disabled by using the flag
* ::WIMLIB_ADD_FLAG_NORPFIX.) */
WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
+
+ /** The file is an absolute symbolic link or junction
+ * that points into the capture directory, and
+ * reparse-point fixups are enabled, so its target is
+ * being adjusted. (Reparse point fixups can be
+ * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
+ */
+ WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
} status;
union {
const wimlib_tchar *wim_target_path;
/** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
- * of @p WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK, this is
- * the target of the absolute symbolic link or junction
- * point. */
+ * of @p WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK or @p
+ * WIMLIB_SCAN_DENTRY_FIXED_SYMLINK, this is the target
+ * of the absolute symbolic link or junction. */
const wimlib_tchar *symlink_target;
};
"absolute symbolic links as-is)\n"),
info->scan.cur_path, info->scan.symlink_target);
break;
+ case WIMLIB_SCAN_DENTRY_FIXED_SYMLINK:
+ /* Symlink fixups are enabled by default. This is
+ * mainly intended for Windows, which for some reason
+ * uses absolute junctions (with drive letters!) in the
+ * default installation. On UNIX-like systems, warn the
+ * user when fixing the target of an absolute symbolic
+ * link, so they know to disable this if they want.
+ * (Although, more likely they will get the warning
+ * about an absolute symbolic link with an out-of-tree
+ * target first.) */
+ #ifndef __WIN32__
+ imagex_printf(T("\nWARNING: Adjusted target of "
+ "absolute symbolic link \"%"TS"\"\n"
+ " (Use --norpfix to capture "
+ "absolute symbolic links as-is)\n"),
+ info->scan.cur_path);
+ #endif
+ break;
}
break;
case WIMLIB_PROGRESS_MSG_SCAN_END:
case WIMLIB_SCAN_DENTRY_UNSUPPORTED:
case WIMLIB_SCAN_DENTRY_EXCLUDED:
case WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK:
+ case WIMLIB_SCAN_DENTRY_FIXED_SYMLINK:
if (!(params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE))
return 0;
}
if ((params->add_flags & WIMLIB_ADD_FLAG_RPFIX) &&
dest[0] == '/')
{
+ /* RPFIX (reparse point fixup) mode: Change target of absolute
+ * symbolic link to be "absolute" relative to the tree being
+ * captured. */
dest = unix_fixup_abslink(dest,
params->capture_root_ino,
params->capture_root_dev);
- if (!dest) {
- /* RPFIX (reparse point fixup) mode: Ignore
- * absolute symbolic link that points out of the
- * tree to be captured. */
+ params->progress.scan.cur_path = full_path;
+ params->progress.scan.symlink_target = deref_name_buf;
+ if (dest) {
+ /* Successfully fixed the link target. */
+ inode->i_not_rpfixed = 0;
+ ret = do_capture_progress(params,
+ WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
+ NULL);
+ if (ret)
+ return ret;
+ } else {
+ /* Link points outside of the tree being captured.
+ * Exclude it. */
free_dentry(*root_p);
*root_p = NULL;
- params->progress.scan.cur_path = full_path;
- params->progress.scan.symlink_target = deref_name_buf;
return do_capture_progress(params,
WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
NULL);
}
- inode->i_not_rpfixed = 0;
}
ret = wim_inode_set_symlink(inode, dest, params->lookup_table);
if (ret)
return p;
}
+static int
+winnt_rpfix_progress(struct add_image_params *params, const wchar_t *path,
+ const struct reparse_data *rpdata,
+ enum wimlib_progress_msg msg)
+{
+ size_t print_name_nchars = rpdata->print_name_nbytes / sizeof(wchar_t);
+ wchar_t print_name0[print_name_nchars + 1];
+
+ wmemcpy(print_name0, rpdata->print_name, print_name_nchars);
+ print_name0[print_name_nchars] = L'\0';
+
+ params->progress.scan.cur_path = printable_path(path);
+ params->progress.scan.symlink_target = print_name0;
+ return do_capture_progress(params, msg, NULL);
+}
+
static int
winnt_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p,
u64 capture_root_ino, u64 capture_root_dev,
{
struct reparse_data rpdata;
const wchar_t *rel_target;
+ int ret;
if (parse_reparse_data(rpbuf, *rpbuflen_p, &rpdata)) {
/* Couldn't even understand the reparse data. Don't try the
/* Target points outside of the tree being captured. Exclude
* this reparse point from the capture (but inform the library
* user). */
- size_t print_name_nchars = rpdata.print_name_nbytes / sizeof(wchar_t);
- wchar_t print_name0[print_name_nchars + 1];
- print_name0[print_name_nchars] = L'\0';
- wmemcpy(print_name0, rpdata.print_name, print_name_nchars);
-
- params->progress.scan.cur_path = printable_path(path);
- params->progress.scan.symlink_target = print_name0;
- int ret = do_capture_progress(params,
- WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
- NULL);
+ ret = winnt_rpfix_progress(params, path, &rpdata,
+ WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK);
if (ret)
return ret;
return RP_EXCLUDED;
if (make_reparse_buffer(&rpdata, rpbuf, rpbuflen_p))
return RP_NOT_FIXED;
}
+ ret = winnt_rpfix_progress(params, path, &rpdata,
+ WIMLIB_SCAN_DENTRY_FIXED_SYMLINK);
+ if (ret)
+ return ret;
return RP_FIXED;
}