Skip to contentSkip to conversation

dev-mornfall-activate - libdm: introduce dm_mountinfo_read

PATCH Petr Rockai 1 participant 1 message Jun 4, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1f30e5a0522a69aac0d246d2fb4e5ce2f6872cff
Commit:        1f30e5a0522a69aac0d246d2fb4e5ce2f6872cff
Parent:        d96b854ac054aafc8a9981016faefb9f122fccbb
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu May 16 11:34:26 2013 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon May 20 16:28:30 2013 +0200

libdm: introduce dm_mountinfo_read

Add function for parsing /proc/self/mountinfo entries. This can be used to detected mounted device.

---
 WHATS_NEW_DM         |    1 +
 libdm/libdevmapper.h |   13 ++++++++
 libdm/libdm-common.c |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 0 deletions(-)
WHATS_NEW_DM +1 -0
index 39ebcb2..8bdbfab 100644
@@ -1,5 +1,6 @@
 Version 1.02.78 - 
 ===================================
+  Add dm_mountinfo_read() for parsing /proc/self/mountinfo.
   Report error for nonexisting devices in dmeventd communication.
   Prevent double free error after dmeventd call of _fill_device_data().
   Update dmevent structure message_data to simplify/fix error path handling.
libdm/libdevmapper.h +13 -0
index b729846..d9cd280 100644
@@ -417,6 +417,19 @@ int dm_device_has_mounted_fs(uint32_t major, uint32_t minor);
 
 
 /*
+ * Callback is invoked for individal mountinfo lines,
+ * minor, major and mount target are parsed and unmangled.
+ */
+typedef int (*dm_mountinfo_line_callback_fn) (char *line, unsigned maj, unsigned min,
+					      char *target, void *cb_data);
+
+/*
+ * Read all lines from /proc/self/mountinfo,
+ * for each line calls read_fn callback.
+ */
+int dm_mountinfo_read(dm_mountinfo_line_callback_fn read_fn, void *cb_data);
+
+/*
  * Initialise library
  */
 void dm_lib_init(void) __attribute__((constructor));
libdm/libdm-common.c +77 -0

89 lines not on this page · raw message