Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udiskslinuxdriveata: Port to libblockdev SMART plugin #1179

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ if test "x$enable_daemon" = "xyes"; then
AC_SUBST(BLOCKDEV_CFLAGS)
AC_SUBST(BLOCKDEV_LIBS)

PKG_CHECK_MODULES(LIBATASMART, [libatasmart >= 0.17])
AC_SUBST(LIBATASMART_CFLAGS)
AC_SUBST(LIBATASMART_LIBS)

PKG_CHECK_MODULES(LIBBLKID, [blkid])
AC_SUBST(LIBBLKID_CFLAGS)
AC_SUBST(LIBBLKID_LIBS)
Expand Down Expand Up @@ -215,6 +211,7 @@ if test "x$enable_daemon" = "xyes"; then
else
have_libsystemd_login=no
have_libelogind=no
AM_CONDITIONAL(HAVE_SMART, [0])
fi
AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, test x$have_libsystemd_login = xyes)
AM_CONDITIONAL(HAVE_LIBELOGIND, test x$have_libelogind = xyes)
Expand Down Expand Up @@ -544,6 +541,28 @@ if test "x$enable_daemon" = "xyes"; then
if test "x$have_nvme" = "xno"; then
AC_MSG_ERROR([BLOCKDEV NVMe support requested but header or library not found])
fi

# libblockdev smart
have_smart=no
AC_ARG_ENABLE(smart, AS_HELP_STRING([--disable-smart], [disable ATA SMART support]))
if test "x$enable_smart" != "xno"; then
SAVE_CFLAGS=$CFLAGS
SAVE_LDFLAGS=$LDFLAGS

CFLAGS="$GLIB_CFLAGS"
LDFLAGS="$GLIB_LIBS"
AC_MSG_CHECKING([libblockdev-smart presence])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <blockdev/smart.h>]], [[]])],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_SMART, 1, [Define, if libblockdev-smart is available])
have_smart=yes],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([libblockdev-smart requested but not found.])
have_smart=no])
CFLAGS=$SAVE_CFLAGS
LDFLAGS=$SAVE_LDFLAGS
fi
AM_CONDITIONAL(HAVE_SMART, [test "$have_smart" = "yes"])
fi


Expand Down Expand Up @@ -674,6 +693,7 @@ echo "
Enable daemon: ${enable_daemon}
Enable modules: ${enable_modules_info}

ATA SMART support: ${have_smart}
BTRFS module: ${have_btrfs}
iSCSI module: ${have_iscsi}${have_libiscsi_session_info_msg}
LVM2 module: ${have_lvm2}
Expand Down
14 changes: 9 additions & 5 deletions data/org.freedesktop.UDisks2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,13 @@
<literal>org.freedesktop.UDisks2.Error.WouldWakeup</literal> is
returned.

The option @atasmart_blob can be used to inject libatasmart
compatible blobs for testing how clients react to different
kinds of SMART data. This option may be removed in the future
without it being considered an ABI break.
The option @atasmart_blob (of type 's' representing a path to
the blob file) can be used to inject libatasmart-compatible
blobs for testing how clients react to different kinds of SMART
data. Only valid when backed with the
<literal>libblockdev_libatasmat</literal> plugin. This option
may be removed in the future without it being considered an ABI
break. Deprecated since 2.11.0.
-->
<method name="SmartUpdate">
<arg name="options" direction="in" type="a{sv}"/>
Expand Down Expand Up @@ -946,7 +949,8 @@

Starts a SMART selftest. The @type parameter is for the type
of test to start - valid values are <literal>short</literal>,
<literal>extended</literal> and <literal>conveyance</literal>.
<literal>extended</literal>, <literal>conveyance</literal> and
<literal>offline</literal> (since 2.11.0).

Note that the method returns immediately after the test has
been started successfully.
Expand Down
5 changes: 4 additions & 1 deletion misc/install-test-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
package: name=libblockdev-nvme-devel state=present
when: ansible_distribution == 'Fedora'

- name: Install libblockdev SMART plugin (Fedora)
package: name=libblockdev-smart-devel state=present
when: ansible_distribution == 'Fedora'

