summaryrefslogtreecommitdiffstats
path: root/meta-openembedded/meta-oe/recipes-extended/libblockdev/files/0003-remove-dmraid-while-compiling-with-with-dm.patch
blob: ac5b5e2bebc7882e5c599211bd1cf1506d2a3f5d (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
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 bda7c937ba544182a5cae2a9cf0c173e0ba268c9 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Thu, 27 Jul 2017 09:47:23 +0800
Subject: [PATCH 3/3] remove dmraid while compiling with --with-dm

Fix the following failure:

...
Perhaps you should add the directory containing `dmraid.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dmraid' found
...

...
../../../git/src/plugins/dm.c:24:10: fatal error: dmraid/dmraid.h: No
such file or directory
 #include <dmraid/dmraid.h>
          ^~~~~~~~~~~~~~~~~
...

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 src/lib/plugin_apis/dm.api          |  50 ------
 src/plugins/Makefile.am             |   2 +-
 src/plugins/dm.c                    | 330 ------------------------------------
 src/plugins/dm.h                    |   5 -
 src/python/gi/overrides/BlockDev.py |   6 -
 5 files changed, 1 insertion(+), 392 deletions(-)

diff --git a/src/lib/plugin_apis/dm.api b/src/lib/plugin_apis/dm.api
index 04fd8d8..5d30b6a 100644
--- a/src/lib/plugin_apis/dm.api
+++ b/src/lib/plugin_apis/dm.api
@@ -111,53 +111,3 @@ gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error);
  * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY
  */
 gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean active_only, GError **error);
-
-/**
- * bd_dm_get_member_raid_sets:
- * @name: (allow-none): name of the member
- * @uuid: (allow-none): uuid of the member
- * @major: major number of the device or -1 if not specified
- * @minor: minor number of the device or -1 if not specified
- * @error: (out): variable to store error (if any)
- *
- * Returns: (transfer full) (array zero-terminated=1): list of names of the RAID sets related to
- * the member or %NULL in case of error
- *
- * One of @name, @uuid or @major:@minor has to be given.
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_QUERY
- */
-gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error);
-
-/**
- * bd_dm_activate_raid_set:
- * @name: name of the DM RAID set to activate
- * @error: (out): variable to store error (if any)
- *
- * Returns: whether the RAID set @name was successfully activate or not
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_CREATE_ACTIVATE
- */
-gboolean bd_dm_activate_raid_set (const gchar *name, GError **error);
-
-/**
- * bd_dm_deactivate_raid_set:
- * @name: name of the DM RAID set to deactivate
- * @error: (out): variable to store error (if any)
- *
- * Returns: whether the RAID set @name was successfully deactivate or not
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_REMOVE_DEACTIVATE
- */
-gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error);
-
-/**
- * bd_dm_get_raid_set_type:
- * @name: name of the DM RAID set to get the type of
- * @error: (out): variable to store error (if any)
- *
- * Returns: string representation of the @name RAID set's type
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_QUERY
- */
-gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index b69c8f7..7575f4a 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -75,7 +75,7 @@ endif
 
 if WITH_DM
 libbd_dm_la_CFLAGS = $(GLIB_CFLAGS) $(DEVMAPPER_CFLAGS) $(UDEV_CFLAGS) -Wall -Wextra -Werror
-libbd_dm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) $(UDEV_LIBS) -ldmraid ${builddir}/../utils/libbd_utils.la
+libbd_dm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) $(UDEV_LIBS) ${builddir}/../utils/libbd_utils.la
 libbd_dm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined
 # Dear author of libdmdraid, VERSION really is not a good name for an enum member!
 libbd_dm_la_CPPFLAGS = -I${builddir}/../../include/ -UVERSION
diff --git a/src/plugins/dm.c b/src/plugins/dm.c
index 0e5466c..31ebe96 100644
--- a/src/plugins/dm.c
+++ b/src/plugins/dm.c
@@ -21,17 +21,11 @@
 #include <unistd.h>
 #include <blockdev/utils.h>
 #include <libdevmapper.h>
-#include <dmraid/dmraid.h>
 #include <libudev.h>
 
 #include "dm.h"
 #include "check_deps.h"
 
-/* macros taken from the pyblock/dmraid.h file plus one more*/
-#define for_each_raidset(_c, _n) list_for_each_entry(_n, LC_RS(_c), list)
-#define for_each_subset(_rs, _n) list_for_each_entry(_n, &(_rs)->sets, list)
-#define for_each_device(_rs, _d) list_for_each_entry(_d, &(_rs)->devs, devs)
-
 /**
  * SECTION: dm
  * @short_description: plugin for basic operations with device mapper
@@ -380,327 +374,3 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a
 
     return ret;
 }
-
-/**
- * init_dmraid_stack: (skip)
- *
- * Initializes the dmraid stack by creating the library context, discovering
- * devices, raid sets, etc.
- */
-static struct lib_context* init_dmraid_stack (GError **error) {
-    gint rc = 0;
-    gchar *argv[] = {"blockdev.dmraid", NULL};
-    struct lib_context *lc;
-
-    /* the code for this function was cherry-picked from the pyblock code */
-    /* XXX: do this all just once, store global lc and provide a reinit
-     *      function? */
-
-    /* initialize dmraid library context */
-    lc = libdmraid_init (1, (gchar **)argv);
-
-    rc = discover_devices (lc, NULL);
-    if (!rc) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL,
-                     "Failed to discover devices");
-        libdmraid_exit (lc);
-        return NULL;
-    }
-    discover_raid_devices (lc, NULL);
-
-    if (!count_devices (lc, RAID)) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_DEVS,
-                     "No RAIDs discovered");
-        libdmraid_exit (lc);
-        return NULL;
-    }
-
-    argv[0] = NULL;
-    if (!group_set (lc, argv)) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL,
-                     "Failed to group_set");
-        libdmraid_exit (lc);
-        return NULL;
-    }
-
-    return lc;
-}
-
-/**
- * raid_dev_matches_spec: (skip)
- *
- * Returns: whether the device specified by @sysname matches the spec given by @name,
- *          @uuid, @major and @minor
- */
-static gboolean raid_dev_matches_spec (struct raid_dev *raid_dev, const gchar *name, const gchar *uuid, gint major, gint minor) {
-    gchar const *dev_name = NULL;
-    gchar const *dev_uuid;
-    gchar const *major_str;
-    gchar const *minor_str;
-    struct udev *context;
-    struct udev_device *device;
-    gboolean ret = TRUE;
-
-    /* find the second '/' to get name (the rest of the string) */
-    dev_name = strchr (raid_dev->di->path, '/');
-    if (dev_name && strlen (dev_name) > 1) {
-        dev_name++;
-        dev_name = strchr (dev_name, '/');
-    }
-    if (dev_name && strlen (dev_name) > 1) {
-        dev_name++;
-    }
-    else
-        dev_name = NULL;
-
-    /* if we don't have the name, we cannot check any match */
-    g_return_val_if_fail (dev_name, FALSE);
-
-    /* g_return_val_if_fail above checks value of dev_name and returns FALSE if
-     * it is NULL so we don't need to check it here */
-    /* coverity[var_deref_model] */
-    if (name && strcmp (dev_name, name) != 0) {
-        return FALSE;
-    }
-
-    context = udev_new ();
-    device = udev_device_new_from_subsystem_sysname (context, "block", dev_name);
-    dev_uuid = udev_device_get_property_value (device, "UUID");
-    major_str = udev_device_get_property_value (device, "MAJOR");
-    minor_str = udev_device_get_property_value (device, "MINOR");
-
-    if (uuid && (g_strcmp0 (uuid, "") != 0) && (g_strcmp0 (uuid, dev_uuid) != 0))
-        ret = FALSE;
-
-    if (major >= 0 && (atoi (major_str) != major))
-        ret = FALSE;
-
-    if (minor >= 0 && (atoi (minor_str) != minor))
-        ret = FALSE;
-
-    udev_device_unref (device);
-    udev_unref (context);
-
-    return ret;
-}
-
-/**
- * find_raid_sets_for_dev: (skip)
- */
-static void find_raid_sets_for_dev (const gchar *name, const gchar *uuid, gint major, gint minor, struct lib_context *lc, struct raid_set *rs, GPtrArray *ret_sets) {
-    struct raid_set *subset = NULL;
-    struct raid_dev *dev = NULL;
-
-    if (T_GROUP(rs) || !list_empty(&(rs->sets))) {
-        for_each_subset (rs, subset)
-            find_raid_sets_for_dev (name, uuid, major, minor, lc, subset, ret_sets);
-    } else {
-        for_each_device (rs, dev) {
-            if (raid_dev_matches_spec (dev, name, uuid, major, minor))
-                g_ptr_array_add (ret_sets, g_strdup (rs->name));
-        }
-    }
-}
-
-/**
- * bd_dm_get_member_raid_sets:
- * @name: (allow-none): name of the member
- * @uuid: (allow-none): uuid of the member
- * @major: major number of the device or -1 if not specified
- * @minor: minor number of the device or -1 if not specified
- * @error: (out): variable to store error (if any)
- *
- * Returns: (transfer full) (array zero-terminated=1): list of names of the RAID sets related to
- * the member or %NULL in case of error
- *
- * One of @name, @uuid or @major:@minor has to be given.
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_QUERY
- */
-gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error) {
-    guint64 i = 0;
-    struct lib_context *lc = NULL;
-    struct raid_set *rs = NULL;
-    GPtrArray *ret_sets = g_ptr_array_new ();
-    gchar **ret = NULL;
-
-    lc = init_dmraid_stack (error);
-    if (!lc)
-        /* error is already populated */
-        return NULL;
-
-    for_each_raidset (lc, rs) {
-        find_raid_sets_for_dev (name, uuid, major, minor, lc, rs, ret_sets);
-    }
-
-    /* now create the return value -- NULL-terminated array of strings */
-    ret = g_new0 (gchar*, ret_sets->len + 1);
-    for (i=0; i < ret_sets->len; i++)
-        ret[i] = (gchar*) g_ptr_array_index (ret_sets, i);
-    ret[i] = NULL;
-
-    g_ptr_array_free (ret_sets, FALSE);
-
-    libdmraid_exit (lc);
-    return ret;
-}
-
-/**
- * find_in_raid_sets: (skip)
- *
- * Runs @eval_fn with @data on each set (traversing recursively) and returns the
- * first RAID set that @eval_fn returns. Thus the @eval_fn should return %NULL
- * on all RAID sets that don't fulfill the search criteria.
- */
-static struct raid_set* find_in_raid_sets (struct raid_set *rs, RSEvalFunc eval_fn, gpointer data) {
-    struct raid_set *subset = NULL;
-    struct raid_set *ret = NULL;
-
-    ret = eval_fn (rs, data);
-    if (ret)
-        return ret;
-
-    if (T_GROUP(rs) || !list_empty(&(rs->sets))) {
-        for_each_subset (rs, subset) {
-            ret = find_in_raid_sets (subset, eval_fn, data);
-            if (ret)
-                return ret;
-        }
-    }
-
-    return ret;
-}
-
-static struct raid_set* rs_matches_name (struct raid_set *rs, gpointer *name_data) {
-    gchar *name = (gchar*) name_data;
-
-    if (g_strcmp0 (rs->name, name) == 0)
-        return rs;
-    else
-        return NULL;
-}
-
-static gboolean change_set_by_name (const gchar *name, enum activate_type action, GError **error) {
-    gint rc = 0;
-    struct lib_context *lc = NULL;
-    struct raid_set *iter_rs = NULL;
-    struct raid_set *match_rs = NULL;
-
-    lc = init_dmraid_stack (error);
-    if (!lc)
-        /* error is already populated */
-        return FALSE;
-
-    for_each_raidset (lc, iter_rs) {
-        match_rs = find_in_raid_sets (iter_rs, (RSEvalFunc)rs_matches_name, (gchar *)name);
-        if (match_rs)
-            break;
-    }
-
-    if (!match_rs) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_EXIST,
-                     "RAID set %s doesn't exist", name);
-        libdmraid_exit (lc);
-        return FALSE;
-    }
-
-    rc = change_set (lc, action, match_rs);
-    if (!rc) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL,
-                     "Failed to activate the RAID set '%s'", name);
-        libdmraid_exit (lc);
-        return FALSE;
-    }
-
-    libdmraid_exit (lc);
-    return TRUE;
-}
-
-/**
- * bd_dm_activate_raid_set:
- * @name: name of the DM RAID set to activate
- * @error: (out): variable to store error (if any)
- *
- * Returns: whether the RAID set @name was successfully activate or not
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_CREATE_ACTIVATE
- */
-gboolean bd_dm_activate_raid_set (const gchar *name, GError **error) {
-    guint64 progress_id = 0;
-    gchar *msg = NULL;
-    gboolean ret = FALSE;
-
-    msg = g_strdup_printf ("Activating DM RAID set '%s'", name);
-    progress_id = bd_utils_report_started (msg);
-    g_free (msg);
-    ret = change_set_by_name (name, A_ACTIVATE, error);
-    bd_utils_report_finished (progress_id, "Completed");
-    return ret;
-}
-
-/**
- * bd_dm_deactivate_raid_set:
- * @name: name of the DM RAID set to deactivate
- * @error: (out): variable to store error (if any)
- *
- * Returns: whether the RAID set @name was successfully deactivate or not
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_REMOVE_DEACTIVATE
- */
-gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error) {
-    guint64 progress_id = 0;
-    gchar *msg = NULL;
-    gboolean ret = FALSE;
-
-    msg = g_strdup_printf ("Deactivating DM RAID set '%s'", name);
-    progress_id = bd_utils_report_started (msg);
-    g_free (msg);
-    ret = change_set_by_name (name, A_DEACTIVATE, error);
-    bd_utils_report_finished (progress_id, "Completed");
-    return ret;
-}
-
-/**
- * bd_dm_get_raid_set_type:
- * @name: name of the DM RAID set to get the type of
- * @error: (out): variable to store error (if any)
- *
- * Returns: string representation of the @name RAID set's type
- *
- * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_QUERY
- */
-gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error) {
-    struct lib_context *lc = NULL;
-    struct raid_set *iter_rs = NULL;
-    struct raid_set *match_rs = NULL;
-    const gchar *type = NULL;
-
-    lc = init_dmraid_stack (error);
-    if (!lc)
-        /* error is already populated */
-        return NULL;
-
-    for_each_raidset (lc, iter_rs) {
-        match_rs = find_in_raid_sets (iter_rs, (RSEvalFunc)rs_matches_name, (gchar *)name);
-        if (match_rs)
-            break;
-    }
-
-    if (!match_rs) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_EXIST,
-                     "RAID set %s doesn't exist", name);
-        libdmraid_exit (lc);
-        return NULL;
-    }
-
-    type = get_set_type (lc, match_rs);
-    if (!type) {
-        g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL,
-                     "Failed to get RAID set's type");
-        libdmraid_exit (lc);
-        return NULL;
-    }
-
-    libdmraid_exit (lc);
-    return g_strdup (type);
-}
diff --git a/src/plugins/dm.h b/src/plugins/dm.h
index 0dce6ac..1ee3788 100644
--- a/src/plugins/dm.h
+++ b/src/plugins/dm.h
@@ -1,5 +1,4 @@
 #include <glib.h>
-#include <dmraid/dmraid.h>
 
 #ifndef BD_DM
 #define BD_DM
@@ -48,9 +47,5 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a
 gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error);
 gchar* bd_dm_node_from_name (const gchar *map_name, GError **error);
 gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error);
-gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error);
-gboolean bd_dm_activate_raid_set (const gchar *name, GError **error);
-gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error);
-gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error);
 
 #endif  /* BD_DM */
diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py
index fb3ffb4..eed0a38 100644
--- a/src/python/gi/overrides/BlockDev.py
+++ b/src/python/gi/overrides/BlockDev.py
@@ -233,12 +233,6 @@ def dm_create_linear(map_name, device, length, uuid=None):
     return _dm_create_linear(map_name, device, length, uuid)
 __all__.append("dm_create_linear")
 
-_dm_get_member_raid_sets = BlockDev.dm_get_member_raid_sets
-@override(BlockDev.dm_get_member_raid_sets)
-def dm_get_member_raid_sets(name=None, uuid=None, major=-1, minor=-1):
-    return _dm_get_member_raid_sets(name, uuid, major, minor)
-__all__.append("dm_get_member_raid_sets")
-
 
 _loop_setup = BlockDev.loop_setup
 @override(BlockDev.loop_setup)
-- 
2.14.3

OpenPOWER on IntegriCloud