lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1275967524-24166-2-git-send-email-wad@chromium.org>
Date:	Mon,  7 Jun 2010 22:25:23 -0500
From:	Will Drewry <wad@...omium.org>
To:	dm-devel@...hat.com
Cc:	Randy Dunlap <rdunlap@...otime.net>, Ingo Molnar <mingo@...e.hu>,
	Len Brown <len.brown@...el.com>, Neil Brown <neilb@...e.de>,
	Alasdair G Kergon <agk@...hat.com>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	Mike Snitzer <snitzer@...hat.com>,
	Kiyoshi Ueda <k-ueda@...jp.nec.com>,
	Jun'ichi Nomura <j-nomura@...jp.nec.com>,
	Mikulas Patocka <mpatocka@...hat.com>,
	Nikanth Karthikesan <knikanth@...e.de>,
	Sam Ravnborg <sam@...nborg.org>, Michal Marek <mmarek@...e.cz>,
	Tejun Heo <tj@...nel.org>, Jan Blunck <jblunck@...e.de>,
	Vegard Nossum <vegard.nossum@...il.com>,
	Kay Sievers <kay.sievers@...y.org>,
	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-raid@...r.kernel.org, Will Drewry <wad@...omium.org>
Subject: [PATCH v4 2/3] dm: export a table+mapped device to the ioctl interface

If a mapped device and table is configured without traversing
the dm-ioctl interface (dm-fs-style), then it will not be bound
to a name or uuid.  This means that it will be inaccessible for
userspace management and udev will be unhappy with the lack of
a name or uuid.

The function added in this change performs the required association
to transition to being managed by the ioctl interface.

v4: same as v3 but keeping bundled

Signed-off-by: Will Drewry <wad@...omium.org>
---
 drivers/md/dm-ioctl.c         |   38 ++++++++++++++++++++++++++++++++++++++
 include/linux/device-mapper.h |    6 ++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index dfde391..8c73b20 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1604,6 +1604,44 @@ void dm_interface_exit(void)
 }
 
 /**
+ * dm_ioctl_export - Permanently export a mapped device via the ioctl interface
+ * @md: Pointer to mapped_device
+ * @name: Buffer (size DM_NAME_LEN) for name
+ * @uuid: Buffer (size DM_UUID_LEN) for uuid or NULL if not desired
+ */
+int dm_ioctl_export(struct mapped_device *md, const char *name, const char *uuid)
+{
+	int r = 0;
+	struct hash_cell *hc;
+
+	if (!md) {
+		r = -ENXIO;
+		goto out;
+	}
+
+	/* The name and uuid can only be set once. */
+	mutex_lock(&dm_hash_cells_mutex);
+	hc = dm_get_mdptr(md);
+	mutex_unlock(&dm_hash_cells_mutex);
+	if (hc) {
+		DMERR("%s: already exported", dm_device_name(md));
+		r = -ENXIO;
+		goto out;
+	}
+
+	r = dm_hash_insert(name, uuid, md);
+	if (r) {
+		DMERR("%s: could not bind to '%s'", dm_device_name(md), name);
+		goto out;
+	}
+
+	/* Let udev know we've changed. */
+	dm_kobject_uevent(md, KOBJ_CHANGE, dm_get_event_nr(md));
+out:
+	return r;
+}
+
+/**
  * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers
  * @md: Pointer to mapped_device
  * @name: Buffer (size DM_NAME_LEN) for name
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 1381cd9..0792cf3 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -215,6 +215,12 @@ void dm_set_mdptr(struct mapped_device *md, void *ptr);
 void *dm_get_mdptr(struct mapped_device *md);
 
 /*
+ * Export the device via the ioctl interface (uses mdptr).
+ */
+int dm_ioctl_export(struct mapped_device *md, const char *name,
+		    const char *uuid);
+
+/*
  * A device can still be used while suspended, but I/O is deferred.
  */
 int dm_suspend(struct mapped_device *md, unsigned suspend_flags);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