/*
- * 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.
*
#ifndef __WIN32__
-#include "wimlib_internal.h"
-#include "dentry.h"
-#include "lookup_table.h"
-#include "timestamp.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <dirent.h>
#include <errno.h>
-#include <unistd.h>
+#include <limits.h>
#include <sys/stat.h>
+#include <unistd.h>
+
+#include "wimlib/capture.h"
+#include "wimlib/dentry.h"
+#include "wimlib/error.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/paths.h"
+#include "wimlib/reparse.h"
+#include "wimlib/timestamp.h"
static int
unix_capture_regular_file(const char *path,
if (!dir) {
ERROR_WITH_ERRNO("Failed to open the directory `%s'",
path);
- return WIMLIB_ERR_OPEN;
+ return WIMLIB_ERR_OPENDIR;
}
/* Recurse on directory contents */
inode->i_attributes = FILE_ATTRIBUTE_REPARSE_POINT;
inode->i_reparse_tag = WIM_IO_REPARSE_TAG_SYMLINK;
- /* The idea here is to call readlink() to get the UNIX target of
- * the symbolic link, then turn the target into a reparse point
- * data buffer that contains a relative or absolute symbolic
- * link (NOT a junction point or *full* path symbolic link with
- * drive letter).
- */
+ /* The idea here is to call readlink() to get the UNIX target of the
+ * symbolic link, then turn the target into a reparse point data buffer
+ * that contains a relative or absolute symbolic link. */
deref_name_len = readlink(path, deref_name_buf,
sizeof(deref_name_buf) - 1);
if (deref_name_len >= 0) {
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)
goto out;
}
- ret = inode_table_new_dentry(params->inode_table,
+ ret = inode_table_new_dentry(¶ms->inode_table,
path_basename_with_len(path, path_len),
stbuf.st_ino, stbuf.st_dev, false, &root);
if (ret)