[dm-devel] [PATCH] Use only specific errors when failing dm-ioctl

Milan Broz mbroz at redhat.com
Wed Feb 16 17:32:05 UTC 2011


The return codes of ioctl are part of device-mapper
API and only defined errno should be returned.

Unify return codes for device lookup function on one place
and allow ENOMEM and ENXIO for now.

(Later it can be added more codes as userspace is prepared
to handle them.)

Signed-off-by: Milan Broz <mbroz at redhat.com>
---
 drivers/md/dm-table.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 38e4eb1..ca19e4d 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -532,7 +532,17 @@ EXPORT_SYMBOL_GPL(dm_set_device_limits);
 int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
 		  struct dm_dev **result)
 {
-	return __table_get_device(ti->table, ti, path, mode, result);
+	int r = __table_get_device(ti->table, ti, path, mode, result);
+
+	/*
+	 * Return code is directly used for dm ioctl.
+	 * Allow only ENOMEM here, all other codes
+	 * means device lookup failed.
+	 */
+	if (r && r != -ENOMEM)
+		r = -ENXIO;
+
+	return r;
 }
 
 
-- 
1.7.2.3




More information about the dm-devel mailing list