1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

o got dbg_malloc_t working, Alasdair could you look at the Makefile.in it

seems to be having trouble with the dependencies.

o removed some files from the lib makefile that don't compile yet.
This commit is contained in:
Joe Thornber 2001-10-04 10:13:07 +00:00
parent 72ecb99e54
commit 7fc0905843
17 changed files with 142 additions and 120 deletions

8
configure vendored
View File

@ -556,7 +556,7 @@ ac_config_sub=$ac_aux_dir/config.sub
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
for ac_prog in gawk mawk nawk awk
for ac_prog in mawk gawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@ -1317,7 +1317,7 @@ else
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x;
typedef int charset[2]; const charset x = {0,0};
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
@ -1392,7 +1392,7 @@ for ac_kw in inline __inline__ __inline; do
#include "confdefs.h"
int main() {
} $ac_kw foo() {
} int $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:1399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
@ -2159,6 +2159,7 @@ include/Makefile \
lib/Makefile \
man/Makefile \
tools/Makefile \
test/mm/Makefile \
" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@ -2254,6 +2255,7 @@ include/Makefile \
lib/Makefile \
man/Makefile \
tools/Makefile \
test/mm/Makefile \
"}
EOF
cat >> $CONFIG_STATUS <<\EOF

View File

@ -135,4 +135,5 @@ include/Makefile \
lib/Makefile \
man/Makefile \
tools/Makefile \
test/mm/Makefile \
)

View File

@ -14,12 +14,7 @@ SOURCES=\
dev-mgr/dev-cache.c \
device/dev-cache.c \
device/dev-io.c \
device/device.c \
display/display.c \
display/metadata.c \
filters/filter.c \
log/log.c \
metadata/metadata.c \
mm/dbg_malloc.c \
mm/pool.c

View File

@ -77,7 +77,7 @@ static int _tok_match(const char *str, const char *b, const char *e);
struct config_file *create_config_file()
{
struct cs *c;
struct pool *mem = create_pool(10 * 1024);
struct pool *mem = pool_create(10 * 1024);
if (!mem) {
stack;
@ -86,7 +86,7 @@ struct config_file *create_config_file()
if (!(c = pool_alloc(mem, sizeof(*c)))) {
stack;
destroy_pool(mem);
pool_destroy(mem);
return 0;
}
@ -97,7 +97,7 @@ struct config_file *create_config_file()
void destroy_config_file(struct config_file *cf)
{
destroy_pool(((struct cs *) cf)->mem);
pool_destroy(((struct cs *) cf)->mem);
}
int read_config(struct config_file *cf, const char *file)

View File

@ -72,7 +72,7 @@ struct hash_table *create_hash_table(unsigned size_hint)
{
size_t len;
unsigned new_size = 16u;
struct hash_c *hc = dbg_malloc(sizeof(*hc));
struct hash_table *hc = dbg_malloc(sizeof(*hc));
if (!hc) {
stack;
@ -92,7 +92,7 @@ struct hash_table *create_hash_table(unsigned size_hint)
goto bad;
}
memset(hc->slots, 0, len);
return (struct hash_table) hc;
return hc;
bad:
dbg_free(hc->slots);
@ -102,7 +102,7 @@ struct hash_table *create_hash_table(unsigned size_hint)
void destroy_hash_table(struct hash_table *t)
{
struct hash_node **c, *n;
struct hash_node *c, *n;
int i;
for (i = 0; i < t->num_slots; i++)
@ -111,8 +111,8 @@ void destroy_hash_table(struct hash_table *t)
dbg_free(c);
}
dbg_free(hc->slots);
dbg_free(hc);
dbg_free(t->slots);
dbg_free(t);
}
static inline struct hash_node **_find(struct hash_table *t, const char *key)
@ -121,10 +121,10 @@ static inline struct hash_node **_find(struct hash_table *t, const char *key)
struct hash_node **c;
for(c = &t->slots[h]; *c; c = &((*c)->next))
if(!strcmp(key, *c->key))
if(!strcmp(key, (*c)->key))
break;
return c
return c;
}
char *hash_lookup(struct hash_table *t, const char *key)
@ -160,8 +160,8 @@ void hash_remove(struct hash_table *t, const char *key)
if (*c) {
struct hash_node *old = *c;
*c = *c->next;
dbg_free(*old);
*c = (*c)->next;
dbg_free(old);
t->num_nodes--;
}
}

