mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-27 01:57:55 +03:00
o checked in the new driver, and the uml dir
This commit is contained in:
parent
b653404542
commit
a9e44426ed
707
driver/device-mapper/device-mapper.c
Normal file
707
driver/device-mapper/device-mapper.c
Normal file
@ -0,0 +1,707 @@
|
||||
/*
|
||||
* device-mapper.c
|
||||
*
|
||||
* Copyright (C) 2001 Sistina Software
|
||||
*
|
||||
* This software is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU CC; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changelog
|
||||
*
|
||||
* 14/08/2001 - First Version [Joe Thornber]
|
||||
*/
|
||||
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* dm_ctr_fn should provide the sector sizes, and hardsector_sizes set
|
||||
* to the smallest of these.
|
||||
*/
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/major.h>
|
||||
#include <linux/iobuf.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/compatmac.h>
|
||||
#include <linux/cache.h>
|
||||
#include <linux/device-mapper.h>
|
||||
|
||||
/*
|
||||
* defines for blk.h
|
||||
*/
|
||||
#define MAJOR_NR DM_BLK_MAJOR
|
||||
#define DEVICE_OFF(device)
|
||||
#define LOCAL_END_REQUEST
|
||||
#define MAX_DEPTH 16
|
||||
#define NODE_SIZE L1_CACHE_BYTES
|
||||
#define KEYS_PER_NODE (NODE_SIZE / sizeof(offset_t))
|
||||
|
||||
|
||||
#include <linux/blk.h>
|
||||
|
||||
/*
|
||||
* FIXME: write description
|
||||
*/
|
||||
|
||||
#define MAX_DEVICES 64
|
||||
#define DEFAULT_READ_AHEAD 64
|
||||
|
||||
#define WARN(f, x...) printk(KERN_WARNING "%s " f, _name , ## x)
|
||||
|
||||
const char *_name = "device-mapper";
|
||||
int _version[3] = {1, 0, 0};
|
||||
|
||||
|
||||
struct mapper {
|
||||
char *name;
|
||||
dm_ctr_fn ctr;
|
||||
dm_dtr_fn dtr;
|
||||
dm_map_fn map;
|
||||
|
||||
struct mapper *next;
|
||||
};
|
||||
|
||||
struct mapped_device {
|
||||
int in_use;
|
||||
spinlock_t lock;
|
||||
kdev_t dev;
|
||||
|
||||
atomic_t pending;
|
||||
int depth;
|
||||
int counts[MAX_DEPTH]; /* in nodes */
|
||||
offset_t *index[MAX_DEPTH];
|
||||
|
||||
int num_targets;
|
||||
dm_map_fn *targets;
|
||||
void **contexts;
|
||||
};
|
||||
|
||||
|
||||
static int _dev_count = 0;
|
||||
static struct mapped_device _devices[MAX_DEVICES];
|
||||
|
||||
static spinlock_t _mappers_lock = SPIN_LOCK_UNLOCKED;
|
||||
static struct mapper *_mappers;
|
||||
|
||||
/* block device arrays */
|
||||
static int _block_size[MAX_DEVICES];
|
||||
static int _blksize_size[MAX_DEVICES];
|
||||
static int _hardsect_size[MAX_DEVICES];
|
||||
|
||||
static int _ctl_open(struct inode *inode, struct file *file);
|
||||
static int _ctl_close(struct inode *inode, struct file *file);
|
||||
static int _ctl_ioctl(struct inode *inode, struct file *file,
|
||||
uint command, ulong a);
|
||||
|
||||
static struct file_operations _ctl_fops = {
|
||||
open: _ctl_open,
|
||||
release: _ctl_close,
|
||||
ioctl: _ctl_ioctl,
|
||||
};
|
||||
|
||||
static int _blk_open(struct inode *inode, struct file *file);
|
||||
static int _blk_close(struct inode *inode, struct file *file);
|
||||
static int _blk_ioctl(struct inode *inode, struct file *file,
|
||||
uint command, ulong a);
|
||||
|
||||
static struct block_device_operations _blk_dops = {
|
||||
open: _blk_open,
|
||||
release: _blk_close,
|
||||
ioctl: _blk_ioctl
|
||||
};
|
||||
|
||||
static void _init_mds(void);
|
||||
static struct mapped_device *_build_map(struct device_table *t);
|
||||
static int _request_fn(request_queue_t *q, int rw, struct buffer_head *bh);
|
||||
static int _register_std_targets(void);
|
||||
static struct mapped_device *_get_free_md(void);
|
||||
static void _put_free_md(struct mapped_device *md);
|
||||
static int _setup_targets(struct mapped_device *md, struct device_table *t);
|
||||
static int _setup_btree(struct mapped_device *md, struct device_table *t);
|
||||
static int _setup_btree_index(int l, struct mapped_device *md);
|
||||
struct mapper *_find_mapper(const char *name);
|
||||
|
||||
/*
|
||||
* setup and teardown the driver
|
||||
*/
|
||||
static int _init(void)
|
||||
{
|
||||
_init_mds();
|
||||
|
||||
if (!_register_std_targets())
|
||||
return -EIO; /* FIXME: better error value */
|
||||
|
||||
/* set up the arrays */
|
||||
read_ahead[MAJOR_NR] = DEFAULT_READ_AHEAD;
|
||||
blk_size[MAJOR_NR] = _block_size;
|
||||
blksize_size[MAJOR_NR] = _blksize_size;
|
||||
hardsect_size[MAJOR_NR] = _hardsect_size;
|
||||
|
||||
if (register_chrdev(DM_CTL_MAJOR, _name, &_ctl_fops) < 0) {
|
||||
printk(KERN_ERR "%s - register_chrdev failed\n", _name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (register_blkdev(MAJOR_NR, _name, &_blk_dops) < 0) {
|
||||
printk(KERN_ERR "%s -- register_blkdev failed\n", _name);
|
||||
if (unregister_chrdev(DM_CTL_MAJOR, _name) < 0)
|
||||
printk(KERN_ERR "%s - unregister_chrdev failed\n",
|
||||
_name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), _request_fn);
|
||||
|
||||
printk(KERN_INFO "%s(%d, %d, %d) successfully initialised\n", _name,
|
||||
_version[0], _version[1], _version[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _fin(void)
|
||||
{
|
||||
if (unregister_chrdev(DM_CTL_MAJOR, _name) < 0)
|
||||
printk(KERN_ERR "%s - unregister_chrdev failed\n", _name);
|
||||
|
||||
if (unregister_blkdev(MAJOR_NR, _name) < 0)
|
||||
printk(KERN_ERR "%s -- unregister_blkdev failed\n", _name);
|
||||
|
||||
read_ahead[MAJOR_NR] = 0;
|
||||
blk_size[MAJOR_NR] = 0;
|
||||
blksize_size[MAJOR_NR] = 0;
|
||||
hardsect_size[MAJOR_NR] = 0;
|
||||
|
||||
printk(KERN_INFO "%s(%d, %d, %d) successfully finalised\n", _name,
|
||||
_version[0], _version[1], _version[2]);
|
||||
}
|
||||
|
||||
/*
|
||||
* character device fns
|
||||
*/
|
||||
static int _ctl_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EACCES;
|
||||
|
||||
MOD_INC_USE_COUNT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _ctl_close(struct inode *inode, struct file *file)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _ctl_ioctl(struct inode *inode, struct file *file,
|
||||
uint command, ulong a)
|
||||
{
|
||||
struct device_table info;
|
||||
|
||||
if (copy_from_user(&info, (void *) a, sizeof(info)))
|
||||
return -EFAULT;
|
||||
|
||||
switch (command) {
|
||||
case MAPPED_DEVICE_CREATE:
|
||||
/* FIXME: copy arrays */
|
||||
_build_map(&info);
|
||||
break;
|
||||
|
||||
case MAPPED_DEVICE_DESTROY:
|
||||
/* FIXME: finish */
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
printk(KERN_WARNING "%s -- _ctl_ioctl: unknown command 0x%x\n",
|
||||
_name, command);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* block device functions
|
||||
*/
|
||||
static int _blk_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int minor = MINOR(inode->i_rdev);
|
||||
struct mapped_device *md = _devices + minor;
|
||||
|
||||
if (minor >= MAX_DEVICES)
|
||||
return -ENXIO;
|
||||
|
||||
spin_lock(&md->lock);
|
||||
|
||||
if (!md->in_use) {
|
||||
spin_unlock(&md->lock);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
md->in_use++;
|
||||
spin_unlock(&md->lock);
|
||||
|
||||
MOD_INC_USE_COUNT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _blk_close(struct inode *inode, struct file *file)
|
||||
{
|
||||
int minor = MINOR(inode->i_rdev);
|
||||
struct mapped_device *md = _devices + minor;
|
||||
|
||||
if (minor >= MAX_DEVICES)
|
||||
return -ENXIO;
|
||||
|
||||
spin_lock(&md->lock);
|
||||
|
||||
if (md->in_use <= 1) {
|
||||
WARN("reference count in mapped_device incorrect\n");
|
||||
spin_unlock(&md->lock);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
md->in_use--;
|
||||
spin_unlock(&md->lock);
|
||||
|
||||
MOD_INC_USE_COUNT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _blk_ioctl(struct inode *inode, struct file *file,
|
||||
uint command, ulong a)
|
||||
{
|
||||
/* FIXME: check in the latest Rubini that all expected ioctl's
|
||||
are supported */
|
||||
|
||||
int minor = MINOR(inode->i_rdev);
|
||||
long size;
|
||||
|
||||
switch (command) {
|
||||
case BLKGETSIZE:
|
||||
size = _block_size[minor] * 1024 / _hardsect_size[minor];
|
||||
if (copy_to_user((void *) a, &size, sizeof(long)))
|
||||
return -EFAULT;
|
||||
break;
|
||||
|
||||
case BLKFLSBUF:
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EACCES;
|
||||
fsync_dev(inode->i_rdev);
|
||||
invalidate_buffers(inode->i_rdev);
|
||||
return 0;
|
||||
|
||||
case BLKRAGET:
|
||||
if (copy_to_user((void *) a, &read_ahead[MAJOR(inode->i_rdev)],
|
||||
sizeof(long)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
|
||||
case BLKRASET:
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EACCES;
|
||||
read_ahead[MAJOR(inode->i_rdev)] = a;
|
||||
return 0;
|
||||
|
||||
case BLKRRPART:
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
printk(KERN_WARNING "%s - unknown block ioctl %d\n",
|
||||
_name, command);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _request_fn(request_queue_t *q, int rw, struct buffer_head *bh)
|
||||
{
|
||||
struct mapped_device *md;
|
||||
offset_t *node;
|
||||
int i = 0, l, next_node = 0, ret = 0;
|
||||
int minor = MINOR(bh->b_dev);
|
||||
dm_map_fn fn;
|
||||
void *context;
|
||||
|
||||
if (minor >= MAX_DEVICES)
|
||||
return -ENXIO;
|
||||
|
||||
md = _devices + minor;
|
||||
if (MINOR(md->dev != minor))
|
||||
return -ENXIO;
|
||||
|
||||
for (l = 0; l < md->depth; l++) {
|
||||
next_node = ((KEYS_PER_NODE + 1) * next_node) + i;
|
||||
node = md->index[l] + (next_node * KEYS_PER_NODE);
|
||||
|
||||
for (i = 0; i < KEYS_PER_NODE; i++)
|
||||
if (node[i] >= bh->b_rsector)
|
||||
break;
|
||||
}
|
||||
|
||||
next_node = (KEYS_PER_NODE * next_node) + i;
|
||||
fn = md->targets[next_node];
|
||||
context = md->contexts[next_node];
|
||||
|
||||
if (fn) {
|
||||
if ((ret = fn(bh, context)))
|
||||
atomic_inc(&md->pending);
|
||||
} else
|
||||
buffer_IO_error(bh);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static struct mapped_device *_build_map(struct device_table *t)
|
||||
{
|
||||
struct mapped_device *md = _get_free_md();
|
||||
|
||||
if (!md)
|
||||
return 0;
|
||||
|
||||
if (!_setup_targets(md, t))
|
||||
goto bad;
|
||||
|
||||
if (!_setup_btree(md, t))
|
||||
goto bad;
|
||||
|
||||
return md;
|
||||
|
||||
bad:
|
||||
_put_free_md(md);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void *__aligned(size_t s, unsigned int align)
|
||||
{
|
||||
return vmalloc(s);
|
||||
}
|
||||
|
||||
static inline void __free_aligned(void *ptr)
|
||||
{
|
||||
vfree(ptr);
|
||||
}
|
||||
|
||||
static int _setup_targets(struct mapped_device *md, struct device_table *t)
|
||||
{
|
||||
int i;
|
||||
offset_t low = 0;
|
||||
|
||||
md->num_targets = t->count;
|
||||
md->targets = __aligned(sizeof(*md->targets) * md->num_targets,
|
||||
NODE_SIZE);
|
||||
|
||||
for (i = 0; i < md->num_targets; i++) {
|
||||
struct mapper *m = _find_mapper(t->map[i].type);
|
||||
if (!m)
|
||||
return 0;
|
||||
|
||||
if (!m->ctr(low, t->map[i].high + 1,
|
||||
t->map[i].context, md->contexts + i)) {
|
||||
WARN("contructor for '%s' failed\n", m->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
md->targets[i] = m->map;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline ulong _round_up(ulong n, ulong size)
|
||||
{
|
||||
ulong r = n % size;
|
||||
return ((n / size) + (r ? 1 : 0)) * size;
|
||||
}
|
||||
|
||||
static inline ulong _div_up(ulong n, ulong size)
|
||||
{
|
||||
return _round_up(n, size) / size;
|
||||
}
|
||||
|
||||
static int _setup_btree(struct mapped_device *md, struct device_table *t)
|
||||
{
|
||||
int n, i;
|
||||
offset_t *k;
|
||||
|
||||
/* how many indexes will the btree have ? */
|
||||
for (n = _div_up(md->num_targets, KEYS_PER_NODE), i = 1; n != 1; i++)
|
||||
n = _div_up(n, KEYS_PER_NODE + 1);
|
||||
|
||||
md->depth = i;
|
||||
md->counts[md->depth - 1] = _div_up(md->num_targets, KEYS_PER_NODE);
|
||||
|
||||
while (--i)
|
||||
md->counts[i - 1] = _div_up(md->counts[i], KEYS_PER_NODE + 1);
|
||||
|
||||
for (i = 0; i < md->depth; i++) {
|
||||
size_t s = NODE_SIZE * md->counts[i];
|
||||
md->index[i] = __aligned(s, NODE_SIZE);
|
||||
memset(md->index[i], -1, s);
|
||||
}
|
||||
|
||||
/* bottom layer is easy */
|
||||
for (k = md->index[md->depth - 1], i = 0; i < md->num_targets; i++)
|
||||
k[i] = t->map[i].high;
|
||||
|
||||
/* fill in higher levels */
|
||||
for (i = md->depth - 1; i; i--)
|
||||
_setup_btree_index(i - 1, md);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static offset_t __high(struct mapped_device *md, int l, int n)
|
||||
{
|
||||
while (1) {
|
||||
if (n >= md->counts[l])
|
||||
return (offset_t) -1;
|
||||
|
||||
if (l == md->depth - 1)
|
||||
return md->index[l][((n + 1) * KEYS_PER_NODE) - 1];
|
||||
|
||||
l++;
|
||||
n = (n + 1) * (KEYS_PER_NODE + 1) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int _setup_btree_index(int l, struct mapped_device *md)
|
||||
{
|
||||
int n, c, cn;
|
||||
|
||||
for (n = 0, cn = 0; n < md->counts[l]; n++) {
|
||||
offset_t *k = md->index[l] + (n * KEYS_PER_NODE);
|
||||
|
||||
for (c = 0; c < KEYS_PER_NODE; c++)
|
||||
k[c] = __high(md, l + 1, cn++);
|
||||
cn++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _init_mds(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
_dev_count = 0;
|
||||
memset(_devices, 0, sizeof(_devices));
|
||||
for (i = 0; i < MAX_DEVICES; i++) {
|
||||
_devices[i].lock = SPIN_LOCK_UNLOCKED;
|
||||
_devices[i].dev = MKDEV(MAJOR_NR, i);
|
||||
}
|
||||
}
|
||||
|
||||
static struct mapped_device *_get_free_md(void)
|
||||
{
|
||||
int i;
|
||||
struct mapped_device *m;
|
||||
|
||||
for (i = 0; i < MAX_DEVICES; i++) {
|
||||
m = _devices + i;
|
||||
|
||||
spin_lock(&m->lock);
|
||||
if (!m->in_use) {
|
||||
m->in_use = 1;
|
||||
spin_unlock(m);
|
||||
return m;
|
||||
}
|
||||
spin_unlock(&m->lock);
|
||||
}
|
||||
|
||||
WARN("no free devices available\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _put_free_md(struct mapped_device *md)
|
||||
{
|
||||
int i;
|
||||
|
||||
spin_lock(&md->lock);
|
||||
|
||||
for (i = 0; i < md->depth; i++)
|
||||
__free_aligned(md->index[i]);
|
||||
|
||||
__free_aligned(md->targets);
|
||||
__free_aligned(md->contexts);
|
||||
|
||||
/* FIXME: check this is the correct length */
|
||||
memset(&md->depth, 0,
|
||||
sizeof(*md) - ((void *) &md->depth - (void *) md));
|
||||
md->in_use = 0;
|
||||
spin_unlock(&md->lock);
|
||||
}
|
||||
|
||||
int register_mapping_type(const char *name, dm_ctr_fn ctr,
|
||||
dm_dtr_fn dtr, dm_map_fn map)
|
||||
{
|
||||
struct mapper *m;
|
||||
|
||||
if (_find_mapper(name)) {
|
||||
WARN("mapper(%s) already registered\n", name);
|
||||
return -1; /* FIXME: what's a good return value ? */
|
||||
}
|
||||
|
||||
/* FIXME: There's a race between the last check and insertion */
|
||||
|
||||
if ((m = kmalloc(sizeof(*m) + strlen(name) + 1, GFP_KERNEL))) {
|
||||
WARN("couldn't allocate memory for mapper\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
m->name = (char *) (m + 1);
|
||||
m->ctr = ctr;
|
||||
m->dtr = dtr;
|
||||
m->map = map;
|
||||
|
||||
spin_lock(&_mappers_lock);
|
||||
m->next = _mappers;
|
||||
_mappers = m;
|
||||
spin_unlock(&_mappers_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mapper *_find_mapper(const char *name)
|
||||
{
|
||||
struct mapper *m;
|
||||
|
||||
spin_lock(&_mappers_lock);
|
||||
for (m = _mappers; m && strcmp(m->name, name); m = m->next)
|
||||
;
|
||||
spin_unlock(&_mappers_lock);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* now for a couple of simple targets:
|
||||
*
|
||||
* 'io-err' target always fails an io, useful for bringing up LV's
|
||||
* that have holes in them.
|
||||
*
|
||||
* 'linear' target maps a linear range of a device
|
||||
*/
|
||||
int _io_err_ctr(offset_t b, offset_t e, const char *context, void **result)
|
||||
{
|
||||
/* this takes no arguments */
|
||||
*result = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _io_err_dtr(void *c)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
|
||||
int _io_err_map(struct buffer_head *bh, void *context)
|
||||
{
|
||||
buffer_IO_error(bh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct linear_c {
|
||||
kdev_t dev;
|
||||
int offset; /* FIXME: we need a signed offset type */
|
||||
};
|
||||
|
||||
int _linear_ctr(offset_t b, offset_t e, const char *context, void **result)
|
||||
{
|
||||
/* context string should be of the form:
|
||||
* <major> <minor> <offset>
|
||||
*/
|
||||
char *ptr = (char *) context;
|
||||
struct linear_c *lc;
|
||||
int major, minor, start;
|
||||
|
||||
/* FIXME: somewhat verbose */
|
||||
major = simple_strtol(context, &ptr, 10);
|
||||
if (ptr == context)
|
||||
return 0;
|
||||
|
||||
context = ptr;
|
||||
minor = simple_strtol(context, &ptr, 10);
|
||||
if (ptr == context)
|
||||
return 0;
|
||||
|
||||
context = ptr;
|
||||
start = simple_strtoul(context, &ptr, 10);
|
||||
if (ptr == context)
|
||||
return 0;
|
||||
|
||||
if (!(lc = kmalloc(sizeof(lc), GFP_KERNEL))) {
|
||||
WARN("couldn't allocate memory for linear context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
lc->dev = MKDEV(major, minor);
|
||||
lc->offset = start - b;
|
||||
|
||||
/* FIXME: we should open the PV */
|
||||
|
||||
*result = lc;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _linear_dtr(void *c)
|
||||
{
|
||||
kfree(c);
|
||||
}
|
||||
|
||||
int _linear_map(struct buffer_head *bh, void *context)
|
||||
{
|
||||
struct linear_c *lc = (struct linear_c *) context;
|
||||
|
||||
bh->b_rdev = lc->dev;
|
||||
bh->b_rsector = bh->b_rsector + lc->offset;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _register_std_targets(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#define xx(n, fn) \
|
||||
if ((ret = register_mapping_type(n, \
|
||||
fn ## _ctr, fn ## _dtr, fn ## _map) < 0)) return ret
|
||||
|
||||
xx("io-err", _io_err);
|
||||
xx("linear", _linear);
|
||||
#undef xx
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* module hooks
|
||||
*/
|
||||
module_init(_init);
|
||||
module_exit(_fin);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
72
driver/device-mapper/device-mapper.h
Normal file
72
driver/device-mapper/device-mapper.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* device-mapper.h
|
||||
*
|
||||
* Copyright (C) 2001 Sistina Software
|
||||
*
|
||||
* This software is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU CC; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changelog
|
||||
*
|
||||
* 14/08/2001 - First version [Joe Thornber]
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_MAPPER_H
|
||||
#define DEVICE_MAPPER_H
|
||||
|
||||
#include <linux/major.h>
|
||||
|
||||
/* FIXME: steal LVM's devices for now */
|
||||
#define DM_BLK_MAJOR LVM_BLK_MAJOR
|
||||
#define DM_CTL_MAJOR LVM_CHAR_MAJOR
|
||||
|
||||
typedef unsigned int offset_t;
|
||||
|
||||
struct device_map {
|
||||
offset_t high;
|
||||
const char *type;
|
||||
const char *context;
|
||||
};
|
||||
|
||||
struct device_table {
|
||||
unsigned int minor;
|
||||
unsigned int major;
|
||||
|
||||
unsigned long count;
|
||||
struct device_map *map;
|
||||
};
|
||||
|
||||
#define MAPPED_DEVICE_CREATE _IOWR(DM_CTL_MAJOR, 0, struct device_table)
|
||||
#define MAPPED_DEVICE_DESTROY _IOW(DM_CTL_MAJOR, 1, struct device_table)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
typedef int (*dm_ctr_fn)(offset_t b, offset_t e,
|
||||
const char *context, void **result);
|
||||
typedef void (*dm_dtr_fn)(void *c);
|
||||
typedef int (*dm_map_fn)(struct buffer_head *bh, void *context);
|
||||
|
||||
int register_mapping_type(const char *name, dm_ctr_fn ctr, dm_dtr_fn dtr,
|
||||
dm_map_fn map);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
30
driver/user_mode_linux/README
Normal file
30
driver/user_mode_linux/README
Normal file
@ -0,0 +1,30 @@
|
||||
FILES
|
||||
-----
|
||||
|
||||
setup-uml - script to build a user mode linux system, with the lvm driver
|
||||
symbolically linked back to the LVM dir so I can work from CVS.
|
||||
|
||||
uml-lvm.patch - patch to enable lvm in the uml configuration
|
||||
|
||||
uml.patch.bz2 - uml patch from
|
||||
http://sourceforge.net/project/showfiles.php?group_id=429
|
||||
|
||||
config-uml - .config which turns on LVM
|
||||
|
||||
|
||||
RUNNING
|
||||
-------
|
||||
|
||||
o checkout an LVM dir for use with uml
|
||||
make sure you've got a copy of a root filesystem kicking about
|
||||
|
||||
o edit the variables at the top of 'setup'
|
||||
|
||||
o run setup-uml
|
||||
|
||||
o move to your uml dir and run lvm-install as root
|
||||
|
||||
o then run the 'up' script to run uml
|
||||
|
||||
o if you want to rebuild uml after changing the LVM driver just change into
|
||||
the linux directory and do a 'make linux ARCH=um'. Don't forget the ARCH=um.
|
282
driver/user_mode_linux/config-uml
Normal file
282
driver/user_mode_linux/config-uml
Normal file
@ -0,0 +1,282 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
#
|
||||
CONFIG_USERMODE=y
|
||||
# CONFIG_ISA is not set
|
||||
# CONFIG_SBUS is not set
|
||||
# CONFIG_PCI is not set
|
||||
CONFIG_UID16=y
|
||||
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
|
||||
|
||||
#
|
||||
# Code maturity level options
|
||||
#
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
|
||||
#
|
||||
# Multi-device support (RAID and LVM)
|
||||
#
|
||||
CONFIG_MD=y
|
||||
# CONFIG_BLK_DEV_MD is not set
|
||||
# CONFIG_MD_LINEAR is not set
|
||||
# CONFIG_MD_RAID0 is not set
|
||||
# CONFIG_MD_RAID1 is not set
|
||||
# CONFIG_MD_RAID5 is not set
|
||||
CONFIG_BLK_DEV_LVM=y
|
||||
|
||||
#
|
||||
# General Setup
|
||||
#
|
||||
CONFIG_STDIO_CONSOLE=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_SYSVIPC=y
|
||||
CONFIG_BSD_PROCESS_ACCT=y
|
||||
CONFIG_SYSCTL=y
|
||||
CONFIG_BINFMT_AOUT=y
|
||||
CONFIG_BINFMT_ELF=y
|
||||
CONFIG_BINFMT_MISC=y
|
||||
CONFIG_UNIX98_PTYS=y
|
||||
CONFIG_UNIX98_PTY_COUNT=256
|
||||
CONFIG_SSL=y
|
||||
CONFIG_HOSTFS=m
|
||||
CONFIG_MCONSOLE=y
|
||||
# CONFIG_MAGIC_SYSRQ is not set
|
||||
|
||||
#
|
||||
# Loadable module support
|
||||
#
|
||||
CONFIG_MODULES=y
|
||||
# CONFIG_KMOD is not set
|
||||
|
||||
#
|
||||
# Devices
|
||||
#
|
||||
CONFIG_BLK_DEV_UBD=y
|
||||
# CONFIG_BLK_DEV_UBD_SYNC is not set
|
||||
CONFIG_BLK_DEV_LOOP=y
|
||||
CONFIG_BLK_DEV_NBD=y
|
||||
CONFIG_BLK_DEV_RAM=y
|
||||
CONFIG_BLK_DEV_RAM_SIZE=4096
|
||||
CONFIG_BLK_DEV_INITRD=y
|
||||
# CONFIG_MMAPPER is not set
|
||||
|
||||
#
|
||||
# Networking options
|
||||
#
|
||||
# CONFIG_PACKET is not set
|
||||
# CONFIG_NETLINK is not set
|
||||
# CONFIG_NETFILTER is not set
|
||||
# CONFIG_FILTER is not set
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
# CONFIG_IP_MULTICAST is not set
|
||||
# CONFIG_IP_ADVANCED_ROUTER is not set
|
||||
# CONFIG_IP_PNP is not set
|
||||
# CONFIG_NET_IPIP is not set
|
||||
# CONFIG_NET_IPGRE is not set
|
||||
# CONFIG_INET_ECN is not set
|
||||
# CONFIG_SYN_COOKIES is not set
|
||||
# CONFIG_IPV6 is not set
|
||||
# CONFIG_KHTTPD is not set
|
||||
# CONFIG_ATM is not set
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# CONFIG_IPX is not set
|
||||
# CONFIG_ATALK is not set
|
||||
# CONFIG_DECNET is not set
|
||||
# CONFIG_BRIDGE is not set
|
||||
# CONFIG_X25 is not set
|
||||
# CONFIG_LAPB is not set
|
||||
# CONFIG_LLC is not set
|
||||
# CONFIG_NET_DIVERT is not set
|
||||
# CONFIG_ECONET is not set
|
||||
# CONFIG_WAN_ROUTER is not set
|
||||
# CONFIG_NET_FASTROUTE is not set
|
||||
# CONFIG_NET_HW_FLOWCONTROL is not set
|
||||
|
||||
#
|
||||
# QoS and/or fair queueing
|
||||
#
|
||||
# CONFIG_NET_SCHED is not set
|
||||
|
||||
#
|
||||
# Network drivers
|
||||
#
|
||||
|
||||
#
|
||||
# ARCnet devices
|
||||
#
|
||||
# CONFIG_ARCNET is not set
|
||||
# CONFIG_DUMMY is not set
|
||||
# CONFIG_BONDING is not set
|
||||
# CONFIG_EQUALIZER is not set
|
||||
# CONFIG_TUN is not set
|
||||
|
||||
#
|
||||
# Ethernet (10 or 100Mbit)
|
||||
#
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
|
||||
#
|
||||
# Ethernet (1000 Mbit)
|
||||
#
|
||||
# CONFIG_ACENIC is not set
|
||||
# CONFIG_ACENIC_OMIT_TIGON_I is not set
|
||||
# CONFIG_DL2K is not set
|
||||
# CONFIG_MYRI_SBUS is not set
|
||||
# CONFIG_HAMACHI is not set
|
||||
# CONFIG_YELLOWFIN is not set
|
||||
# CONFIG_SK98LIN is not set
|
||||
# CONFIG_FDDI is not set
|
||||
# CONFIG_HIPPI is not set
|
||||
# CONFIG_PLIP is not set
|
||||
# CONFIG_PPP is not set
|
||||
# CONFIG_SLIP is not set
|
||||
|
||||
#
|
||||
# Wireless LAN (non-hamradio)
|
||||
#
|
||||
# CONFIG_NET_RADIO is not set
|
||||
|
||||
#
|
||||
# Token Ring devices
|
||||
#
|
||||
# CONFIG_TR is not set
|
||||
# CONFIG_NET_FC is not set
|
||||
# CONFIG_RCPCI is not set
|
||||
# CONFIG_SHAPER is not set
|
||||
|
||||
#
|
||||
# Wan interfaces
|
||||
#
|
||||
# CONFIG_WAN is not set
|
||||
|
||||
#
|
||||
# Network device support
|
||||
#
|
||||
# CONFIG_NETDEVICES is not set
|
||||
|
||||
#
|
||||
# File systems
|
||||
#
|
||||
CONFIG_QUOTA=y
|
||||
CONFIG_AUTOFS_FS=m
|
||||
CONFIG_AUTOFS4_FS=m
|
||||
CONFIG_REISERFS_FS=m
|
||||
# CONFIG_REISERFS_CHECK is not set
|
||||
# CONFIG_ADFS_FS is not set
|
||||
# CONFIG_ADFS_FS_RW is not set
|
||||
# CONFIG_AFFS_FS is not set
|
||||
# CONFIG_HFS_FS is not set
|
||||
# CONFIG_BFS_FS is not set
|
||||
CONFIG_FAT_FS=m
|
||||
CONFIG_MSDOS_FS=m
|
||||
CONFIG_UMSDOS_FS=m
|
||||
CONFIG_VFAT_FS=m
|
||||
# CONFIG_EFS_FS is not set
|
||||
# CONFIG_JFFS_FS is not set
|
||||
# CONFIG_CRAMFS is not set
|
||||
# CONFIG_TMPFS is not set
|
||||
# CONFIG_RAMFS is not set
|
||||
CONFIG_ISO9660_FS=m
|
||||
# CONFIG_JOLIET is not set
|
||||
CONFIG_MINIX_FS=m
|
||||
# CONFIG_VXFS_FS is not set
|
||||
# CONFIG_NTFS_FS is not set
|
||||
# CONFIG_NTFS_RW is not set
|
||||
# CONFIG_HPFS_FS is not set
|
||||
CONFIG_PROC_FS=y
|
||||
CONFIG_DEVFS_FS=y
|
||||
CONFIG_DEVFS_MOUNT=y
|
||||
# CONFIG_DEVFS_DEBUG is not set
|
||||
CONFIG_DEVPTS_FS=y
|
||||
# CONFIG_QNX4FS_FS is not set
|
||||
# CONFIG_QNX4FS_RW is not set
|
||||
# CONFIG_ROMFS_FS is not set
|
||||
CONFIG_EXT2_FS=y
|
||||
# CONFIG_SYSV_FS is not set
|
||||
# CONFIG_UDF_FS is not set
|
||||
# CONFIG_UDF_RW is not set
|
||||
# CONFIG_UFS_FS is not set
|
||||
# CONFIG_UFS_FS_WRITE is not set
|
||||
|
||||
#
|
||||
# Network File Systems
|
||||
#
|
||||
# CONFIG_CODA_FS is not set
|
||||
# CONFIG_NFS_FS is not set
|
||||
# CONFIG_NFS_V3 is not set
|
||||
# CONFIG_ROOT_NFS is not set
|
||||
# CONFIG_NFSD is not set
|
||||
# CONFIG_NFSD_V3 is not set
|
||||
# CONFIG_SUNRPC is not set
|
||||
# CONFIG_LOCKD is not set
|
||||
# CONFIG_SMB_FS is not set
|
||||
# CONFIG_NCP_FS is not set
|
||||
# CONFIG_NCPFS_PACKET_SIGNING is not set
|
||||
# CONFIG_NCPFS_IOCTL_LOCKING is not set
|
||||
# CONFIG_NCPFS_STRONG is not set
|
||||
# CONFIG_NCPFS_NFS_NS is not set
|
||||
# CONFIG_NCPFS_OS2_NS is not set
|
||||
# CONFIG_NCPFS_SMALLDOS is not set
|
||||
# CONFIG_NCPFS_NLS is not set
|
||||
# CONFIG_NCPFS_EXTRAS is not set
|
||||
|
||||
#
|
||||
# Partition Types
|
||||
#
|
||||
# CONFIG_PARTITION_ADVANCED is not set
|
||||
CONFIG_MSDOS_PARTITION=y
|
||||
# CONFIG_SMB_NLS is not set
|
||||
CONFIG_NLS=y
|
||||
|
||||
#
|
||||
# Native Language Support
|
||||
#
|
||||
CONFIG_NLS_DEFAULT="iso8859-1"
|
||||
# CONFIG_NLS_CODEPAGE_437 is not set
|
||||
# CONFIG_NLS_CODEPAGE_737 is not set
|
||||
# CONFIG_NLS_CODEPAGE_775 is not set
|
||||
# CONFIG_NLS_CODEPAGE_850 is not set
|
||||
# CONFIG_NLS_CODEPAGE_852 is not set
|
||||
# CONFIG_NLS_CODEPAGE_855 is not set
|
||||
# CONFIG_NLS_CODEPAGE_857 is not set
|
||||
# CONFIG_NLS_CODEPAGE_860 is not set
|
||||
# CONFIG_NLS_CODEPAGE_861 is not set
|
||||
# CONFIG_NLS_CODEPAGE_862 is not set
|
||||
# CONFIG_NLS_CODEPAGE_863 is not set
|
||||
# CONFIG_NLS_CODEPAGE_864 is not set
|
||||
# CONFIG_NLS_CODEPAGE_865 is not set
|
||||
# CONFIG_NLS_CODEPAGE_866 is not set
|
||||
# CONFIG_NLS_CODEPAGE_869 is not set
|
||||
# CONFIG_NLS_CODEPAGE_936 is not set
|
||||
# CONFIG_NLS_CODEPAGE_950 is not set
|
||||
# CONFIG_NLS_CODEPAGE_932 is not set
|
||||
# CONFIG_NLS_CODEPAGE_949 is not set
|
||||
# CONFIG_NLS_CODEPAGE_874 is not set
|
||||
# CONFIG_NLS_ISO8859_8 is not set
|
||||
# CONFIG_NLS_CODEPAGE_1251 is not set
|
||||
# CONFIG_NLS_ISO8859_1 is not set
|
||||
# CONFIG_NLS_ISO8859_2 is not set
|
||||
# CONFIG_NLS_ISO8859_3 is not set
|
||||
# CONFIG_NLS_ISO8859_4 is not set
|
||||
# CONFIG_NLS_ISO8859_5 is not set
|
||||
# CONFIG_NLS_ISO8859_6 is not set
|
||||
# CONFIG_NLS_ISO8859_7 is not set
|
||||
# CONFIG_NLS_ISO8859_9 is not set
|
||||
# CONFIG_NLS_ISO8859_13 is not set
|
||||
# CONFIG_NLS_ISO8859_14 is not set
|
||||
# CONFIG_NLS_ISO8859_15 is not set
|
||||
# CONFIG_NLS_KOI8_R is not set
|
||||
# CONFIG_NLS_KOI8_U is not set
|
||||
# CONFIG_NLS_UTF8 is not set
|
||||
|
||||
#
|
||||
# Kernel hacking
|
||||
#
|
||||
CONFIG_DEBUGSYM=y
|
||||
CONFIG_PT_PROXY=y
|
||||
# CONFIG_GPROF is not set
|
||||
# CONFIG_GCOV is not set
|
195
driver/user_mode_linux/setup-uml
Executable file
195
driver/user_mode_linux/setup-uml
Executable file
@ -0,0 +1,195 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use Cwd;
|
||||
|
||||
##############################
|
||||
# Start user configurable bit
|
||||
##############################
|
||||
|
||||
# Please use absolute paths too.
|
||||
# you can't use ~'s in your paths here.
|
||||
|
||||
# the directory where you've checked out lvm, keep a seperate copy for uml,
|
||||
# the uml kernel will have links to these files
|
||||
$lvm_src="/home/joe/sistina/LVM-thin";
|
||||
|
||||
|
||||
# the debian root image, get it from here:
|
||||
# http://prdownloads.sourceforge.net/user-mode-linux/root_fs_debian2.2_small.bz2
|
||||
# unzip it once you've downloaded it
|
||||
$root_fs="/home/joe/uml/root_fs";
|
||||
|
||||
# these are 100 Meg files created with dd
|
||||
# these become our PV's /dev/ubd/[1-4]
|
||||
# I sometimes use ubd/1 as swap though.
|
||||
@block_devices = ("/home/joe/uml/block_devices/scratch1",
|
||||
"/home/joe/uml/block_devices/scratch2",
|
||||
"/home/joe/uml/block_devices/scratch3",
|
||||
"/home/joe/uml/block_devices/scratch4");
|
||||
|
||||
# directory where uml will be built, and the up, lvm-install scripts will
|
||||
# be placed
|
||||
$dest_dir="/home/joe/builds/uml-thin";
|
||||
|
||||
# It must be 2.4.8, can be .gz or .bz2
|
||||
$kernel_tarball="/home/joe/packages/2.4/linux-2.4.8.tar";
|
||||
|
||||
###############################
|
||||
# end of user configurable bit
|
||||
###############################
|
||||
|
||||
|
||||
$wd = cwd;
|
||||
$uml_patch = $wd . "/uml.patch.bz2";
|
||||
$lvm_uml_patch = $wd . "/uml-lvm.patch";
|
||||
|
||||
|
||||
# check we've got everything we need
|
||||
&check_file($root_fs);
|
||||
&check_dir($lvm_src);
|
||||
&check_file($kernel_tarball);
|
||||
&check_dir($dest_dir);
|
||||
&check_file($uml_patch);
|
||||
&check_file($lvm_uml_patch);
|
||||
|
||||
|
||||
chdir($dest_dir);
|
||||
&extract_kernel($dest_dir, $kernel_tarball);
|
||||
chdir("linux");
|
||||
&run_command("bzip2 -dc $uml_patch | patch -p1", "patching kernel with uml");
|
||||
&run_command("patch -p1 < $lvm_uml_patch", "enabling LVM driver");
|
||||
|
||||
#chdir($lvm_src);
|
||||
#&run_command("make clean; rm -f config.cache", "cleaning lvm src");
|
||||
#&run_command("./configure --prefix=$dest_dir/root_fs_mnt " .
|
||||
# "--with-kernel_dir=$dest_dir/linux",
|
||||
# "configuring lvm");
|
||||
|
||||
chdir("$dest_dir/linux");
|
||||
|
||||
#&run_command("patch -p1 < $lvm_src/PATCHES/lvm--2.4.6.patch",
|
||||
# "patching lvm driver");
|
||||
|
||||
&run_command("cd include/linux; rm -f lvm.h", "removing lvm.h");
|
||||
|
||||
&run_command("cd drivers/md; rm -f lvm*",
|
||||
"removing the rest of the lvm files");
|
||||
|
||||
&run_command("cd include/linux; ln -s $lvm_src/kernel/device-mapper.h",
|
||||
"creating symbolic link to device-mapper.h");
|
||||
|
||||
&run_command("cd drivers/md; ln -s $lvm_src/kernel/device-mapper.c",
|
||||
"creating symbolic link to device-mapper.c");
|
||||
|
||||
&run_command("cp $wd/config-uml $dest_dir/linux/.config",
|
||||
"copying linux config file");
|
||||
|
||||
chdir("$dest_dir/linux");
|
||||
&run_command("make oldconfig ARCH=um", "making oldconfig ARCH=um");
|
||||
&run_command("make dep ARCH=um", "making dependencies");
|
||||
&run_command("make linux ARCH=um", "building linux uml");
|
||||
|
||||
chdir($dest_dir);
|
||||
&run_command("ln -s $dest_dir/linux/linux uml", "creating link for linux");
|
||||
|
||||
chdir("$lvm_src");
|
||||
&run_command("make",
|
||||
"building lvm tools - you will need to install them as root");
|
||||
|
||||
chdir($dest_dir);
|
||||
&run_command("ln -s $root_fs ./root_fs", "linking root filesystem");
|
||||
|
||||
chdir($dest_dir);
|
||||
&link_devices();
|
||||
&write_up();
|
||||
mkdir "root_fs_mnt";
|
||||
&write_lvm_install();
|
||||
|
||||
print "Dont forget to run $dest_dir/lvm-install as root\n";
|
||||
|
||||
|
||||
sub write_lvm_install {
|
||||
open(OUT, "> lvm-install");
|
||||
print OUT "#! /bin/sh\n\n";
|
||||
print OUT <<"end";
|
||||
mount root_fs root_fs_mnt -o loop
|
||||
cd $lvm_src; make install; cd $dest_dir
|
||||
umount root_fs_mnt
|
||||
end
|
||||
|
||||
close OUT;
|
||||
system "chmod +x lvm-install";
|
||||
}
|
||||
|
||||
|
||||
sub write_up {
|
||||
open(UP, "> up");
|
||||
print UP "#! /bin/sh\n\n./uml ";
|
||||
$count = 1;
|
||||
for $d (@block_devices) {
|
||||
print UP "ubd$count=ubd$count ";
|
||||
$count++;
|
||||
}
|
||||
print UP "\n";
|
||||
close UP;
|
||||
system("chmod +x up");
|
||||
}
|
||||
|
||||
sub link_devices {
|
||||
$count = 1;
|
||||
foreach $d (@block_devices) {
|
||||
&run_command("ln -s $d ubd$count",
|
||||
"linking block device ubd$count");
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
sub extract_kernel {
|
||||
my($dest, $tb) = @_;
|
||||
my($cmd);
|
||||
if($tb =~ m/\.bz2/) {
|
||||
$cmd = "tar Ixf $tb";
|
||||
|
||||
} elsif($tb =~ m/\.gz/) {
|
||||
$cmd = "tar zxf $tb";
|
||||
|
||||
} else {
|
||||
$cmd = "tar xf $tb";
|
||||
}
|
||||
|
||||
&run_command($cmd, "extracting kernel");
|
||||
}
|
||||
|
||||
sub run_command {
|
||||
my($cmd) = shift;
|
||||
my($desc) = shift;
|
||||
my($r);
|
||||
print STDERR $desc, " ... ";
|
||||
$r = system("$cmd > /dev/null");
|
||||
if(!$r) {
|
||||
print STDERR "done.\n";
|
||||
return;
|
||||
} else {
|
||||
print STDERR "failed.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_file {
|
||||
$f = shift;
|
||||
if(! -e $f) {
|
||||
print STDERR "couldn't find $f\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
sub check_dir {
|
||||
$f = shift;
|
||||
if(! -e $f || ! -d $f) {
|
||||
print STDERR "couldn't find a directory called $f\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
22
driver/user_mode_linux/uml-lvm.patch
Normal file
22
driver/user_mode_linux/uml-lvm.patch
Normal file
@ -0,0 +1,22 @@
|
||||
--- uml_build/arch/um/config.in.orig Tue Jan 2 14:33:42 2001
|
||||
+++ uml_build/arch/um/config.in Tue Jan 2 14:35:42 2001
|
||||
@@ -15,6 +15,8 @@
|
||||
bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL
|
||||
endmenu
|
||||
|
||||
+source drivers/md/Config.in
|
||||
+
|
||||
mainmenu_option next_comment
|
||||
comment 'Processor features'
|
||||
bool 'Symmetric multi-processing support' CONFIG_SMP
|
||||
--- linux/drivers/md/Makefile.orig Thu Jul 26 14:58:21 2001
|
||||
+++ linux/drivers/md/Makefile Thu Jul 26 14:58:40 2001
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
export-objs := md.o xor.o
|
||||
list-multi := lvm-mod.o
|
||||
-lvm-mod-objs := lvm.o lvm-snap.o
|
||||
+lvm-mod-objs := device-mapper.o
|
||||
|
||||
# Note: link order is important. All raid personalities
|
||||
# and xor.o must come before md.o, as they each initialise
|
BIN
driver/user_mode_linux/uml.patch.bz2
Normal file
BIN
driver/user_mode_linux/uml.patch.bz2
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user