- struct sockaddr_storage address;
- struct sockaddr *sap = (struct sockaddr *)&address;
- socklen_t salen = sizeof(address);
- struct pmap nfs_pmap, mnt_pmap;
-
- nfs_options2pmap(options, &nfs_pmap, &mnt_pmap);
+ struct mntentchn *pmc;
+ struct mount_options *options;
+ int retval;
+
+ retval = -1;
+ pmc = getprocmntdirbackward(mc->m.mnt_dir, NULL);
+ if (!pmc)
+ goto not_found;
+
+ do {
+ size_t nlen = strlen(pmc->m.mnt_fsname);
+
+ /*
+ * It's possible the mount location string in /proc/mounts
+ * ends with a '/'. In this case, if the entry came from
+ * /etc/mtab, it won't have the trailing '/' so deal with
+ * it.
+ */
+ while (pmc->m.mnt_fsname[nlen - 1] == '/')
+ nlen--;
+ if (strncmp(pmc->m.mnt_fsname, mc->m.mnt_fsname, nlen) != 0)
+ continue;
+
+ if (strcmp(pmc->m.mnt_type, "nfs4") == 0)
+ goto out_nfs4;
+
+ options = po_split(pmc->m.mnt_opts);
+ if (options != NULL) {
+ unsigned long version;
+ int rc = nfs_nfs_version(options, &version);
+ po_destroy(options);
+ if (rc && version == 4)
+ goto out_nfs4;
+ }