View File

@ -16,7 +16,7 @@ struct hash_table *hash_create(unsigned size_hint);
void hash_destroy(struct hash_table *t);
char *hash_lookup(struct hash_table *t, const char *key);
void hash_insert(struct hash_table *t, const char *key, void *data);
int hash_insert(struct hash_table *t, const char *key, void *data);
void hash_remove(struct hash_table *t, const char *key);
unsigned hash_get_num_entries(struct hash_table *t);

View File

@ -8,8 +8,15 @@
#include "log.h"
#include "pool.h"
#include "hash.h"
#include "list.h"
#include "dbg_malloc.h"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/param.h>
#include <dirent.h>
/*
* FIXME: really need to seperate names from the devices since
@ -22,8 +29,8 @@ struct dev_iter {
};
struct dir_list {
struct list_head dir_list;
char *dir[0];
struct list_head list;
char dir[0];
};
static struct {
@ -42,11 +49,11 @@ static struct {
/*
* return a new path for the destination of the path.
*/
static char * _follow_link(const char *path, struct stat *info)
static char *_follow_link(const char *path, struct stat *info)
{
char buffer[PATH_MAX + 1], *r;
char buffer[PATH_MAX + 1];
int n;
n = readlink(path, buffer);
n = readlink(path, buffer, sizeof(buffer) - 1);
if (n <= 0)
return NULL;
@ -87,52 +94,56 @@ static struct device *_create_dev(const char *path)
{
struct stat info;
struct device *dev;
char *normed = _collapse_slashes(path);
char *name = pool_strdup(_cache.mem, path);
if (!normed) {
if (!name) {
stack;
return NULL;
}
if (stat(normed, &info) < 0) {
log_sys_error("stat");
return NULL;
_collapse_slashes(name);
if (stat(name, &info) < 0) {
log_sys_err("stat");
goto bad;
}
if (S_ISLNK(info.st_mode)) {
char *new_path;
log_debug("%s is a symbolic link, following\n", normed);
normed = _follow_link(normed, &info);
if (!normed)
return NULL;
log_debug("%s is a symbolic link, following\n", name);
if (!(name = _follow_link(name, &info))) {
stack;
goto bad;
}
}
if (!S_ISBLK(info.st_mode)) {
log_debug("%s is not a block device\n", normed);
return NULL;
log_debug("%s is not a block device\n", name);
goto bad;
}
if (!(dev = _alloc(sizeof(*dev)))) {
stack;
return NULL;
goto bad;
}
dev->name = normed;
dev->name = name;
dev->dev = info.st_rdev;
return dev;
bad:
_free(name);
return NULL;
}
static struct device *_add(const char *dir, const char *path)
{
struct device *d;
int len = strlen(dir) + strlen(path) + 2;
char *buffer = _alloc(len);
char *buffer = dbg_malloc(len);
snprintf(buffer, len, "%s/%s", path);
d = dev_cache_get(path);
if (!d)
_free(buffer); /* pool_free is safe in this case */
snprintf(buffer, len, "%s/%s", dir, path);
d = dev_cache_get(buffer, NULL);
dbg_free(buffer);
return d;
}
@ -156,13 +167,15 @@ static int _dir_scan(const char *dir)
static void _full_scan(void)
{
struct dir_list *dl;
struct list_head *tmp;
if (_cache.has_scanned)
return;
for (dl = _cache.dirs.next; dl != &_cache.dirs; dl = dl->next)
_dir_scan(dl.dir);
list_for_each(tmp, &_cache.dirs) {
struct dir_list *dl = list_entry(tmp, struct dir_list, list);
_dir_scan(dl->dir);
}
_cache.has_scanned = 1;
}
@ -198,19 +211,25 @@ int dev_cache_add_dir(const char *path)
return 0;
strcpy(dl->dir, path);
list_add(dl, _cache.directories);
list_add(&dl->list, &_cache.dirs);
return 1;
}
struct device *dev_cache_get(const char *name)
struct device *_insert_new(const char *name)
{
struct device *d = hash_lookup(_cache.devices, name);
if (!d && (d = _create_device(name)))
hash_insert(t, name, d);
struct device *d = _create_dev(name);
if (!d || !hash_insert(_cache.devices, name, d))
return NULL;
return d;
}
struct device *dev_cache_get(const char *name, struct dev_filter *f)
{
struct device *d = (struct device *) hash_lookup(_cache.devices, name);
return (d && (!f || f->passes_filter(f, d))) ? d : NULL;
}
struct dev_iter *dev_iter_create(struct dev_filter *f)
{
struct dev_iter *di = dbg_malloc(sizeof(*di));
@ -219,7 +238,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f)
return NULL;
_full_scan();
di->current = hash_get_first();
di->current = hash_get_first(_cache.devices);
di->filter = f;
return di;
@ -233,7 +252,7 @@ void dev_iter_destroy(struct dev_iter *iter)
static inline struct device *_iter_next(struct dev_iter *iter)
{
struct device *d = hash_get_data(_cache.devices, iter->current);
iter->current = hash_next(_cache.devices, iter->current);
iter->current = hash_get_next(_cache.devices, iter->current);
return d;
}
@ -242,7 +261,7 @@ struct device *dev_iter_get(struct dev_iter *iter)
while (iter->current) {
struct device *d = _iter_next(iter);
if (!iter->filter ||
iter->filter->pass_filter(iter->filter, d))
iter->filter->passes_filter(iter->filter, d))
return d;
}

View File

@ -7,7 +7,7 @@
#ifndef _LVM_DEV_CACHE_H
#define _LVM_DEV_CACHE_H
#include <sys/types.h>
#include "lvm-types.h"
/*
* All devices in LVM will be represented by one of these.

View File

@ -4,14 +4,25 @@
* This file is released under the GPL.
*/
#include "device.h"
#include "lvm-types.h"
#include "log.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
int dev_get_size(struct device *dev, uint64_t *size)
{
int fd;
long s;
log_verbose("Getting device size");
if ((fd = open(pv, O_RDONLY)) < 0) {
log_sys_error("open");
if ((fd = open(dev->name, O_RDONLY)) < 0) {
log_sys_err("open");
return 0;
}

View File

@ -38,6 +38,7 @@
#include <linux/major.h>
#include <linux/genhd.h>
#if 0
int _get_partition_type(struct dev_filter *filter, struct device *d);
#define MINOR_PART(dm, d) (MINOR((d)->dev) % dev_max_partitions(dm, (d)->dev))
@ -208,3 +209,4 @@ int _get_partition_type(struct dev_mgr *dm, struct device *d)
return 0;
}
#endif

View File

@ -59,8 +59,12 @@ char *display_size(unsigned long long size, size_len_t sl)
return size_buf;
}
char *display_uuid(char *uuidstr)
{
/*
* FIXME: this function is badly named, it doesn't display the data it
* creates a new uuid string with -'s in it. It would be better if
* the destination was passed in as well. EJT
*/
char *display_uuid(char *uuidstr) {
int i, j;
char *uuid;

View File

@ -21,6 +21,7 @@
#ifndef _LVM_DISPLAY_METADATA_H
#define _LVM_DISPLAY_METADATA_H
#if 0
#include "metadata/metadata.h"
void pv_display_colons(pv_t * pv);
@ -34,5 +35,5 @@ static inline unsigned long get_pe_offset(ulong p, pv_t *pv)
{
return pv->pe_start + (p * pv->pe_size);
}
#endif
#endif

View File

@ -8,6 +8,8 @@
#define _LVM_LOG_H
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define _LOG_DEBUG 7
#define _LOG_INFO 6

View File

@ -13,6 +13,8 @@
#include <sys/types.h>
#include "dev-cache.h"
#include "list.h"
#include "lvm-types.h"
#define ID_LEN 32
#define NAME_LEN 128
@ -49,7 +51,7 @@
struct id {
__uint8_t uuid[ID_LEN];
uint8_t uuid[ID_LEN];
};
struct physical_volume {
@ -58,19 +60,19 @@ struct physical_volume {
char *vg_name;
char *exported;
__uint32_t status;
__uint64_t size;
uint32_t status;
uint64_t size;
/* physical extents */
__uint64_t pe_size;
__uint64_t pe_start;
__uint32_t pe_count;
__uint32_t pe_allocated;
uint64_t pe_size;
uint64_t pe_start;
uint32_t pe_count;
uint32_t pe_allocated;
};
struct pe_specifier {
struct physical_volume *pv;
__uint32_t pe;
uint32_t pe;
};
struct logical_volume {
@ -78,12 +80,12 @@ struct logical_volume {
struct id *id;
char *name;
__uint32_t access;
__uint32_t status;
__uint32_t open;
uint32_t access;
uint32_t status;
uint32_t open;
__uint64_t size;
__uint32_t le_count;
uint64_t size;
uint32_t le_count;
/* le -> pe mapping array */
struct pe_specifier *map;
@ -93,22 +95,22 @@ struct volume_group {
struct id *id;
char *name;
__uint32_t status;
__uint32_t access;
uint32_t status;
uint32_t access;
__uint64_t extent_size;
__uint32_t extent_count;
__uint32_t free_count;
uint64_t extent_size;
uint32_t extent_count;
uint32_t free_count;
__uint32_t max_lv;
__uint32_t max_pv;
uint32_t max_lv;
uint32_t max_pv;
/* physical volumes */
__uint32_t pv_count;
uint32_t pv_count;
struct physical_volume **pv;
/* logical volumes */
__uint32_t lv_count;
uint32_t lv_count;
struct logical_volume **lv;
};
@ -145,12 +147,6 @@ struct io_space *create_text_format(struct dev_filter *filter,
const char *text_file);
struct io_space *create_lvm_v1_format(struct dev_filter *filter);
inline int write_backup(struct io_space *orig, struct io_space *text)
{
}
int id_eq(struct id *op1, struct id *op2);
struct volume_group *vg_create();

View File

@ -1,20 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* LVM is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* LVM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LVM; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* This file is released under the GPL.
*/
#ifndef _LVM_POOL_H
@ -25,8 +12,8 @@
struct pool;
/* constructor and destructor */
struct pool *create_pool(size_t chunk_hint);
void destroy_pool(struct pool *p);
struct pool *pool_create(size_t chunk_hint);
void pool_destroy(struct pool *p);
/* simple allocation/free routines */
void *pool_alloc(struct pool *p, size_t s);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001 Sistina Software (UK) Limited
*
* This file is released under the GPL.
*/
@ -30,7 +30,7 @@ struct block_list {
static void _leak_memory(void)
{
int i;
struct block_list *b, *head, **l = &head;
struct block_list *b, *head, **l = &head, *n;
/* allocate a list of blocks */
for (i = 0; i < 1000; i++) {
@ -39,20 +39,21 @@ static void _leak_memory(void)
log_fatal("Couldn't allocate memory");
exit(1);
}
b->next = 0;
*l = b;
l = &b->next;
}
/* free off every other block */
for (i = 0, l = head; *l; l = &(*l)->next, i++) {
for (b = head, i = 0; b; b = n, i++) {
n = b->next;
if(i & 0x1)
db_free(b);
dbg_free(b);
}
}
static void _bounds_overrun()
static void _bounds_overrun(void)
{
char *b;
@ -66,7 +67,7 @@ static void _bounds_overrun()
dbg_free(b);
}
static void _bounds_underrun()
static void _bounds_underrun(void)
{
char *b;
@ -80,7 +81,7 @@ static void _bounds_underrun()
dbg_free(b);
}
static void _free_dud()
static void _free_dud(void)
{
char *b;
@ -91,7 +92,7 @@ static void _free_dud()
dbg_free(b + 100);
}
static void _free_twice()
static void _free_twice(void)
{
char *b;
@ -107,7 +108,8 @@ int main(int argc, char **argv)
{
char opt;
init_log();
init_log(stderr);
init_debug(_LOG_DEBUG);
opt = getopt(argc, argv, "hlbufd");
switch(opt) {
case EOF:

View File

@ -39,11 +39,11 @@ xx(help,
xx(lvactivate,
"Activate logical volume on given partition(s)",
"lvactivate "
"lvactivate "
"\t[-d/--debug]\n"
"\t[-h/-?/--help]\n"
"\t[-v/--verbose]\n"
"Physical Volume(s)\n")
"Logical Volume(s)\n")
xx(lvchange,
"Change the attributes of logical volume(s)",