ubase

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

commit fc7c1c0a881a08272afd71204ad2de5c6239e2e7
parent 163a17a8354320a86302f6229db9ab1341b47eb7
Author: sin <sin@2f30.org>
Date:   Tue Sep  3 13:24:08 +0100

Implement -x option for mountpoint(1)

Diffstat:
mountpoint.c | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/mountpoint.c b/mountpoint.c @@ -11,14 +11,14 @@ static void usage(void) { - eprintf("usage: %s [-dq] target\n", argv0); + eprintf("usage: %s [-dqx] target\n", argv0); } int main(int argc, char *argv[]) { int i; - int qflag = 0, dflag = 0; + int qflag = 0, dflag = 0, xflag = 0; struct mntinfo *minfo = NULL; int siz; int ret = 0; @@ -31,6 +31,9 @@ main(int argc, char *argv[]) case 'd': dflag = 1; break; + case 'x': + xflag = 1; + break; default: usage(); } ARGEND; @@ -41,8 +44,17 @@ main(int argc, char *argv[]) if (stat(argv[0], &st1) < 0) eprintf("stat %s:", argv[0]); + if (xflag) { + if (!S_ISBLK(st1.st_mode)) + eprintf("stat: %s: not a block device\n", + argv[0]); + printf("%u:%u\n", major(st1.st_rdev), + minor(st1.st_rdev)); + return 0; + } + if (!S_ISDIR(st1.st_mode)) - eprintf("lstat %s: not a directory\n", argv[0]); + eprintf("stat %s: not a directory\n", argv[0]); if (dflag) { printf("%u:%u\n", major(st1.st_dev),