summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bdbc066)
raw | patch | inline | side by side (parent: bdbc066)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Wed, 25 May 2016 07:54:46 +0000 (13:54 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Wed, 25 May 2016 07:54:46 +0000 (13:54 +0600) |
src/disk.c | patch | blob | history |
diff --git a/src/disk.c b/src/disk.c
index 07383c75d7b0b833a455a6c9c347f815a4b34c74..255d4db6076d905210e7fd1628217c05bcaf6db1 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
/* #endif HAVE_IOKIT_IOKITLIB_H */
#elif KERNEL_LINUX
- /* do nothing */
+#if HAVE_LIBUDEV
+ if (conf_udev_name_attr != NULL)
+ {
+ handle_udev = udev_new();
+ if (handle_udev == NULL) {
+ ERROR ("disk plugin: udev_new() failed!");
+ return (-1);
+ }
+ }
+#endif /* HAVE_LIBUDEV */
/* #endif KERNEL_LINUX */
#elif KERNEL_FREEBSD
return (0);
} /* int disk_init */
+static int disk_shutdown (void)
+{
+#if KERNEL_LINUX
+#if HAVE_LIBUDEV
+ if (handle_udev != NULL)
+ udev_unref(handle_udev);
+#endif /* HAVE_LIBUDEV */
+#endif /* KERNEL_LINUX */
+ return (0);
+} /* int disk_shutdown */
+
static void disk_submit (const char *plugin_instance,
const char *type,
derive_t read, derive_t write)
fieldshift = 1;
}
-#if HAVE_LIBUDEV
- handle_udev = udev_new();
-#endif
-
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
char *disk_name;
#endif
} /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */
-#if HAVE_LIBUDEV
- udev_unref(handle_udev);
-#endif
fclose (fh);
/* #endif defined(KERNEL_LINUX) */
plugin_register_config ("disk", disk_config,
config_keys, config_keys_num);
plugin_register_init ("disk", disk_init);
+ plugin_register_shutdown ("disk", disk_shutdown);
plugin_register_read ("disk", disk_read);
} /* void module_register */