Git Product home page Git Product logo

libblockdev's People

Contributors

adamwill avatar andhe avatar atodorov avatar bertogg avatar clumens avatar dashea avatar giuliobenetti avatar gtristan avatar guazhangrh avatar intrigeri avatar japokorn avatar jelly avatar jtulak avatar krieghof avatar maxkellermann avatar mbiebl avatar mulkieran avatar mvollmer avatar phatina avatar poncovka avatar pothos avatar segfault3 avatar snbueno avatar squimrel avatar tasleson avatar tbzatek avatar tgurr avatar tpgxyz avatar vojtechtrefny avatar vpodzime avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libblockdev's Issues

Coverity: Issues in crypto.c

Error: NEGATIVE_RETURNS (CWE-394): [#def15]
libblockdev-2.9/src/plugins/crypto.c:277: negative_return_fn: Function "open("/dev/random", 0)" returns a negative number. [Note: The source code implementation of the function has been overridden by a user model.]
libblockdev-2.9/src/plugins/crypto.c:277: var_assign: Assigning: signed variable "dev_random_fd" = "open".
libblockdev-2.9/src/plugins/crypto.c:284: negative_returns: "dev_random_fd" is passed to a parameter that cannot be negative.
#  282|               ioctl (dev_random_fd, RNDGETENTCNT, &current_entropy);
#  283|           }
#  284|->         close (dev_random_fd);
#  285|       }
#  286|   

Error: DEADCODE (CWE-561): [#def16]
libblockdev-2.9/src/plugins/crypto.c:595: assignment: Assigning: "nkey_buf" = "NULL".
libblockdev-2.9/src/plugins/crypto.c:630: null: At condition "nkey_buf", the value of "nkey_buf" must be "NULL".
libblockdev-2.9/src/plugins/crypto.c:628: dead_error_condition: The condition "nkey_buf" cannot be true.
libblockdev-2.9/src/plugins/crypto.c:628: dead_error_line: Execution cannot reach the expression "(guint8 const *)nkey_buf" inside this statement: "success = bd_crypto_luks_ad...".
libblockdev-2.9/src/plugins/crypto.c:628: effectively_constant: Local variable "nkey_buf" is assigned only once, to a constant value, making it effectively constant throughout its scope. If this is not the intent, examine the logic to see if there is a missing assignment that would make "nkey_buf" not remain constant.
#  626|           nbuf_len = strlen (npass);
#  627|   
#  628|->     success = bd_crypto_luks_add_key_blob (device,
#  629|                                              key_buf ? (const guint8*) key_buf : (const guint8*) pass, buf_len,
#  630|                                              nkey_buf ? (const guint8*) nkey_buf : (const guint8*) np

Coverity: Issues in crypto.c

Error: COMPILER_WARNING: [#def5]
libblockdev-2.9/src/lib/blockdev.c:15: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/crypto.c:5:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const crypto_functions[] = {
#                    ^~~~~
#    3|   }
#    4|   
#    5|-> static const gchar const * const crypto_functions[] = {
#    6|       "bd_crypto_generate_backup_passphrase",
#    7|       "bd_crypto_device_is_luks",

Build dependencies not specified in configure.ac

$ ./autogen.sh && ./configure

"GObject introspection must be enabled" which is misleading as what you may need to do is install package for gobject-introspection-devel

Once I got ./configure to run without complaints, I get the following compile errors:

crypto.c:24:27: fatal error: libvolume_key.h: No such file or directory
 #include <libvolume_key.h>
fatal error: dmraid/dmraid.h: No such file or directory
 #include <dmraid/dmraid.h>

gtkdoc-scan: Command not found

Which can be corrected by installing development libraries for volume_key-devel, dmraid-devel and gtk-doc packages.

Mark gchar* parameters as const

We don't do any changes to these strings, but since in C strings are pointers to chars, the way to say that explicitly is by using const.

Selection of LUKS hash algorithm

The bd_crypto_luks_format() function does not allow to specify the hash algorithm that is used for LUKS volumes. This can create compliance issues as cryptsetup uses its default hash algorithm (SHA-1) if no hash algorithm is specified.

Leaked file descriptors

These show up all over in the logs.

Verify that it is possible to wipe an ext2 file system ... File descriptor 6 (pipe:[2436816]) leaked on pvcreate invocation. Parent PID 22887: sh
File descriptor 7 (pipe:[2441744]) leaked on pvcreate invocation. Parent PID 22887: sh
File descriptor 9 (pipe:[2446707]) leaked on pvcreate invocation. Parent PID 22887: sh
File descriptor 11 (pipe:[2451810]) leaked on pvcreate invocation. Parent PID 22887: sh
File descriptor 13 (pipe:[2456933]) leaked on pvcreate invocation. Parent PID 22887: sh
File descriptor 15 (pipe:[2462100]) leaked on pvcreate invocation. Parent PID 22887: sh
ok
test_ext3_wipe (fs_test.ExtTestWipe)
Verify that it is possible to wipe an ext3 file system ... File descriptor 6 (pipe:[2436816]) leaked on pvcreate invocation. Parent PID 23009: sh
File descriptor 7 (pipe:[2441744]) leaked on pvcreate invocation. Parent PID 23009: sh
File descriptor 9 (pipe:[2446707]) leaked on pvcreate invocation. Parent PID 23009: sh
File descriptor 11 (pipe:[2451810]) leaked on pvcreate invocation. Parent PID 23009: sh
File descriptor 13 (pipe:[2456933]) leaked on pvcreate invocation. Parent PID 23009: sh
File descriptor 15 (pipe:[2462100]) leaked on pvcreate invocation. Parent PID 23009: sh
ok
test_ext4_wipe (fs_test.ExtTestWipe)
Verify that it is possible to wipe an ext4 file system ... File descriptor 6 (pipe:[2436816]) leaked on pvcreate invocation. Parent PID 23131: sh
File descriptor 7 (pipe:[2441744]) leaked on pvcreate invocation. Parent PID 23131: sh
File descriptor 9 (pipe:[2446707]) leaked on pvcreate invocation. Parent PID 23131: sh
File descriptor 11 (pipe:[2451810]) leaked on pvcreate invocation. Parent PID 23131: sh
File descriptor 13 (pipe:[2456933]) leaked on pvcreate invocation. Parent PID 23131: sh
File descriptor 15 (pipe:[2462100]) leaked on pvcreate invocation. Parent PID 23131: sh

the libblockdev package requires python2

And I guess that's a problem in the bright new tomorrow. I guess the python2 and python3 gi/overrides files need to go in separate packages. I don't know what all that will do to packages that depend on libblockdev, or if one of the overrides should stay in the main libblockdev package, or what. Unsurprisingly there's no guidance from the Fedora guidelines for things like this.

Switching online a nonexistent dasd device

When the bd_s390_dasd_online function from s390.c is called and the device with the given number does not exist, the function returns false without a message (an exception in Python).

Usage:

try:
  if not blockdev.s390.dasd_online(device):
    error = "The device could not be switched online. It may not exist."
except blockdev.S390Error as e:
  error = str(e)

make test modifies sources

On a fresh checkout I did run make test and the result is a modified git tree. I'm still not sure what causes it, but will look into it.

# git diff
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
index 5f4ab44..99c479c 100644
--- a/src/plugins/lvm.c
+++ b/src/plugins/lvm.c
@@ -415,7 +415,7 @@ guint64 *bd_lvm_get_supported_pe_sizes (GError **error __attribute__((unused)))
  * Returns: maximum LV size in bytes
  */
 guint64 bd_lvm_get_max_lv_size (GError **error __attribute__((unused))) {
-    return BD_LVM_MAX_LV_SIZE;
+    return 1024;//test-change
 }

 /**

RFE: Add support for GPT partitions

To get rid of an inversed-dependency in Storaged (direct calls of parted and sgdisk), I would like the libblockdev-part to provide following functionality:

1. Change a name of the given partition

2. Change a type of the given partition

3. Change flags of the given partition

  • Current implementation

    sgdisk --attributes partition_number:=:gpt_partition_flags_in_a_mask device_name
    
  • Please note, that part.h from 604fff2 doesn't provide API for manipulating all the necessary flags required by Storaged; we need to set these:

    • Bit 0 - System partition
    • Bit 2 - Legacy BIOS Bootable
    • Bit 60 - Read-only
    • Bit 62 - Hidden
    • Bit 63 - Do not automount

    Those bit number do not need to match 1-1, though (same as per BD_PART_FLAG_BOOT flag)

The wipe() function needs to try harder

Right now it errors out if it fails to get a libblkid probe for the block device. But the wipefs utility works in those cases. So we probably need to try multiple times, with some delays.?

Coverity: Issues in lvm.c

Error: COMPILER_WARNING: [#def10]
libblockdev-2.9/src/lib/blockdev.c:7: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/lvm.c:252:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const lvm_functions[] = {
#                    ^~~~~
#  250|   }
#  251|   
#  252|-> static const gchar const * const lvm_functions[] = {
#  253|       "bd_lvm_is_supported_pe_size",
#  254|       "bd_lvm_get_supported_pe_sizes",

Error: USE_AFTER_FREE (CWE-825): [#def38]
libblockdev-2.9/src/plugins/lvm.c:610: freed_arg: "g_free" frees "output".
libblockdev-2.9/src/plugins/lvm.c:612: pass_freed_arg: Passing freed pointer "output" as an argument to "g_set_error".
#  610|       g_free (output);
#  611|       if (ret == 0) {
#  612|->         g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
#  613|                        "Failed to parse number from thin_metadata_size's output: '%s'",
#  614|                        output);

Fix/improve the btrfs_resize function

In order to resize a btrfs file system one needs to specify sizes of space that should be used on devices used by the btrfs file system. Simply calling btrfs filesystem resize SIZE MNT_POINT only resizes the first device not the whole file system. btrfs filesystem resize DEV_ID:SIZE MNT_POINT resizes a particular device.

Thus we need to add a parameter to bd_btrfs_resize() that will allow callers to specify a device and if none is specified, we need to calculate how much space we need to take from devices used by the file system to get the given total size (as one would expect from such function).

Coverity: Issues in kbd.c

Error: COMPILER_WARNING: [#def8]
libblockdev-2.9/src/lib/blockdev.c:23: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/kbd.c:107:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const kbd_functions[] = {
#                    ^~~~~
#  105|   }
#  106|   
#  107|-> static const gchar const * const kbd_functions[] = {
#  108|       "bd_kbd_zram_create_devices",
#  109|       "bd_kbd_zram_destroy_devices",

RFE: Generic file system resizing support

Hello,
I'm missing the support for generic filesystem resizing (see fsadm(8)). Having an option to resize the underlying file system in lvresize would be nice too ("lvresize -r").

libblockdev-2.8 fails to compile

gcc (GCC) 6.3.0
systemd 233

./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --prefix=/usr/x86_64-pc-linux-gnu --bindir=/usr/x86_64-pc-linux-gnu/bin --sbindir=/usr/x86_64-pc-linux-gnu/bin --libdir=/usr/x86_64-pc-linux-gnu/lib --datadir=/usr/share --datarootdir=/usr/share --docdir=/usr/share/doc/libblockdev-2.8 --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --enable-fast-install --enable-introspection --with-python3 --without-gtk-doc --without-bcache --without-btrfs --without-crypto --without-dm --without-loop --without-lvm --without-lvm_dbus --without-mdraid --without-mpath --without-swap --without-kbd --without-part --without-fs --enable-tests

[...]
/bin/sh ../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-cc -I/usr/x86_64-pc-linux-gnu/include/glib-2.0 -I/usr/x86_64-pc-linux-gnu/lib/glib-2.0/include  -Wall -Wextra -Werror -pipe -O2 -march=native -version-info 3:0:1 -Wl,--no-undefined  -o libbd_utils.la -rpath /usr/x86_64-pc-linux-gnu/lib libbd_utils_la-exec.lo libbd_utils_la-extra_arg.lo libbd_utils_la-dev_utils.lo -lglib-2.0 -lm -lgio-2.0 -lgobject-2.0 -lglib-2.0  
libtool: link: x86_64-pc-linux-gnu-cc -shared  -fPIC -DPIC  .libs/libbd_utils_la-exec.o .libs/libbd_utils_la-extra_arg.o .libs/libbd_utils_la-dev_utils.o   -Wl,-rpath -Wl,/usr/x86_64-pc-linux-gnu/lib -Wl,-rpath -Wl,/usr/x86_64-pc-linux-gnu/lib -lm /usr/x86_64-pc-linux-gnu/lib/libgio-2.0.so -L/usr/x86_64-pc-linux-gnu/lib /usr/x86_64-pc-linux-gnu/lib/libgmodule-2.0.so -ldl -lz -lresolv /usr/x86_64-pc-linux-gnu/lib/libmount.so /usr/x86_64-pc-linux-gnu/lib/libblkid.so /usr/x86_64-pc-linux-gnu/lib/libuuid.so -lrt /usr/x86_64-pc-linux-gnu/lib/libgobject-2.0.so /usr/x86_64-pc-linux-gnu/lib/libffi.so /usr/x86_64-pc-linux-gnu/lib/libglib-2.0.so /usr/x86_64-pc-linux-gnu/lib/libpcre.so -lpthread  -O2 -march=native -Wl,--no-undefined   -pthread -Wl,-soname -Wl,libbd_utils.so.2 -o .libs/libbd_utils.so.2.1.0
.libs/libbd_utils_la-dev_utils.o: In function `bd_utils_get_device_symlinks':
dev_utils.c:(.text+0x11d): undefined reference to `udev_new'
dev_utils.c:(.text+0x133): undefined reference to `udev_device_new_from_subsystem_sysname'
dev_utils.c:(.text+0x147): undefined reference to `udev_device_get_devlinks_list_entry'
dev_utils.c:(.text+0x17b): undefined reference to `udev_list_entry_get_next'
dev_utils.c:(.text+0x1a8): undefined reference to `udev_list_entry_get_name'
dev_utils.c:(.text+0x1bd): undefined reference to `udev_list_entry_get_next'
dev_utils.c:(.text+0x1d5): undefined reference to `udev_device_unref'
dev_utils.c:(.text+0x1dd): undefined reference to `udev_unref'
dev_utils.c:(.text+0x21a): undefined reference to `udev_device_unref'
dev_utils.c:(.text+0x222): undefined reference to `udev_unref'
dev_utils.c:(.text+0x253): undefined reference to `udev_unref'
collect2: error: ld returned 1 exit status
make[2]: Leaving directory '/var/tmp/paludis/build/base-libblockdev-2.8/work/libblockdev-libblockdev-2.8-1/src/utils'
make[2]: *** [Makefile:470: libbd_utils.la] Error 1
make[1]: *** [Makefile:413: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/paludis/build/base-libblockdev-2.8/work/libblockdev-libblockdev-2.8-1/src'
make: *** [Makefile:473: all-recursive] Error 1
[...]

Please see the attached file for a full build log.

Warning for missing command line tools

When running make test I see the following warnings repeated over and over again:

** (process:25560): WARNING **: Cannot load the LVM plugin: The 'lvm' utility is not available

** (process:25560): WARNING **: Cannot load the LVM plugin: The 'thin_metadata_size' utility is not available
** (process:25560): WARNING **: Cannot load the BTRFS plugin: The 'btrfs' utility is not available
** (process:25560): WARNING **: Cannot load the swap plugin: The 'mkswap' utility is not available
** (process:25560): WARNING **: Cannot load the mpath plugin: The 'multipath' utility is not available
** (process:25560): WARNING **: Cannot load the DM plugin: The 'dmsetup' utility is not available
** (process:25560): WARNING **: Cannot load the MDRAID plugin: The 'mdadm' utility is not available
** (process:25560): WARNING **: Cannot load the kbd plugin: The 'make-bcache' utility is not available
** (process:25560): WARNING **: Cannot load the part plugin: The 'sgdisk' utility is not available
** (process:25560): WARNING **: Cannot load the part plugin: The 'sfdisk' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'mke2fs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'e2fsck' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'tune2fs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'dumpe2fs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'resize2fs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'mkfs.xfs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'xfs_db' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'xfs_repair' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'xfs_admin' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'xfs_growfs' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'mkfs.vfat' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'fatlabel' utility is not available
** (process:25560): WARNING **: Cannot load the FS plugin: The 'fsck.vfat' utility is not available

All of these command line utilities appear to be installed ...

Error when creating new bcache device

Creating new bcache using bd_kbd_bcache_create sometimes fail when trying to register the device:

Failed to write '/dev/sdb' to file '/sys/fs/bcache/register': No such file or directory

RFE: support random/one-time LUKS encryption (for swap)

Encrypted swap using a randomly generated passphrase (on every boot) is a common data-security technique, we should support it. But maybe there's nothing to do for this in libblockdev? This needs some research and potentially a bit of development.

Coverity: Issues in loop.c

Error: COMPILER_WARNING: [#def9]
libblockdev-2.9/src/lib/blockdev.c:13: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/loop.c:5:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const loop_functions[] = {
#                    ^~~~~
#    3|   }
#    4|   
#    5|-> static const gchar const * const loop_functions[] = {
#    6|       "bd_loop_get_backing_file",
#    7|       "bd_loop_get_loop_name",

Make init/close_plugin() functions callable from the outside

The plugins' initialization and finalization functions need to be callable when the plugins are used as standalone libraries. Right now, they are directly pulled out with the dlsym() calls when the plugins are loaded, but we cannot expect C code using the plugins as standalone libraries to do the same.

Parted warning is treated as an error

Currently any parted exception is treated as an error (which leads to abort). A parted exception may be only a warning and it should be treated as such in that case.

I would love to work on a PR to fix this.

I'm not sure how warnings should be treated in this library and therefore suggestions are welcome.

Furthermore this issue is a question on whether PRs on this are welcome at all.

Out of memory during the input sanitization in s390.c plugin

Functions bd_s390_sanitize_dev_input and bd_s390_zfcp_sanitize_lun_input can cause an out of memory error for invalid input.

For example in the command prepend = g_strnfill((4 - strlen(tmptok)), '0');, the length of the string tmpok is not checked, therefore 4 - strlen(tmptok) could be a negative number. However, g_strnfill expects an unsigned long integer, so the number will be converted to a very large number and g_strnfill will try to create a string of this length.

Problematic inputs:
bd_s390_sanitize_dev_input("123456")
bd_s390_zfcp_sanitize_wwpn_input("12345678901234567890")

Linking fails, missing gobject-2.0 and libm?

Trying to build libblockdev 2.6 (on Debian) results in the following error:

/bin/bash ../../libtool  --tag=CC   --mode=link gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -fdebug-prefix-map=/build/libblockdev-2.6=. -fstack-protector-strong -Wformat -Werror=format-security -L./../utils/ -version-info 2:0:0 -Wl,--no-undefined -Wl,-z,relro -o libblockdev.la -rpath /usr/lib/x86_64-linux-gnu libblockdev_la-blockdev.lo libblockdev_la-plugins.lo -lglib-2.0 ./../utils/libbd_utils.la -ldl 
libtool: link: gcc -shared  -fPIC -DPIC  .libs/libblockdev_la-blockdev.o .libs/libblockdev_la-plugins.o   -Wl,-rpath -Wl,/build/libblockdev-2.6/src/utils/.libs -L./../utils/ -lglib-2.0 ./../utils/.libs/libbd_utils.so -ldl  -g -O2 -fstack-protector-strong -Wl,--no-undefined -Wl,-z -Wl,relro   -Wl,-soname -Wl,libblockdev.so.2 -o .libs/libblockdev.so.2.0.0
.libs/libblockdev_la-blockdev.o: In function `bd_lvm_pvdata_get_type':
./src/lib/plugin_apis/lvm.c:61: undefined reference to `g_boxed_type_register_static'
.libs/libblockdev_la-blockdev.o: In function `bd_lvm_vgdata_get_type':
./src/lib/plugin_apis/lvm.c:115: undefined reference to `g_boxed_type_register_static'
.libs/libblockdev_la-blockdev.o: In function `bd_lvm_lvdata_get_type':
./src/lib/plugin_apis/lvm.c:186: undefined reference to `g_boxed_type_register_static'
.libs/libblockdev_la-blockdev.o: In function `bd_lvm_cache_stats_get_type':
./src/lib/plugin_apis/lvm.c:244: undefined reference to `g_boxed_type_register_static'
.libs/libblockdev_la-blockdev.o: In function `bd_btrfs_device_info_get_type':
./src/lib/plugin_apis/btrfs.c:42: undefined reference to `g_boxed_type_register_static'
.libs/libblockdev_la-blockdev.o:./src/lib/plugin_apis/btrfs.c:85: more undefined references to `g_boxed_type_register_static' follow
collect2: error: ld returned 1 exit status
Makefile:557: recipe for target 'libblockdev.la' failed
make[4]: *** [libblockdev.la] Error 1
make[4]: Leaving directory '/build/libblockdev-2.6/src/lib'

It seems to me like there's a missing -lgobject-2.0 as g_boxed_type_register_static is part of gobject, not glib.
See pkg-config --libs gobject-2.0 vs pkg-config --libs glib-2.0

PS. I've also had to add -lm in a couple of places to not run into problems with missing ceil etc.

--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -93,7 +93,7 @@
 
 if WITH_LVM
 libbd_lvm_la_CFLAGS = $(GLIB_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror
-libbd_lvm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la
+libbd_lvm_la_LIBADD = -lm $(GLIB_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la
 libbd_lvm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined
 libbd_lvm_la_CPPFLAGS = -I${builddir}/../../include/
 libbd_lvm_la_SOURCES = lvm.c lvm.h
@@ -101,7 +101,7 @@
 
 if WITH_LVM_DBUS
 libbd_lvm_dbus_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror
-libbd_lvm_dbus_la_LIBADD = $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la
+libbd_lvm_dbus_la_LIBADD = -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la
 libbd_lvm_dbus_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined
 libbd_lvm_dbus_la_CPPFLAGS = -I${builddir}/../../include/
 libbd_lvm_dbus_la_SOURCES = lvm-dbus.c lvm.h
@@ -150,7 +150,7 @@
 
 if WITH_PART
 libbd_part_la_CFLAGS = $(GLIB_CFLAGS) $(PARTED_CFLAGS) -Wall -Wextra -Werror
-libbd_part_la_LIBADD = $(GLIB_LIBS) $(PARTED_LIBS) ${builddir}/../utils/libbd_utils.la ${builddir}/libbd_part_err.la
+libbd_part_la_LIBADD = -lm $(GLIB_LIBS) $(PARTED_LIBS) ${builddir}/../utils/libbd_utils.la ${builddir}/libbd_part_err.la
 libbd_part_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined
 libbd_part_la_CPPFLAGS = -I${builddir}/../../include/
 libbd_part_la_SOURCES = part.c part.h

Coverity: Fix issues in blockdev.c

Error: COMPILER_WARNING: [#def1]
libblockdev-2.9/src/lib/blockdev.c:86:18: warning: unused variable 'name1' [-Wunused-variable]
#     const gchar *name1 = (const gchar *) a;
#                  ^~~~~
#   84|   
#   85|   static gint config_file_cmp (gconstpointer a, gconstpointer b, gpointer user_data __attribute__((unused))) {
#   86|->     const gchar *name1 = (const gchar *) a;
#   87|       const gchar *name2 = (const gchar *) b;
#   88|   

Error: COMPILER_WARNING: [#def2]
libblockdev-2.9/src/lib/blockdev.c: scope_hint: In function 'config_file_cmp'
libblockdev-2.9/src/lib/blockdev.c:87:18: warning: unused variable 'name2' [-Wunused-variable]
#     const gchar *name2 = (const gchar *) b;
#                  ^~~~~
#   85|   static gint config_file_cmp (gconstpointer a, gconstpointer b, gpointer user_data __attribute__((unused))) {
#   86|       const gchar *name1 = (const gchar *) a;
#   87|->     const gchar *name2 = (const gchar *) b;
#   88|   
#   89|       return g_strcmp0 (a, b);

Error: COMPILER_WARNING: [#def3]
libblockdev-2.9/src/lib/blockdev.c: scope_hint: In function 'load_config'
libblockdev-2.9/src/lib/blockdev.c:163:14: warning: unused variable 'i' [-Wunused-variable]
#     BDPlugin i = 0;
#              ^
#  161|       GSequenceIter *config_file_iter = NULL;
#  162|       gchar *config_file = NULL;
#  163|->     BDPlugin i = 0;
#  164|   
#  165|       /* process config files one after another in order */

Coverity: Fix duplicate const in mdraid.c, mpatch.c, part.c, swap.c

Error: COMPILER_WARNING: [#def11]
libblockdev-2.9/src/lib/blockdev.c:21: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/mdraid.c:140:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const mdraid_functions[] = {
#                    ^~~~~
#  138|   }
#  139|   
#  140|-> static const gchar const * const mdraid_functions[] = {
#  141|       "bd_md_get_superblock_size",
#  142|       "bd_md_create",

Error: COMPILER_WARNING: [#def12]
libblockdev-2.9/src/lib/blockdev.c:16: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/mpath.c:5:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const mpath_functions[] = {
#                    ^~~~~
#    3|   }
#    4|   
#    5|-> static const gchar const * const mpath_functions[] = {
#    6|       "bd_mpath_flush_mpaths",
#    7|       "bd_mpath_is_mpath_member",

Error: COMPILER_WARNING: [#def13]
libblockdev-2.9/src/lib/blockdev.c:25: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/part.c:84:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const part_functions[] = {
#                    ^~~~~
#   82|   }
#   83|   
#   84|-> static const gchar const * const part_functions[] = {
#   85|       "bd_part_create_table",
#   86|       "bd_part_get_part_spec",

Error: COMPILER_WARNING: [#def14]
libblockdev-2.9/src/lib/blockdev.c:11: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/swap.c:5:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const swap_functions[] = {
#                    ^~~~~
#    3|   }
#    4|   
#    5|-> static const gchar const * const swap_functions[] = {
#    6|       "bd_swap_mkswap",
#    7|       "bd_swap_swapon",

RFE: add support for TrueCrypt to the crypto plugin

The dm-crypt target as well as libcryptsetup both support TrueCrypt for disk encryption. libblockdev should provide functions for manipulation with block devices using this widely-supported encryption technology too.

Coverity: Issues in btrfs.c

Error: COMPILER_WARNING: [#def4]
libblockdev-2.9/src/lib/blockdev.c:9: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/btrfs.c:139:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const btrfs_functions[] = {
#                    ^~~~~
#  137|   }
#  138|   
#  139|-> static const gchar const * const btrfs_functions[] = {
#  140|       "bd_btrfs_create_volume",
#  141|       "bd_btrfs_add_device",

Use the LVM DBus API

A new implementation for the LVM plugin using the LVM DBus API instead of the CLI tools should be added.

improve error granularity

As of now, all errors raised by libblockdev are GLib.GError which, while sufficient, is not ideal for users like blivet. Ideally, libblockdev could increase the granularity of the errors it raises while also making them less generic.

@vpodzime mentioned the possibility of an error proxy in the BlockDev.py gi overrides, which sounds like a nice solution.

Coverity: Issues in fs.c

Error: COMPILER_WARNING: [#def7]
libblockdev-2.9/src/lib/blockdev.c:27: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/fs.c:209:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const fs_functions[] = {
#                    ^~~~~
#  207|   }
#  208|   
#  209|-> static const gchar const * const fs_functions[] = {
#  210|       "bd_fs_wipe",
#  211|       "bd_fs_clean",

Coverity: Issues in dm.c

Error: COMPILER_WARNING: [#def6]
libblockdev-2.9/src/lib/blockdev.c:18: included_from: Included from here.
libblockdev-2.9/src/lib/plugin_apis/dm.c:5:20: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
# static const gchar const * const dm_functions[] = {
#                    ^~~~~
#    3|   }
#    4|   
#    5|-> static const gchar const * const dm_functions[] = {
#    6|       "bd_dm_create_linear",
#    7|       "bd_dm_remove",
``

Make distcheck fails

I wanted to simply run the local unit tests and ran make ci which ends with:

...
make[1]: Entering directory '/home/tasleson/projects/libblockdev'
if test -d "libblockdev-2.7"; then find "libblockdev-2.7" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "libblockdev-2.7" || { sleep 5 && rm -rf "libblockdev-2.7"; }; else :; fi
test -d "libblockdev-2.7" || mkdir "libblockdev-2.7"
cp: failed to preserve ownership for libblockdev-2.7/tests/lvm_dbus_config/10-lvm-dbus.cfg: No such file or directory
cp: failed to preserve ownership for libblockdev-2.7/tests/lvm_dbus_config/00-default.cfg: No such file or directory
cp: failed to preserve ownership for libblockdev-2.7/tests/default_config/00-default.cfg: No such file or directory
make[1]: *** [Makefile:575: distdir] Error 1
make[1]: Leaving directory '/home/tasleson/projects/libblockdev'
make: *** [Makefile:672: dist] Error 2

I then used make test which it likely what I wanted to begin with.

Btrfs: Should be using ioctls instead of wrapping command line

ioctls exist for btrfs (indeed this is what btrfs-progs is using.) Instead of wrapping the command-line tool, which can change, and is meant for human consumption, libblockdev should use the ioctls directly. This is the only btrfs API guaranteed to be stable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.