ubase

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

commit aa665ffc85a1d06780f73a47fc0811c69ce679bf
parent a81264cda1579437c197869396256c8032f3a664
Author: sin <sin@2f30.org>
Date:   Thu Aug 29 19:05:09 +0100

Complain for invalid paths

Diffstat:
mountpoint.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/mountpoint.c b/mountpoint.c @@ -1,4 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -19,6 +22,7 @@ main(int argc, char *argv[]) struct mntinfo *minfo = NULL; int siz; int ret = 0; + struct stat st; ARGBEGIN { case 'q': @@ -31,6 +35,12 @@ main(int argc, char *argv[]) if (argc < 1) usage(); + if (stat(argv[0], &st) < 0) + eprintf("stat %s:", argv[0]); + + if (!S_ISDIR(st.st_mode)) + eprintf("lstat %s: not a directory\n", argv[0]); + siz = grabmntinfo(&minfo); if (!siz) eprintf("grabmntinfo:");