Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360325
b: refs/heads/master
c: a260624
h: refs/heads/master
i:
  360323: eaceeba
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Mar 1, 2013
1 parent 6df8cf0 commit 3b83f2c
Show file tree
Hide file tree
Showing 3 changed files with 41 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: 02cde50b7ea74557d32ff778c73809322445ccd2
refs/heads/master: a26062416ef8add48f16fbadded2b5f6fb84d024
36 changes: 35 additions & 1 deletion trunk/drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,22 @@ static int table_status(struct dm_ioctl *param, size_t param_size)
return 0;
}

static bool buffer_test_overflow(char *result, unsigned maxlen)
{
return !maxlen || strlen(result) + 1 >= maxlen;
}

/*
* Process device-mapper dependent messages.
* Returns a number <= 1 if message was processed by device mapper.
* Returns 2 if message should be delivered to the target.
*/
static int message_for_md(struct mapped_device *md, unsigned argc, char **argv,
char *result, unsigned maxlen)
{
return 2;
}

/*
* Pass a message to the target that's at the supplied device offset.
*/
Expand All @@ -1425,6 +1441,8 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
struct dm_table *table;
struct dm_target *ti;
struct dm_target_msg *tmsg = (void *) param + param->data_start;
size_t maxlen;
char *result = get_result_buffer(param, param_size, &maxlen);

md = find_device(param);
if (!md)
Expand All @@ -1448,6 +1466,10 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
goto out_argv;
}

r = message_for_md(md, argc, argv, result, maxlen);
if (r <= 1)
goto out_argv;

table = dm_get_live_table(md);
if (!table)
goto out_argv;
Expand All @@ -1473,7 +1495,18 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
out_argv:
kfree(argv);
out:
param->data_size = 0;
if (r >= 0)
__dev_status(md, param);

if (r == 1) {
param->flags |= DM_DATA_OUT_FLAG;
if (buffer_test_overflow(result, maxlen))
param->flags |= DM_BUFFER_FULL_FLAG;
else
param->data_size = param->data_start + strlen(result) + 1;
r = 0;
}

dm_put(md);
return r;
}
Expand Down Expand Up @@ -1653,6 +1686,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
param->flags &= ~DM_BUFFER_FULL_FLAG;
param->flags &= ~DM_UEVENT_GENERATED_FLAG;
param->flags &= ~DM_SECURE_DATA_FLAG;
param->flags &= ~DM_DATA_OUT_FLAG;

/* Ignores parameters */
if (cmd == DM_REMOVE_ALL_CMD ||
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/uapi/linux/dm-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,9 @@ enum {
*/
#define DM_SECURE_DATA_FLAG (1 << 15) /* In */

/*
* If set, a message generated output data.
*/
#define DM_DATA_OUT_FLAG (1 << 16) /* Out */

#endif /* _LINUX_DM_IOCTL_H */

0 comments on commit 3b83f2c

Please sign in to comment.