mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-01-04 13:47:35 -08:00
sys-fs/reiserfsprogs: fix building on musl
The patch addition is safe for glibc, since all additions are behind "#if !defined(__GLIBC__)". The patches are from void-linux. On musl it also requires sys-libs/obstack-standalone, and manual add of "-lobstack" to linking (needed by debugreiserfs). Also noted that we are missing sys-fs/e2fsprogs in R/DEP, for which I've revbumped. Closes: https://bugs.gentoo.org/832972 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
This commit is contained in:
parent
1689da0dbd
commit
9ae65d39ea
281
sys-fs/reiserfsprogs/files/reiserfsprogs-3.6.27-musl.patch
Normal file
281
sys-fs/reiserfsprogs/files/reiserfsprogs-3.6.27-musl.patch
Normal file
@ -0,0 +1,281 @@
|
||||
https://github.com/void-linux/void-packages/tree/master/srcpkgs/reiserfsprogs/patches
|
||||
|
||||
Define _GNU_SOURCE for the declaration of loff_t in fcntl.h
|
||||
Add missing typedefs for __compar_fn_t and compare_fn_t for
|
||||
non __GLIBC__ case.
|
||||
|
||||
--- a/include/misc.h
|
||||
+++ b/include/misc.h
|
||||
@@ -35,6 +35,11 @@
|
||||
|
||||
#define INVAL_PTR (void *)-1
|
||||
|
||||
+#if !defined(__GLIBC__)
|
||||
+typedef int (*__compar_fn_t) (const void*, const void*);
|
||||
+typedef __compar_fn_t comparison_fn_t;
|
||||
+#endif
|
||||
+
|
||||
void check_memory_msg(void);
|
||||
void die(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
|
||||
void *getmem(int size);
|
||||
See https://www.openwall.com/lists/musl/2013/01/23/6
|
||||
--- a/include/reiserfs_lib.h
|
||||
+++ b/include/reiserfs_lib.h
|
||||
@@ -3,6 +3,10 @@
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
+#if !defined(__GLIBC__)
|
||||
+#define loff_t off_t
|
||||
+#endif
|
||||
+
|
||||
#ifndef REISERFSPROGS_LIB_H
|
||||
#define REISERFSPROGS_LIB_H
|
||||
|
||||
Add definitions for LONG_LONG_MIN and _MAX derived
|
||||
from the values for int64_t.
|
||||
|
||||
--- a/resize_reiserfs/resize_reiserfs.c
|
||||
+++ b/resize_reiserfs/resize_reiserfs.c
|
||||
@@ -15,6 +15,13 @@
|
||||
#include "resize.h"
|
||||
#include <limits.h>
|
||||
|
||||
+#if !defined(__GLIBC__)
|
||||
+/* These are not defined in musl libc */
|
||||
+#include <stdint.h>
|
||||
+#define LONG_LONG_MIN INT64_MIN
|
||||
+#define LONG_LONG_MAX INT64_MAX
|
||||
+#endif
|
||||
+
|
||||
static int opt_banner = 0;
|
||||
static int opt_skipj = 0;
|
||||
int opt_force = 0;
|
||||
--- a/reiserfscore/prints.c
|
||||
+++ b/reiserfscore/prints.c
|
||||
@@ -7,8 +7,11 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include <stdarg.h>
|
||||
+#include <stdint.h>
|
||||
#include <limits.h>
|
||||
+#if defined(__GLIBC__)
|
||||
#include <printf.h>
|
||||
+#endif
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
@@ -16,6 +19,38 @@
|
||||
# include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
+
|
||||
+char ftypelet (mode_t mode)
|
||||
+{
|
||||
+ if (S_ISBLK (mode))
|
||||
+ return 'b';
|
||||
+ if (S_ISCHR (mode))
|
||||
+ return 'c';
|
||||
+ if (S_ISDIR (mode))
|
||||
+ return 'd';
|
||||
+ if (S_ISREG (mode))
|
||||
+ return '-';
|
||||
+ if (S_ISFIFO (mode))
|
||||
+ return 'p';
|
||||
+ if (S_ISLNK (mode))
|
||||
+ return 'l';
|
||||
+ if (S_ISSOCK (mode))
|
||||
+ return 's';
|
||||
+ return '?';
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int rwx (FILE * stream, mode_t mode)
|
||||
+{
|
||||
+ return fprintf (stream, "%c%c%c",
|
||||
+ (mode & S_IRUSR) ? 'r' : '-',
|
||||
+ (mode & S_IWUSR) ? 'w' : '-',
|
||||
+ (mode & S_IXUSR) ? 'x' : '-');
|
||||
+}
|
||||
+
|
||||
+#if defined(__GLIBC__)
|
||||
+
|
||||
+
|
||||
#ifndef HAVE_REGISTER_PRINTF_SPECIFIER
|
||||
#define register_printf_specifier(x, y, z) register_printf_function(x, y, z)
|
||||
static int arginfo_ptr(const struct printf_info *info, size_t n, int *argtypes)
|
||||
@@ -129,33 +164,6 @@ static int print_disk_child(FILE * stream,
|
||||
FPRINTF;
|
||||
}
|
||||
|
||||
-char ftypelet(mode_t mode)
|
||||
-{
|
||||
- if (S_ISBLK(mode))
|
||||
- return 'b';
|
||||
- if (S_ISCHR(mode))
|
||||
- return 'c';
|
||||
- if (S_ISDIR(mode))
|
||||
- return 'd';
|
||||
- if (S_ISREG(mode))
|
||||
- return '-';
|
||||
- if (S_ISFIFO(mode))
|
||||
- return 'p';
|
||||
- if (S_ISLNK(mode))
|
||||
- return 'l';
|
||||
- if (S_ISSOCK(mode))
|
||||
- return 's';
|
||||
- return '?';
|
||||
-}
|
||||
-
|
||||
-static int rwx(FILE * stream, mode_t mode)
|
||||
-{
|
||||
- return fprintf(stream, "%c%c%c",
|
||||
- (mode & S_IRUSR) ? 'r' : '-',
|
||||
- (mode & S_IWUSR) ? 'w' : '-',
|
||||
- (mode & S_IXUSR) ? 'x' : '-');
|
||||
-}
|
||||
-
|
||||
/* %M */
|
||||
static int print_sd_mode(FILE * stream,
|
||||
const struct printf_info *info,
|
||||
@@ -211,6 +219,140 @@ void reiserfs_warning(FILE * fp, const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
+#else /* defined(__GLIBC__) */
|
||||
+
|
||||
+typedef void* void_ptr;
|
||||
+
|
||||
+void reiserfs_warning (FILE * fp, const char * fmt, ...)
|
||||
+{
|
||||
+ char * buffer;
|
||||
+ int len;
|
||||
+ char format_buf[32];
|
||||
+ char* dst = format_buf;
|
||||
+ char* end = &dst[30];
|
||||
+ const struct buffer_head * bh;
|
||||
+ const struct item_head * ih;
|
||||
+ const struct disk_child * dc;
|
||||
+ const struct reiserfs_key * key;
|
||||
+ uint16_t mode;
|
||||
+#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
+ const unsigned char *uuid;
|
||||
+ char uuid_buf[37];
|
||||
+#endif
|
||||
+ va_list args;
|
||||
+ int esc = 0;
|
||||
+
|
||||
+ va_start (args, fmt);
|
||||
+ while (*fmt) {
|
||||
+ int ch = *fmt++;
|
||||
+ if (esc) {
|
||||
+ switch (ch) {
|
||||
+ case '%':
|
||||
+ fputc(ch, fp);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'b': // block head
|
||||
+ bh = (const struct buffer_head *) va_arg(args, void_ptr);
|
||||
+ len = asprintf(&buffer, "level=%d, nr_items=%d, free_space=%d rdkey",
|
||||
+ B_LEVEL (bh), B_NR_ITEMS (bh), B_FREE_SPACE (bh));
|
||||
+ *dst++ = 's';
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, buffer);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'K': // short key
|
||||
+ key = (const struct reiserfs_key *) va_arg(args, void_ptr);
|
||||
+ len = asprintf(&buffer, "[%u %u]", get_key_dirid (key),
|
||||
+ get_key_objectid (key));
|
||||
+ *dst++ = 's';
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, buffer);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'k': // key
|
||||
+ key = (const struct reiserfs_key *) va_arg(args, void_ptr);
|
||||
+ len = asprintf(&buffer, "[%u %u 0x%Lx %s (%d)]",
|
||||
+ get_key_dirid (key), get_key_objectid (key),
|
||||
+ (unsigned long long)get_offset (key), key_of_what (key), get_type (key));
|
||||
+ *dst++ = 's';
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, buffer);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'H': // item head
|
||||
+ ih = (const struct item_head *) va_arg(args, void_ptr);
|
||||
+ len = asprintf(&buffer, "%u %u 0x%Lx %s (%d), "
|
||||
+ "len %u, location %u entry count %u, fsck need %u, format %s",
|
||||
+ get_key_dirid (&ih->ih_key), get_key_objectid (&ih->ih_key),
|
||||
+ (unsigned long long)get_offset (&ih->ih_key), key_of_what (&ih->ih_key),
|
||||
+ get_type (&ih->ih_key), get_ih_item_len (ih), get_ih_location (ih),
|
||||
+ get_ih_entry_count (ih), get_ih_flags (ih),
|
||||
+ get_ih_key_format (ih) == KEY_FORMAT_2 ?
|
||||
+ "new" :
|
||||
+ ((get_ih_key_format (ih) == KEY_FORMAT_1) ? "old" : "BAD"));
|
||||
+ *dst++ = 's';
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, buffer);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'y': // disk child
|
||||
+ dc = (const struct disk_child *) va_arg(args, void_ptr);
|
||||
+ len = asprintf(&buffer, "[dc_number=%u, dc_size=%u]", get_dc_child_blocknr (dc),
|
||||
+ get_dc_child_size (dc));
|
||||
+ *dst++ = 's';
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, buffer);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'M': // sd mode
|
||||
+ mode = (mode_t) va_arg(args, void_ptr);
|
||||
+ fputc(ftypelet (mode), fp);
|
||||
+ rwx (fp, (mode & 0700) << 0);
|
||||
+ rwx (fp, (mode & 0070) << 3);
|
||||
+ rwx (fp, (mode & 0007) << 6);
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case 'U': // UUID
|
||||
+#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
+ uuid = (const unsigned char *) va_arg(args, void_ptr);
|
||||
+ uuid_buf[36] = '\0';
|
||||
+ uuid_unparse(uuid, uuid_buf);
|
||||
+ fprintf(fp, "%s", uuid_buf);
|
||||
+#else
|
||||
+ fprintf(fp, "<no libuuid installed>");
|
||||
+#endif
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ case '-': case '+': case '#': case '.':
|
||||
+ case '0': case '1': case '2': case '3': case '4':
|
||||
+ case '5': case '6': case '7': case '8': case '9':
|
||||
+ case 'l': case 'L': case 'h':
|
||||
+ // non-terminal format modifiers
|
||||
+ if (dst < end)
|
||||
+ *dst++ = ch;
|
||||
+ break;
|
||||
+ default:
|
||||
+ *dst++ = ch;
|
||||
+ *dst = '\0';
|
||||
+ fprintf(fp, format_buf, va_arg(args, void_ptr));
|
||||
+ esc = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else if (ch == '%') {
|
||||
+ esc = 1;
|
||||
+ dst = format_buf;
|
||||
+ end = &dst[30]; // leave room for final "s\0"
|
||||
+ *dst++ = ch;
|
||||
+ } else {
|
||||
+ fputc(ch, fp);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ va_end (args);
|
||||
+}
|
||||
+
|
||||
+#endif /* !defined(__GLIBC__) */
|
||||
+
|
||||
static void print_directory_item(FILE *fp, reiserfs_filsys_t fs,
|
||||
struct buffer_head *bh, struct item_head *ih)
|
||||
{
|
||||
@ -18,10 +18,14 @@ IUSE="static-libs"
|
||||
PATCHES=(
|
||||
"${FILESDIR}/${PN}-3.6.25-no_acl.patch"
|
||||
"${FILESDIR}/${PN}-3.6.27-loff_t.patch"
|
||||
"${FILESDIR}/${PN}-3.6.27-musl.patch"
|
||||
)
|
||||
|
||||
# Needed for libuuid
|
||||
RDEPEND="sys-apps/util-linux"
|
||||
RDEPEND="
|
||||
sys-apps/util-linux
|
||||
sys-fs/e2fsprogs
|
||||
elibc_musl? ( sys-libs/obstack-standalone )
|
||||
"
|
||||
DEPEND="${RDEPEND}"
|
||||
|
||||
src_prepare() {
|
||||
@ -31,6 +35,7 @@ src_prepare() {
|
||||
|
||||
src_configure() {
|
||||
append-flags -std=gnu89 #427300
|
||||
use elibc_musl && append-ldflags -lobstack
|
||||
|
||||
local myeconfargs=(
|
||||
--bindir="${EPREFIX}/bin"
|
||||
Loading…
x
Reference in New Issue
Block a user