summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-03-13 10:07:12 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-03-14 15:14:47 +0800
commit43f340b66d8323c6e797868d07fc98482052ba35 (patch)
tree5a7b93384aa112a7e9a15b6ee55c0f3f0d29e8a6 /discover/device-handler.c
parentbb3ddd63720501f451d3f2797f315c25efd3bd4a (diff)
downloadtalos-petitboot-43f340b66d8323c6e797868d07fc98482052ba35.tar.gz
talos-petitboot-43f340b66d8323c6e797868d07fc98482052ba35.zip
discover: Use ID_FS_TYPE property for filesystem type detection
Currently, we don't hand any -t option to mount, as we expect the mount binary to do autodetection of the filesystem type for us. Turns out this isn't great with busybox mount, (which we're likely to be using in petitboot builds), which implements "autodetection" by trying the mount() syscall with every fs type in /proc/filesystems, until one succeeds. We expect a lot of the mount calls to fail, as we currently try to mount everything (and abort discovery on devices that don't mount), including non-filesystem partitions. On a test machine with 560 block devices, and 37 entries in /proc/partitions, this results in around 20,000 calls to mount(). A better way would be to pass a -t option to mount. It turns out that udev uses libblkid to probe the filesystem type, which is available in the ID_FS_TYPE property. This change only attempts to mount filesystems with this property, and passes an explicit fstype to the mount binary. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 80187ff..9c8dea8 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -806,6 +806,7 @@ static bool check_existing_mount(struct discover_device *dev)
static int mount_device(struct discover_device *dev)
{
+ const char *fstype;
int rc;
if (!dev->device_path)
@@ -817,6 +818,10 @@ static int mount_device(struct discover_device *dev)
if (check_existing_mount(dev))
return 0;
+ fstype = discover_device_get_param(dev, "ID_FS_TYPE");
+ if (!fstype)
+ return 0;
+
dev->mount_path = join_paths(dev, mount_base(),
dev->device_path);
@@ -828,7 +833,7 @@ static int mount_device(struct discover_device *dev)
rc = process_run_simple(dev, pb_system_apps.mount,
dev->device_path, dev->mount_path,
- "-o", "ro", NULL);
+ "-t", fstype, "-o", "ro", NULL);
if (!rc) {
dev->mounted = true;
dev->mounted_rw = false;
OpenPOWER on IntegriCloud