#include <inttypes.h>
#include <pthread.h>
+#include <assert.h>
#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
#include <libcfs/util/string.h>
fsnamelen = ptr_end - ptr;
+ /* avoid stat/statx call if path does not match mountpoint */
+ if (path && (strlen(path) >= mntlen) &&
+ (strncmp(mnt.mnt_dir, path, mntlen) != 0))
+ continue;
+
/* ignore unaccessible filesystem */
if (get_file_dev(mnt.mnt_dir, &devmnt))
continue;
break;
}
- /* Otherwise find the longest matching path */
- if (path && strlen(path) >= mntlen &&
- (strncmp(mnt.mnt_dir, path, mntlen) == 0) &&
- (strlen(path) == mntlen || path[mntlen] == '/')) {
+ /*
+ * Otherwise find the longest matching path beginning of path
+ * and mnt_dir already verified to be the same.
+ */
+ if (path && (strlen(path) == mntlen || path[mntlen] == '/')) {
rc = 0;
break;
}
{
int rc = -ENODEV;
+ assert(fsname || path);
+
if (!(want & WANT_INDEX))
rc = get_root_path_fast(want, fsname, outfd, path, dev, nid);
if (rc)