81b2be5ea206300eb705cfda1c9f800e484d5b35
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / util-linux / 0001-sscanf-no-ms-as.patch
1 Fix libmount build under uClibc
2
3 See https://bugs.gentoo.org/show_bug.cgi?id=406303
4 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
5
6 [Gustavo: Ported to util-linux-2.26]
7
8 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
9
10 diff -Nura util-linux-2.26.orig/configure.ac util-linux-2.26/configure.ac
11 --- util-linux-2.26.orig/configure.ac   2015-02-19 09:11:13.146192401 -0300
12 +++ util-linux-2.26/configure.ac        2015-02-20 08:13:32.740006582 -0300
13 @@ -840,7 +840,6 @@
14  )
15  UL_BUILD_INIT([libmount])
16  UL_REQUIRES_BUILD([libmount], [libblkid])
17 -UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
18  AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
19  AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes])
20  
21 diff -Nura util-linux-2.26.orig/libmount/src/tab_parse.c util-linux-2.26/libmount/src/tab_parse.c
22 --- util-linux-2.26.orig/libmount/src/tab_parse.c       2015-02-16 09:57:34.070017496 -0300
23 +++ util-linux-2.26/libmount/src/tab_parse.c    2015-02-20 08:13:32.741006617 -0300
24 @@ -22,6 +22,10 @@
25  #include "pathnames.h"
26  #include "strutils.h"
27  
28 +#ifndef HAVE_SCANF_MS_MODIFIER
29 +# define UL_SCNsA "%s"
30 +#endif
31 +
32  static int next_number(char **s, int *num)
33  {
34         char *end = NULL;
35 @@ -52,16 +56,31 @@
36         int rc, n = 0, xrc;
37         char *src = NULL, *fstype = NULL, *optstr = NULL;
38  
39 +#ifndef HAVE_SCANF_MS_MODIFIER
40 +       size_t len = strlen(s) + 1;
41 +       src = malloc(len);
42 +       fstype = malloc(len);
43 +       fs->target = malloc(len);
44 +       optstr = malloc(len);
45 +#endif
46 +
47         rc = sscanf(s,  UL_SCNsA" "     /* (1) source */
48                         UL_SCNsA" "     /* (2) target */
49                         UL_SCNsA" "     /* (3) FS type */
50                         UL_SCNsA" "     /* (4) options */
51                         "%n",           /* byte count */
52  
53 +#ifdef HAVE_SCANF_MS_MODIFIER
54                         &src,
55                         &fs->target,
56                         &fstype,
57                         &optstr,
58 +#else
59 +                       src,
60 +                       fs->target,
61 +                       fstype,
62 +                       optstr,
63 +#endif
64                         &n);
65         xrc = rc;
66  
67 @@ -127,6 +146,16 @@
68         unsigned int maj, min;
69         char *fstype = NULL, *src = NULL, *p;
70  
71 +#ifndef HAVE_SCANF_MS_MODIFIER
72 +       size_t len = strlen(s) + 1;
73 +       fs->root = malloc(len);
74 +       fs->target = malloc(len);
75 +       fs->vfs_optstr = malloc(len);
76 +       fs->fs_optstr = malloc(len);
77 +       fstype = malloc(len);
78 +       src = malloc(len);
79 +#endif
80 +
81         rc = sscanf(s,  "%d "           /* (1) id */
82                         "%d "           /* (2) parent */
83                         "%u:%u "        /* (3) maj:min */
84 @@ -138,9 +167,15 @@
85                         &fs->id,
86                         &fs->parent,
87                         &maj, &min,
88 +#ifdef HAVE_SCANF_MS_MODIFIER
89                         &fs->root,
90                         &fs->target,
91                         &fs->vfs_optstr,
92 +#else
93 +                       fs->root,
94 +                       fs->target,
95 +                       fs->vfs_optstr,
96 +#endif
97                         &end);
98  
99         if (rc >= 7 && end > 0)
100 @@ -160,9 +195,15 @@
101                         UL_SCNsA" "     /* (9) source */
102                         UL_SCNsA,       /* (10) fs options (fs specific) */
103  
104 +#ifdef HAVE_SCANF_MS_MODIFIER
105                         &fstype,
106                         &src,
107                         &fs->fs_optstr);
108 +#else
109 +                       fstype,
110 +                       src,
111 +                       fs->fs_optstr);
112 +#endif
113  
114         if (rc >= 10) {
115                 size_t sz;
116 @@ -281,14 +322,25 @@
117         int rc;
118         char *src = NULL;
119  
120 +#ifndef HAVE_SCANF_MS_MODIFIER
121 +       size_t len = strlen(s) + 1;
122 +       src = malloc(len);
123 +       fs->swaptype = malloc(len);
124 +#endif
125 +
126         rc = sscanf(s,  UL_SCNsA" "     /* (1) source */
127                         UL_SCNsA" "     /* (2) type */
128                         "%ju"           /* (3) size */
129                         "%ju"           /* (4) used */
130                         "%d",           /* priority */
131  
132 +#ifdef HAVE_SCANF_MS_MODIFIER
133                         &src,
134                         &fs->swaptype,
135 +#else
136 +                       src,
137 +                       fs->swaptype,
138 +#endif
139                         &fsz,
140                         &usz,
141                         &fs->priority);