ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 01bbe2820af01501a841eecebe15d31bc8f742e9
parent 9716ca2c7ad8a1af9e0a764cfa11613431337c31
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat Jun  7 19:21:16 +0200

mount: resolve path given

this allows: cd /mnt; mount somename.

Diffstat:
mount.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mount.c b/mount.c @@ -7,6 +7,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <limits.h> #include "util.h" struct { @@ -121,7 +122,7 @@ main(int argc, char *argv[]) { int aflag = 0, oflag = 0, status = EXIT_SUCCESS, i; unsigned long flags = 0; - char *types = NULL, data[512] = ""; + char *types = NULL, data[512] = "", *resolvpath = NULL; char *files[] = { "/proc/mounts", "/etc/fstab", NULL }; size_t datasiz = sizeof(data); const char *source, *target; @@ -177,6 +178,9 @@ main(int argc, char *argv[]) source = NULL; if(stat(target, &st) < 0) eprintf("stat %s:", target); + if(!(resolvpath = realpath(target, NULL))) + eprintf("realpath %s:", target); + target = resolvpath; } for(i = 0; files[i]; i++) { @@ -214,6 +218,7 @@ mountsingle: } if(fp) endmntent(fp); + free(resolvpath); return status; mountall: