Make mountpoint(1) work based on device id and the inode number
This commit is contained in:
parent
aa665ffc85
commit
6a1970caa4
14
mountpoint.c
14
mountpoint.c
@ -22,7 +22,7 @@ main(int argc, char *argv[])
|
|||||||
struct mntinfo *minfo = NULL;
|
struct mntinfo *minfo = NULL;
|
||||||
int siz;
|
int siz;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct stat st;
|
struct stat st1, st2;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'q':
|
case 'q':
|
||||||
@ -35,18 +35,22 @@ main(int argc, char *argv[])
|
|||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (stat(argv[0], &st) < 0)
|
if (stat(argv[0], &st1) < 0)
|
||||||
eprintf("stat %s:", argv[0]);
|
eprintf("stat %s:", argv[0]);
|
||||||
|
|
||||||
if (!S_ISDIR(st.st_mode))
|
if (!S_ISDIR(st1.st_mode))
|
||||||
eprintf("lstat %s: not a directory\n", argv[0]);
|
eprintf("lstat %s: not a directory\n", argv[0]);
|
||||||
|
|
||||||
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, argv[0]))
|
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)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
free(minfo);
|
free(minfo);
|
||||||
|
|
||||||
if (i == siz)
|
if (i == siz)
|
||||||
|
Loading…
Reference in New Issue
Block a user