- name: Install test dependencies (Fedora)
package: name={{item}} state=present
with_items:
Expand All @@ -59,5 +63,4 @@
- python-systemd
- python3-systemd
- python3-monotonic
- python3-monotonic
when: ansible_distribution == 'Fedora'
7 changes: 3 additions & 4 deletions packaging/udisks2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
%global gobject_introspection_version 1.30.0
%global polkit_version 0.102
%global systemd_version 208
%global libatasmart_version 0.17
%global dbus_version 1.4.0
%global with_gtk_doc 1
%global libblockdev_version 3.0
Expand Down Expand Up @@ -36,7 +35,6 @@ Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{v
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version}
BuildRequires: libgudev1-devel >= %{systemd_version}
BuildRequires: libatasmart-devel >= %{libatasmart_version}
BuildRequires: polkit-devel >= %{polkit_version}
BuildRequires: systemd >= %{systemd_version}
BuildRequires: systemd-devel >= %{systemd_version}
Expand All @@ -54,6 +52,7 @@ BuildRequires: libblockdev-mdraid-devel >= %{libblockdev_version}
BuildRequires: libblockdev-fs-devel >= %{libblockdev_version}
BuildRequires: libblockdev-crypto-devel >= %{libblockdev_version}
BuildRequires: libblockdev-nvme-devel >= %{libblockdev_version}
BuildRequires: libblockdev-smart-devel >= %{libblockdev_version}
BuildRequires: libmount-devel
BuildRequires: libuuid-devel

Expand All @@ -65,15 +64,14 @@ Requires: libblockdev-mdraid >= %{libblockdev_version}
Requires: libblockdev-fs >= %{libblockdev_version}
Requires: libblockdev-crypto >= %{libblockdev_version}
Requires: libblockdev-nvme >= %{libblockdev_version}
Requires: libblockdev-smart >= %{libblockdev_version}

Requires: lib%{name}%{?_isa} = %{version}-%{release}

# Needed to pull in the system bus daemon
Requires: dbus >= %{dbus_version}
# Needed to pull in the udev daemon
Requires: udev >= %{systemd_version}
# We need at least this version for bugfixes/features etc.
Requires: libatasmart >= %{libatasmart_version}
# For mount, umount, mkswap
Requires: util-linux
# For ejecting removable disks
Expand Down Expand Up @@ -201,6 +199,7 @@ autoreconf -ivf
%else
--disable-gtk-doc \
%endif
--enable-smart \
%if 0%{?with_btrfs}
--enable-btrfs \
%endif
Expand Down
2 changes: 0 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ libudisks_daemon_la_CFLAGS = \
$(GIO_CFLAGS) \
$(GMODULE_CFLAGS) \
$(GUDEV_CFLAGS) \
$(LIBATASMART_CFLAGS) \
$(LIBBLKID_CFLAGS) \
$(LIBMOUNT_CFLAGS) \
$(LIBUUID_CFLAGS) \
Expand All @@ -138,7 +137,6 @@ libudisks_daemon_la_LIBADD = \
$(GUDEV_LIBS) \
$(BLOCKDEV_LIBS) \
-lbd_utils \
$(LIBATASMART_LIBS) \
$(LIBBLKID_LIBS) \
$(LIBMOUNT_LIBS) \
$(LIBUUID_LIBS) \
Expand Down
10 changes: 8 additions & 2 deletions src/udisksdaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,18 @@ udisks_daemon_constructed (GObject *object)
BDPluginSpec fs_plugin = {BD_PLUGIN_FS, NULL};
BDPluginSpec crypto_plugin = {BD_PLUGIN_CRYPTO, NULL};
BDPluginSpec nvme_plugin = {BD_PLUGIN_NVME, NULL};

#ifdef HAVE_SMART
BDPluginSpec smart_plugin = {BD_PLUGIN_SMART, NULL};
#endif
/* 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. */
BDPluginSpec *plugins[] = {&part_plugin, &swap_plugin, &loop_plugin, &mdraid_plugin,
&fs_plugin, &crypto_plugin, &nvme_plugin, NULL};
&fs_plugin, &crypto_plugin, &nvme_plugin,
#ifdef HAVE_SMART
&smart_plugin,
#endif
NULL};
BDPluginSpec **plugin_p = NULL;
error = NULL;

Expand Down
4 changes: 2 additions & 2 deletions src/udiskslinuxdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ udisks_linux_device_new_sync (GUdevDevice *udev_device)
out:
if (error != NULL)
{
udisks_critical ("Error probing device: %s (%s, %d)",
error->message, g_quark_to_string (error->domain), error->code);
udisks_warning ("Error probing device: %s (%s, %d)",
error->message, g_quark_to_string (error->domain), error->code);
g_clear_error (&error);
}

Expand Down
Loading
Loading