mirror of git://git.suckless.org/sbase
Make mount(8) work based on device id and inode number
This commit is contained in:
parent
1927d28990
commit
7afa5b8791
15
mount.c
15
mount.c
|
@ -1,5 +1,7 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -41,6 +43,7 @@ main(int argc, char *argv[])
|
||||||
char *types = NULL, *opt = NULL, *p;
|
char *types = NULL, *opt = NULL, *p;
|
||||||
const char *source;
|
const char *source;
|
||||||
const char *target;
|
const char *target;
|
||||||
|
struct stat st1, st2;
|
||||||
int validopt;
|
int validopt;
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
struct mntinfo *minfo = NULL;
|
struct mntinfo *minfo = NULL;
|
||||||
|
@ -103,12 +106,20 @@ main(int argc, char *argv[])
|
||||||
if (!target) {
|
if (!target) {
|
||||||
target = source;
|
target = source;
|
||||||
source = NULL;
|
source = NULL;
|
||||||
|
if (stat(target, &st1) < 0)
|
||||||
|
eprintf("stat %s:", target);
|
||||||
siz = grabmntinfo(&minfo);
|
siz = grabmntinfo(&minfo);
|
||||||
if (!siz)
|
if (!siz)
|
||||||
eprintf("grabmntinfo:");
|
eprintf("grabmntinfo:");
|
||||||
for (i = 0; i < siz; i++)
|
for (i = 0; i < siz; i++) {
|
||||||
if (!strcmp(minfo[i].mntdir, target))
|
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;
|
source = minfo[i].fsname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!source)
|
if (!source)
|
||||||
enprintf(1, "can't find %s mountpoint\n",
|
enprintf(1, "can't find %s mountpoint\n",
|
||||||
target);
|
target);
|
||||||
|
|
Loading…
Reference in New Issue