aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-22 11:01:09 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-22 11:28:23 +0100
commiteafaffa0f09b7c22eed906ef5356b1460d44da55 (patch)
treee77a1c3ddf714301b93810c2d123b6a7fcdc2ee8
parent435c9ef3de5797d7c49fa8fae12a02fd6bd209d6 (diff)
Cleanup: move all the compatibillity fluff to a dedicated "libcompat"
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--Makefile.am1
-rw-r--r--README.md3
-rw-r--r--include/common.h3
-rw-r--r--include/compat.h (renamed from include/util/compat.h)0
-rw-r--r--include/fstree.h2
-rw-r--r--lib/compat/Makemodule.am4
-rw-r--r--lib/compat/getline.c (renamed from lib/util/getline.c)4
-rw-r--r--lib/compat/getsubopt.c (renamed from lib/util/getsubopt.c)4
-rw-r--r--lib/compat/strndup.c (renamed from lib/util/strndup.c)4
-rw-r--r--lib/sqfs/id_table.c2
-rw-r--r--lib/sqfs/readdir.c2
-rw-r--r--lib/sqfs/write_inode.c2
-rw-r--r--lib/util/Makemodule.am8
-rw-r--r--mkfs/Makemodule.am4
-rw-r--r--tar/Makemodule.am5
-rw-r--r--tests/Makemodule.am4
-rw-r--r--unpack/Makemodule.am2
-rw-r--r--unpack/restore_fstree.c4
18 files changed, 32 insertions, 26 deletions
diff --git a/Makefile.am b/Makefile.am
index 2f65420..6502a26 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,7 @@ include doc/Makemodule.am
include lib/fstree/Makemodule.am
include lib/common/Makemodule.am
include lib/tar/Makemodule.am
+include lib/compat/Makemodule.am
include tar/Makemodule.am
include mkfs/Makemodule.am
include unpack/Makemodule.am
diff --git a/README.md b/README.md
index 6a6f1a0..67c1127 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,9 @@ The following components exist:
package. It uses `libutil.la` internally.
- `libcommon.a` built from files in `lib/common` contains a bunch
of commonly used code shared across the utilities.
+ - `libcompat.a` built from files in `lib/compat` contains minimal
+ implementations of POSIX or GNU functions that are not available on some
+ platforms.
The headers in `include` are stuffed with comments on functions an data
structures.
diff --git a/include/common.h b/include/common.h
index 684b047..f7e139f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -26,9 +26,8 @@
#include "sqfs/dir.h"
#include "sqfs/io.h"
-#include "util/compat.h"
#include "util/util.h"
-
+#include "compat.h"
#include "fstree.h"
#include "tar.h"
diff --git a/include/util/compat.h b/include/compat.h
index fae9d92..fae9d92 100644
--- a/include/util/compat.h
+++ b/include/compat.h
diff --git a/include/fstree.h b/include/fstree.h
index 5caac51..a63c593 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -15,7 +15,7 @@
#include <stdio.h>
#include "sqfs/predef.h"
-#include "util/compat.h"
+#include "compat.h"
typedef struct tree_node_t tree_node_t;
typedef struct file_info_t file_info_t;
diff --git a/lib/compat/Makemodule.am b/lib/compat/Makemodule.am
new file mode 100644
index 0000000..c197fb0
--- /dev/null
+++ b/lib/compat/Makemodule.am
@@ -0,0 +1,4 @@
+libcompat_a_SOURCES = lib/compat/getline.c lib/compat/getsubopt.c
+libcompat_a_SOURCES += lib/compat/strndup.c include/compat.h
+
+noinst_LIBRARIES += libcompat.a
diff --git a/lib/util/getline.c b/lib/compat/getline.c
index 996bef2..f330c6d 100644
--- a/lib/util/getline.c
+++ b/lib/compat/getline.c
@@ -1,11 +1,11 @@
-/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
* getline.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/compat.h"
+#include "compat.h"
#include <string.h>
#include <stdlib.h>
diff --git a/lib/util/getsubopt.c b/lib/compat/getsubopt.c
index 5cf19d1..d53a37d 100644
--- a/lib/util/getsubopt.c
+++ b/lib/compat/getsubopt.c
@@ -1,11 +1,11 @@
-/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
* getsubopt.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/compat.h"
+#include "compat.h"
#include <stdlib.h>
#include <string.h>
diff --git a/lib/util/strndup.c b/lib/compat/strndup.c
index 8031d23..dff79d7 100644
--- a/lib/util/strndup.c
+++ b/lib/compat/strndup.c
@@ -1,11 +1,11 @@
-/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
* strndup.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/compat.h"
+#include "compat.h"
#include <string.h>
#include <stdlib.h>
diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c
index 4080015..a320eca 100644
--- a/lib/sqfs/id_table.c
+++ b/lib/sqfs/id_table.c
@@ -11,7 +11,7 @@
#include "sqfs/super.h"
#include "sqfs/table.h"
#include "sqfs/error.h"
-#include "util/compat.h"
+#include "compat.h"
#include <stdlib.h>
#include <string.h>
diff --git a/lib/sqfs/readdir.c b/lib/sqfs/readdir.c
index d800cb7..8899475 100644
--- a/lib/sqfs/readdir.c
+++ b/lib/sqfs/readdir.c
@@ -10,7 +10,7 @@
#include "sqfs/meta_reader.h"
#include "sqfs/error.h"
#include "sqfs/dir.h"
-#include "util/compat.h"
+#include "compat.h"
#include <stdlib.h>
#include <string.h>
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index f1f8abf..5f0ef4c 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -11,7 +11,7 @@
#include "sqfs/error.h"
#include "sqfs/inode.h"
#include "sqfs/dir.h"
-#include "util/compat.h"
+#include "compat.h"
#include <string.h>
diff --git a/lib/util/Makemodule.am b/lib/util/Makemodule.am
index b5fef29..6a1a6a8 100644
--- a/lib/util/Makemodule.am
+++ b/lib/util/Makemodule.am
@@ -1,8 +1,6 @@
-libutil_la_SOURCES = include/util/util.h include/util/compat.h
-libutil_la_SOURCES += lib/util/str_table.c include/util/str_table.h
-libutil_la_SOURCES += lib/util/alloc.c lib/util/canonicalize_name.c
-libutil_la_SOURCES += lib/util/strndup.c lib/util/getline.c
-libutil_la_SOURCES += lib/util/getsubopt.c
+libutil_la_SOURCES = include/util/util.h include/util/str_table.h
+libutil_la_SOURCES += lib/util/str_table.c lib/util/canonicalize_name.c
+libutil_la_SOURCES += lib/util/alloc.c
libutil_la_CFLAGS = $(AM_CFLAGS)
libutil_la_CPPFLAGS = $(AM_CPPFLAGS)
libutil_la_LDFLAGS = $(AM_LDFLAGS)
diff --git a/mkfs/Makemodule.am b/mkfs/Makemodule.am
index 9fd8bed..f4dffa7 100644
--- a/mkfs/Makemodule.am
+++ b/mkfs/Makemodule.am
@@ -1,7 +1,7 @@
gensquashfs_SOURCES = mkfs/mkfs.c mkfs/mkfs.h mkfs/options.c
gensquashfs_SOURCES += mkfs/dirscan.c mkfs/selinux.c
-gensquashfs_LDADD = libcommon.a libsquashfs.la libfstree.a libutil.la
-gensquashfs_LDADD += $(LIBSELINUX_LIBS)
+gensquashfs_LDADD = libcommon.a libsquashfs.la libfstree.a
+gensquashfs_LDADD += libcompat.a libutil.la $(LIBSELINUX_LIBS)
gensquashfs_CPPFLAGS = $(AM_CPPFLAGS)
gensquashfs_CFLAGS = $(AM_CFLAGS) $(LIBSELINUX_CFLAGS)
diff --git a/tar/Makemodule.am b/tar/Makemodule.am
index e3f40d0..ec65d3a 100644
--- a/tar/Makemodule.am
+++ b/tar/Makemodule.am
@@ -1,7 +1,8 @@
sqfs2tar_SOURCES = tar/sqfs2tar.c
-sqfs2tar_LDADD = libcommon.a libsquashfs.la libtar.a libutil.la
+sqfs2tar_LDADD = libcommon.a libsquashfs.la libtar.a libcompat.a libutil.la
tar2sqfs_SOURCES = tar/tar2sqfs.c
-tar2sqfs_LDADD = libcommon.a libsquashfs.la libtar.a libfstree.a libutil.la
+tar2sqfs_LDADD = libcommon.a libsquashfs.la libtar.a
+tar2sqfs_LDADD += libfstree.a libcompat.a libutil.la
bin_PROGRAMS += sqfs2tar tar2sqfs
diff --git a/tests/Makemodule.am b/tests/Makemodule.am
index 45565bb..34b0238 100644
--- a/tests/Makemodule.am
+++ b/tests/Makemodule.am
@@ -78,10 +78,10 @@ test_tar_xattr_schily_CPPFLAGS = $(AM_CPPFLAGS)
test_tar_xattr_schily_CPPFLAGS += -DTESTPATH=$(top_srcdir)/tests/tar
fstree_fuzz_SOURCES = tests/fstree_fuzz.c
-fstree_fuzz_LDADD = libfstree.a libutil.la
+fstree_fuzz_LDADD = libfstree.a libcompat.a libutil.la
tar_fuzz_SOURCES = tests/tar_fuzz.c
-tar_fuzz_LDADD = libtar.a libutil.la
+tar_fuzz_LDADD = libtar.a libcompat.a libutil.la
check_PROGRAMS += test_mknode_simple test_mknode_slink test_mknode_reg
check_PROGRAMS += test_mknode_dir test_gen_inode_table test_add_by_path
diff --git a/unpack/Makemodule.am b/unpack/Makemodule.am
index 2609db4..b137787 100644
--- a/unpack/Makemodule.am
+++ b/unpack/Makemodule.am
@@ -2,6 +2,6 @@ rdsquashfs_SOURCES = unpack/rdsquashfs.c unpack/rdsquashfs.h
rdsquashfs_SOURCES += unpack/list_files.c unpack/options.c
rdsquashfs_SOURCES += unpack/restore_fstree.c unpack/describe.c
rdsquashfs_SOURCES += unpack/fill_files.c unpack/dump_xattrs.c
-rdsquashfs_LDADD = libcommon.a libsquashfs.la libutil.la
+rdsquashfs_LDADD = libcommon.a libcompat.a libsquashfs.la libutil.la
bin_PROGRAMS += rdsquashfs
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index dbcebfa..7cecf16 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -258,7 +258,7 @@ static int set_attribs(sqfs_xattr_reader_t *xattr,
goto fail;
}
}
-
+#endif
if (flags & UNPACK_CHOWN) {
if (fchownat(AT_FDCWD, path, n->uid, n->gid,
AT_SYMLINK_NOFOLLOW)) {
@@ -276,7 +276,7 @@ static int set_attribs(sqfs_xattr_reader_t *xattr,
goto fail;
}
}
-#endif
+
free(path);
return 0;
fail: