diff options
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index e9c0de75010e..afe08146f73e 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -1455,20 +1455,26 @@ static int table_status(struct dm_ioctl *param, size_t param_size) | |||
1455 | return 0; | 1455 | return 0; |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | static bool buffer_test_overflow(char *result, unsigned maxlen) | ||
1459 | { | ||
1460 | return !maxlen || strlen(result) + 1 >= maxlen; | ||
1461 | } | ||
1462 | |||
1463 | /* | 1458 | /* |
1464 | * Process device-mapper dependent messages. | 1459 | * Process device-mapper dependent messages. Messages prefixed with '@' |
1460 | * are processed by the DM core. All others are delivered to the target. | ||
1465 | * Returns a number <= 1 if message was processed by device mapper. | 1461 | * Returns a number <= 1 if message was processed by device mapper. |
1466 | * Returns 2 if message should be delivered to the target. | 1462 | * Returns 2 if message should be delivered to the target. |
1467 | */ | 1463 | */ |
1468 | static int message_for_md(struct mapped_device *md, unsigned argc, char **argv, | 1464 | static int message_for_md(struct mapped_device *md, unsigned argc, char **argv, |
1469 | char *result, unsigned maxlen) | 1465 | char *result, unsigned maxlen) |
1470 | { | 1466 | { |
1471 | return 2; | 1467 | int r; |
1468 | |||
1469 | if (**argv != '@') | ||
1470 | return 2; /* no '@' prefix, deliver to target */ | ||
1471 | |||
1472 | r = dm_stats_message(md, argc, argv, result, maxlen); | ||
1473 | if (r < 2) | ||
1474 | return r; | ||
1475 | |||
1476 | DMERR("Unsupported message sent to DM core: %s", argv[0]); | ||
1477 | return -EINVAL; | ||
1472 | } | 1478 | } |
1473 | 1479 | ||
1474 | /* | 1480 | /* |
@@ -1542,7 +1548,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size) | |||
1542 | 1548 | ||
1543 | if (r == 1) { | 1549 | if (r == 1) { |
1544 | param->flags |= DM_DATA_OUT_FLAG; | 1550 | param->flags |= DM_DATA_OUT_FLAG; |
1545 | if (buffer_test_overflow(result, maxlen)) | 1551 | if (dm_message_test_buffer_overflow(result, maxlen)) |
1546 | param->flags |= DM_BUFFER_FULL_FLAG; | 1552 | param->flags |= DM_BUFFER_FULL_FLAG; |
1547 | else | 1553 | else |
1548 | param->data_size = param->data_start + strlen(result) + 1; | 1554 | param->data_size = param->data_start + strlen(result) + 1; |