From eafaffa0f09b7c22eed906ef5356b1460d44da55 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 22 Nov 2019 11:01:09 +0100 Subject: Cleanup: move all the compatibillity fluff to a dedicated "libcompat" Signed-off-by: David Oberhollenzer --- Makefile.am | 1 + README.md | 3 ++ include/common.h | 3 +- include/compat.h | 124 +++++++++++++++++++++++++++++++++++++++++++++++ include/fstree.h | 2 +- include/util/compat.h | 124 ----------------------------------------------- lib/compat/Makemodule.am | 4 ++ lib/compat/getline.c | 50 +++++++++++++++++++ lib/compat/getsubopt.c | 45 +++++++++++++++++ lib/compat/strndup.c | 31 ++++++++++++ lib/sqfs/id_table.c | 2 +- lib/sqfs/readdir.c | 2 +- lib/sqfs/write_inode.c | 2 +- lib/util/Makemodule.am | 8 ++- lib/util/getline.c | 50 ------------------- lib/util/getsubopt.c | 45 ----------------- lib/util/strndup.c | 31 ------------ mkfs/Makemodule.am | 4 +- tar/Makemodule.am | 5 +- tests/Makemodule.am | 4 +- unpack/Makemodule.am | 2 +- unpack/restore_fstree.c | 4 +- 22 files changed, 276 insertions(+), 270 deletions(-) create mode 100644 include/compat.h delete mode 100644 include/util/compat.h create mode 100644 lib/compat/Makemodule.am create mode 100644 lib/compat/getline.c create mode 100644 lib/compat/getsubopt.c create mode 100644 lib/compat/strndup.c delete mode 100644 lib/util/getline.c delete mode 100644 lib/util/getsubopt.c delete mode 100644 lib/util/strndup.c 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/compat.h b/include/compat.h new file mode 100644 index 0000000..fae9d92 --- /dev/null +++ b/include/compat.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * util.h + * + * Copyright (C) 2019 David Oberhollenzer + */ +#ifndef COMPAT_H +#define COMPAT_H + +#if defined(__APPLE__) +#include + +#define htole16(x) OSSwapHostToLittleInt16(x) +#define htole32(x) OSSwapHostToLittleInt32(x) +#define htole64(x) OSSwapHostToLittleInt64(x) + +#define le32toh(x) OSSwapLittleToHostInt32(x) +#define le16toh(x) OSSwapLittleToHostInt16(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) +#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#include +#elif defined(_WIN32) || defined(__WINDOWS__) +#define htole16(x) (x) +#define htole32(x) (x) +#define htole64(x) (x) + +#define le16toh(x) (x) +#define le32toh(x) (x) +#define le64toh(x) (x) +#else +#include +#endif + +#if defined(_WIN32) || defined(__WINDOWS__) +#include "sqfs/inode.h" + +#define S_IFSOCK SQFS_INODE_MODE_SOCK +#define S_IFLNK SQFS_INODE_MODE_LNK +#define S_IFREG SQFS_INODE_MODE_REG +#define S_IFBLK SQFS_INODE_MODE_BLK +#define S_IFDIR SQFS_INODE_MODE_DIR +#define S_IFCHR SQFS_INODE_MODE_CHR +#define S_IFIFO SQFS_INODE_MODE_FIFO +#define S_IFMT SQFS_INODE_MODE_MASK + +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_ISUID SQFS_INODE_SET_UID +#define S_ISGID SQFS_INODE_SET_GID +#define S_ISVTX SQFS_INODE_STICKY + +#define S_IRWXU SQFS_INODE_OWNER_MASK +#define S_IRUSR SQFS_INODE_OWNER_R +#define S_IWUSR SQFS_INODE_OWNER_W +#define S_IXUSR SQFS_INODE_OWNER_X + +#define S_IRWXG SQFS_INODE_GROUP_MASK +#define S_IRGRP SQFS_INODE_GROUP_R +#define S_IWGRP SQFS_INODE_GROUP_W +#define S_IXGRP SQFS_INODE_GROUP_X + +#define S_IRWXO SQFS_INODE_OTHERS_MASK +#define S_IROTH SQFS_INODE_OTHERS_R +#define S_IWOTH SQFS_INODE_OTHERS_W +#define S_IXOTH SQFS_INODE_OTHERS_X + +struct stat { + sqfs_u32 st_dev; + sqfs_u32 st_ino; + sqfs_u16 st_mode; + sqfs_u16 st_nlink; + sqfs_u32 st_uid; + sqfs_u32 st_gid; + sqfs_u32 st_rdev; + sqfs_u64 st_size; + sqfs_u32 st_blksize; + sqfs_u32 st_blocks; + sqfs_u64 st_atime; + sqfs_u64 st_mtime; + sqfs_u64 st_ctime; +}; + +/* lifted from musl libc */ +#define major(x) \ + ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) )) + +#define minor(x) \ + ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) )) + +#define makedev(x,y) ( \ + (((x)&0xfffff000ULL) << 32) | \ + (((x)&0x00000fffULL) << 8) | \ + (((y)&0xffffff00ULL) << 12) | \ + (((y)&0x000000ffULL)) ) +#else +#include +#include + +#ifdef __linux__ +#include +#endif +#endif + +#ifndef HAVE_GETLINE +#include + +ssize_t getline(char **line, size_t *n, FILE *fp); +#endif + +#ifndef HAVE_STRNDUP +char *strndup(const char *str, size_t max_len); +#endif + +#ifndef HAVE_GETSUBOPT +int getsubopt(char **opt, char *const *keys, char **val); +#endif + +#endif /* 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 #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/include/util/compat.h b/include/util/compat.h deleted file mode 100644 index fae9d92..0000000 --- a/include/util/compat.h +++ /dev/null @@ -1,124 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * util.h - * - * Copyright (C) 2019 David Oberhollenzer - */ -#ifndef COMPAT_H -#define COMPAT_H - -#if defined(__APPLE__) -#include - -#define htole16(x) OSSwapHostToLittleInt16(x) -#define htole32(x) OSSwapHostToLittleInt32(x) -#define htole64(x) OSSwapHostToLittleInt64(x) - -#define le32toh(x) OSSwapLittleToHostInt32(x) -#define le16toh(x) OSSwapLittleToHostInt16(x) -#define le64toh(x) OSSwapLittleToHostInt64(x) -#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) -#include -#elif defined(_WIN32) || defined(__WINDOWS__) -#define htole16(x) (x) -#define htole32(x) (x) -#define htole64(x) (x) - -#define le16toh(x) (x) -#define le32toh(x) (x) -#define le64toh(x) (x) -#else -#include -#endif - -#if defined(_WIN32) || defined(__WINDOWS__) -#include "sqfs/inode.h" - -#define S_IFSOCK SQFS_INODE_MODE_SOCK -#define S_IFLNK SQFS_INODE_MODE_LNK -#define S_IFREG SQFS_INODE_MODE_REG -#define S_IFBLK SQFS_INODE_MODE_BLK -#define S_IFDIR SQFS_INODE_MODE_DIR -#define S_IFCHR SQFS_INODE_MODE_CHR -#define S_IFIFO SQFS_INODE_MODE_FIFO -#define S_IFMT SQFS_INODE_MODE_MASK - -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) - -#define S_ISUID SQFS_INODE_SET_UID -#define S_ISGID SQFS_INODE_SET_GID -#define S_ISVTX SQFS_INODE_STICKY - -#define S_IRWXU SQFS_INODE_OWNER_MASK -#define S_IRUSR SQFS_INODE_OWNER_R -#define S_IWUSR SQFS_INODE_OWNER_W -#define S_IXUSR SQFS_INODE_OWNER_X - -#define S_IRWXG SQFS_INODE_GROUP_MASK -#define S_IRGRP SQFS_INODE_GROUP_R -#define S_IWGRP SQFS_INODE_GROUP_W -#define S_IXGRP SQFS_INODE_GROUP_X - -#define S_IRWXO SQFS_INODE_OTHERS_MASK -#define S_IROTH SQFS_INODE_OTHERS_R -#define S_IWOTH SQFS_INODE_OTHERS_W -#define S_IXOTH SQFS_INODE_OTHERS_X - -struct stat { - sqfs_u32 st_dev; - sqfs_u32 st_ino; - sqfs_u16 st_mode; - sqfs_u16 st_nlink; - sqfs_u32 st_uid; - sqfs_u32 st_gid; - sqfs_u32 st_rdev; - sqfs_u64 st_size; - sqfs_u32 st_blksize; - sqfs_u32 st_blocks; - sqfs_u64 st_atime; - sqfs_u64 st_mtime; - sqfs_u64 st_ctime; -}; - -/* lifted from musl libc */ -#define major(x) \ - ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) )) - -#define minor(x) \ - ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) )) - -#define makedev(x,y) ( \ - (((x)&0xfffff000ULL) << 32) | \ - (((x)&0x00000fffULL) << 8) | \ - (((y)&0xffffff00ULL) << 12) | \ - (((y)&0x000000ffULL)) ) -#else -#include -#include - -#ifdef __linux__ -#include -#endif -#endif - -#ifndef HAVE_GETLINE -#include - -ssize_t getline(char **line, size_t *n, FILE *fp); -#endif - -#ifndef HAVE_STRNDUP -char *strndup(const char *str, size_t max_len); -#endif - -#ifndef HAVE_GETSUBOPT -int getsubopt(char **opt, char *const *keys, char **val); -#endif - -#endif /* COMPAT_H */ 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/compat/getline.c b/lib/compat/getline.c new file mode 100644 index 0000000..f330c6d --- /dev/null +++ b/lib/compat/getline.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * getline.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "config.h" +#include "compat.h" + +#include +#include + +#ifndef HAVE_GETLINE +ssize_t getline(char **line, size_t *n, FILE *fp) +{ + size_t new_cap, len = 0, cap = 0; + char *buffer = NULL, *new; + int c; + + if (feof(fp) || ferror(fp)) + return -1; + + do { + c = fgetc(fp); + + if (ferror(fp)) + return -1; + + if (c == EOF) + c = '\n'; + + if (len == cap) { + new_cap = cap ? cap * 2 : 32; + new = realloc(buffer, new_cap); + + if (new == NULL) + return -1; + + buffer = new; + cap = new_cap; + } + + buffer[len++] = c; + } while (c != '\n'); + + *line = buffer; + *n = len; + return len; +} +#endif diff --git a/lib/compat/getsubopt.c b/lib/compat/getsubopt.c new file mode 100644 index 0000000..d53a37d --- /dev/null +++ b/lib/compat/getsubopt.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * getsubopt.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "config.h" +#include "compat.h" + +#include +#include + +#ifndef HAVE_GETSUBOPT +int getsubopt(char **opt, char *const *keys, char **val) +{ + char *str = *opt; + size_t i, len; + + *val = NULL; + *opt = strchr(str, ','); + + if (*opt == NULL) { + *opt = str + strlen(str); + } else { + *(*opt)++ = '\0'; + } + + for (i = 0; keys[i]; ++i) { + len = strlen(keys[i]); + + if (strncmp(keys[i], str, len) != 0) + continue; + + if (str[len] != '=' && str[len] != '\0') + continue; + + if (str[len] == '=') + *val = str + len + 1; + + return i; + } + + return -1; +} +#endif diff --git a/lib/compat/strndup.c b/lib/compat/strndup.c new file mode 100644 index 0000000..dff79d7 --- /dev/null +++ b/lib/compat/strndup.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * strndup.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "config.h" +#include "compat.h" + +#include +#include + +#ifndef HAVE_STRNDUP +char *strndup(const char *str, size_t max_len) +{ + size_t len = 0; + char *out; + + while (len < max_len && str[len] != '\0') + ++len; + + out = malloc(len + 1); + + if (out != NULL) { + memcpy(out, str, len); + out[len] = '\0'; + } + + return out; +} +#endif 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 #include 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 #include 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 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/lib/util/getline.c b/lib/util/getline.c deleted file mode 100644 index 996bef2..0000000 --- a/lib/util/getline.c +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * getline.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "config.h" -#include "util/compat.h" - -#include -#include - -#ifndef HAVE_GETLINE -ssize_t getline(char **line, size_t *n, FILE *fp) -{ - size_t new_cap, len = 0, cap = 0; - char *buffer = NULL, *new; - int c; - - if (feof(fp) || ferror(fp)) - return -1; - - do { - c = fgetc(fp); - - if (ferror(fp)) - return -1; - - if (c == EOF) - c = '\n'; - - if (len == cap) { - new_cap = cap ? cap * 2 : 32; - new = realloc(buffer, new_cap); - - if (new == NULL) - return -1; - - buffer = new; - cap = new_cap; - } - - buffer[len++] = c; - } while (c != '\n'); - - *line = buffer; - *n = len; - return len; -} -#endif diff --git a/lib/util/getsubopt.c b/lib/util/getsubopt.c deleted file mode 100644 index 5cf19d1..0000000 --- a/lib/util/getsubopt.c +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * getsubopt.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "config.h" -#include "util/compat.h" - -#include -#include - -#ifndef HAVE_GETSUBOPT -int getsubopt(char **opt, char *const *keys, char **val) -{ - char *str = *opt; - size_t i, len; - - *val = NULL; - *opt = strchr(str, ','); - - if (*opt == NULL) { - *opt = str + strlen(str); - } else { - *(*opt)++ = '\0'; - } - - for (i = 0; keys[i]; ++i) { - len = strlen(keys[i]); - - if (strncmp(keys[i], str, len) != 0) - continue; - - if (str[len] != '=' && str[len] != '\0') - continue; - - if (str[len] == '=') - *val = str + len + 1; - - return i; - } - - return -1; -} -#endif diff --git a/lib/util/strndup.c b/lib/util/strndup.c deleted file mode 100644 index 8031d23..0000000 --- a/lib/util/strndup.c +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * strndup.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "config.h" -#include "util/compat.h" - -#include -#include - -#ifndef HAVE_STRNDUP -char *strndup(const char *str, size_t max_len) -{ - size_t len = 0; - char *out; - - while (len < max_len && str[len] != '\0') - ++len; - - out = malloc(len + 1); - - if (out != NULL) { - memcpy(out, str, len); - out[len] = '\0'; - } - - return out; -} -#endif 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: -- cgit v1.2.3