summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Medhurst <tixy@linaro.org>2012-09-06 10:09:00 +0100
committerAmit Pundir <amit.pundir@linaro.org>2014-05-31 18:45:06 +0530
commit46d6180ea873addc27efb64693ddf82c6d96cfcc (patch)
tree6b6f297247491fc5aa176928c82ffe5daeab46aa
parentc6752b06987207bd69b12ad1feadd358e296d52e (diff)
downloadvold-linaro-armv8-20140531.tar.gz
Allow symlinks to be used in vold managed fstab entrieslinaro-armv8-20140531
Allow symlinks to be used in vold managed fstab entries With device-tree kernels the sysfs path for SD cards varies depending on device-tree layout and the actual card used. It is therefore impossible to specify the sysfs path for the device in fstab. However, there exists a symlink to the device which is created under a generic path like '/sys/block/mmcblk0/device'. To use such a path with vold we need to convert the symlinked path to the real path, which this patch does. Change-Id: I68e693772e70b758dab22fcd5f0eb4b9e84a2443 Signed-off-by: Jon Medhurst <tixy@linaro.org>
-rw-r--r--main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index d4b7d28d..a2837222 100644
--- a/main.cpp
+++ b/main.cpp
@@ -188,7 +188,24 @@ static int process_config(VolumeManager *vm)
}
dv = new DirectVolume(vm, &(fstab->recs[i]), flags);
- if (dv->addPath(fstab->recs[i].blk_device)) {
+ /* To allow symlinked paths to be specified we need to convert
+ * them with realpath(). This is made a bit more complicated
+ * because our paths are relative to the sysfs base, so we need
+ * to prefix them with '/sys' before conversion and also remove
+ * '/sys' from the result (by skipping the first 4 characters).
+ */
+ char* sp = (char*)malloc(4 + strlen(fstab->recs[i].blk_device) + 1);
+ int error = !sp;
+ if (!error) {
+ strcpy(sp, "/sys");
+ strcat(sp, fstab->recs[i].blk_device);
+ char *rp = realpath(sp, NULL);
+ if (rp && strncmp(rp, "/sys", 4)==0)
+ error = dv->addPath(rp + 4); /* Real path without '/sys' */
+ free(rp);
+ free(sp);
+ }
+ if (error) {
SLOGE("Failed to add devpath %s to volume %s",
fstab->recs[i].blk_device, fstab->recs[i].label);
goto out_fail;