2017-06-20 16:04:40 +02:00
|
|
|
Use string comparision only if case of searching for NFS shares
|
|
|
|
|
|
|
|
---
|
2017-06-20 17:36:37 +02:00
|
|
|
src/fuser.c | 29 +++++++++++++++++++++--------
|
2017-06-20 16:04:40 +02:00
|
|
|
src/fuser.h | 2 +-
|
2017-06-20 17:36:37 +02:00
|
|
|
2 files changed, 22 insertions(+), 9 deletions(-)
|
2017-06-20 16:04:40 +02:00
|
|
|
|
|
|
|
--- src/fuser.c
|
2017-06-20 17:36:37 +02:00
|
|
|
+++ src/fuser.c 2017-06-20 14:30:08.176217649 +0000
|
|
|
|
@@ -2007,6 +2007,7 @@ static void clear_mntinfo(void)
|
2017-06-20 16:04:40 +02:00
|
|
|
|
|
|
|
static void init_mntinfo(void)
|
|
|
|
{
|
2017-06-20 17:36:37 +02:00
|
|
|
+ char type[256];
|
|
|
|
char mpoint[PATH_MAX*4 + 1]; // octal escaping takes 4 chars per 1 char
|
2017-06-20 16:04:40 +02:00
|
|
|
int mid, parid, max = 0;
|
|
|
|
uint maj, min;
|
2017-06-20 17:36:37 +02:00
|
|
|
@@ -2018,8 +2019,8 @@ static void init_mntinfo(void)
|
2017-06-20 16:04:40 +02:00
|
|
|
if ((mnt = fopen("/proc/self/mountinfo", "r")) == (FILE *) 0)
|
|
|
|
return;
|
|
|
|
while (fscanf
|
|
|
|
- (mnt, "%i %i %u:%u %*s %s %*[^\n]", &mid, &parid, &maj, &min,
|
|
|
|
- &mpoint[0]) == 5) {
|
|
|
|
+ (mnt, "%i %i %u:%u %*s %s %*s %*s - %s %*[^\n]",
|
|
|
|
+ &mid, &parid, &maj, &min, &mpoint[0], &type[0]) == 6) {
|
|
|
|
const size_t nlen = strlen(mpoint);
|
|
|
|
mntinfo_t *restrict mnt;
|
|
|
|
if (posix_memalign
|
2017-06-20 17:36:37 +02:00
|
|
|
@@ -2038,6 +2039,9 @@ static void init_mntinfo(void)
|
2017-06-20 16:04:40 +02:00
|
|
|
mnt->parid = parid;
|
|
|
|
mnt->dev = makedev(maj, min);
|
|
|
|
mnt->id = mid;
|
|
|
|
+ if (strncmp("nfs", type, 3) == 0)
|
|
|
|
+ mnt->nfs = 1;
|
|
|
|
+ else mnt->nfs = 0;
|
|
|
|
if (mid > max)
|
|
|
|
max = mid;
|
|
|
|
}
|
2017-06-20 17:36:37 +02:00
|
|
|
@@ -2105,16 +2109,25 @@ static int mntstat(const char *path, str
|
2017-06-20 16:04:40 +02:00
|
|
|
if (nlen < mnt->nlen)
|
|
|
|
continue;
|
|
|
|
if (mnt->nlen == 1) { /* root fs is the last entry */
|
|
|
|
- buf->st_dev = mnt->dev;
|
|
|
|
- buf->st_ino = 0;
|
|
|
|
- return 0;
|
|
|
|
+ if (mnt->nfs) {
|
|
|
|
+ fprintf(stderr, "NFS %s\n", use);
|
|
|
|
+ buf->st_dev = mnt->dev;
|
|
|
|
+ buf->st_ino = 0;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ errno = 0;
|
|
|
|
+ return stat(path, buf);
|
|
|
|
}
|
|
|
|
if (use[mnt->nlen] != '\0' && use[mnt->nlen] != '/')
|
|
|
|
continue;
|
|
|
|
if (strncmp(use, mnt->mpoint, mnt->nlen) == 0) {
|
|
|
|
- buf->st_dev = mnt->dev;
|
|
|
|
- buf->st_ino = 0;
|
|
|
|
- return 0;
|
|
|
|
+ if (mnt->nfs) {
|
|
|
|
+ buf->st_dev = mnt->dev;
|
|
|
|
+ buf->st_ino = 0;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ errno = 0;
|
|
|
|
+ return stat(path, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
errno = ENOENT;
|
|
|
|
--- src/fuser.h
|
2017-06-20 17:36:37 +02:00
|
|
|
+++ src/fuser.h 2017-06-20 14:28:48.013689702 +0000
|
|
|
|
@@ -91,7 +91,7 @@ struct mount_list {
|
2017-06-20 16:04:40 +02:00
|
|
|
# include "lists.h"
|
|
|
|
typedef struct mntinfo_s {
|
|
|
|
list_t this;
|
|
|
|
- int id, parid;
|
|
|
|
+ int id, parid, nfs:1;
|
|
|
|
dev_t dev;
|
|
|
|
size_t nlen;
|
|
|
|
char *mpoint;
|