aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-28 21:04:20 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-28 23:34:17 +0200
commit5e4d53c713d3f01ae2d24a7d2311d65761b143dc (patch)
tree91674319d42ceb0f6309b43844fae1291f25ce03
parent3c219238d9b9d8b600a55a273698c52a5d447d01 (diff)
Move fstree_from_dir to gensquashfs code
It's actually the only user and the dir-scanner xattr code is going to get a lot closer integerated with libsquashfs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/fstree.h15
-rw-r--r--lib/fstree/Makemodule.am2
-rw-r--r--mkfs/Makemodule.am1
-rw-r--r--mkfs/dirscan.c (renamed from lib/fstree/fstree_from_dir.c)17
-rw-r--r--mkfs/mkfs.h15
5 files changed, 18 insertions, 32 deletions
diff --git a/include/fstree.h b/include/fstree.h
index 337b598..110ad1f 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -26,14 +26,6 @@ typedef struct dir_info_t dir_info_t;
typedef struct fstree_t fstree_t;
typedef struct tree_xattr_t tree_xattr_t;
-enum {
- DIR_SCAN_KEEP_TIME = 0x01,
-
- DIR_SCAN_ONE_FILESYSTEM = 0x02,
-
- DIR_SCAN_READ_XATTR = 0x04,
-};
-
/* Encapsulates a set of key-value pairs attached to a tree_node_t */
struct tree_xattr_t {
/* Number of key-value pairs */
@@ -230,13 +222,6 @@ void fstree_xattr_deduplicate(fstree_t *fs);
*/
int fstree_from_file(fstree_t *fs, const char *filename, FILE *fp);
-/*
- Recursively scan a directory and generate a file system tree from it.
-
- Returns 0 on success, prints errors to stderr.
- */
-int fstree_from_dir(fstree_t *fs, const char *path, unsigned int flags);
-
/* Add labels from an SELinux labeling file to all tree nodes.
Returns 0 on success. Internally prints errors to stderr. */
int fstree_relabel_selinux(fstree_t *fs, const char *filename);
diff --git a/lib/fstree/Makemodule.am b/lib/fstree/Makemodule.am
index 6d3498a..960ab1d 100644
--- a/lib/fstree/Makemodule.am
+++ b/lib/fstree/Makemodule.am
@@ -1,5 +1,5 @@
libfstree_a_SOURCES = lib/fstree/fstree.c lib/fstree/fstree_from_file.c
-libfstree_a_SOURCES += lib/fstree/fstree_sort.c lib/fstree/fstree_from_dir.c
+libfstree_a_SOURCES += lib/fstree/fstree_sort.c
libfstree_a_SOURCES += lib/fstree/gen_inode_table.c lib/fstree/get_path.c
libfstree_a_SOURCES += lib/fstree/mknode.c
libfstree_a_SOURCES += lib/fstree/add_by_path.c lib/fstree/xattr.c
diff --git a/mkfs/Makemodule.am b/mkfs/Makemodule.am
index 1955852..f1e0d0d 100644
--- a/mkfs/Makemodule.am
+++ b/mkfs/Makemodule.am
@@ -1,4 +1,5 @@
gensquashfs_SOURCES = mkfs/mkfs.c mkfs/mkfs.h mkfs/options.c
+gensquashfs_SOURCES += mkfs/dirscan.c
gensquashfs_LDADD = libsqfshelper.a libsquashfs.la libfstree.a libutil.la
gensquashfs_LDADD += $(LIBSELINUX_LIBS)
gensquashfs_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/lib/fstree/fstree_from_dir.c b/mkfs/dirscan.c
index d68fafa..5cb955a 100644
--- a/lib/fstree/fstree_from_dir.c
+++ b/mkfs/dirscan.c
@@ -4,22 +4,7 @@
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "config.h"
-
-#include "fstree.h"
-#include "util.h"
-
-#ifdef HAVE_SYS_XATTR_H
-#include <sys/xattr.h>
-#endif
-#include <dirent.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
+#include "mkfs.h"
static char *get_file_path(tree_node_t *n, const char *name)
{
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index 0e374dc..bce98d8 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -19,12 +19,17 @@
#include "fstree.h"
#include "util.h"
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+
#include <getopt.h>
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <dirent.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
@@ -48,6 +53,16 @@ typedef struct {
char *comp_extra;
} options_t;
+enum {
+ DIR_SCAN_KEEP_TIME = 0x01,
+
+ DIR_SCAN_ONE_FILESYSTEM = 0x02,
+
+ DIR_SCAN_READ_XATTR = 0x04,
+};
+
void process_command_line(options_t *opt, int argc, char **argv);
+int fstree_from_dir(fstree_t *fs, const char *path, unsigned int flags);
+
#endif /* MKFS_H */