]> wimlib.net Git - wimlib/blobdiff - src/modify.c
wimlib_add_image(): Fix variable name (--enable-debug only)
[wimlib] / src / modify.c
index 3403eb323720a9fda7e10306bdeee27834eabf81..5b8fe415c50dda5a5905200e906ad38316934722 100644 (file)
@@ -167,9 +167,15 @@ static int build_dentry_tree(struct dentry **root_ret,
 
        inode = root->d_inode;
 
+#ifdef HAVE_STAT_NANOSECOND_PRECISION
        inode->creation_time = timespec_to_wim_timestamp(&root_stbuf.st_mtim);
        inode->last_write_time = timespec_to_wim_timestamp(&root_stbuf.st_mtim);
        inode->last_access_time = timespec_to_wim_timestamp(&root_stbuf.st_atim);
+#else
+       inode->creation_time = unix_timestamp_to_wim(root_stbuf.st_mtime);
+       inode->last_write_time = unix_timestamp_to_wim(root_stbuf.st_mtime);
+       inode->last_access_time = unix_timestamp_to_wim(root_stbuf.st_atime);
+#endif
        if (sizeof(ino_t) >= 8)
                inode->ino = (u64)root_stbuf.st_ino;
        else
@@ -230,7 +236,7 @@ static int build_dentry_tree(struct dentry **root_ret,
                inode->attributes = FILE_ATTRIBUTE_DIRECTORY;
 
                DIR *dir;
-               struct dirent *p;
+               struct dirent entry, *result;
                struct dentry *child;
 
                dir = opendir(root_disk_path);
@@ -251,20 +257,20 @@ static int build_dentry_tree(struct dentry **root_ret,
                 * to any subdirectories. */
                while (1) {
                        errno = 0;
-                       p = readdir(dir);
-                       if (p == NULL) {
-                               if (errno) {
-                                       ret = WIMLIB_ERR_READ;
-                                       ERROR_WITH_ERRNO("Error reading the "
-                                                        "directory `%s'",
-                                                        root_disk_path);
-                               }
+                       ret = readdir_r(dir, &entry, &result);
+                       if (ret != 0) {
+                               ret = WIMLIB_ERR_READ;
+                               ERROR_WITH_ERRNO("Error reading the "
+                                                "directory `%s'",
+                                                root_disk_path);
                                break;
                        }
-                       if (p->d_name[0] == '.' && (p->d_name[1] == '\0'
-                             || (p->d_name[1] == '.' && p->d_name[2] == '\0')))
+                       if (result == NULL)
+                               break;
+                       if (result->d_name[0] == '.' && (result->d_name[1] == '\0'
+                             || (result->d_name[1] == '.' && result->d_name[2] == '\0')))
                                        continue;
-                       strcpy(name + len + 1, p->d_name);
+                       strcpy(name + len + 1, result->d_name);
                        ret = build_dentry_tree(&child, name, lookup_table,
                                                NULL, config, add_image_flags,
                                                progress_func, NULL);
@@ -983,8 +989,8 @@ WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *source,
                capture_tree = build_dentry_tree_ntfs;
                extra_arg = &w->ntfs_vol;
 #else
-               ERROR("wimlib was compiled without support for NTFS-3g, so");
-               ERROR("we cannot capture a WIM image directly from a NTFS volume");
+               ERROR("wimlib was compiled without support for NTFS-3g, so\n"
+                     "        cannot capture a WIM image directly from a NTFS volume!");
                return WIMLIB_ERR_UNSUPPORTED;
 #endif
        } else {
@@ -992,7 +998,7 @@ WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *source,
                extra_arg = NULL;
        }
 
-       DEBUG("Adding dentry tree from directory or NTFS volume `%s'.", dir);
+       DEBUG("Adding dentry tree from directory or NTFS volume `%s'.", source);
 
        if (!name || !*name) {
                ERROR("Must specify a non-empty string for the image name");