Skip to content

Commit

Permalink
udiskslinuxdriveata: Port to libblockdev SMART plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tbzatek committed Sep 5, 2023
1 parent 6527ea3 commit 8b50633
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 377 deletions.
24 changes: 20 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 @@ -544,6 +540,25 @@ 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/SCSI 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])
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 +689,7 @@ echo "
Enable daemon: ${enable_daemon}
Enable modules: ${enable_modules_info}

ATA/SCSI SMART support: ${have_smart}
BTRFS module: ${have_btrfs}
iSCSI module: ${have_iscsi}${have_libiscsi_session_info_msg}
LVM2 module: ${have_lvm2}
Expand Down
3 changes: 2 additions & 1 deletion data/org.freedesktop.UDisks2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,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
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
Loading

0 comments on commit 8b50633

Please sign in to comment.