LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2011-09-22 17:23:36
Modified files:
. : WHATS_NEW_DM
libdm : libdevmapper.h libdm-common.c libdm-file.c
Log message:
Add dm_device_has_holders fn to to check use of the device by another device. Add dm_device_has_mounted_fs fn to check mounted filesystem on a device.
This requires sysfs directory to be correctly set via dm_set_sysfs_dir (/sys by default). If sysfs dir is not used or it's set incorrectly, dm_device_has_{holders,mounted_fs} will return 0!
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.502&r2=1.503
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.151&r2=1.152
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-file.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
WHATS_NEW_DM +2 -0
@@ -1,5 +1,7 @@ Version 1.02.68 - ================================== + Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. + Add dm_device_has_holders fn to to check use of the device by another device. Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set. Add dm_set_sysfs_dir to libdevmapper to set sysfs location. Add --retry option for dmsetup remove to retry removal if not successful.
libdm/libdevmapper.h +15 -0
@@ -267,6 +267,19 @@int dm_is_dm_major (uint32_t major);/* +* Determine whether a device has any holders (devices +* using this device). If sysfs is not used (or configured +* incorrectly), returns 0. +*/ +int dm_device_has_holders (uint32_t major,uint32_t minor); + +/* +* Determine whether a device contains mounted filesystem. +* If sysfs is not used (or configured incorrectly), returns 0. +*/ +int dm_device_has_mounted_fs (uint32_t major,uint32_t minor); + +/* * Release library resources */ void dm_lib_release (void );
@@ -1069,6 +1082,8 @@*/ int dm_create_dir (const char *dir); +int dm_is_empty_dir (const char *dir); +/* * Close a stream, with nicer error checking than fclose's. * Derived from gnulib's close-stream.c.
libdm/libdm-common.c +100 -0
106 lines not on this page · raw message
libdm/libdm-file.c +20 -0
@@ -76,6 +76,26 @@return 0 ; } +int dm_is_empty_dir (const char *dir) +{ +struct dirent *dirent; +DIR *d; + +if (!(d =opendir (dir))) { +log_sys_error ("opendir" , dir); +return 0 ; + } + +while ((dirent =readdir (d))) +if (strcmp (dirent->d_name,"." ) &&strcmp (dirent->d_name,".." )) +break ; + +if (closedir (d)) +log_sys_error ("closedir" , dir); + +return dirent ?0 :1 ; +} +int dm_fclose (FILE *stream) {int prev_fail =ferror (stream);