Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38080
b: refs/heads/master
c: aa129a2
h: refs/heads/master
v: v3
  • Loading branch information
Milan Broz authored and Linus Torvalds committed Oct 3, 2006
1 parent e5482c7 commit ff28090
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70abac6e4f4bfb05a8198e22225f9e066239c7a2
refs/heads/master: aa129a2247b164173d45da8ad43cca5de9211403
41 changes: 41 additions & 0 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/idr.h>
#include <linux/hdreg.h>
#include <linux/blktrace_api.h>
#include <linux/smp_lock.h>

#define DM_MSG_PREFIX "core"

Expand Down Expand Up @@ -288,6 +289,45 @@ static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return dm_get_geometry(md, geo);
}

static int dm_blk_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct mapped_device *md;
struct dm_table *map;
struct dm_target *tgt;
int r = -ENOTTY;

/* We don't really need this lock, but we do need 'inode'. */
unlock_kernel();

md = inode->i_bdev->bd_disk->private_data;

map = dm_get_table(md);

if (!map || !dm_table_get_size(map))
goto out;

/* We only support devices that have a single target */
if (dm_table_get_num_targets(map) != 1)
goto out;

tgt = dm_table_get_target(map, 0);

if (dm_suspended(md)) {
r = -EAGAIN;
goto out;
}

if (tgt->type->ioctl)
r = tgt->type->ioctl(tgt, inode, file, cmd, arg);

out:
dm_table_put(map);

lock_kernel();
return r;
}

static inline struct dm_io *alloc_io(struct mapped_device *md)
{
return mempool_alloc(md->io_pool, GFP_NOIO);
Expand Down Expand Up @@ -1377,6 +1417,7 @@ int dm_suspended(struct mapped_device *md)
static struct block_device_operations dm_blk_dops = {
.open = dm_blk_open,
.release = dm_blk_close,
.ioctl = dm_blk_ioctl,
.getgeo = dm_blk_getgeo,
.owner = THIS_MODULE
};
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,

typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);

typedef int (*dm_ioctl_fn) (struct dm_target *ti, struct inode *inode,
struct file *filp, unsigned int cmd,
unsigned long arg);

void dm_error(const char *message);

/*
Expand Down Expand Up @@ -91,6 +95,7 @@ struct target_type {
dm_resume_fn resume;
dm_status_fn status;
dm_message_fn message;
dm_ioctl_fn ioctl;
};

struct io_restrictions {
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/dm-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ typedef char ioctl_struct[308];
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)

#define DM_VERSION_MAJOR 4
#define DM_VERSION_MINOR 7
#define DM_VERSION_MINOR 8
#define DM_VERSION_PATCHLEVEL 0
#define DM_VERSION_EXTRA "-ioctl (2006-06-24)"

Expand Down

0 comments on commit ff28090

Please sign in to comment.