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:
parent
12a8b590e0
commit
1993c0acc2
@ -31,6 +31,7 @@
|
|||||||
* _list_insert. Most of the logic from _hash_insert is now in
|
* _list_insert. Most of the logic from _hash_insert is now in
|
||||||
* _add.
|
* _add.
|
||||||
* 20/08/2001 - Created _add_named_device and used it in dev_by_name
|
* 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 "pool.h"
|
||||||
#include "dev-manager.h"
|
#include "dev-manager.h"
|
||||||
|
|
||||||
|
#define DEFAULT_BASE_DIR "/dev"
|
||||||
|
|
||||||
struct dev_i {
|
struct dev_i {
|
||||||
struct device d;
|
struct device d;
|
||||||
|
|
||||||
@ -91,10 +94,11 @@ static inline struct device *_get_dev(struct dev_i *di)
|
|||||||
return di ? &di->d : 0;
|
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 pool *pool = create_pool(10 * 1024);
|
||||||
struct dev_mgr *dm;
|
struct dev_mgr *dm = NULL;
|
||||||
|
const char * base_dir = NULL;
|
||||||
|
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
stack;
|
stack;
|
||||||
@ -110,9 +114,13 @@ struct dev_mgr *init_dev_manager()
|
|||||||
memset(dm, 0, sizeof(*dm));
|
memset(dm, 0, sizeof(*dm));
|
||||||
dm->pool = pool;
|
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 = 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)) {
|
if (!_create_hash_table(dm, 128)) {
|
||||||
stack;
|
stack;
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#ifndef DEV_MANAGER_H
|
#ifndef DEV_MANAGER_H
|
||||||
#define DEV_MANAGER_H
|
#define DEV_MANAGER_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
struct device {
|
struct device {
|
||||||
char *name;
|
char *name;
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
@ -30,7 +32,7 @@ struct device {
|
|||||||
struct dev_mgr;
|
struct dev_mgr;
|
||||||
typedef struct _dummy_counter *dev_counter_t;
|
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);
|
void fin_dev_manager(struct dev_mgr *dm);
|
||||||
|
|
||||||
struct device *dev_by_name(struct dev_mgr *dm, const char *name);
|
struct device *dev_by_name(struct dev_mgr *dm, const char *name);
|
||||||
|
Loading…
Reference in New Issue
Block a user