aboutsummaryrefslogtreecommitdiffstats
path: root/meta-systemd/recipes-core/systemd/systemd/format-replace-m-uclibc.patch
blob: dd86121bb8277f327734021df6714c8231fb7f33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
Patch from Henning. %m is a glibc only thing. For uclibc we need to do it
differently. So we use static strings instead of mallocing them and free'ing

I dont know if upstream systemd have plans to make systemd work on non
glibc system libraries if not then this patch would not make sense for 
upstream

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: git/src/mount-setup.c
===================================================================
--- git.orig/src/mount-setup.c	2012-01-26 21:15:12.573084007 -0800
+++ git/src/mount-setup.c	2012-01-26 21:15:16.005084174 -0800
@@ -182,10 +182,10 @@
         (void) fgets(buf, sizeof(buf), f);
 
         for (;;) {
-                char *controller;
+                char controller[30];
                 int enabled = 0;
 
-                if (fscanf(f, "%ms %*i %*i %i", &controller, &enabled) != 2) {
+                if (fscanf(f, "%s %*i %*i %i", controller, &enabled) != 2) {
 
                         if (feof(f))
                                 break;
@@ -196,14 +196,12 @@
                 }
 
                 if (!enabled) {
-                        free(controller);
                         continue;
                 }
 
                 r = set_put(controllers, controller);
                 if (r < 0) {
                         log_error("Failed to add controller to set.");
-                        free(controller);
                         goto finish;
                 }
         }
@@ -273,7 +271,6 @@
                 p.fatal = false;
 
                 r = mount_one(&p, true);
-                free(controller);
                 free(where);
 
                 if (r < 0) {
Index: git/src/socket-util.c
===================================================================
--- git.orig/src/socket-util.c	2012-01-26 21:15:12.593084008 -0800
+++ git/src/socket-util.c	2012-01-26 21:15:16.005084174 -0800
@@ -192,7 +192,7 @@
 int socket_address_parse_netlink(SocketAddress *a, const char *s) {
         int family;
         unsigned group = 0;
-        char* sfamily = NULL;
+        char sfamily[50];
         assert(a);
         assert(s);
 
@@ -200,17 +200,14 @@
         a->type = SOCK_RAW;
 
         errno = 0;
-        if (sscanf(s, "%ms %u", &sfamily, &group) < 1)
+        if (sscanf(s, "%49s %u", &sfamily, &group) < 1)
                 return errno ? -errno : -EINVAL;
 
         if ((family = netlink_family_from_string(sfamily)) < 0)
                 if (safe_atoi(sfamily, &family) < 0) {
-                        free(sfamily);
                         return -EINVAL;
                 }
 
-        free(sfamily);
-
         a->sockaddr.nl.nl_family = AF_NETLINK;
         a->sockaddr.nl.nl_groups = group;
 
Index: git/src/swap.c
===================================================================
--- git.orig/src/swap.c	2012-01-26 21:15:12.593084008 -0800
+++ git/src/swap.c	2012-01-26 21:15:16.005084174 -0800
@@ -1049,11 +1049,12 @@
         (void) fscanf(m->proc_swaps, "%*s %*s %*s %*s %*s\n");
 
         for (i = 1;; i++) {
-                char *dev = NULL, *d;
+                char *d;
+                char dev[20];
                 int prio = 0, k;
 
                 if ((k = fscanf(m->proc_swaps,
-                                "%ms "  /* device/file */
+                                "%19s "  /* device/file */
                                 "%*s "  /* type of swap */
                                 "%*s "  /* swap size */
                                 "%*s "  /* used */
@@ -1064,12 +1065,10 @@
                                 break;
 
                         log_warning("Failed to parse /proc/swaps:%u.", i);
-                        free(dev);
                         continue;
                 }
 
                 d = cunescape(dev);
-                free(dev);
 
                 if (!d)
                         return -ENOMEM;
Index: git/src/tmpfiles.c
===================================================================
--- git.orig/src/tmpfiles.c	2012-01-26 21:15:12.617084010 -0800
+++ git/src/tmpfiles.c	2012-01-26 23:17:01.185437712 -0800
@@ -73,8 +73,8 @@
 typedef struct Item {
         ItemType type;
 
-        char *path;
-        char *argument;
+        char path[50];
+        char argument[50];
         uid_t uid;
         gid_t gid;
         mode_t mode;
@@ -822,7 +822,6 @@
         case CREATE_CHAR_DEVICE:
         case CREATE_BLOCK_DEVICE:
         case IGNORE_PATH:
-        case RELABEL_PATH:
         case RECURSIVE_RELABEL_PATH:
         case WRITE_FILE:
                 break;
@@ -858,8 +857,6 @@
 static void item_free(Item *i) {
         assert(i);
 
-        free(i->path);
-        free(i->argument);
         free(i);
 }
 
@@ -906,7 +903,7 @@
 
 static int parse_line(const char *fname, unsigned line, const char *buffer) {
         Item *i, *existing;
-        char *mode = NULL, *user = NULL, *group = NULL, *age = NULL;
+        char mode[50], user[50], group[50], age[50];
         char type;
         Hashmap *h;
         int r, n = -1;
@@ -923,18 +920,18 @@
 
         if (sscanf(buffer,
                    "%c "
-                   "%ms "
-                   "%ms "
-                   "%ms "
-                   "%ms "
-                   "%ms "
+                   "%s "
+                   "%s "
+                   "%s "
+                   "%s "
+                   "%s "
                    "%n",
                    &type,
                    &i->path,
-                   &mode,
-                   &user,
-                   &group,
-                   &age,
+                   mode,
+                   user,
+                   group,
+                   age,
                    &n) < 2) {
                 log_error("[%s:%u] Syntax error.", fname, line);
                 r = -EIO;
@@ -944,7 +941,7 @@
         if (n >= 0)  {
                 n += strspn(buffer+n, WHITESPACE);
                 if (buffer[n] != 0 && (buffer[n] != '-' || buffer[n+1] != 0)) {
-                        i->argument = unquote(buffer+n, "\"");
+                        strcpy(i->argument, unquote(buffer+n, "\""));
                         if (!i->argument) {
                                 log_error("Out of memory");
                                 return -ENOMEM;
@@ -1096,11 +1093,6 @@
         r = 0;
 
 finish:
-        free(user);
-        free(group);
-        free(mode);
-        free(age);
-
         if (i)
                 item_free(i);
 
Index: git/src/mount.c
===================================================================
--- git.orig/src/mount.c	2012-01-26 21:15:12.573084007 -0800
+++ git/src/mount.c	2012-01-26 21:15:16.005084174 -0800
@@ -24,6 +24,7 @@
 #include <mntent.h>
 #include <sys/epoll.h>
 #include <signal.h>
+#include <string.h>
 
 #include "unit.h"
 #include "mount.h"
@@ -1561,7 +1562,13 @@
 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
         int r = 0;
         unsigned i;
-        char *device, *path, *options, *options2, *fstype, *d, *p, *o;
+        char *d, *p, *o;
+        char device[50];
+        char path[50];
+        char options[50];
+        char options2[50];
+        char fstype[50];
+
 
         assert(m);
 
@@ -1570,26 +1577,26 @@
         for (i = 1;; i++) {
                 int k;
 
-                device = path = options = options2 = fstype = d = p = o = NULL;
+                d = p = o = NULL;
 
                 if ((k = fscanf(m->proc_self_mountinfo,
                                 "%*s "       /* (1) mount id */
                                 "%*s "       /* (2) parent id */
                                 "%*s "       /* (3) major:minor */
                                 "%*s "       /* (4) root */
-                                "%ms "       /* (5) mount point */
-                                "%ms"        /* (6) mount options */
+                                "%49s "       /* (5) mount point */
+                                "%49s"        /* (6) mount options */
                                 "%*[^-]"     /* (7) optional fields */
                                 "- "         /* (8) separator */
-                                "%ms "       /* (9) file system type */
-                                "%ms"        /* (10) mount source */
-                                "%ms"        /* (11) mount options 2 */
+                                "%49s "       /* (9) file system type */
+                                "%49s"        /* (10) mount source */
+                                "%49s"        /* (11) mount options 2 */
                                 "%*[^\n]",   /* some rubbish at the end */
-                                &path,
-                                &options,
-                                &fstype,
-                                &device,
-                                &options2)) != 5) {
+                                path,
+                                options,
+                                fstype,
+                                device,
+                                options2)) != 5) {
 
                         if (k == EOF)
                                 break;
@@ -1613,22 +1620,12 @@
                         r = k;
 
 clean_up:
-                free(device);
-                free(path);
-                free(options);
-                free(options2);
-                free(fstype);
                 free(d);
                 free(p);
                 free(o);
         }
 
 finish:
-        free(device);
-        free(path);
-        free(options);
-        free(options2);
-        free(fstype);
         free(d);
         free(p);
         free(o);
Index: git/src/umount.c
===================================================================
--- git.orig/src/umount.c	2012-01-26 21:15:12.617084010 -0800
+++ git/src/umount.c	2012-01-26 21:15:16.005084174 -0800
@@ -60,7 +60,9 @@
 
 static int mount_points_list_get(MountPoint **head) {
         FILE *proc_self_mountinfo;
-        char *path, *p;
+        char *p;
+        char path[50];
+
         unsigned int i;
         int r;
 
@@ -72,17 +74,17 @@
         for (i = 1;; i++) {
                 int k;
                 MountPoint *m;
-                char *root;
+                char root[50];
                 bool skip_ro;
 
-                path = p = NULL;
+                p = NULL;
 
                 if ((k = fscanf(proc_self_mountinfo,
                                 "%*s "       /* (1) mount id */
                                 "%*s "       /* (2) parent id */
                                 "%*s "       /* (3) major:minor */
-                                "%ms "       /* (4) root */
-                                "%ms "       /* (5) mount point */
+                                "%49s "       /* (4) root */
+                                "%49s "       /* (5) mount point */
                                 "%*s"        /* (6) mount options */
                                 "%*[^-]"     /* (7) optional fields */
                                 "- "         /* (8) separator */
@@ -90,24 +92,21 @@
                                 "%*s"        /* (10) mount source */
                                 "%*s"        /* (11) mount options 2 */
                                 "%*[^\n]",   /* some rubbish at the end */
-                                &root,
-                                &path)) != 2) {
+                                root,
+                                path)) != 2) {
                         if (k == EOF)
                                 break;
 
                         log_warning("Failed to parse /proc/self/mountinfo:%u.", i);
 
-                        free(path);
                         continue;
                 }
 
                 /* If we encounter a bind mount, don't try to remount
                  * the source dir too early */
                 skip_ro = !streq(root, "/");
-                free(root);
 
                 p = cunescape(path);
-                free(path);
 
                 if (!p) {
                         r = -ENOMEM;
@@ -152,28 +151,28 @@
 
         for (i = 2;; i++) {
                 MountPoint *swap;
-                char *dev = NULL, *d;
+                char *d;
+                char dev[50];
+
                 int k;
 
                 if ((k = fscanf(proc_swaps,
-                                "%ms " /* device/file */
+                                "%50s " /* device/file */
                                 "%*s " /* type of swap */
                                 "%*s " /* swap size */
                                 "%*s " /* used */
                                 "%*s\n", /* priority */
-                                &dev)) != 1) {
+                                dev)) != 1) {
 
                         if (k == EOF)
                                 break;
 
                         log_warning("Failed to parse /proc/swaps:%u.", i);
 
-                        free(dev);
                         continue;
                 }
 
                 if (endswith(dev, "(deleted)")) {
-                        free(dev);
                         continue;
                 }