]> wimlib.net Git - wimlib/blobdiff - src/unix_capture.c
unix_capture.c: Include <limits.h> for PATH_MAX
[wimlib] / src / unix_capture.c
index f3e9f0e564866f3b7b760a39f5f64627ec5d34dc..963e53dabfb388c1e33dc1a0383348ea972e8ab7 100644 (file)
@@ -1,5 +1,9 @@
 /*
- * Copyright (C) 2013 Eric Biggers
+ * unix_capture.c:  Capture a directory tree on UNIX.
+ */
+
+/*
+ * Copyright (C) 2012, 2013 Eric Biggers
  *
  * This file is part of wimlib, a library for working with WIM files.
  *
@@ -26,8 +30,9 @@
 
 #include <dirent.h>
 #include <errno.h>
-#include <unistd.h>
+#include <limits.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 static int
 unix_capture_regular_file(const char *path,
@@ -82,7 +87,7 @@ unix_capture_directory(struct wim_dentry *dir_dentry,
        if (!dir) {
                ERROR_WITH_ERRNO("Failed to open the directory `%s'",
                                 path);
-               return WIMLIB_ERR_OPEN;
+               return WIMLIB_ERR_OPENDIR;
        }
 
        /* Recurse on directory contents */
@@ -147,7 +152,7 @@ unix_capture_symlink(struct wim_dentry **root_p,
                dest[deref_name_len] = '\0';
                DEBUG("Read symlink `%s'", dest);
 
-               if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_RPFIX) &&
+               if ((params->add_flags & WIMLIB_ADD_FLAG_RPFIX) &&
                     dest[0] == '/')
                {
                        dest = capture_fixup_absolute_symlink(dest,
@@ -196,7 +201,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        struct wim_inode *inode;
 
        if (exclude_path(path, path_len, params->config, true)) {
-               if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE)
+               if ((params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE)
                    && params->progress_func)
                {
                        union wimlib_progress_info info;
@@ -207,7 +212,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                goto out;
        }
 
-       if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
+       if ((params->add_flags & WIMLIB_ADD_FLAG_VERBOSE)
            && params->progress_func)
        {
                union wimlib_progress_info info;
@@ -218,15 +223,16 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
 
        struct stat stbuf;
        int (*stat_fn)(const char *restrict, struct stat *restrict);
-       if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE) ||
-           (params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT))
+       if ((params->add_flags & WIMLIB_ADD_FLAG_DEREFERENCE) ||
+           (params->add_flags & WIMLIB_ADD_FLAG_ROOT))
                stat_fn = stat;
        else
                stat_fn = lstat;
 
        ret = (*stat_fn)(path, &stbuf);
-       if (ret != 0) {
+       if (ret) {
                ERROR_WITH_ERRNO("Failed to stat `%s'", path);
+               ret = WIMLIB_ERR_STAT;
                goto out;
        }
        if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)
@@ -258,7 +264,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        inode->i_last_access_time = unix_timestamp_to_wim(stbuf.st_atime);
 #endif
        inode->i_resolved = 1;
-       if (params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA) {
+       if (params->add_flags & WIMLIB_ADD_FLAG_UNIX_DATA) {
                ret = inode_set_unix_data(inode, stbuf.st_uid,
                                          stbuf.st_gid,
                                          stbuf.st_mode,
@@ -267,7 +273,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                if (ret)
                        goto out;
        }
-       params->add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;
+       params->add_flags &= ~WIMLIB_ADD_FLAG_ROOT;
        if (S_ISREG(stbuf.st_mode))
                ret = unix_capture_regular_file(path, stbuf.st_size,
                                                inode, params->lookup_table);
@@ -320,7 +326,7 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
                        return WIMLIB_ERR_STAT;
                }
 
-               if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
+               if ((params->add_flags & WIMLIB_ADD_FLAG_ROOT) &&
                    !S_ISDIR(root_stbuf.st_mode))
                {
                        ERROR("Root of capture \"%s\" is not a directory",