diff options
author | Jon Medhurst <tixy@linaro.org> | 2012-09-06 10:09:00 +0100 |
---|---|---|
committer | Vishal Bhoj <vishal.bhoj@linaro.org> | 2014-04-14 10:58:25 +0530 |
commit | a76cadd0868d8d7f2f4879a7f3f62435c5b8aa8b (patch) | |
tree | b842dbf7d535764f8d84edec3df35bed7f0fd5c9 | |
parent | 470f0b3ff46493b4a46b3599db33a29e94615d30 (diff) | |
download | vold-linaro-master.tar.gz |
Allow symlinks to be used in vold managed fstab entrieslinaro-master
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.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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; |