ubase

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

commit 7afa5b879172a429fde5146d70079610328374dc
parent 1927d289903e1729699e7ee95161b652799f1106
Author: sin <sin@2f30.org>
Date:   Sat, 31 Aug 2013 17:39:17 +0100

Make mount(8) work based on device id and inode number

Diffstat:
Mmount.c | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ #include <sys/mount.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -41,6 +43,7 @@ main(int argc, char *argv[]) char *types = NULL, *opt = NULL, *p; const char *source; const char *target; + struct stat st1, st2; int validopt; void *data = NULL; struct mntinfo *minfo = NULL; @@ -103,12 +106,20 @@ main(int argc, char *argv[]) if (!target) { target = source; source = NULL; + if (stat(target, &st1) < 0) + eprintf("stat %s:", target); siz = grabmntinfo(&minfo); if (!siz) eprintf("grabmntinfo:"); - for (i = 0; i < siz; i++) - if (!strcmp(minfo[i].mntdir, target)) + for (i = 0; i < siz; i++) { + if (stat(minfo[i].mntdir, &st2) < 0) + eprintf("stat %s:", minfo[i].mntdir); + if (st1.st_dev == st2.st_dev && + st1.st_ino == st2.st_ino) { source = minfo[i].fsname; + break; + } + } if (!source) enprintf(1, "can't find %s mountpoint\n", target);