All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs-utils umount command does not use correct TCP/UDP protocol
@ 2007-03-05 12:43 Wei Yongjun
  2007-03-13  3:12 ` Wei Yongjun
  2007-03-14  6:46 ` [PATCH 0/4] nfs-utils : fix some bugs of umount.nfs Wei Yongjun
  0 siblings, 2 replies; 5+ messages in thread
From: Wei Yongjun @ 2007-03-05 12:43 UTC (permalink / raw)
  To: nfs

After I install nfs-utils-1.0.12, the least release, I found that umount
command can not use the correct TCP/UDP protocol as which it been mount.

You can test this used following commands:
#mount -t nfs -o proto=udp 127.0.0.1:/nfsroot /mnt
#umount /mnt
umount will use TCP protocol to do the umount process.

Following is my patch to fix this BUG.

Signed-off-by: Wei Yongjun <yjwei@nanjing-fnst.com>

--- utils/mount/nfsumount.c.orig	2007-03-05 03:11:48.000000000 -0500
+++ utils/mount/nfsumount.c	2007-03-05 03:06:25.000000000 -0500
@@ -103,31 +103,35 @@ int nfs_call_umount(clnt_addr_t *mnt_ser
 	return 0;
 }
 
+static int
+contains(const char *list, const char *s) {
+	int n = strlen(s);
+	char *p, *rest = list;
+
+	while ((p = strstr(rest, s)) != NULL) {
+		if ((p == rest || p[-1] == ',' || p[-1] == '=')
+			&& (p[n] == '\0' || p[n] == ','))
+			return 1;
+
+                while (*rest && *rest++ != ',');
+		if(rest == NULL) break;
+        }
+        return 0;
+}
+
 u_int get_mntproto(const char *);
 u_int
 get_mntproto(const char *dirname)
 {
-	FILE *mtab;
-	struct mntent mntbuf;
-	char tmpbuf[BUFSIZ];
+	struct mntentchn *mc;
 	u_int proto = IPPROTO_TCP; /* assume tcp */
 
-	 mtab = setmntent ("/proc/mounts", "r");
-	 if (mtab == NULL)
-	 	mtab = setmntent (_PATH_MOUNTED, "r");
-	if (mtab == NULL)
-		return proto;
-
-	while(getmntent_r(mtab, &mntbuf, tmpbuf, sizeof (tmpbuf))) {
-		if (strcmp(mntbuf.mnt_type, "nfs"))
-			continue;
-		if (strcmp(dirname,  mntbuf.mnt_fsname))
-			continue;
-		if (hasmntopt(&mntbuf, "udp"))
-			proto = IPPROTO_UDP;
-		break;
-	}
-	endmntent (mtab);
+	mc = getmntdirbackward(dirname, NULL);
+	if (!mc)
+		mc = getmntdevbackward(dirname, NULL);
+
+	if(mc && contains(mc->m.mnt_opts, "udp"))
+		proto = IPPROTO_UDP;
 
 	return proto;
 }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-16  3:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-05 12:43 [PATCH] nfs-utils umount command does not use correct TCP/UDP protocol Wei Yongjun
2007-03-13  3:12 ` Wei Yongjun
2007-03-13  5:20   ` Neil Brown
2007-03-14  6:46 ` [PATCH 0/4] nfs-utils : fix some bugs of umount.nfs Wei Yongjun
2007-03-16  3:04   ` Neil Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.