1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

o Added _basic_ config file support to the device manager

This commit is contained in:
AJ Lewis 2001-08-21 14:44:18 +00:00
parent 12a8b590e0
commit 1993c0acc2
2 changed files with 15 additions and 5 deletions

View File

@ -31,6 +31,7 @@
* _list_insert. Most of the logic from _hash_insert is now in
* _add.
* 20/08/2001 - Created _add_named_device and used it in dev_by_name
* 21/08/2001 - Basic config file support added
*
*/
@ -39,6 +40,8 @@
#include "pool.h"
#include "dev-manager.h"
#define DEFAULT_BASE_DIR "/dev"
struct dev_i {
struct device d;
@ -91,10 +94,11 @@ static inline struct device *_get_dev(struct dev_i *di)
return di ? &di->d : 0;
}
struct dev_mgr *init_dev_manager()
struct dev_mgr *init_dev_manager(struct config_node *cn)
{
struct pool *pool = create_pool(10 * 1024);
struct dev_mgr *dm;
struct dev_mgr *dm = NULL;
const char * base_dir = NULL;
if (!pool) {
stack;
@ -110,9 +114,13 @@ struct dev_mgr *init_dev_manager()
memset(dm, 0, sizeof(*dm));
dm->pool = pool;
/* FIXME: This should be setup based on the config file */
if(cn)
base_dir = find_config_str(cn, "dev-mgr/base_dir", '/', 0);
if(!base_dir)
base_dir = DEFAULT_BASE_DIR;
dm->devdir = pool_alloc(dm->pool, sizeof(char*));
dm->devdir[0] = pool_strdup(dm->pool, "/dev");
dm->devdir[0] = pool_strdup(dm->pool, base_dir);
if (!_create_hash_table(dm, 128)) {
stack;

View File

@ -22,6 +22,8 @@
#ifndef DEV_MANAGER_H
#define DEV_MANAGER_H
#include "config.h"
struct device {
char *name;
dev_t dev;
@ -30,7 +32,7 @@ struct device {
struct dev_mgr;
typedef struct _dummy_counter *dev_counter_t;
struct dev_mgr *init_dev_manager();
struct dev_mgr *init_dev_manager(struct config_node *cfg_node);
void fin_dev_manager(struct dev_mgr *dm);
struct device *dev_by_name(struct dev_mgr *dm, const char *name);