From a5072db62aa152ddd219e49fafa8367cd53940ec Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 1 Oct 2001 15:27:16 +0000 Subject: [PATCH] o added filter type. --- lib/dev-mgr/dev-cache.h | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/dev-mgr/dev-cache.h b/lib/dev-mgr/dev-cache.h index ad8700312..b35adc655 100644 --- a/lib/dev-mgr/dev-cache.h +++ b/lib/dev-mgr/dev-cache.h @@ -9,21 +9,51 @@ #ifndef _LVM_DEV_CACHE_H #define _LVM_DEV_CACHE_H +/* + * All devices in LVM will be represented by one of these. + * pointer comparisons are valid. + */ struct device { char *name; dev_t dev; }; -int init_dev_cache(); -void exit_dev_cache(); +struct dev_filter { + int (*fn)(struct device *dev, struct dev_cache_filter *f); + void *private; +}; + + +/* + * The global device cache. + */ +int dev_cache_init(void); +void dev_cache_exit(void); + +int dev_cache_add_dir(const char *path); +struct device *dev_cache_get(const char *name); +void dev_cache_put(struct device *d); + + +/* + * Object for iterating through the cache. + */ +struct dev_iter; +struct dev_iter dev_iter_create(struct dev_filter *f); +void dev_iter_destroy(struct dev_iter *iter); + +struct device *dev_cache_iter_get(struct dev_iter *iter); +void dev_cache_iter_put(struct dev_iter *iter); + +/* returns 0 on eof */ +int dev_cache_next(struct dev_iter *iter); -struct device *get_device(const char *name); -void put_device(struct device *d); /* * All io should use these routines, rather than opening the devices * by hand. You do not have to call an open routine. */ +uint64_t dev_get_size(struct device *dev); /* in 512 byte sectors */ ssize_t dev_read(struct device *dev, size_t offset, size_t len, void *buffer); ssize_t dev_write(struct device *dev, size_t offset, size_t len, void *buffer);