mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
[unit tests] remove old unit tests that weren't built or run.
This commit is contained in:
parent
7a475bef32
commit
38d77898ae
5
configure
vendored
5
configure
vendored
@ -15860,7 +15860,7 @@ _ACEOF
|
||||
|
||||
|
||||
################################################################################
|
||||
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -16637,9 +16637,6 @@ do
|
||||
"test/unit/Makefile") CONFIG_FILES="$CONFIG_FILES test/unit/Makefile" ;;
|
||||
"tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
|
||||
"udev/Makefile") CONFIG_FILES="$CONFIG_FILES udev/Makefile" ;;
|
||||
"unit-tests/datastruct/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/datastruct/Makefile" ;;
|
||||
"unit-tests/regex/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/regex/Makefile" ;;
|
||||
"unit-tests/mm/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/mm/Makefile" ;;
|
||||
|
||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||
esac
|
||||
|
@ -2254,9 +2254,6 @@ test/api/Makefile
|
||||
test/unit/Makefile
|
||||
tools/Makefile
|
||||
udev/Makefile
|
||||
unit-tests/datastruct/Makefile
|
||||
unit-tests/regex/Makefile
|
||||
unit-tests/mm/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
1
old-tests/config/.gitignore
vendored
1
old-tests/config/.gitignore
vendored
@ -1 +0,0 @@
|
||||
!Makefile
|
@ -1,5 +0,0 @@
|
||||
config_t: config_t.c
|
||||
gcc -g -I../../include config_t.c -L../../lib -llvm -o config_t
|
||||
|
||||
clean:
|
||||
rm config_t
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Test program that reads, then writes a config file.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct config_file *cf;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <config_file>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cf = create_config_file();
|
||||
if (cf == NULL) {
|
||||
fprintf(stderr, "Couldn't create config_file object.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (!read_config(cf, argv[1])) {
|
||||
fprintf(stderr, "Couldn't read config file '%s'\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!write_config(cf, "out")) {
|
||||
fprintf(stderr, "Couldn't write config file 'out'\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
destroy_config_file(cf);
|
||||
dump_memory();
|
||||
return 0;
|
||||
}
|
@ -1 +0,0 @@
|
||||
foo = []
|
@ -1,169 +0,0 @@
|
||||
# This file was originally generated by the LVM2 library
|
||||
# Generated: Wed Jul 17 22:41:37 2002
|
||||
|
||||
|
||||
description = "Created *after* executing 'lvcreate --quiet -s -n snap -c 512k -L200M vg0/origin /dev/hda8'"
|
||||
creation_time = 1026942097
|
||||
|
||||
vg0 {
|
||||
id = "Qmd96y-771S-Esbb-Zp6u-8xo9-Cfmt-YvndHY"
|
||||
seqno = 2
|
||||
status = ["RESIZEABLE", "READ", "WRITE"]
|
||||
system_id = "reti1014805292"
|
||||
extent_size = 8192 # 4 Megabytes
|
||||
max_lv = 255
|
||||
max_pv = 255
|
||||
|
||||
physical_volumes {
|
||||
|
||||
pv0 {
|
||||
id = "8nRQub-EquY-VR1C-Ipdv-6hEO-FuFT-wnlN5R"
|
||||
device = "/dev/discs/disc0/part8" # Hint only
|
||||
|
||||
status = ["ALLOCATABLE"]
|
||||
pe_start = 256
|
||||
pe_count = 501 # 1.95703 Gigabytes
|
||||
}
|
||||
|
||||
pv1 {
|
||||
id = "mRU6Mf-z1Sv-Kuqw-Ct1v-eC42-mnqs-YD1RrL"
|
||||
device = "/dev/discs/disc1/part2" # Hint only
|
||||
|
||||
status = ["ALLOCATABLE"]
|
||||
pe_start = 384
|
||||
pe_count = 7269 # 28.3945 Gigabytes
|
||||
}
|
||||
}
|
||||
|
||||
logical_volumes {
|
||||
|
||||
music {
|
||||
id = "000000-0000-0000-0000-0000-0000-000000"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 2
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 1024 # 4 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 0
|
||||
]
|
||||
}
|
||||
segment2 {
|
||||
start_extent = 1024
|
||||
extent_count = 2560 # 10 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 3584
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
photos {
|
||||
id = "000000-0000-0000-0000-0000-0000-000002"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 1
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 1024 # 4 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 2048
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
id = "000000-0000-0000-0000-0000-0000-000003"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 1
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 512 # 2 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 3072
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
origin {
|
||||
id = "000000-0000-0000-0000-0000-0000-000004"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 1
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 50 # 200 Megabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 6144
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
packages {
|
||||
id = "000000-0000-0000-0000-0000-0000-000006"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 2
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 451 # 1.76172 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv0", 50
|
||||
]
|
||||
}
|
||||
segment2 {
|
||||
start_extent = 451
|
||||
extent_count = 573 # 2.23828 Gigabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv1", 6194
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
snap {
|
||||
id = "000000-0000-0000-0000-0000-0000-000001"
|
||||
status = ["READ", "WRITE", "ALLOC_SIMPLE"]
|
||||
read_ahead = 0
|
||||
segment_count = 1
|
||||
|
||||
segment1 {
|
||||
start_extent = 0
|
||||
extent_count = 50 # 200 Megabytes
|
||||
stripes = 1
|
||||
|
||||
areas = [
|
||||
"pv0", 0
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
snapshots {
|
||||
|
||||
snapshot0 {
|
||||
chunk_size = 1024
|
||||
origin = "origin"
|
||||
cow_store = "snap"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void _help(FILE *fp, const char *prog)
|
||||
{
|
||||
fprintf(fp, "Usage : %s <table size> <num_entries>\n", prog);
|
||||
}
|
||||
|
||||
struct key_list {
|
||||
struct key_list *next;
|
||||
char key[1];
|
||||
};
|
||||
|
||||
static struct key_list *_create_word(int n)
|
||||
{
|
||||
struct key_list *kl = dbg_malloc(sizeof(*kl) + 32);
|
||||
snprintf(kl->key, 32, "abc%ddef%d", n, n);
|
||||
kl->next = 0;
|
||||
return kl;
|
||||
}
|
||||
|
||||
static struct key_list *_create_word_from_file(int n)
|
||||
{
|
||||
char word[128], *ptr;
|
||||
struct key_list *kl;
|
||||
|
||||
if (!fgets(word, sizeof(word), stdin))
|
||||
return 0;
|
||||
|
||||
for (ptr = word; *ptr; ptr++) {
|
||||
if (*ptr == '\n') {
|
||||
*ptr = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
kl = dbg_malloc(sizeof(*kl) + 32);
|
||||
snprintf(kl->key, 32, "%s", word);
|
||||
kl->next = 0;
|
||||
return kl;
|
||||
}
|
||||
|
||||
static void _do_test(int table_size, int num_entries)
|
||||
{
|
||||
int i;
|
||||
hash_table_t ht = hash_create(table_size);
|
||||
struct key_list *tmp, *key, *all = 0;
|
||||
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
/* make up a word */
|
||||
if (!(key = _create_word_from_file(i))) {
|
||||
log_error("Ran out of words !\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* insert it */
|
||||
hash_insert(ht, key->key, key);
|
||||
key->next = all;
|
||||
all = key;
|
||||
}
|
||||
|
||||
for (key = all; key; key = key->next) {
|
||||
tmp = (struct key_list *) hash_lookup(ht, key->key);
|
||||
if (!tmp || (tmp != key)) {
|
||||
log_error("lookup failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
for (key = all; key; key = tmp) {
|
||||
tmp = key->next;
|
||||
dbg_free(key);
|
||||
}
|
||||
|
||||
hash_destroy(ht);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log();
|
||||
|
||||
if (argc != 3) {
|
||||
_help(stderr, argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_do_test(atoi(argv[1]), atoi(argv[2]));
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "dev-cache.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct device *dev;
|
||||
struct dev_iter *iter;
|
||||
|
||||
init_log();
|
||||
if (!dev_cache_init()) {
|
||||
log_error("couldn't initialise dev_cache_init failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!dev_cache_add_dir(argv[i])) {
|
||||
log_error("couldn't add '%s' to dev_cache\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(NULL))) {
|
||||
log_error("couldn't create iterator\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((dev = dev_iter_next(iter)))
|
||||
printf("%s\n", dev->name);
|
||||
|
||||
dev_iter_destroy(iter):
|
||||
dev_cache_exit();
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SOURCES=\
|
||||
dev_cache_t.c
|
||||
|
||||
TARGETS=dev_cache_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
dev_cache_t: dev_cache_t.o $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o dev_cache_t dev_cache_t.o -L$(top_builddir)/lib -llvm
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "dev-cache.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct device *dev;
|
||||
struct dev_iter *iter;
|
||||
struct list_head *tmp;
|
||||
struct dm_str_list *sl;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: %s <dir>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
log_err("couldn't initialise dev_cache_init failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!dev_cache_add_dir(argv[i])) {
|
||||
log_err("couldn't add '%s' to dev_cache", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(NULL))) {
|
||||
log_err("couldn't create iterator");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((dev = dev_iter_get(iter))) {
|
||||
printf("%s", dev->name);
|
||||
|
||||
list_for_each(tmp, &dev->aliases) {
|
||||
sl = list_entry(tmp, struct dm_str_list, list);
|
||||
printf(", %s", sl->str);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
dev_iter_destroy(iter);
|
||||
dev_cache_exit();
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "random.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "random.h"
|
||||
#include "log.h"
|
||||
|
||||
int32_t _a[56];
|
||||
int32_t *_r;
|
||||
|
||||
static inline int32_t _mod_diff(int32_t x, int32_t y)
|
||||
{
|
||||
return (x - y) & 0x7fffffff;
|
||||
}
|
||||
|
||||
static int32_t _flip_cycle(void)
|
||||
{
|
||||
int32_t *ii, *jj;
|
||||
for (ii = _a + 1, jj = _a + 32; jj <= _a + 55; ii++, jj++)
|
||||
*ii = _mod_diff(*ii, *jj);
|
||||
|
||||
for (jj = _a + 1; ii <= _a + 55; ii++, jj++)
|
||||
*ii = _mod_diff(*ii, *jj);
|
||||
|
||||
_r = _a + 54;
|
||||
return _a[55];
|
||||
}
|
||||
|
||||
static void rand_init(int32_t seed)
|
||||
{
|
||||
int64_t i;
|
||||
int64_t prev = seed, next = 1;
|
||||
|
||||
seed = prev = _mod_diff(prev, 0); /* strip the sign */
|
||||
_a[55] = prev;
|
||||
for (i = 21; i; i = (i + 21) % 55) {
|
||||
_a[i] = next;
|
||||
next = _mod_diff(prev, next);
|
||||
if(seed & 1)
|
||||
seed = 0x40000000L + (seed >> 1);
|
||||
else
|
||||
seed >>= 1;
|
||||
|
||||
next = _mod_diff(next, seed);
|
||||
prev = _a[i];
|
||||
}
|
||||
|
||||
_flip_cycle();
|
||||
_flip_cycle();
|
||||
_flip_cycle();
|
||||
_flip_cycle();
|
||||
_flip_cycle();
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: move this to be an inline in the
|
||||
* header.
|
||||
*/
|
||||
int32_t rand_get(void)
|
||||
{
|
||||
return (*_r >= 0) ? *_r-- : _flip_cycle();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* just used by rand_check
|
||||
*/
|
||||
#define t31 0x80000000
|
||||
static int32_t _uniform(int32_t m)
|
||||
{
|
||||
uint32_t t = t31 - (t31 % m);
|
||||
int32_t r;
|
||||
|
||||
do
|
||||
r = next_rand(sc);
|
||||
|
||||
while (t <= (uint32_t) r);
|
||||
|
||||
return r % m;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks I've copied the code correctly.
|
||||
*/
|
||||
int rand_check(void)
|
||||
{
|
||||
int j;
|
||||
|
||||
rand_init(-314159L);
|
||||
|
||||
if (next_rand(sc) != 119318998) {
|
||||
log_err("Random number generator failed check 1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(j = 1; j <= 133; j++)
|
||||
rand_get();
|
||||
|
||||
if (_uniform(0x55555555L) != 748103812) {
|
||||
log_err("Random number generator failed check 2");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Random number generator snarfed from the
|
||||
* Stanford Graphbase.
|
||||
*/
|
||||
|
||||
#ifndef _LVM_RANDOM_H
|
||||
#define _LVM_RANDOM_H
|
||||
|
||||
void rand_init(int32_t seed);
|
||||
int32_t rand_get(void);
|
||||
|
||||
/*
|
||||
* Note this will reset the seed.
|
||||
*/
|
||||
int rand_check(void);
|
||||
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SOURCES=\
|
||||
rfilter_t.c \
|
||||
pfilter_t.c
|
||||
|
||||
TARGETS=\
|
||||
rfilter_t \
|
||||
pfilter_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
rfilter_t: rfilter_t.o $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o rfilter_t rfilter_t.o -L$(top_builddir)/lib -llvm
|
||||
|
||||
pfilter_t: pfilter_t.o $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o pfilter_t pfilter_t.o -L$(top_builddir)/lib -llvm
|
||||
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "filter-persistent.h"
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
#include "filter-regex.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct config_file *cft;
|
||||
struct config_node *cn;
|
||||
struct dev_filter *rfilter, *pfilter;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage : %s <regex config>\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_DEBUG);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "couldn't initialise dev_cache_init failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev")) {
|
||||
fprintf(stderr, "couldn't add '/dev' to dev_cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(cft = create_config_file())) {
|
||||
fprintf(stderr, "couldn't create config file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!read_config(cft, argv[1])) {
|
||||
fprintf(stderr, "couldn't read config file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(cft->root, "/devices/filter", '/'))) {
|
||||
fprintf(stderr, "couldn't find filter section\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(rfilter = regex_filter_create(cn->v))) {
|
||||
fprintf(stderr, "couldn't build filter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(pfilter = persistent_filter_create(rfilter, "./pfilter.cfg"))) {
|
||||
fprintf(stderr, "couldn't build filter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(pfilter))) {
|
||||
log_err("couldn't create iterator");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "filling cache\n");
|
||||
while ((dev = dev_iter_get(iter)))
|
||||
;
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
fprintf(stderr, "dumping\n");
|
||||
if (!persistent_filter_dump(pfilter)) {
|
||||
fprintf(stderr, "couldn't dump pfilter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "loading\n");
|
||||
if (!persistent_filter_load(pfilter)) {
|
||||
fprintf(stderr, "couldn't load pfilter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(pfilter))) {
|
||||
log_err("couldn't create iterator");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((dev = dev_iter_get(iter)))
|
||||
printf("%s\n", dev_name(dev));
|
||||
|
||||
dev_iter_destroy(iter);
|
||||
pfilter->destroy(pfilter);
|
||||
dev_cache_exit();
|
||||
destroy_config_file(cft);
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "filter-regex.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct config_file *cft;
|
||||
struct config_node *cn;
|
||||
struct dev_filter *filter;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage : %s <config_file>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_DEBUG);
|
||||
|
||||
if (!(cft = create_config_file())) {
|
||||
fprintf(stderr, "couldn't create config file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!read_config(cft, argv[1])) {
|
||||
fprintf(stderr, "couldn't read config file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(cft->root, "/devices/filter", '/'))) {
|
||||
fprintf(stderr, "couldn't find filter section\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "couldn't initialise dev_cache_init failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev")) {
|
||||
fprintf(stderr, "couldn't add '/dev' to dev_cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(filter = regex_filter_create(cn->v))) {
|
||||
fprintf(stderr, "couldn't build filter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(filter))) {
|
||||
log_err("couldn't create iterator");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((dev = dev_iter_get(iter)))
|
||||
printf("%s\n", dev_name(dev));
|
||||
|
||||
dev_iter_destroy(iter);
|
||||
filter->destroy(filter);
|
||||
dev_cache_exit();
|
||||
destroy_config_file(cft);
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
devices {
|
||||
|
||||
# first match is final, eg. /dev/ide/cdrom
|
||||
# get's rejected due to the first pattern
|
||||
|
||||
filter=["r/cdrom/", # don't touch the music !
|
||||
"a/hd[a-d][0-9]+/",
|
||||
"a/ide/",
|
||||
"a/sd/",
|
||||
"a/md/",
|
||||
"a|loop/[0-9]+|", # accept devfs style loop back
|
||||
"r/loop/", # and reject old style
|
||||
"a/dasd/",
|
||||
"a/dac960/",
|
||||
"a/nbd/",
|
||||
"a/ida/",
|
||||
"a/cciss/",
|
||||
"a/ubd/",
|
||||
"r/.*/"] # reject all others
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SOURCES=\
|
||||
read_vg_t.c \
|
||||
write_vg_t.c \
|
||||
pretty_print.c \
|
||||
get_pvs_t.c \
|
||||
read_pv_t.c \
|
||||
get_vgs_t.c
|
||||
|
||||
TARGETS=\
|
||||
read_vg_t \
|
||||
write_vg_t \
|
||||
get_pvs_t \
|
||||
read_pv_t \
|
||||
get_vgs_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
read_vg_t: read_vg_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
|
||||
$(CC) -o read_vg_t read_vg_t.o pretty_print.o -L$(top_builddir)/lib -llvm
|
||||
|
||||
write_vg_t: write_vg_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
|
||||
$(CC) -o write_vg_t write_vg_t.o pretty_print.o \
|
||||
-L$(top_builddir)/lib -llvm
|
||||
|
||||
get_pvs_t: get_pvs_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
|
||||
$(CC) -o get_pvs_t get_pvs_t.o pretty_print.o -L$(top_builddir)/lib -llvm
|
||||
|
||||
read_pv_t: read_pv_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
|
||||
$(CC) -o read_pv_t read_pv_t.o pretty_print.o -L$(top_builddir)/lib -llvm
|
||||
|
||||
get_vgs_t: get_vgs_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
|
||||
$(CC) -o get_vgs_t get_vgs_t.o pretty_print.o -L$(top_builddir)/lib -llvm
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "pretty_print.h"
|
||||
#include "list.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct list_head *pvs, *tmp;
|
||||
struct dm_pool *mem;
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "init of dev-cache failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev/loop")) {
|
||||
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(mem = dm_pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pvs = ios->get_pvs(ios);
|
||||
|
||||
if (!pvs) {
|
||||
fprintf(stderr, "couldn't read vg %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
list_for_each(tmp, pvs) {
|
||||
struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
|
||||
dump_pv(&pvl->pv, stdout);
|
||||
}
|
||||
|
||||
ios->destroy(ios);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
dev_cache_exit();
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "pretty_print.h"
|
||||
#include "list.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct list_head *vgs;
|
||||
struct dm_pool *mem;
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "init of dev-cache failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev/loop")) {
|
||||
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(mem = dm_pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vgs = ios->get_vgs(ios);
|
||||
|
||||
if (!vgs) {
|
||||
fprintf(stderr, "couldn't read vg names\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dump_vg_names(vgs, stdout);
|
||||
ios->destroy(ios);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
dev_cache_exit();
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "pretty_print.h"
|
||||
|
||||
void dump_pv(struct physical_volume *pv, FILE *fp)
|
||||
{
|
||||
fprintf(fp, "physical_volume {\n");
|
||||
fprintf(fp, "\tname = '%s'\n", pv->dev->name);
|
||||
fprintf(fp, "\tvg_name = '%s'\n", pv->vg_name);
|
||||
fprintf(fp, "\tsize = %llu\n", pv->size);
|
||||
fprintf(fp, "\tpe_size = %llu\n", pv->pe_size);
|
||||
fprintf(fp, "\tpe_start = %llu\n", pv->pe_start);
|
||||
fprintf(fp, "\tpe_count = %u\n", pv->pe_count);
|
||||
fprintf(fp, "\tpe_allocated = %u\n", pv->pe_allocated);
|
||||
fprintf(fp, "}\n\n");
|
||||
}
|
||||
|
||||
void dump_lv(struct logical_volume *lv, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(fp, "logical_volume {\n");
|
||||
fprintf(fp, "\tname = '%s'\n", lv->name);
|
||||
fprintf(fp, "\tsize = %llu\n", lv->size);
|
||||
fprintf(fp, "\tle_count = %u\n", lv->le_count);
|
||||
|
||||
fprintf(fp, "\tmap {\n");
|
||||
for (i = 0; i < lv->le_count; i++) {
|
||||
struct physical_volume *pv = lv->map[i].pv;
|
||||
|
||||
fprintf(fp, "\t\tpv = '%s', ",
|
||||
pv ? pv->dev->name : "null ???");
|
||||
fprintf(fp, "\textent = %u\n", lv->map[i].pe);
|
||||
}
|
||||
fprintf(fp, "\t}\n}\n\n");
|
||||
}
|
||||
|
||||
void dump_vg(struct volume_group *vg, FILE *fp)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
|
||||
fprintf(fp, "volume_group {\n");
|
||||
fprintf(fp, "\tname = '%s'\n", vg->name);
|
||||
fprintf(fp, "\textent_size = %llu\n", vg->extent_size);
|
||||
fprintf(fp, "\textent_count = %d\n", vg->extent_count);
|
||||
fprintf(fp, "\tfree_count = %d\n", vg->free_count);
|
||||
fprintf(fp, "\tmax_lv = %d\n", vg->max_lv);
|
||||
fprintf(fp, "\tmax_pv = %d\n", vg->max_pv);
|
||||
fprintf(fp, "\tpv_count = %d\n", vg->pv_count);
|
||||
fprintf(fp, "\tlv_count = %d\n", vg->lv_count);
|
||||
fprintf(fp, "}\n\n");
|
||||
|
||||
list_for_each(tmp, &vg->pvs) {
|
||||
struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
|
||||
dump_pv(&pvl->pv, fp);
|
||||
}
|
||||
|
||||
list_for_each(tmp, &vg->lvs) {
|
||||
struct lv_list *lvl = list_entry(tmp, struct lv_list, list);
|
||||
dump_lv(&lvl->lv, fp);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_vg_names(struct list_head *vg_names, FILE *fp)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct name_list *nl;
|
||||
|
||||
list_for_each(tmp, vg_names) {
|
||||
nl = list_entry(tmp, struct name_list, list);
|
||||
fprintf(fp, "%s\n", nl->name);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_PRETTY_PRINT
|
||||
#define _LVM_PRETTY_PRINT
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void dump_pv(struct physical_volume *pv, FILE *fp);
|
||||
void dump_lv(struct logical_volume *lv, FILE *fp);
|
||||
void dump_vg(struct volume_group *vg, FILE *fp);
|
||||
void dump_vg_names(struct list_head *vg_names, FILE *fp);
|
||||
|
||||
#endif
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "pretty_print.h"
|
||||
#include "list.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct physical_volume *pv;
|
||||
struct dm_pool *mem;
|
||||
struct device *dev;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: read_pv_t <device>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "init of dev-cache failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev/loop")) {
|
||||
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(mem = dm_pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pv = ios->pv_read(ios, argv[1]);
|
||||
|
||||
if (!pv) {
|
||||
fprintf(stderr, "couldn't read pv %s\n", dev->name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dump_pv(pv, stdout);
|
||||
ios->destroy(ios);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
dev_cache_exit();
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "pretty_print.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct volume_group *vg;
|
||||
struct dm_pool *mem;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: read_vg_t <vg_name>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "init of dev-cache failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev/loop")) {
|
||||
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(mem = dm_pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vg = ios->vg_read(ios, argv[1]);
|
||||
|
||||
if (!vg) {
|
||||
fprintf(stderr, "couldn't read vg %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dump_vg(vg, stdout);
|
||||
|
||||
ios->destroy(ios);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
dev_cache_exit();
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "pretty_print.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct volume_group *vg;
|
||||
struct dm_pool *mem;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: read_vg_t <vg_name>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_INFO);
|
||||
|
||||
if (!dev_cache_init()) {
|
||||
fprintf(stderr, "init of dev-cache failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!dev_cache_add_dir("/dev/loop")) {
|
||||
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(mem = dm_pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vg = ios->vg_read(ios, argv[1]);
|
||||
|
||||
if (!vg) {
|
||||
fprintf(stderr, "couldn't read vg %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!ios->vg_write(ios, vg)) {
|
||||
fprintf(stderr, "couldn't write vg\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios->destroy(ios);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
dev_cache_exit();
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SOURCES=\
|
||||
dbg_malloc_t.c
|
||||
|
||||
TARGETS=dbg_malloc_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
dbg_malloc_t: dbg_malloc_t.o
|
||||
$(CC) $(CFLAGS) -o dbg_malloc_t dbg_malloc_t.o \
|
||||
-L$(top_builddir)/lib -llvm
|
||||
|
||||
pool_t: pool_t.o
|
||||
$(CC) $(CFLAGS) -o pool_t pool_t.o -L$(top_builddir)/lib -llvm
|
||||
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void _print_help(FILE *out, const char *prog)
|
||||
{
|
||||
fprintf(out, "usage : %s [-hlbufd]\n\n", prog);
|
||||
fprintf(out, " h : this message\n");
|
||||
fprintf(out, " l : cause memory leak\n");
|
||||
fprintf(out, " b : overrun memory block\n");
|
||||
fprintf(out, " u : underrun memory block\n");
|
||||
fprintf(out, " f : free random pointer\n");
|
||||
fprintf(out, " d : free block twice\n");
|
||||
}
|
||||
|
||||
struct block_list {
|
||||
struct block_list *next;
|
||||
char dummy[9];
|
||||
};
|
||||
|
||||
static void _leak_memory(void)
|
||||
{
|
||||
int i;
|
||||
struct block_list *b, *head, **l = &head, *n;
|
||||
|
||||
/* allocate a list of blocks */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
if (!(b = dbg_malloc(sizeof(*b)))) {
|
||||
log_fatal("Couldn't allocate memory");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
b->next = 0;
|
||||
*l = b;
|
||||
l = &b->next;
|
||||
}
|
||||
|
||||
/* free off every other block */
|
||||
for (b = head, i = 0; b; b = n, i++) {
|
||||
n = b->next;
|
||||
if(i & 0x1)
|
||||
dbg_free(b);
|
||||
}
|
||||
}
|
||||
|
||||
static void _bounds_overrun(void)
|
||||
{
|
||||
char *b;
|
||||
|
||||
/* allocate a block */
|
||||
b = dbg_malloc(534);
|
||||
|
||||
/* overrun */
|
||||
b[534] = 56;
|
||||
|
||||
/* free it, which should trigger the bounds error */
|
||||
dbg_free(b);
|
||||
}
|
||||
|
||||
static void _bounds_underrun(void)
|
||||
{
|
||||
char *b;
|
||||
|
||||
/* allocate a block */
|
||||
b = dbg_malloc(534);
|
||||
|
||||
/* underrun */
|
||||
*(b - 1) = 56;
|
||||
|
||||
/* free it, which should trigger the bounds error */
|
||||
dbg_free(b);
|
||||
}
|
||||
|
||||
static void _free_dud(void)
|
||||
{
|
||||
char *b;
|
||||
|
||||
/* allocate a block */
|
||||
b = dbg_malloc(534);
|
||||
|
||||
/* free it, which should trigger the bounds error */
|
||||
dbg_free(b + 100);
|
||||
}
|
||||
|
||||
static void _free_twice(void)
|
||||
{
|
||||
char *b;
|
||||
|
||||
/* allocate a block */
|
||||
b = dbg_malloc(534);
|
||||
|
||||
/* free it, which should trigger the bounds error */
|
||||
dbg_free(b);
|
||||
dbg_free(b);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char opt;
|
||||
|
||||
init_log(stderr);
|
||||
init_debug(_LOG_DEBUG);
|
||||
opt = getopt(argc, argv, "hlbufd");
|
||||
switch(opt) {
|
||||
case EOF:
|
||||
case 'h':
|
||||
_print_help(stdout, argv[0]);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
_leak_memory();
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
_bounds_overrun();
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
_bounds_underrun();
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
_free_dud();
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
_free_twice();
|
||||
break;
|
||||
|
||||
case '?':
|
||||
fprintf(stderr, "Unknown option -%c\n", opt);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
return 0;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
SOURCES=\
|
||||
bitset_t.c
|
||||
|
||||
TARGETS=\
|
||||
bitset_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
INCLUDES += -I$(top_srcdir)/libdm
|
||||
DM_DEPS = $(top_builddir)/libdm/libdevmapper.so
|
||||
DM_LIBS = -ldevmapper $(LIBS)
|
||||
|
||||
bitset_t: bitset_t.o $(DM_DEPS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ bitset_t.o $(DM_LIBS)
|
@ -1 +0,0 @@
|
||||
bitset iteration:$TEST_TOOL ./bitset_t
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libdevmapper.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
enum {
|
||||
NR_BITS = 137
|
||||
};
|
||||
|
||||
static void test_get_next(struct dm_pool *mem)
|
||||
{
|
||||
int i, j, last, first;
|
||||
dm_bitset_t bs = dm_bitset_create(mem, NR_BITS);
|
||||
|
||||
for (i = 0; i < NR_BITS; i++)
|
||||
assert(!dm_bit(bs, i));
|
||||
|
||||
for (i = 0, j = 1; i < NR_BITS; i += j, j++)
|
||||
dm_bit_set(bs, i);
|
||||
|
||||
first = 1;
|
||||
for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
|
||||
if (first) {
|
||||
last = dm_bit_get_first(bs);
|
||||
first = 0;
|
||||
} else
|
||||
last = dm_bit_get_next(bs, last);
|
||||
|
||||
assert(last == i);
|
||||
}
|
||||
|
||||
assert(dm_bit_get_next(bs, last) == -1);
|
||||
}
|
||||
|
||||
static void bit_flip(dm_bitset_t bs, int bit)
|
||||
{
|
||||
int old = dm_bit(bs, bit);
|
||||
if (old)
|
||||
dm_bit_clear(bs, bit);
|
||||
else
|
||||
dm_bit_set(bs, bit);
|
||||
}
|
||||
|
||||
static void test_equal(struct dm_pool *mem)
|
||||
{
|
||||
dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
|
||||
dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
|
||||
|
||||
int i, j;
|
||||
for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
|
||||
dm_bit_set(bs1, i);
|
||||
dm_bit_set(bs2, i);
|
||||
}
|
||||
|
||||
assert(dm_bitset_equal(bs1, bs2));
|
||||
assert(dm_bitset_equal(bs2, bs1));
|
||||
|
||||
for (i = 0; i < NR_BITS; i++) {
|
||||
bit_flip(bs1, i);
|
||||
assert(!dm_bitset_equal(bs1, bs2));
|
||||
assert(!dm_bitset_equal(bs2, bs1));
|
||||
|
||||
assert(dm_bitset_equal(bs1, bs1)); /* comparing with self */
|
||||
bit_flip(bs1, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_and(struct dm_pool *mem)
|
||||
{
|
||||
dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
|
||||
dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
|
||||
dm_bitset_t bs3 = dm_bitset_create(mem, NR_BITS);
|
||||
|
||||
int i, j;
|
||||
for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
|
||||
dm_bit_set(bs1, i);
|
||||
dm_bit_set(bs2, i);
|
||||
}
|
||||
|
||||
dm_bit_and(bs3, bs1, bs2);
|
||||
|
||||
assert(dm_bitset_equal(bs1, bs2));
|
||||
assert(dm_bitset_equal(bs1, bs3));
|
||||
assert(dm_bitset_equal(bs2, bs3));
|
||||
|
||||
dm_bit_clear_all(bs1);
|
||||
dm_bit_clear_all(bs2);
|
||||
|
||||
for (i = 0; i < NR_BITS; i++) {
|
||||
if (i % 2)
|
||||
dm_bit_set(bs1, i);
|
||||
else
|
||||
dm_bit_set(bs2, i);
|
||||
}
|
||||
|
||||
dm_bit_and(bs3, bs1, bs2);
|
||||
for (i = 0; i < NR_BITS; i++)
|
||||
assert(!dm_bit(bs3, i));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
typedef void (*test_fn)(struct dm_pool *);
|
||||
static test_fn tests[] = {
|
||||
test_get_next,
|
||||
test_equal,
|
||||
test_and
|
||||
};
|
||||
|
||||
int i;
|
||||
for (i = 0; i < DM_ARRAY_SIZE(tests); ++i) {
|
||||
struct dm_pool *mem = dm_pool_create("bitset test", 1024);
|
||||
assert(mem);
|
||||
tests[i](mem);
|
||||
dm_pool_destroy(mem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SOURCES=\
|
||||
pool_valgrind_t.c
|
||||
|
||||
TARGETS=\
|
||||
pool_valgrind_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
DM_LIBS = -ldevmapper $(LIBS)
|
||||
|
||||
pool_valgrind_t: pool_valgrind_t.o
|
||||
$(CC) $(CFLAGS) -o $@ pool_valgrind_t.o $(LDFLAGS) $(DM_LIBS)
|
||||
|
@ -1 +0,0 @@
|
||||
valgrind pool awareness:valgrind ./pool_valgrind_t 2>&1 | ./check_results
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env ruby1.9
|
||||
|
||||
require 'pp'
|
||||
|
||||
patterns = [
|
||||
/Invalid read of size 1/,
|
||||
/Invalid write of size 1/,
|
||||
/Invalid read of size 1/,
|
||||
/still reachable: [0-9,]+ bytes in 3 blocks/
|
||||
]
|
||||
|
||||
lines = STDIN.readlines
|
||||
pp lines
|
||||
|
||||
result = catch(:done) do
|
||||
patterns.each do |pat|
|
||||
loop do
|
||||
throw(:done, false) if lines.size == 0
|
||||
|
||||
line = lines.shift
|
||||
if line =~ pat
|
||||
STDERR.puts "matched #{pat}"
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
throw(:done, true)
|
||||
end
|
||||
|
||||
exit(result ? 0 : 1)
|
@ -1,181 +0,0 @@
|
||||
#include "libdevmapper.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Checks that valgrind is picking up unallocated pool memory as
|
||||
* uninitialised, even if the chunk has been recycled.
|
||||
*
|
||||
* $ valgrind --track-origins=yes ./pool_valgrind_t
|
||||
*
|
||||
* ==7023== Memcheck, a memory error detector
|
||||
* ==7023== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
|
||||
* ==7023== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
|
||||
* ==7023== Command: ./pool_valgrind_t
|
||||
* ==7023==
|
||||
* first branch worked (as expected)
|
||||
* ==7023== Conditional jump or move depends on uninitialised value(s)
|
||||
* ==7023== at 0x4009AC: main (in /home/ejt/work/lvm2/unit-tests/mm/pool_valgrind_t)
|
||||
* ==7023== Uninitialised value was created by a client request
|
||||
* ==7023== at 0x4E40CB8: dm_pool_free (in /home/ejt/work/lvm2/libdm/ioctl/libdevmapper.so.1.02)
|
||||
* ==7023== by 0x4009A8: main (in /home/ejt/work/lvm2/unit-tests/mm/pool_valgrind_t)
|
||||
* ==7023==
|
||||
* second branch worked (valgrind should have flagged this as an error)
|
||||
* ==7023==
|
||||
* ==7023== HEAP SUMMARY:
|
||||
* ==7023== in use at exit: 0 bytes in 0 blocks
|
||||
* ==7023== total heap usage: 2 allocs, 2 frees, 2,104 bytes allocated
|
||||
* ==7023==
|
||||
* ==7023== All heap blocks were freed -- no leaks are possible
|
||||
* ==7023==
|
||||
* ==7023== For counts of detected and suppressed errors, rerun with: -v
|
||||
* ==7023== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)
|
||||
*/
|
||||
|
||||
#define COUNT 10
|
||||
|
||||
static void check_free()
|
||||
{
|
||||
int i;
|
||||
char *blocks[COUNT];
|
||||
struct dm_pool *p = dm_pool_create("blah", 1024);
|
||||
|
||||
for (i = 0; i < COUNT; i++)
|
||||
blocks[i] = dm_pool_alloc(p, 37);
|
||||
|
||||
/* check we can access the last block */
|
||||
blocks[COUNT - 1][0] = 'E';
|
||||
if (blocks[COUNT - 1][0] == 'E')
|
||||
printf("first branch worked (as expected)\n");
|
||||
|
||||
dm_pool_free(p, blocks[5]);
|
||||
|
||||
if (blocks[COUNT - 1][0] == 'E')
|
||||
printf("second branch worked (valgrind should have flagged this as an error)\n");
|
||||
|
||||
dm_pool_destroy(p);
|
||||
}
|
||||
|
||||
/* Checks that freed chunks are marked NOACCESS */
|
||||
static void check_free2()
|
||||
{
|
||||
struct dm_pool *p = dm_pool_create("", 900); /* 900 will get
|
||||
* rounded up to 1024,
|
||||
* 1024 would have got
|
||||
* rounded up to
|
||||
* 2048 */
|
||||
char *data1, *data2;
|
||||
|
||||
assert(p);
|
||||
data1 = dm_pool_alloc(p, 123);
|
||||
assert(data1);
|
||||
|
||||
data1 = dm_pool_alloc(p, 1024);
|
||||
assert(data1);
|
||||
|
||||
data2 = dm_pool_alloc(p, 123);
|
||||
assert(data2);
|
||||
|
||||
data2[0] = 'A'; /* should work fine */
|
||||
|
||||
dm_pool_free(p, data1);
|
||||
|
||||
/*
|
||||
* so now the first chunk is active, the second chunk has become
|
||||
* the free one.
|
||||
*/
|
||||
data2[0] = 'B'; /* should prompt an invalid write error */
|
||||
|
||||
dm_pool_destroy(p);
|
||||
}
|
||||
|
||||
static void check_alignment()
|
||||
{
|
||||
/*
|
||||
* Pool always tries to allocate blocks with particular alignment.
|
||||
* So there are potentially small gaps between allocations. This
|
||||
* test checks that valgrind is spotting illegal accesses to these
|
||||
* gaps.
|
||||
*/
|
||||
|
||||
int i, sum;
|
||||
struct dm_pool *p = dm_pool_create("blah", 1024);
|
||||
char *data1, *data2;
|
||||
char buffer[16];
|
||||
|
||||
|
||||
data1 = dm_pool_alloc_aligned(p, 1, 4);
|
||||
assert(data1);
|
||||
data2 = dm_pool_alloc_aligned(p, 1, 4);
|
||||
assert(data1);
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "%c", *(data1 + 1)); /* invalid read size 1 */
|
||||
dm_pool_destroy(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Looking at the code I'm not sure allocations that are near the chunk
|
||||
* size are working. So this test is trying to exhibit a specific problem.
|
||||
*/
|
||||
static void check_allocation_near_chunk_size()
|
||||
{
|
||||
int i;
|
||||
char *data;
|
||||
struct dm_pool *p = dm_pool_create("", 900);
|
||||
|
||||
/*
|
||||
* allocate a lot and then free everything so we know there
|
||||
* is a spare chunk.
|
||||
*/
|
||||
for (i = 0; i < 1000; i++) {
|
||||
data = dm_pool_alloc(p, 37);
|
||||
memset(data, 0, 37);
|
||||
assert(data);
|
||||
}
|
||||
|
||||
dm_pool_empty(p);
|
||||
|
||||
/* now we allocate something close to the chunk size ... */
|
||||
data = dm_pool_alloc(p, 1020);
|
||||
assert(data);
|
||||
memset(data, 0, 1020);
|
||||
|
||||
dm_pool_destroy(p);
|
||||
}
|
||||
|
||||
/* FIXME: test the dbg_malloc at exit (this test should be in dbg_malloc) */
|
||||
static void check_leak_detection()
|
||||
{
|
||||
int i;
|
||||
struct dm_pool *p = dm_pool_create("", 1024);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
dm_pool_alloc(p, (i + 1) * 37);
|
||||
}
|
||||
|
||||
/* we shouldn't get any errors from this one */
|
||||
static void check_object_growth()
|
||||
{
|
||||
int i;
|
||||
struct dm_pool *p = dm_pool_create("", 32);
|
||||
char data[100] = { 0 };
|
||||
void *obj;
|
||||
|
||||
dm_pool_begin_object(p, 43);
|
||||
for (i = 1; i < 100; i++)
|
||||
dm_pool_grow_object(p, data, i);
|
||||
obj = dm_pool_end_object(p);
|
||||
|
||||
dm_pool_destroy(p);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
check_free();
|
||||
check_free2();
|
||||
check_alignment();
|
||||
check_allocation_near_chunk_size();
|
||||
check_leak_detection();
|
||||
check_object_growth();
|
||||
return 0;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
SOURCES=\
|
||||
parse_t.c \
|
||||
matcher_t.c
|
||||
|
||||
TARGETS=\
|
||||
parse_t \
|
||||
matcher_t
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
INCLUDES += -I$(top_srcdir)/libdm
|
||||
DM_DEPS = $(top_builddir)/libdm/libdevmapper.so
|
||||
DM_LIBS = -ldevmapper $(LIBS)
|
||||
|
||||
parse_t: parse_t.o $(DM_DEPS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ parse_t.o $(DM_LIBS)
|
||||
|
||||
matcher_t: matcher_t.o $(DM_DEPS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ matcher_t.o $(DM_LIBS)
|
@ -1,3 +0,0 @@
|
||||
dfa matching:$TEST_TOOL ./matcher_t --fingerprint dev_patterns < devices.list > matcher_t.output && diff -u matcher_t.expected matcher_t.output
|
||||
dfa matching:$TEST_TOOL ./matcher_t --fingerprint random_regexes < /dev/null > matcher_t.output && diff -u matcher_t.expected2 matcher_t.output
|
||||
dfa with non-print regex chars:$TEST_TOOL ./matcher_t nonprint_regexes < nonprint_input > matcher_t.output && diff -u matcher_t.expected3 matcher_t.output
|
@ -1,2 +0,0 @@
|
||||
"loop/[0-9]+"
|
||||
"hd[a-d][0-5]+"
|
@ -1,880 +0,0 @@
|
||||
/dev
|
||||
/dev/.devfsd
|
||||
/dev/cpu
|
||||
/dev/cpu/mtrr
|
||||
/dev/netlink
|
||||
/dev/netlink/route
|
||||
/dev/netlink/skip
|
||||
/dev/netlink/USERSOCK
|
||||
/dev/netlink/fwmonitor
|
||||
/dev/netlink/ARPD
|
||||
/dev/netlink/ROUTE6
|
||||
/dev/netlink/IP6_FW
|
||||
/dev/netlink/tap0
|
||||
/dev/netlink/tap1
|
||||
/dev/netlink/tap2
|
||||
/dev/netlink/tap3
|
||||
/dev/netlink/tap4
|
||||
/dev/netlink/tap5
|
||||
/dev/netlink/tap6
|
||||
/dev/netlink/tap7
|
||||
/dev/netlink/tap8
|
||||
/dev/netlink/tap9
|
||||
/dev/netlink/tap10
|
||||
/dev/netlink/tap11
|
||||
/dev/netlink/tap12
|
||||
/dev/netlink/tap13
|
||||
/dev/netlink/tap14
|
||||
/dev/netlink/tap15
|
||||
/dev/shm
|
||||
/dev/mem
|
||||
/dev/kmem
|
||||
/dev/null
|
||||
/dev/port
|
||||
/dev/zero
|
||||
/dev/full
|
||||
/dev/random
|
||||
/dev/urandom
|
||||
/dev/tty
|
||||
/dev/console
|
||||
/dev/vc
|
||||
/dev/vc/1
|
||||
/dev/vc/2
|
||||
/dev/vc/3
|
||||
/dev/vc/4
|
||||
/dev/vc/5
|
||||
/dev/vc/6
|
||||
/dev/vc/7
|
||||
/dev/vc/8
|
||||
/dev/vc/9
|
||||
/dev/vc/10
|
||||
/dev/vc/11
|
||||
/dev/vc/12
|
||||
/dev/vc/13
|
||||
/dev/vc/14
|
||||
/dev/vc/15
|
||||
/dev/vc/16
|
||||
/dev/vc/17
|
||||
/dev/vc/18
|
||||
/dev/vc/19
|
||||
/dev/vc/20
|
||||
/dev/vc/21
|
||||
/dev/vc/22
|
||||
/dev/vc/23
|
||||
/dev/vc/24
|
||||
/dev/vc/25
|
||||
/dev/vc/26
|
||||
/dev/vc/27
|
||||
/dev/vc/28
|
||||
/dev/vc/29
|
||||
/dev/vc/30
|
||||
/dev/vc/31
|
||||
/dev/vc/32
|
||||
/dev/vc/33
|
||||
/dev/vc/34
|
||||
/dev/vc/35
|
||||
/dev/vc/36
|
||||
/dev/vc/37
|
||||
/dev/vc/38
|
||||
/dev/vc/39
|
||||
/dev/vc/40
|
||||
/dev/vc/41
|
||||
/dev/vc/42
|
||||
/dev/vc/43
|
||||
/dev/vc/44
|
||||
/dev/vc/45
|
||||
/dev/vc/46
|
||||
/dev/vc/47
|
||||
/dev/vc/48
|
||||
/dev/vc/49
|
||||
/dev/vc/50
|
||||
/dev/vc/51
|
||||
/dev/vc/52
|
||||
/dev/vc/53
|
||||
/dev/vc/54
|
||||
/dev/vc/55
|
||||
/dev/vc/56
|
||||
/dev/vc/57
|
||||
/dev/vc/58
|
||||
/dev/vc/59
|
||||
/dev/vc/60
|
||||
/dev/vc/61
|
||||
/dev/vc/62
|
||||
/dev/vc/63
|
||||
/dev/vc/0
|
||||
/dev/ptmx
|
||||
/dev/misc
|
||||
/dev/misc/psaux
|
||||
/dev/pty
|
||||
/dev/pty/m0
|
||||
/dev/pty/m1
|
||||
/dev/pty/m2
|
||||
/dev/pty/m3
|
||||
/dev/pty/m4
|
||||
/dev/pty/m5
|
||||
/dev/pty/m6
|
||||
/dev/pty/m7
|
||||
/dev/pty/m8
|
||||
/dev/pty/m9
|
||||
/dev/pty/m10
|
||||
/dev/pty/m11
|
||||
/dev/pty/m12
|
||||
/dev/pty/m13
|
||||
/dev/pty/m14
|
||||
/dev/pty/m15
|
||||
/dev/pty/m16
|
||||
/dev/pty/m17
|
||||
/dev/pty/m18
|
||||
/dev/pty/m19
|
||||
/dev/pty/m20
|
||||
/dev/pty/m21
|
||||
/dev/pty/m22
|
||||
/dev/pty/m23
|
||||
/dev/pty/m24
|
||||
/dev/pty/m25
|
||||
/dev/pty/m26
|
||||
/dev/pty/m27
|
||||
/dev/pty/m28
|
||||
/dev/pty/m29
|
||||
/dev/pty/m30
|
||||
/dev/pty/m31
|
||||
/dev/pty/m32
|
||||
/dev/pty/m33
|
||||
/dev/pty/m34
|
||||
/dev/pty/m35
|
||||
/dev/pty/m36
|
||||
/dev/pty/m37
|
||||
/dev/pty/m38
|
||||
/dev/pty/m39
|
||||
/dev/pty/m40
|
||||
/dev/pty/m41
|
||||
/dev/pty/m42
|
||||
/dev/pty/m43
|
||||
/dev/pty/m44
|
||||
/dev/pty/m45
|
||||
/dev/pty/m46
|
||||
/dev/pty/m47
|
||||
/dev/pty/m48
|
||||
/dev/pty/m49
|
||||
/dev/pty/m50
|
||||
/dev/pty/m51
|
||||
/dev/pty/m52
|
||||
/dev/pty/m53
|
||||
/dev/pty/m54
|
||||
/dev/pty/m55
|
||||
/dev/pty/m56
|
||||
/dev/pty/m57
|
||||
/dev/pty/m58
|
||||
/dev/pty/m59
|
||||
/dev/pty/m60
|
||||
/dev/pty/m61
|
||||
/dev/pty/m62
|
||||
/dev/pty/m63
|
||||
/dev/pty/m64
|
||||
/dev/pty/m65
|
||||
/dev/pty/m66
|
||||
/dev/pty/m67
|
||||
/dev/pty/m68
|
||||
/dev/pty/m69
|
||||
/dev/pty/m70
|
||||
/dev/pty/m71
|
||||
/dev/pty/m72
|
||||
/dev/pty/m73
|
||||
/dev/pty/m74
|
||||
/dev/pty/m75
|
||||
/dev/pty/m76
|
||||
/dev/pty/m77
|
||||
/dev/pty/m78
|
||||
/dev/pty/m79
|
||||
/dev/pty/m80
|
||||
/dev/pty/m81
|
||||
/dev/pty/m82
|
||||
/dev/pty/m83
|
||||
/dev/pty/m84
|
||||
/dev/pty/m85
|
||||
/dev/pty/m86
|
||||
/dev/pty/m87
|
||||
/dev/pty/m88
|
||||
/dev/pty/m89
|
||||
/dev/pty/m90
|
||||
/dev/pty/m91
|
||||
/dev/pty/m92
|
||||
/dev/pty/m93
|
||||
/dev/pty/m94
|
||||
/dev/pty/m95
|
||||
/dev/pty/m96
|
||||
/dev/pty/m97
|
||||
/dev/pty/m98
|
||||
/dev/pty/m99
|
||||
/dev/pty/m100
|
||||
/dev/pty/m101
|
||||
/dev/pty/m102
|
||||
/dev/pty/m103
|
||||
/dev/pty/m104
|
||||
/dev/pty/m105
|
||||
/dev/pty/m106
|
||||
/dev/pty/m107
|
||||
/dev/pty/m108
|
||||
/dev/pty/m109
|
||||
/dev/pty/m110
|
||||
/dev/pty/m111
|
||||
/dev/pty/m112
|
||||
/dev/pty/m113
|
||||
/dev/pty/m114
|
||||
/dev/pty/m115
|
||||
/dev/pty/m116
|
||||
/dev/pty/m117
|
||||
/dev/pty/m118
|
||||
/dev/pty/m119
|
||||
/dev/pty/m120
|
||||
/dev/pty/m121
|
||||
/dev/pty/m122
|
||||
/dev/pty/m123
|
||||
/dev/pty/m124
|
||||
/dev/pty/m125
|
||||
/dev/pty/m126
|
||||
/dev/pty/m127
|
||||
/dev/pty/m128
|
||||
/dev/pty/m129
|
||||
/dev/pty/m130
|
||||
/dev/pty/m131
|
||||
/dev/pty/m132
|
||||
/dev/pty/m133
|
||||
/dev/pty/m134
|
||||
/dev/pty/m135
|
||||
/dev/pty/m136
|
||||
/dev/pty/m137
|
||||
/dev/pty/m138
|
||||
/dev/pty/m139
|
||||
/dev/pty/m140
|
||||
/dev/pty/m141
|
||||
/dev/pty/m142
|
||||
/dev/pty/m143
|
||||
/dev/pty/m144
|
||||
/dev/pty/m145
|
||||
/dev/pty/m146
|
||||
/dev/pty/m147
|
||||
/dev/pty/m148
|
||||
/dev/pty/m149
|
||||
/dev/pty/m150
|
||||
/dev/pty/m151
|
||||
/dev/pty/m152
|
||||
/dev/pty/m153
|
||||
/dev/pty/m154
|
||||
/dev/pty/m155
|
||||
/dev/pty/m156
|
||||
/dev/pty/m157
|
||||
/dev/pty/m158
|
||||
/dev/pty/m159
|
||||
/dev/pty/m160
|
||||
/dev/pty/m161
|
||||
/dev/pty/m162
|
||||
/dev/pty/m163
|
||||
/dev/pty/m164
|
||||
/dev/pty/m165
|
||||
/dev/pty/m166
|
||||
/dev/pty/m167
|
||||
/dev/pty/m168
|
||||
/dev/pty/m169
|
||||
/dev/pty/m170
|
||||
/dev/pty/m171
|
||||
/dev/pty/m172
|
||||
/dev/pty/m173
|
||||
/dev/pty/m174
|
||||
/dev/pty/m175
|
||||
/dev/pty/m176
|
||||
/dev/pty/m177
|
||||
/dev/pty/m178
|
||||
/dev/pty/m179
|
||||
/dev/pty/m180
|
||||
/dev/pty/m181
|
||||
/dev/pty/m182
|
||||
/dev/pty/m183
|
||||
/dev/pty/m184
|
||||
/dev/pty/m185
|
||||
/dev/pty/m186
|
||||
/dev/pty/m187
|
||||
/dev/pty/m188
|
||||
/dev/pty/m189
|
||||
/dev/pty/m190
|
||||
/dev/pty/m191
|
||||
/dev/pty/m192
|
||||
/dev/pty/m193
|
||||
/dev/pty/m194
|
||||
/dev/pty/m195
|
||||
/dev/pty/m196
|
||||
/dev/pty/m197
|
||||
/dev/pty/m198
|
||||
/dev/pty/m199
|
||||
/dev/pty/m200
|
||||
/dev/pty/m201
|
||||
/dev/pty/m202
|
||||
/dev/pty/m203
|
||||
/dev/pty/m204
|
||||
/dev/pty/m205
|
||||
/dev/pty/m206
|
||||
/dev/pty/m207
|
||||
/dev/pty/m208
|
||||
/dev/pty/m209
|
||||
/dev/pty/m210
|
||||
/dev/pty/m211
|
||||
/dev/pty/m212
|
||||
/dev/pty/m213
|
||||
/dev/pty/m214
|
||||
/dev/pty/m215
|
||||
/dev/pty/m216
|
||||
/dev/pty/m217
|
||||
/dev/pty/m218
|
||||
/dev/pty/m219
|
||||
/dev/pty/m220
|
||||
/dev/pty/m221
|
||||
/dev/pty/m222
|
||||
/dev/pty/m223
|
||||
/dev/pty/m224
|
||||
/dev/pty/m225
|
||||
/dev/pty/m226
|
||||
/dev/pty/m227
|
||||
/dev/pty/m228
|
||||
/dev/pty/m229
|
||||
/dev/pty/m230
|
||||
/dev/pty/m231
|
||||
/dev/pty/m232
|
||||
/dev/pty/m233
|
||||
/dev/pty/m234
|
||||
/dev/pty/m235
|
||||
/dev/pty/m236
|
||||
/dev/pty/m237
|
||||
/dev/pty/m238
|
||||
/dev/pty/m239
|
||||
/dev/pty/m240
|
||||
/dev/pty/m241
|
||||
/dev/pty/m242
|
||||
/dev/pty/m243
|
||||
/dev/pty/m244
|
||||
/dev/pty/m245
|
||||
/dev/pty/m246
|
||||
/dev/pty/m247
|
||||
/dev/pty/m248
|
||||
/dev/pty/m249
|
||||
/dev/pty/m250
|
||||
/dev/pty/m251
|
||||
/dev/pty/m252
|
||||
/dev/pty/m253
|
||||
/dev/pty/m254
|
||||
/dev/pty/m255
|
||||
/dev/pts
|
||||
/dev/pts/0
|
||||
/dev/pts/1
|
||||
/dev/pts/2
|
||||
/dev/pts/3
|
||||
/dev/pts/4
|
||||
/dev/pts/5
|
||||
/dev/pts/6
|
||||
/dev/pts/7
|
||||
/dev/vcc
|
||||
/dev/vcc/0
|
||||
/dev/vcc/a
|
||||
/dev/vcc/1
|
||||
/dev/vcc/a1
|
||||
/dev/vcc/2
|
||||
/dev/vcc/a2
|
||||
/dev/vcc/3
|
||||
/dev/vcc/a3
|
||||
/dev/vcc/5
|
||||
/dev/vcc/a5
|
||||
/dev/vcc/4
|
||||
/dev/vcc/a4
|
||||
/dev/vcc/6
|
||||
/dev/vcc/a6
|
||||
/dev/vcc/7
|
||||
/dev/vcc/a7
|
||||
/dev/tts
|
||||
/dev/tts/0
|
||||
/dev/cua
|
||||
/dev/cua/0
|
||||
/dev/ide
|
||||
/dev/ide/host0
|
||||
/dev/ide/host0/bus0
|
||||
/dev/ide/host0/bus0/target0
|
||||
/dev/ide/host0/bus0/target0/lun0
|
||||
/dev/ide/host0/bus0/target0/lun0/disc
|
||||
/dev/ide/host0/bus0/target0/lun0/part1
|
||||
/dev/ide/host0/bus0/target0/lun0/part2
|
||||
/dev/ide/host0/bus0/target0/lun0/part3
|
||||
/dev/ide/host0/bus0/target0/lun0/part4
|
||||
/dev/ide/host0/bus0/target0/lun0/part5
|
||||
/dev/ide/host0/bus0/target0/lun0/part6
|
||||
/dev/ide/host0/bus0/target0/lun0/part7
|
||||
/dev/ide/host0/bus0/target0/lun0/part8
|
||||
/dev/ide/host0/bus0/target1
|
||||
/dev/ide/host0/bus0/target1/lun0
|
||||
/dev/ide/host0/bus0/target1/lun0/disc
|
||||
/dev/ide/host0/bus0/target1/lun0/part1
|
||||
/dev/ide/host0/bus1
|
||||
/dev/ide/host0/bus1/target0
|
||||
/dev/ide/host0/bus1/target0/lun0
|
||||
/dev/ide/host0/bus1/target0/lun0/disc
|
||||
/dev/ide/host0/bus1/target0/lun0/part1
|
||||
/dev/ide/host0/bus1/target1
|
||||
/dev/ide/host0/bus1/target1/lun0
|
||||
/dev/discs
|
||||
/dev/discs/disc0
|
||||
/dev/discs/disc1
|
||||
/dev/discs/disc2
|
||||
/dev/floppy
|
||||
/dev/floppy/0u1440
|
||||
/dev/floppy/0u1680
|
||||
/dev/floppy/0u1722
|
||||
/dev/floppy/0u1743
|
||||
/dev/floppy/0u1760
|
||||
/dev/floppy/0u1920
|
||||
/dev/floppy/0u1840
|
||||
/dev/floppy/0u1600
|
||||
/dev/floppy/0u360
|
||||
/dev/floppy/0u720
|
||||
/dev/floppy/0u820
|
||||
/dev/floppy/0u830
|
||||
/dev/floppy/0u1040
|
||||
/dev/floppy/0u1120
|
||||
/dev/floppy/0u800
|
||||
/dev/floppy/0
|
||||
/dev/loop
|
||||
/dev/loop/0
|
||||
/dev/loop/1
|
||||
/dev/loop/2
|
||||
/dev/loop/3
|
||||
/dev/loop/4
|
||||
/dev/loop/5
|
||||
/dev/loop/6
|
||||
/dev/loop/7
|
||||
/dev/cdroms
|
||||
/dev/sound
|
||||
/dev/sound/dsp
|
||||
/dev/sound/dsp1
|
||||
/dev/sound/mixer
|
||||
/dev/sound/midi
|
||||
/dev/usb
|
||||
/dev/root
|
||||
/dev/initctl
|
||||
/dev/xconsole
|
||||
/dev/fd
|
||||
/dev/stdin
|
||||
/dev/stdout
|
||||
/dev/stderr
|
||||
/dev/route
|
||||
/dev/skip
|
||||
/dev/USERSOCK
|
||||
/dev/fwmonitor
|
||||
/dev/ARPD
|
||||
/dev/ROUTE6
|
||||
/dev/IP6_FW
|
||||
/dev/tap0
|
||||
/dev/tap1
|
||||
/dev/tap2
|
||||
/dev/tap3
|
||||
/dev/tap4
|
||||
/dev/tap5
|
||||
/dev/tap6
|
||||
/dev/tap7
|
||||
/dev/tap8
|
||||
/dev/tap9
|
||||
/dev/tap10
|
||||
/dev/tap11
|
||||
/dev/tap12
|
||||
/dev/tap13
|
||||
/dev/tap14
|
||||
/dev/tap15
|
||||
/dev/tty1
|
||||
/dev/tty2
|
||||
/dev/tty3
|
||||
/dev/tty4
|
||||
/dev/tty5
|
||||
/dev/tty6
|
||||
/dev/tty7
|
||||
/dev/tty8
|
||||
/dev/tty9
|
||||
/dev/tty10
|
||||
/dev/tty11
|
||||
/dev/tty12
|
||||
/dev/tty13
|
||||
/dev/tty14
|
||||
/dev/tty15
|
||||
/dev/tty16
|
||||
/dev/tty17
|
||||
/dev/tty18
|
||||
/dev/tty19
|
||||
/dev/tty20
|
||||
/dev/tty21
|
||||
/dev/tty22
|
||||
/dev/tty23
|
||||
/dev/tty24
|
||||
/dev/tty25
|
||||
/dev/tty26
|
||||
/dev/tty27
|
||||
/dev/tty28
|
||||
/dev/tty29
|
||||
/dev/tty30
|
||||
/dev/tty31
|
||||
/dev/tty32
|
||||
/dev/tty33
|
||||
/dev/tty34
|
||||
/dev/tty35
|
||||
/dev/tty36
|
||||
/dev/tty37
|
||||
/dev/tty38
|
||||
/dev/tty39
|
||||
/dev/tty40
|
||||
/dev/tty41
|
||||
/dev/tty42
|
||||
/dev/tty43
|
||||
/dev/tty44
|
||||
/dev/tty45
|
||||
/dev/tty46
|
||||
/dev/tty47
|
||||
/dev/tty48
|
||||
/dev/tty49
|
||||
/dev/tty50
|
||||
/dev/tty51
|
||||
/dev/tty52
|
||||
/dev/tty53
|
||||
/dev/tty54
|
||||
/dev/tty55
|
||||
/dev/tty56
|
||||
/dev/tty57
|
||||
/dev/tty58
|
||||
/dev/tty59
|
||||
/dev/tty60
|
||||
/dev/tty61
|
||||
/dev/tty62
|
||||
/dev/tty63
|
||||
/dev/tty0
|
||||
/dev/psaux
|
||||
/dev/ptyp0
|
||||
/dev/ptyp1
|
||||
/dev/ptyp2
|
||||
/dev/ptyp3
|
||||
/dev/ptyp4
|
||||
/dev/ptyp5
|
||||
/dev/ptyp6
|
||||
/dev/ptyp7
|
||||
/dev/ptyp8
|
||||
/dev/ptyp9
|
||||
/dev/ptypa
|
||||
/dev/ptypb
|
||||
/dev/ptypc
|
||||
/dev/ptypd
|
||||
/dev/ptype
|
||||
/dev/ptypf
|
||||
/dev/ptyq0
|
||||
/dev/ptyq1
|
||||
/dev/ptyq2
|
||||
/dev/ptyq3
|
||||
/dev/ptyq4
|
||||
/dev/ptyq5
|
||||
/dev/ptyq6
|
||||
/dev/ptyq7
|
||||
/dev/ptyq8
|
||||
/dev/ptyq9
|
||||
/dev/ptyqa
|
||||
/dev/ptyqb
|
||||
/dev/ptyqc
|
||||
/dev/ptyqd
|
||||
/dev/ptyqe
|
||||
/dev/ptyqf
|
||||
/dev/ptyr0
|
||||
/dev/ptyr1
|
||||
/dev/ptyr2
|
||||
/dev/ptyr3
|
||||
/dev/ptyr4
|
||||
/dev/ptyr5
|
||||
/dev/ptyr6
|
||||
/dev/ptyr7
|
||||
/dev/ptyr8
|
||||
/dev/ptyr9
|
||||
/dev/ptyra
|
||||
/dev/ptyrb
|
||||
/dev/ptyrc
|
||||
/dev/ptyrd
|
||||
/dev/ptyre
|
||||
/dev/ptyrf
|
||||
/dev/ptys0
|
||||
/dev/ptys1
|
||||
/dev/ptys2
|
||||
/dev/ptys3
|
||||
/dev/ptys4
|
||||
/dev/ptys5
|
||||
/dev/ptys6
|
||||
/dev/ptys7
|
||||
/dev/ptys8
|
||||
/dev/ptys9
|
||||
/dev/ptysa
|
||||
/dev/ptysb
|
||||
/dev/ptysc
|
||||
/dev/ptysd
|
||||
/dev/ptyse
|
||||
/dev/ptysf
|
||||
/dev/ptyt0
|
||||
/dev/ptyt1
|
||||
/dev/ptyt2
|
||||
/dev/ptyt3
|
||||
/dev/ptyt4
|
||||
/dev/ptyt5
|
||||
/dev/ptyt6
|
||||
/dev/ptyt7
|
||||
/dev/ptyt8
|
||||
/dev/ptyt9
|
||||
/dev/ptyta
|
||||
/dev/ptytb
|
||||
/dev/ptytc
|
||||
/dev/ptytd
|
||||
/dev/ptyte
|
||||
/dev/ptytf
|
||||
/dev/ptyu0
|
||||
/dev/ptyu1
|
||||
/dev/ptyu2
|
||||
/dev/ptyu3
|
||||
/dev/ptyu4
|
||||
/dev/ptyu5
|
||||
/dev/ptyu6
|
||||
/dev/ptyu7
|
||||
/dev/ptyu8
|
||||
/dev/ptyu9
|
||||
/dev/ptyua
|
||||
/dev/ptyub
|
||||
/dev/ptyuc
|
||||
/dev/ptyud
|
||||
/dev/ptyue
|
||||
/dev/ptyuf
|
||||
/dev/ptyv0
|
||||
/dev/ptyv1
|
||||
/dev/ptyv2
|
||||
/dev/ptyv3
|
||||
/dev/ptyv4
|
||||
/dev/ptyv5
|
||||
/dev/ptyv6
|
||||
/dev/ptyv7
|
||||
/dev/ptyv8
|
||||
/dev/ptyv9
|
||||
/dev/ptyva
|
||||
/dev/ptyvb
|
||||
/dev/ptyvc
|
||||
/dev/ptyvd
|
||||
/dev/ptyve
|
||||
/dev/ptyvf
|
||||
/dev/ptyw0
|
||||
/dev/ptyw1
|
||||
/dev/ptyw2
|
||||
/dev/ptyw3
|
||||
/dev/ptyw4
|
||||
/dev/ptyw5
|
||||
/dev/ptyw6
|
||||
/dev/ptyw7
|
||||
/dev/ptyw8
|
||||
/dev/ptyw9
|
||||
/dev/ptywa
|
||||
/dev/ptywb
|
||||
/dev/ptywc
|
||||
/dev/ptywd
|
||||
/dev/ptywe
|
||||
/dev/ptywf
|
||||
/dev/ptyx0
|
||||
/dev/ptyx1
|
||||
/dev/ptyx2
|
||||
/dev/ptyx3
|
||||
/dev/ptyx4
|
||||
/dev/ptyx5
|
||||
/dev/ptyx6
|
||||
/dev/ptyx7
|
||||
/dev/ptyx8
|
||||
/dev/ptyx9
|
||||
/dev/ptyxa
|
||||
/dev/ptyxb
|
||||
/dev/ptyxc
|
||||
/dev/ptyxd
|
||||
/dev/ptyxe
|
||||
/dev/ptyxf
|
||||
/dev/ptyy0
|
||||
/dev/ptyy1
|
||||
/dev/ptyy2
|
||||
/dev/ptyy3
|
||||
/dev/ptyy4
|
||||
/dev/ptyy5
|
||||
/dev/ptyy6
|
||||
/dev/ptyy7
|
||||
/dev/ptyy8
|
||||
/dev/ptyy9
|
||||
/dev/ptyya
|
||||
/dev/ptyyb
|
||||
/dev/ptyyc
|
||||
/dev/ptyyd
|
||||
/dev/ptyye
|
||||
/dev/ptyyf
|
||||
/dev/ptyz0
|
||||
/dev/ptyz1
|
||||
/dev/ptyz2
|
||||
/dev/ptyz3
|
||||
/dev/ptyz4
|
||||
/dev/ptyz5
|
||||
/dev/ptyz6
|
||||
/dev/ptyz7
|
||||
/dev/ptyz8
|
||||
/dev/ptyz9
|
||||
/dev/ptyza
|
||||
/dev/ptyzb
|
||||
/dev/ptyzc
|
||||
/dev/ptyzd
|
||||
/dev/ptyze
|
||||
/dev/ptyzf
|
||||
/dev/ptya0
|
||||
/dev/ptya1
|
||||
/dev/ptya2
|
||||
/dev/ptya3
|
||||
/dev/ptya4
|
||||
/dev/ptya5
|
||||
/dev/ptya6
|
||||
/dev/ptya7
|
||||
/dev/ptya8
|
||||
/dev/ptya9
|
||||
/dev/ptyaa
|
||||
/dev/ptyab
|
||||
/dev/ptyac
|
||||
/dev/ptyad
|
||||
/dev/ptyae
|
||||
/dev/ptyaf
|
||||
/dev/ptyb0
|
||||
/dev/ptyb1
|
||||
/dev/ptyb2
|
||||
/dev/ptyb3
|
||||
/dev/ptyb4
|
||||
/dev/ptyb5
|
||||
/dev/ptyb6
|
||||
/dev/ptyb7
|
||||
/dev/ptyb8
|
||||
/dev/ptyb9
|
||||
/dev/ptyba
|
||||
/dev/ptybb
|
||||
/dev/ptybc
|
||||
/dev/ptybd
|
||||
/dev/ptybe
|
||||
/dev/ptybf
|
||||
/dev/ptyc0
|
||||
/dev/ptyc1
|
||||
/dev/ptyc2
|
||||
/dev/ptyc3
|
||||
/dev/ptyc4
|
||||
/dev/ptyc5
|
||||
/dev/ptyc6
|
||||
/dev/ptyc7
|
||||
/dev/ptyc8
|
||||
/dev/ptyc9
|
||||
/dev/ptyca
|
||||
/dev/ptycb
|
||||
/dev/ptycc
|
||||
/dev/ptycd
|
||||
/dev/ptyce
|
||||
/dev/ptycf
|
||||
/dev/ptyd0
|
||||
/dev/ptyd1
|
||||
/dev/ptyd2
|
||||
/dev/ptyd3
|
||||
/dev/ptyd4
|
||||
/dev/ptyd5
|
||||
/dev/ptyd6
|
||||
/dev/ptyd7
|
||||
/dev/ptyd8
|
||||
/dev/ptyd9
|
||||
/dev/ptyda
|
||||
/dev/ptydb
|
||||
/dev/ptydc
|
||||
/dev/ptydd
|
||||
/dev/ptyde
|
||||
/dev/ptydf
|
||||
/dev/ptye0
|
||||
/dev/ptye1
|
||||
/dev/ptye2
|
||||
/dev/ptye3
|
||||
/dev/ptye4
|
||||
/dev/ptye5
|
||||
/dev/ptye6
|
||||
/dev/ptye7
|
||||
/dev/ptye8
|
||||
/dev/ptye9
|
||||
/dev/ptyea
|
||||
/dev/ptyeb
|
||||
/dev/ptyec
|
||||
/dev/ptyed
|
||||
/dev/ptyee
|
||||
/dev/ptyef
|
||||
/dev/vcs
|
||||
/dev/vcsa
|
||||
/dev/vcs1
|
||||
/dev/vcsa1
|
||||
/dev/ttyS0
|
||||
/dev/cua0
|
||||
/dev/hda
|
||||
/dev/hda1
|
||||
/dev/hda2
|
||||
/dev/hda3
|
||||
/dev/hda4
|
||||
/dev/hda5
|
||||
/dev/hda6
|
||||
/dev/hda7
|
||||
/dev/hda8
|
||||
/dev/hdb
|
||||
/dev/hdb1
|
||||
/dev/hdc
|
||||
/dev/hdc1
|
||||
/dev/fd0u1440
|
||||
/dev/fd0u1680
|
||||
/dev/fd0u1722
|
||||
/dev/fd0u1743
|
||||
/dev/fd0u1760
|
||||
/dev/fd0u1920
|
||||
/dev/fd0u1840
|
||||
/dev/fd0u1600
|
||||
/dev/fd0u360
|
||||
/dev/fd0u720
|
||||
/dev/fd0u820
|
||||
/dev/fd0u830
|
||||
/dev/fd0u1040
|
||||
/dev/fd0u1120
|
||||
/dev/fd0u800
|
||||
/dev/fd0
|
||||
/dev/loop0
|
||||
/dev/loop1
|
||||
/dev/loop2
|
||||
/dev/loop3
|
||||
/dev/loop4
|
||||
/dev/loop5
|
||||
/dev/loop6
|
||||
/dev/loop7
|
||||
/dev/dsp
|
||||
/dev/dsp1
|
||||
/dev/mixer
|
||||
/dev/midi
|
||||
/dev/lvm
|
||||
/dev/vg0
|
||||
/dev/vg0/group
|
||||
/dev/vg0/packages
|
||||
/dev/vg0/photos
|
||||
/dev/vg0/music
|
||||
/dev/log
|
||||
/dev/MAKEDEV
|
||||
/dev/printer
|
||||
/dev/vcs2
|
||||
/dev/vcsa2
|
||||
/dev/vcs3
|
||||
/dev/vcsa3
|
||||
/dev/vcs5
|
||||
/dev/vcsa5
|
||||
/dev/vcs4
|
||||
/dev/vcsa4
|
||||
/dev/vcs6
|
||||
/dev/vcsa6
|
||||
/dev/nvidia0
|
||||
/dev/nvidia1
|
||||
/dev/nvidia2
|
||||
/dev/nvidia3
|
||||
/dev/nvidiactl
|
||||
/dev/vcs7
|
||||
/dev/vcsa7
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libdevmapper.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
||||
static int _read_spec(const char *file, char ***regex, int *nregex)
|
||||
{
|
||||
char buffer[1024], *start, *ptr;
|
||||
FILE *fp = fopen(file, "r");
|
||||
int asize = 100;
|
||||
char **rx = dm_malloc(sizeof(*rx) * asize);
|
||||
int nr = 0;
|
||||
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer),fp)) {
|
||||
|
||||
/* trim leading whitespace */
|
||||
for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++);
|
||||
|
||||
if (!*ptr || *ptr == '#')
|
||||
continue;
|
||||
|
||||
if (*ptr == '\"') {
|
||||
ptr++;
|
||||
start = ptr;
|
||||
while (*ptr && *ptr != '\"') {
|
||||
if (*ptr == '\\')
|
||||
ptr++;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (!*ptr) {
|
||||
fprintf(stderr, "Formatting error : "
|
||||
"No terminating quote\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
rx[nr] = dm_malloc((ptr - start) + 1);
|
||||
strncpy(rx[nr], start, ptr - start);
|
||||
rx[nr][ptr - start] = '\0';
|
||||
nr++;
|
||||
} else {
|
||||
fprintf(stderr, "%s", ptr);
|
||||
fprintf(stderr, "Formatting error : \"<regex>\" "
|
||||
"<token_name>\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*regex = rx;
|
||||
*nregex = nr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _free_regex(char **regex, int nregex)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nregex; i++)
|
||||
dm_free(regex[i]);
|
||||
|
||||
dm_free(regex);
|
||||
}
|
||||
|
||||
static void _scan_input(struct dm_regex *m, char **regex)
|
||||
{
|
||||
char buffer[256], *ptr;
|
||||
int r;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), stdin)) {
|
||||
if ((ptr = strchr(buffer, '\n')))
|
||||
*ptr = '\0';
|
||||
|
||||
r = dm_regex_match(m, buffer);
|
||||
|
||||
if (r >= 0)
|
||||
printf("%s : %s\n", buffer, regex[r]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct dm_pool *mem;
|
||||
struct dm_regex *scanner;
|
||||
char **regex;
|
||||
int nregex;
|
||||
int ret = 0;
|
||||
int want_finger_print = 0, i;
|
||||
const char *pattern_file = NULL;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if (!strcmp(argv[i], "--fingerprint"))
|
||||
want_finger_print = 1;
|
||||
|
||||
else
|
||||
pattern_file = argv[i];
|
||||
|
||||
if (!pattern_file) {
|
||||
fprintf(stderr, "Usage : %s [--fingerprint] <pattern_file>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dm_log_init_verbose(_LOG_DEBUG);
|
||||
|
||||
if (!(mem = dm_pool_create("match_regex", 10 * 1024))) {
|
||||
fprintf(stderr, "Couldn't create pool\n");
|
||||
ret = 2;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!_read_spec(pattern_file, ®ex, &nregex)) {
|
||||
fprintf(stderr, "Couldn't read the lex specification\n");
|
||||
ret = 3;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(scanner = dm_regex_create(mem, (const char **)regex, nregex))) {
|
||||
fprintf(stderr, "Couldn't build the lexer\n");
|
||||
ret = 4;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (want_finger_print)
|
||||
printf("fingerprint: %x\n", dm_regex_fingerprint(scanner));
|
||||
_scan_input(scanner, regex);
|
||||
_free_regex(regex, nregex);
|
||||
|
||||
err:
|
||||
dm_pool_destroy(mem);
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
fingerprint: 352b6c4f
|
||||
/dev/loop/0 : loop/[0-9]+
|
||||
/dev/loop/1 : loop/[0-9]+
|
||||
/dev/loop/2 : loop/[0-9]+
|
||||
/dev/loop/3 : loop/[0-9]+
|
||||
/dev/loop/4 : loop/[0-9]+
|
||||
/dev/loop/5 : loop/[0-9]+
|
||||
/dev/loop/6 : loop/[0-9]+
|
||||
/dev/loop/7 : loop/[0-9]+
|
||||
/dev/hda1 : hd[a-d][0-5]+
|
||||
/dev/hda2 : hd[a-d][0-5]+
|
||||
/dev/hda3 : hd[a-d][0-5]+
|
||||
/dev/hda4 : hd[a-d][0-5]+
|
||||
/dev/hda5 : hd[a-d][0-5]+
|
||||
/dev/hdb1 : hd[a-d][0-5]+
|
||||
/dev/hdc1 : hd[a-d][0-5]+
|
@ -1 +0,0 @@
|
||||
fingerprint: eed8ceb8
|
@ -1,3 +0,0 @@
|
||||
foo€bar : €
|
||||
fooÂb : fooÂb
|
||||
€ : €
|
@ -1,4 +0,0 @@
|
||||
foo.bar
|
||||
foo€bar
|
||||
fooÂb
|
||||
€
|
@ -1,3 +0,0 @@
|
||||
"foo€bar"
|
||||
"fooÂb"
|
||||
"€"
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* hack - using unexported internal function */
|
||||
#define DEBUG
|
||||
#include "regex/parse_rx.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static void _pretty_print(struct rx_node *rx, int depth)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < depth; i++)
|
||||
printf(" ");
|
||||
|
||||
/* display info about the node */
|
||||
switch (rx->type) {
|
||||
case CAT:
|
||||
printf("Cat");
|
||||
break;
|
||||
|
||||
case OR:
|
||||
printf("Or");
|
||||
break;
|
||||
|
||||
case STAR:
|
||||
printf("Star");
|
||||
break;
|
||||
|
||||
case PLUS:
|
||||
printf("Plus");
|
||||
break;
|
||||
|
||||
case QUEST:
|
||||
printf("Quest");
|
||||
break;
|
||||
|
||||
case CHARSET:
|
||||
printf("Charset : ");
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (dm_bit(rx->charset, i) && isprint(i))
|
||||
printf("%c", (char) i);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unknown type");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (rx->left)
|
||||
_pretty_print(rx->left, depth + 1);
|
||||
|
||||
if (rx->right)
|
||||
_pretty_print(rx->right, depth + 1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct dm_pool *mem;
|
||||
struct rx_node *rx;
|
||||
int regex_print = 0;
|
||||
int show_nodes = 0;
|
||||
int regex_arg = 1;
|
||||
|
||||
if (argc == 3 && !strcmp(argv[1], "-r")) {
|
||||
regex_print++;
|
||||
regex_arg++;
|
||||
argc--;
|
||||
}
|
||||
|
||||
if (argc == 3 && !strcmp(argv[1], "-R")) {
|
||||
regex_print++;
|
||||
show_nodes++;
|
||||
regex_arg++;
|
||||
argc--;
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage : %s [-r] <regex>\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
dm_log_init_verbose(_LOG_DEBUG);
|
||||
|
||||
if (!(mem = dm_pool_create("parse_regex", 1024))) {
|
||||
fprintf(stderr, "Couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(rx = rx_parse_str(mem, argv[regex_arg]))) {
|
||||
dm_pool_destroy(mem);
|
||||
fprintf(stderr, "Couldn't parse regex\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (regex_print)
|
||||
_regex_print(rx, 0, show_nodes);
|
||||
else
|
||||
_pretty_print(rx, 0);
|
||||
|
||||
dm_pool_destroy(mem);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
"(((a?)(([Ub]*)|z))((([qr]|X)+)([Qn]*)))+"
|
||||
"[HZejtuw]*"
|
||||
"((B|s)*)|(((([Fv]l)(N+))(([el]|C)(tJ)))?)"
|
||||
"((([Ma]?)|(t*))*)|((([cm]E)|(M?))|(([BE][EV])|([Qj][Mh])))"
|
||||
"(((([bw]*)|([IO]*))((zK)*))|(((pU)|(i|q))|((z?)|([HL]?))))*"
|
||||
"((([Pt]?)|[Tr])?)((Hq)*)"
|
||||
"[HOXcfgikosvwxz]"
|
||||
"[BCEFGHNPTUWfjlprsy]"
|
||||
"((((aD)*)|([Xo]+))+)(([HKn](([Eq]|[JQ])(I*)))*)"
|
||||
"([LNWYeghv]|e)*"
|
||||
"(((y(L*))*)|((([EP]+)(W+))*))*"
|
||||
"U*"
|
||||
"((((R+)(W|[Qr]))|([py]+))+)([LM]*)"
|
||||
"(([DOjx](D(b?)))|([Ke]*))*"
|
||||
"((([ls](c|[FT]))*)([JS]*))*"
|
||||
"((l?)|(([Gz]+)|(D*)))*"
|
||||
"[ABgjn]"
|
||||
"(((q|[dg])?)|([Uk]*))((([Fl]?)|([Ry]+))|(([IR]|c)|(T?)))"
|
||||
"((([an]|P)|[Jw])((a*)|(m*)))*"
|
||||
"((((R[ht])(h+))?)|(([pz](n?))+))+"
|
||||
"(((([Dc]b)([Sp][Ii]))|((k|F)*))|[Uiovz])*"
|
||||
"[Res]*"
|
||||
"[Zl]|a"
|
||||
"^[ANZdf]$"
|
||||
"[En]|(((Q+)(U+))([pt]*))"
|
||||
"[ADEIMQUWXZhklrsvz]"
|
||||
"(((S(y*))*)|(j*))*"
|
||||
"n*"
|
||||
"[NUau]*"
|
||||
"((((Z*)(D|[Nd]))|(([np]|B)+))|(([Xy][Fi])*))+"
|
||||
"((([EZ]?)|(d[HR]))*)((([Hg]|q)(P+))*)"
|
||||
"q"
|
||||
"((m*)|(p|B))|((((x?)|(t+))(([Sb][PX])(O|[HM])))+)"
|
||||
"((((A*)(z[RS]))*)|(((z+)(Q*))+))*"
|
||||
"(((M*)([Uu]*))+)|[Uk]"
|
||||
"[imv]"
|
||||
"[GLSchtw](([Yw]((F[Dd])|([Tw]+)))?)"
|
||||
"([MOZj]*)(S|[Wknr])"
|
||||
"((G|q)*)[BHKN]"
|
||||
"((((NW)|([Ao]?))|((l|[UV])+))+)|((i|(z*))*)"
|
||||
"((((Z+)|([IR]?))|(L*))|([JKQ]+))+"
|
||||
"([Bdin](S*))+"
|
||||
"[HLNSTp]*"
|
||||
"(((J*)([Bq]|[Yu]))*)|([Kv]*)"
|
||||
"(((([BJ]|[Zy])(wI))*)(y*))+"
|
||||
"(((hF)+)|(H*))*"
|
||||
"((([QU][Pj])([GQ]?))+)|[PWo]"
|
||||
"(((([cq][BX])?)|((f[DI])*))*)(([GM]*)[SVYr])"
|
||||
"(([Zt]*)|((qx)|(([BV]+)(f?))))*"
|
||||
"[ILWYhsx]*"
|
||||
"(([Uy]*)|[sv])|([NSc]*)"
|
||||
"((c*)|([JUfhy]?))+"
|
||||
"(((q*)([So]*))(((g[jq])(j?))+))*"
|
||||
"((b+)|(((T+)([fw]T))?))*"
|
||||
"((([DS]?)|([Th]|u))(Q*))*"
|
||||
"[FKLX]|((([fw](L?))(([gq]*)|(O?)))?)"
|
||||
"((([HZ]+)u)*)|[APWijn]"
|
||||
"(e*)|(((v?)|((J+)(Hb)))?)"
|
||||
"(e|((w+)f))*"
|
||||
"[BEHKPQVdelnqy]"
|
||||
"((((B|N)(s*))|[Rr])(((g?)|([rv]+))+))+"
|
||||
"(((s*)|(K*))([AP]G))*"
|
||||
"[CELTp]"
|
||||
"(([Fq]?)|([Al]+))*"
|
||||
"((((r?)|(y[jx]))|([mp]*))+)|((B(S*))*)"
|
||||
"((([Eq]+)|(Y[ds]))|(x|(i|[Ku])))[IJNrvy]"
|
||||
"((([NO]*)[Ix])+)([Jenq]+)"
|
||||
"(((([HP]*)(j|y))*)[Ylqvy])*"
|
||||
"[PTv]+"
|
||||
"[AINSZhpx]|([EOYZ]*)"
|
||||
"([ABCFQv]*)((([Zx]|h)+)|([ej]*))"
|
||||
"((([pr]*)|(([Dq]|p)|(H?)))?)([NRUXmoq]*)"
|
||||
"(([er]*)|([mx]*))(((nV)([am]?))+)"
|
||||
"[BHPRlpu]"
|
||||
"(((([Ah]|[tx])|(e|[uy]))?)((([fl]+)([Vz]|v))*))*"
|
||||
"[AGdm]"
|
||||
"(((K*)^(O*)$)|(B?))*"
|
||||
"((([Ks]|[Ka])*)|([FSTab]?))?"
|
||||
"(([kw]+)[ei])(([Hy]*)(([Mc]*)|(G|f)))"
|
||||
"((((e*)|(Zf))|(R|[nq]))((([Jz]v)([Rj]+))+))*"
|
||||
"(((a?)|(e?))(([Uc]*)(S+)))*"
|
||||
"((((E+)([MZ]?))+)|(((s|[Az])|z)*))?"
|
||||
"((((i[MO])*)|((LH)*))|(((BA)|([AI]+))|[Ug]))*"
|
||||
"[EGHILcho]*"
|
||||
"(((Z[vw])?)((z|g)+))(((H|U)([iv]Q))|([qw]?))"
|
||||
"(([ehmr]|((L[Uw])*))+)((a+)I)"
|
||||
"[EKNSWYagj](((v|[TX])|([Uk]+))*)"
|
||||
"(((R[Mo])|(O*))|([Fm]|([qw]*)))((m*)|((S|[Ki])?))"
|
||||
"((((kP)|c)?)((([do]+)|([Gi]?))*))*"
|
||||
"((^(B|W)$|([Ww]+))([no]*))|((([iv]?)|(M*))|((x|L)?))"
|
||||
"[AEGPRSbcfhsy]"
|
||||
"[Wbcf]|((([MO]?)|([NT]|m))(([Oo]?)([Wg]*)))"
|
||||
"(((YZ)*)[PQVei])*"
|
||||
"[GJKYt][AEGWdegmnt]"
|
||||
"^[CDEGJKNUVYZagkv]$"
|
||||
"([DPWbx]*)|(((q|B)|(P|u))((M[Bq])*))"
|
||||
"[FHIJRTVYZdiorsuvz]*"
|
||||
"([MWoqvz]*)|^(l*)"
|
||||
"(((I|[Rx])*)((X[Mf])([Xa]L)))([Ha]|([HY]*))"
|
||||
"(((l|[Sd])*)((([Ix]+)|([XY]?))(Z*)))+"
|
Loading…
Reference in New Issue
Block a user