From ebfe584afcfc48434113b74c182dd732219bd1f4 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 16 May 2005 15:15:34 +0000 Subject: [PATCH] Call dm_lib_exit() and dm_lib_release() automatically now. --- WHATS_NEW_DM | 1 + libdm/ioctl/libdm-iface.c | 7 +++---- libdm/libdevmapper.h | 2 +- tools/dmsetup.c | 3 --- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 7e900e429..6fa4bec9c 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.01.02 - ============================= + Call dm_lib_exit() and dm_lib_release() automatically now. Add --target filter to dmsetup table/status. Fix dmsetup getopt_long usage. diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 27ba1f4dc..471ca851a 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -117,6 +117,7 @@ static void *_align(void *ptr, unsigned int a) return (void *) (((unsigned long) ptr + agn) & ~agn); } +#ifdef DM_IOCTLS static int _get_proc_number(const char *file, const char *name, uint32_t *number) { @@ -226,6 +227,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor) return 1; } +#endif static int _open_control(void) { @@ -1396,10 +1398,7 @@ void dm_lib_release(void) void dm_lib_exit(void) { - if (_control_fd != -1) { - close(_control_fd); - _control_fd = -1; - } + dm_lib_release(); _version_ok = 1; _version_checked = 0; } diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 8cab2d94c..44be174af 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -166,6 +166,6 @@ const char *dm_dir(void); /* Release library resources */ void dm_lib_release(void); -void dm_lib_exit(void); +void dm_lib_exit(void) __attribute((destructor)); #endif /* LIB_DEVICE_MAPPER_H */ diff --git a/tools/dmsetup.c b/tools/dmsetup.c index f38c1d804..19a53f875 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -1073,8 +1073,5 @@ int main(int argc, char **argv) exit(1); } - dm_lib_release(); - dm_lib_exit(); - return 0; }