]> wimlib.net Git - wimlib/blobdiff - src/add_image.c
Minor cleanups
[wimlib] / src / add_image.c
index 085fd044e386d1626bc2e9f649da704ee799ce2c..20b554eb86d7342899181ac0df882a1c58d92884 100644 (file)
@@ -193,9 +193,20 @@ static int build_dentry_tree(struct dentry **root_ret,
        }
 
        if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
-             !S_ISDIR(root_stbuf.st_mode)) {
-               ERROR("`%s' is not a directory", root_disk_path);
-               return WIMLIB_ERR_NOTDIR;
+             !S_ISDIR(root_stbuf.st_mode))
+       {
+               /* Do a dereference-stat in case the root is a symbolic link.
+                * This case is allowed, provided that the symbolic link points
+                * to a directory. */
+               ret = stat(root_disk_path, &root_stbuf);
+               if (ret != 0) {
+                       ERROR_WITH_ERRNO("Failed to stat `%s'", root_disk_path);
+                       return WIMLIB_ERR_STAT;
+               }
+               if (!S_ISDIR(root_stbuf.st_mode)) {
+                       ERROR("`%s' is not a directory", root_disk_path);
+                       return WIMLIB_ERR_NOTDIR;
+               }
        }
        if (!S_ISREG(root_stbuf.st_mode) && !S_ISDIR(root_stbuf.st_mode)
            && !S_ISLNK(root_stbuf.st_mode)) {
@@ -231,7 +242,7 @@ static int build_dentry_tree(struct dentry **root_ret,
                                   ((u64)root_stbuf.st_dev << ((sizeof(ino_t) * 8) & 63));
 
        add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;
-       inode->resolved = true;
+       inode->resolved = 1;
 
        if (S_ISREG(root_stbuf.st_mode)) { /* Archiving a regular file */
 
@@ -741,6 +752,7 @@ WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *source,
 
        DEBUG("Assigning hard link group IDs");
        assign_inode_numbers(&inode_list);
+       w->image_metadata[w->hdr.image_count - 1].inode_list = inode_list;
 
        ret = xml_add_image(w, name);
        if (ret != 0)