/
0001-Disable-libblockdev-mdraid-and-part-support-from-sou.patch
493 lines (438 loc) · 14.9 KB
/
0001-Disable-libblockdev-mdraid-and-part-support-from-sou.patch
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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
From d2bb5ff5f9a26797f69c04bd8bd8966e670d1149 Mon Sep 17 00:00:00 2001
From: Raine Makelainen <raine.makelainen@jolla.com>
Date: Tue, 5 Dec 2017 11:17:50 +0200
Subject: [PATCH 01/10] Disable libblockdev-mdraid and part support from source
tree
Signed-off-by: Raine Makelainen <raine.makelainen@jolla.com>
---
configure.ac | 4 ----
src/Makefile.am | 1 -
src/udisksdaemon.c | 23 +++++++++++++++++++++++
src/udiskslinuxblock.c | 14 ++++++++++++++
src/udiskslinuxmanager.c | 24 ++++++++++++++++++++++++
src/udiskslinuxmdraidobject.c | 10 ++++++++++
src/udiskslinuxpartition.c | 28 ++++++++++++++++++++++++----
src/udiskslinuxpartitiontable.c | 10 ++++++++++
8 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 488b27c1..bc8f7af1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -575,10 +575,6 @@ AC_TRY_COMPILE([#include <blockdev/mdraid.h>], [],
CFLAGS=$SAVE_CFLAGS
LDFLAGS=$SAVE_LDFLAGS
-if test "x$have_mdraid" = "xno"; then
- AC_MSG_ERROR([BLOCKDEV MDRAID support requested but header or library not found])
-fi
-
# libblockdev fs
SAVE_CFLAGS=$CFLAGS
SAVE_LDFLAGS=$LDFLAGS
diff --git a/src/Makefile.am b/src/Makefile.am
index c6e89ca2..96ea3cc1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,7 +67,6 @@ libudisks_daemon_la_SOURCES = \
udiskslinuxdriveata.h udiskslinuxdriveata.c \
udiskslinuxmdraidobject.h udiskslinuxmdraidobject.c \
udiskslinuxmdraidhelpers.h udiskslinuxmdraidhelpers.c \
- udiskslinuxmdraid.h udiskslinuxmdraid.c \
udiskslinuxmanager.h udiskslinuxmanager.c \
udiskslinuxfsinfo.h udiskslinuxfsinfo.c \
udisksbasejob.h udisksbasejob.c \
diff --git a/src/udisksdaemon.c b/src/udisksdaemon.c
index 9a013ec9..aafd79ed 100644
--- a/src/udisksdaemon.c
+++ b/src/udisksdaemon.c
@@ -19,6 +19,14 @@
*
*/
+#ifndef BLOCKDEV_PART_ENABLED
+#define BLOCKDEV_PART_ENABLED 0
+#endif
+
+#ifndef BLOCKDEV_MDRAID_ENABLED
+#define BLOCKDEV_MDRAID_ENABLED 0
+#endif
+
#include "config.h"
#include <glib/gi18n-lib.h>
#include <blockdev/blockdev.h>
@@ -248,18 +256,33 @@ udisks_daemon_constructed (GObject *object)
gboolean ret = FALSE;
/* NULL means no specific so_name (implementation) */
+#if BLOCKDEV_PART_ENABLED
BDPluginSpec part_plugin = {BD_PLUGIN_PART, NULL};
+#endif
BDPluginSpec swap_plugin = {BD_PLUGIN_SWAP, NULL};
BDPluginSpec loop_plugin = {BD_PLUGIN_LOOP, NULL};
+#if BLOCKDEV_MDRAID_ENABLED
BDPluginSpec mdraid_plugin = {BD_PLUGIN_MDRAID, NULL};
+#endif
BDPluginSpec fs_plugin = {BD_PLUGIN_FS, NULL};
BDPluginSpec crypto_plugin = {BD_PLUGIN_CRYPTO, NULL};
/* The core daemon needs the part, swap, loop, mdraid, fs and crypto plugins.
Additional plugins are required by various modules, but they make sure
plugins are loaded themselves. */
+#if BLOCKDEV_PART_ENABLED && BLOCKDEV_MDRAID_ENABLED
BDPluginSpec *plugins[] = {&part_plugin, &swap_plugin, &loop_plugin, &mdraid_plugin,
&fs_plugin, &crypto_plugin, NULL};
+#elif BLOCKDEV_PART_ENABLED
+ BDPluginSpec *plugins[] = {&part_plugin, &swap_plugin, &loop_plugin
+ &fs_plugin, &crypto_plugin, NULL};
+#elif BLOCKDEV_MDRAID_ENABLED
+ BDPluginSpec *plugins[] = {&swap_plugin, &loop_plugin, &mdraid_plugin,
+ &fs_plugin, &crypto_plugin, NULL};
+#else
+ BDPluginSpec *plugins[] = {&swap_plugin, &loop_plugin, &fs_plugin, &crypto_plugin, NULL};
+#endif
+
BDPluginSpec **plugin_p = NULL;
error = NULL;
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
index 3ac48da5..09fa90a0 100644
--- a/src/udiskslinuxblock.c
+++ b/src/udiskslinuxblock.c
@@ -20,6 +20,10 @@
#define _GNU_SOURCE /* for O_DIRECT */
+#ifndef BLOCKDEV_PART_ENABLED
+#define BLOCKDEV_PART_ENABLED 0
+#endif
+
#include "config.h"
#include <glib/gi18n-lib.h>
@@ -37,7 +41,9 @@
#include <glib/gstdio.h>
#include <gio/gunixfdlist.h>
+#if BLOCKDEV_PART_ENABLED
#include <blockdev/part.h>
+#endif
#include <blockdev/fs.h>
#include "udiskslogging.h"
@@ -2722,7 +2728,10 @@ udisks_linux_block_handle_format (UDisksBlock *block,
GVariant *config_items = NULL;
gboolean teardown_flag = FALSE;
gboolean no_discard_flag = FALSE;
+
+#if BLOCKDEV_PART_ENABLED
BDPartTableType part_table_type = BD_PART_TABLE_UNDEF;
+#endif
error = NULL;
object = udisks_daemon_util_dup_object (block, &error);
@@ -3083,11 +3092,13 @@ udisks_linux_block_handle_format (UDisksBlock *block,
}
}
+#if BLOCKDEV_PART_ENABLED
if (g_strcmp0 (type, "dos") == 0)
part_table_type = BD_PART_TABLE_MSDOS;
else if (g_strcmp0 (type, "gpt") == 0)
part_table_type = BD_PART_TABLE_GPT;
if (part_table_type == BD_PART_TABLE_UNDEF)
+#endif
{
/* Build and run mkfs shell command */
const gchar *device = udisks_block_get_device (block_to_mkfs);
@@ -3115,6 +3126,8 @@ udisks_linux_block_handle_format (UDisksBlock *block,
goto out;
}
}
+
+#if BLOCKDEV_PART_ENABLED
else
{
/* Create the partition table. */
@@ -3124,6 +3137,7 @@ udisks_linux_block_handle_format (UDisksBlock *block,
goto out;
}
}
+#endif
/* The mkfs program may not generate all the uevents we need - so explicitly
* trigger an event here
diff --git a/src/udiskslinuxmanager.c b/src/udiskslinuxmanager.c
index 157746fc..31133019 100644
--- a/src/udiskslinuxmanager.c
+++ b/src/udiskslinuxmanager.c
@@ -18,6 +18,10 @@
*
*/
+#ifndef BLOCKDEV_MDRAID_ENABLED
+#define BLOCKDEV_MDRAID_ENABLED 0
+#endif
+
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gio/gunixfdlist.h>
@@ -35,7 +39,9 @@
#include <blockdev/loop.h>
#include <blockdev/fs.h>
+#if BLOCKDEV_MDRAID_ENABLED
#include <blockdev/mdraid.h>
+#endif
#include "udiskslogging.h"
#include "udiskslinuxmanager.h"
@@ -487,7 +493,9 @@ wait_for_array_object (UDisksDaemon *daemon,
return ret;
}
+#if BLOCKDEV_MDRAID_ENABLED
static const gchar *raid_level_whitelist[] = {"raid0", "raid1", "raid4", "raid5", "raid6", "raid10", NULL};
+#endif
static gboolean
handle_mdraid_create (UDisksManager *_object,
@@ -498,6 +506,7 @@ handle_mdraid_create (UDisksManager *_object,
guint64 arg_chunk,
GVariant *arg_options)
{
+#if BLOCKDEV_MDRAID_ENABLED
UDisksLinuxManager *manager = UDISKS_LINUX_MANAGER (_object);
UDisksObject *array_object = NULL;
uid_t caller_uid;
@@ -845,6 +854,9 @@ handle_mdraid_create (UDisksManager *_object,
g_clear_object (&array_object);
return TRUE; /* returning TRUE means that we handled the method invocation */
+#else
+ return FALSE;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -935,6 +947,7 @@ handle_can_resize (UDisksManager *object,
GDBusMethodInvocation *invocation,
const gchar *type)
{
+#if BLOCKDEV_MDRAID_ENABLED
GError *error = NULL;
gchar *required_utility = NULL;
BDFsResizeFlags mode;
@@ -956,6 +969,9 @@ handle_can_resize (UDisksManager *object,
g_free (required_utility);
return TRUE;
+#else
+ return FALSE;
+#endif
}
static gboolean
@@ -963,6 +979,7 @@ handle_can_check (UDisksManager *object,
GDBusMethodInvocation *invocation,
const gchar *type)
{
+#if BLOCKDEV_MDRAID_ENABLED
GError *error = NULL;
gchar *required_utility = NULL;
gboolean ret;
@@ -983,6 +1000,9 @@ handle_can_check (UDisksManager *object,
g_free (required_utility);
return TRUE;
+#else
+ return FALSE;
+#endif
}
static gboolean
@@ -990,6 +1010,7 @@ handle_can_repair (UDisksManager *object,
GDBusMethodInvocation *invocation,
const gchar *type)
{
+#if BLOCKDEV_MDRAID_ENABLED
GError *error = NULL;
gchar *required_utility = NULL;
gboolean ret;
@@ -1010,6 +1031,9 @@ handle_can_repair (UDisksManager *object,
g_free (required_utility);
return TRUE;
+#else
+ return FALSE;
+#endif
}
diff --git a/src/udiskslinuxmdraidobject.c b/src/udiskslinuxmdraidobject.c
index 8014664e..ef772320 100644
--- a/src/udiskslinuxmdraidobject.c
+++ b/src/udiskslinuxmdraidobject.c
@@ -36,6 +36,10 @@
#include "udiskslinuxdevice.h"
#include "udiskssimplejob.h"
+#ifndef BLOCKDEV_MDRAID_ENABLED
+#define BLOCKDEV_MDRAID_ENABLED 0
+#endif
+
/**
* SECTION:udiskslinuxmdraidobject
* @title: UDisksLinuxMDRaidObject
@@ -430,7 +434,11 @@ mdraid_update (UDisksLinuxMDRaidObject *object,
const gchar *uevent_action,
GDBusInterface *_iface)
{
+#if BLOCKDEV_MDRAID_ENABLED
return udisks_linux_mdraid_update (UDISKS_LINUX_MDRAID (object->iface_mdraid), object);
+#else
+ return FALSE;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -604,6 +612,7 @@ udisks_linux_mdraid_object_uevent (UDisksLinuxMDRaidObject *object,
UDisksLinuxDevice *device,
gboolean is_member)
{
+#if BLOCKDEV_MDRAID_ENABLED
gboolean conf_changed = FALSE;
g_return_if_fail (UDISKS_IS_LINUX_MDRAID_OBJECT (object));
@@ -720,6 +729,7 @@ udisks_linux_mdraid_object_uevent (UDisksLinuxMDRaidObject *object,
}
out:
;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/udiskslinuxpartition.c b/src/udiskslinuxpartition.c
index 5fa20482..7260c00f 100644
--- a/src/udiskslinuxpartition.c
+++ b/src/udiskslinuxpartition.c
@@ -18,6 +18,10 @@
*
*/
+#ifndef BLOCKDEV_PART_ENABLED
+#define BLOCKDEV_PART_ENABLED 0
+#endif
+
#include "config.h"
#include <glib/gi18n-lib.h>
@@ -33,7 +37,9 @@
#include <glib/gstdio.h>
+#if BLOCKDEV_PART_ENABLED
#include <blockdev/part.h>
+#endif
#include "udiskslogging.h"
#include "udiskslinuxpartition.h"
@@ -292,6 +298,7 @@ handle_set_flags (UDisksPartition *partition,
guint64 flags,
GVariant *options)
{
+#if BLOCKDEV_PART_ENABLED
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
UDisksDaemon *daemon = NULL;
@@ -419,7 +426,7 @@ handle_set_flags (UDisksPartition *partition,
g_clear_object (&partition_table);
g_clear_object (&partition_table_block);
g_clear_object (&object);
-
+#endif
return TRUE; /* returning TRUE means that we handled the method invocation */
}
@@ -432,6 +439,7 @@ handle_set_name (UDisksPartition *partition,
const gchar *name,
GVariant *options)
{
+#if BLOCKDEV_PART_ENABLED
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
UDisksDaemon *daemon = NULL;
@@ -536,7 +544,7 @@ handle_set_name (UDisksPartition *partition,
g_clear_object (&partition_table);
g_clear_object (&partition_table_block);
g_clear_object (&object);
-
+#endif
return TRUE; /* returning TRUE means that we handled the method invocation */
}
@@ -593,6 +601,7 @@ udisks_linux_partition_set_type_sync (UDisksLinuxPartition *partition,
GCancellable *cancellable,
GError **error)
{
+#if BLOCKDEV_PART_ENABLED
gboolean ret = FALSE;
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
@@ -724,8 +733,10 @@ udisks_linux_partition_set_type_sync (UDisksLinuxPartition *partition,
g_clear_object (&partition_table_block);
g_clear_object (&object);
g_clear_error (&loc_error);
-
return ret;
+#else
+ return TRUE;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -763,6 +774,7 @@ typedef struct
guint64 new_size;
} WaitForPartitionResizeData;
+#if BLOCKDEV_PART_ENABLED
static UDisksObject *
wait_for_partition_resize (UDisksDaemon *daemon,
gpointer user_data)
@@ -785,6 +797,7 @@ wait_for_partition_resize (UDisksDaemon *daemon,
return object;
}
+#endif
/* runs in thread dedicated to handling @invocation */
static gboolean
@@ -793,6 +806,7 @@ handle_resize (UDisksPartition *partition,
guint64 size,
GVariant *options)
{
+#if BLOCKDEV_PART_ENABLED
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
UDisksDaemon *daemon = NULL;
@@ -891,7 +905,9 @@ handle_resize (UDisksPartition *partition,
g_clear_object (&partition_table_block);
return TRUE; /* returning TRUE means that we handled the method invocation */
-
+#else
+ return FALSE;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -902,6 +918,7 @@ handle_delete (UDisksPartition *partition,
GDBusMethodInvocation *invocation,
GVariant *options)
{
+#if BLOCKDEV_PART_ENABLED
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
UDisksDaemon *daemon = NULL;
@@ -989,6 +1006,9 @@ handle_delete (UDisksPartition *partition,
g_clear_object (&object);
return TRUE; /* returning TRUE means that we handled the method invocation */
+#else
+ return FALSE;
+#endif
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c
index 7a92057f..90c7cf24 100644
--- a/src/udiskslinuxpartitiontable.c
+++ b/src/udiskslinuxpartitiontable.c
@@ -18,6 +18,10 @@
*
*/
+#ifndef BLOCKDEV_PART_ENABLED
+#define BLOCKDEV_PART_ENABLED 0
+#endif
+
#include "config.h"
#include <glib/gi18n-lib.h>
@@ -31,7 +35,9 @@
#include <glib/gstdio.h>
+#if BLOCKDEV_PART_ENABLED
#include <blockdev/part.h>
+#endif
#include <blockdev/fs.h>
#include "udiskslogging.h"
@@ -255,6 +261,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
const gchar *name,
GVariant *options)
{
+#if BLOCKDEV_PART_ENABLED
const gchar *action_id = NULL;
const gchar *message = NULL;
UDisksBlock *block = NULL;
@@ -563,6 +570,9 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
if (part_spec)
bd_part_spec_free (part_spec);
return partition_object;
+#else
+ return NULL;
+#endif
}
static int
--
2.17.1