-static int extract_regular_file_unlinked(struct dentry *dentry,
- struct apply_args *args,
- const char *output_path,
- struct lookup_table_entry *lte)
+static int
+symlink_apply_unix_data(const char *link,
+ const struct wimlib_unix_data *unix_data)
+{
+ if (lchown(link, unix_data->uid, unix_data->gid)) {
+ if (errno == EPERM) {
+ /* Ignore */
+ WARNING_WITH_ERRNO("failed to set symlink UNIX owner/group");
+ } else {
+ ERROR_WITH_ERRNO("failed to set symlink UNIX owner/group");
+ return WIMLIB_ERR_INVALID_DENTRY;
+ }
+ }
+ return 0;
+}
+
+static int
+fd_apply_unix_data(int fd, const struct wimlib_unix_data *unix_data)
+{
+ if (fchown(fd, unix_data->uid, unix_data->gid)) {
+ if (errno == EPERM) {
+ WARNING_WITH_ERRNO("failed to set file UNIX owner/group");
+ /* Ignore? */
+ } else {
+ ERROR_WITH_ERRNO("failed to set file UNIX owner/group");
+ return WIMLIB_ERR_INVALID_DENTRY;
+ }
+ }
+
+ if (fchmod(fd, unix_data->mode)) {
+ if (errno == EPERM) {
+ WARNING_WITH_ERRNO("failed to set UNIX file mode");
+ /* Ignore? */
+ } else {
+ ERROR_WITH_ERRNO("failed to set UNIX file mode");
+ return WIMLIB_ERR_INVALID_DENTRY;
+ }
+ }
+ return 0;
+}
+
+static int
+dir_apply_unix_data(const char *dir, const struct wimlib_unix_data *unix_data)
+{
+ int dfd = open(dir, O_RDONLY);
+ int ret;
+ if (dfd >= 0) {
+ ret = fd_apply_unix_data(dfd, unix_data);
+ if (close(dfd)) {
+ ERROR_WITH_ERRNO("can't close directory `%s'", dir);
+ ret = WIMLIB_ERR_MKDIR;
+ }
+ } else {
+ ERROR_WITH_ERRNO("can't open directory `%s'", dir);
+ ret = WIMLIB_ERR_MKDIR;
+ }
+ return ret;
+}
+
+static int
+extract_regular_file_unlinked(struct wim_dentry *dentry,
+ struct apply_args *args,
+ const char *output_path,
+ struct wim_lookup_table_entry *lte)