void dev_cache_exit(void)
{
- _check_for_open_devices();
-
- pool_destroy(_cache.mem);
if (_cache.names)
+ _check_for_open_devices();
+
+ if (_cache.mem) {
+ pool_destroy(_cache.mem);
+ _cache.mem = NULL;
+ }
+
+ if (_cache.names) {
hash_destroy(_cache.names);
+ _cache.names = NULL;
+ }
+
+ _cache.devices = NULL;
+ _cache.has_scanned = 0;
+ list_init(&_cache.dirs);
}
int dev_cache_add_dir(const char *path)
}
if (!block_size)
- block_size = SECTOR_SIZE * 2;
+ block_size = getpagesize();
_widen_region(block_size, where, &widened);
}
}
-int dev_close(struct device *dev)
+static int _dev_close(struct device *dev, int immediate)
{
if (dev->fd < 0) {
log_error("Attempt to close device '%s' "
#endif
/* FIXME lookup device in cache to get vgname and see if it's locked? */
- if (--dev->open_count < 1 && !vgs_locked())
+ if (--dev->open_count < 1 && (immediate || !vgs_locked()))
_close(dev);
return 1;
}
+int dev_close(struct device *dev)
+{
+ return _dev_close(dev, 0);
+}
+
+int dev_close_immediate(struct device *dev)
+{
+ return _dev_close(dev, 1);
+}
+
void dev_close_all(void)
{
struct list *doh, *doht;
int dev_open_quiet(struct device *dev);
int dev_open_flags(struct device *dev, int flags, int append, int quiet);
int dev_close(struct device *dev);
+int dev_close_immediate(struct device *dev);
void dev_close_all(void);
static inline int dev_fd(struct device *dev)
return 0;
dev_zero(dev, UINT64_C(0), (size_t) 4096);
- dev_close(dev);
+ dev_close_immediate(dev);
return 1;
}