+static int
+apply_file_attributes_and_security_data(ntfs_inode *ni,
+ const struct dentry *dentry,
+ const WIMStruct *w)
+{
+ DEBUG("Setting NTFS file attributes on `%s' to %#"PRIx32,
+ dentry->full_path_utf8, dentry->attributes);
+ if (!_ntfs_set_file_attributes(ni, dentry->attributes)) {
+ ERROR("Failed to set NTFS file attributes on `%s'",
+ dentry->full_path_utf8);
+ return WIMLIB_ERR_NTFS_3G;
+ }
+
+ if (dentry->security_id != -1) {
+ const struct wim_security_data *sd;
+
+ sd = wim_const_security_data(w);
+ wimlib_assert(dentry->security_id < sd->num_entries);
+ DEBUG("Applying security descriptor %d to `%s'",
+ dentry->security_id, dentry->full_path_utf8);
+ if (!_ntfs_set_file_security(ni->vol, ni, ~0,
+ sd->descriptors[dentry->security_id]))
+ {
+ ERROR_WITH_ERRNO("Failed to set security data on `%s'",
+ dentry->full_path_utf8);
+ return WIMLIB_ERR_NTFS_3G;
+ }
+ }
+ return 0;
+}
+
+static int apply_reparse_data(ntfs_inode *ni, const struct dentry *dentry,
+ const WIMStruct *w)
+{
+ struct lookup_table_entry *lte;
+ int ret = 0;
+
+ wimlib_assert(dentry->attributes & FILE_ATTRIBUTE_REPARSE_POINT);
+
+ lte = dentry_first_lte(dentry, w->lookup_table);
+
+ if (!lte) {
+ ERROR("Could not find reparse data for `%s'",
+ dentry->full_path_utf8);
+ return WIMLIB_ERR_INVALID_DENTRY;
+ }
+
+ if (wim_resource_size(lte) >= 0xffff) {
+ ERROR("Reparse data of `%s' is too long (%lu bytes)",
+ dentry->full_path_utf8, wim_resource_size(lte));
+ return WIMLIB_ERR_INVALID_DENTRY;
+ }
+
+ char reparse_data_buf[8 + wim_resource_size(lte)];
+ char *p = reparse_data_buf;
+ p = put_u32(p, dentry->reparse_tag); /* ReparseTag */
+ p = put_u16(p, wim_resource_size(lte)); /* ReparseDataLength */
+ p = put_u16(p, 0); /* Reserved */
+
+ ret = read_full_wim_resource(lte, p);
+ if (ret != 0)
+ return ret;
+
+ ret = ntfs_set_ntfs_reparse_data(ni, reparse_data_buf,
+ wim_resource_size(lte) + 8, 0);
+ if (ret != 0) {
+ ERROR_WITH_ERRNO("Failed to set NTFS reparse data on `%s'",
+ dentry->full_path_utf8);
+ return WIMLIB_ERR_NTFS_3G;
+ }
+ return 0;
+}
+