<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Fix libmount build under uClibc

See https://bugs.gentoo.org/show_bug.cgi?id=406303
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/util-linux/files/util-linux-2.21.1-no-printf-alloc.patch?revision=1.2

[Gustavo: Ported to util-linux-2.26]

Signed-off-by: Gustavo Zacarias &lt;gustavo@zacarias.com.ar&gt;

--- configure.ac
+++ configure.ac
@@ -907,7 +907,6 @@
 )
 UL_BUILD_INIT([libmount])
 UL_REQUIRES_BUILD([libmount], [libblkid])
-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
 AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
 AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes])
 AS_IF([test "x$build_libmount" = xyes], [
--- libmount/src/tab_parse.c
+++ libmount/src/tab_parse.c
@@ -38,6 +38,10 @@
 	memset(pa, 0, sizeof(*pa));
 }
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+# define UL_SCNsA "%s"
+#endif
+
 static int next_number(char **s, int *num)
 {
 	char *end = NULL;
@@ -68,16 +72,31 @@
 	int rc, n = 0, xrc;
 	char *src = NULL, *fstype = NULL, *optstr = NULL;
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+	size_t len = strlen(s) + 1;
+	src = malloc(len);
+	fstype = malloc(len);
+	fs-&gt;target = malloc(len);
+	optstr = malloc(len);
+#endif
+
 	rc = sscanf(s,	UL_SCNsA" "	/* (1) source */
 			UL_SCNsA" "	/* (2) target */
 			UL_SCNsA" "	/* (3) FS type */
 			UL_SCNsA" "	/* (4) options */
 			"%n",		/* byte count */
 
+#ifdef HAVE_SCANF_MS_MODIFIER
 			&amp;src,
 			&amp;fs-&gt;target,
 			&amp;fstype,
 			&amp;optstr,
+#else
+			src,
+			fs-&gt;target,
+			fstype,
+			optstr,
+#endif
 			&amp;n);
 	xrc = rc;
 
@@ -143,6 +162,16 @@
 	unsigned int maj, min;
 	char *fstype = NULL, *src = NULL, *p;
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+	size_t len = strlen(s) + 1;
+	fs-&gt;root = malloc(len);
+	fs-&gt;target = malloc(len);
+	fs-&gt;vfs_optstr = malloc(len);
+	fs-&gt;fs_optstr = malloc(len);
+	fstype = malloc(len);
+	src = malloc(len);
+#endif
+
 	rc = sscanf(s,	"%d "		/* (1) id */
 			"%d "		/* (2) parent */
 			"%u:%u "	/* (3) maj:min */
@@ -154,9 +183,15 @@
 			&amp;fs-&gt;id,
 			&amp;fs-&gt;parent,
 			&amp;maj, &amp;min,
+#ifdef HAVE_SCANF_MS_MODIFIER
 			&amp;fs-&gt;root,
 			&amp;fs-&gt;target,
 			&amp;fs-&gt;vfs_optstr,
+#else
+			fs-&gt;root,
+			fs-&gt;target,
+			fs-&gt;vfs_optstr,
+#endif
 			&amp;end);
 
 	if (rc &gt;= 7 &amp;&amp; end &gt; 0)
@@ -176,9 +211,15 @@
 			UL_SCNsA" "	/* (9) source */
 			UL_SCNsA,	/* (10) fs options (fs specific) */
 
+#ifdef HAVE_SCANF_MS_MODIFIER
 			&amp;fstype,
 			&amp;src,
 			&amp;fs-&gt;fs_optstr);
+#else
+			fstype,
+			src,
+			fs-&gt;fs_optstr);
+#endif
 
 	if (rc &gt;= 10) {
 		size_t sz;
@@ -297,14 +338,25 @@
 	int rc;
 	char *src = NULL;
 
+#ifndef HAVE_SCANF_MS_MODIFIER
+	size_t len = strlen(s) + 1;
+	src = malloc(len);
+	fs-&gt;swaptype = malloc(len);
+#endif
+
 	rc = sscanf(s,	UL_SCNsA" "	/* (1) source */
 			UL_SCNsA" "	/* (2) type */
 			"%ju"		/* (3) size */
 			"%ju"		/* (4) used */
 			"%d",		/* priority */
 
+#ifdef HAVE_SCANF_MS_MODIFIER
 			&amp;src,
 			&amp;fs-&gt;swaptype,
+#else
+			src,
+			fs-&gt;swaptype,
+#endif
 			&amp;fsz,
 			&amp;usz,
 			&amp;fs-&gt;priority);
</pre></body></html>