1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-02 22:42:30 +03:00

deallocations

This commit is contained in:
Alasdair Kergon 2001-10-23 12:33:57 +00:00
parent 10a6939753
commit 014a5c0bf0
3 changed files with 22 additions and 9 deletions

View File

@ -33,6 +33,7 @@ static void _destroy(struct dev_filter *f)
}
dbg_free(f->private);
dbg_free(f);
}

View File

@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <linux/kdev_t.h>
#define NUMBER_OF_MAJORS 256
@ -56,11 +57,21 @@ static int *scan_proc_dev(void);
static int passes_lvm_type_device_filter(struct dev_filter *f, struct device *dev)
{
int fd;
/* Is this a recognised device type? */
if (!(((int *) f->private)[MAJOR(dev->dev)]))
return 0;
else
return 1;
/* Check it's accessible */
if ((fd = open(dev->name, O_RDONLY)) < 0) {
log_debug("Unable to open %s: %s", dev->name, strerror(errno));
return 0;
}
close(fd);
return 1;
}
struct dev_filter *lvm_type_filter_create()
@ -68,11 +79,12 @@ struct dev_filter *lvm_type_filter_create()
struct dev_filter *f;
if (!(f = dbg_malloc(sizeof (struct dev_filter)))) {
log_error("lvm_v1_filter allocation failed");
log_error("LVM type filter allocation failed");
return NULL;
}
f->passes_filter = passes_lvm_type_device_filter;
f->destroy = lvm_type_filter_destroy;
if (!(f->private = scan_proc_dev()))
return NULL;

View File

@ -608,22 +608,22 @@ static struct dev_filter *filter_setup(void)
struct config_node *cn;
struct dev_filter *f1, *f2, *f3, *f4;
if (!(f1 = lvm_type_filter_create()))
if (!(f2 = lvm_type_filter_create()))
return 0;
if (!(cn = find_config_node(_cf->root, "devices/filter", '/'))) {
log_debug("devices/filter not found in config file");
return f1;
return f2;
}
if (!(f2 = regex_filter_create(cn->v))) {
if (!(f1 = regex_filter_create(cn->v))) {
log_error("Failed to create regex device filter");
return f1;
return f2;
}
if (!(f4 = composite_filter_create(2, f1, f2))) {
log_error("Failed to create composite device filter");
return f1;
return f2;
}
return f4;
@ -699,7 +699,7 @@ static void __fin_commands(void)
static void fin(void)
{
ios->destroy(ios);
lvm_type_filter_destroy(_filter);
_filter->destroy(_filter);
dev_cache_exit();
destroy_config_file(_cf);
__fin_commands();