From: Wei Yongjun <yjwei@nanjing-fnst.com>
To: nfs@lists.sourceforge.net
Subject: [PATCH] nfs-utils umount command does not use correct TCP/UDP protocol
Date: Mon, 05 Mar 2007 07:43:06 -0500 [thread overview]
Message-ID: <1173098587.4825.9.camel@LINE> (raw)
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
next reply other threads:[~2007-03-05 10:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-05 12:43 Wei Yongjun [this message]
2007-03-13 3:12 ` [PATCH] nfs-utils umount command does not use correct TCP/UDP protocol 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1173098587.4825.9.camel@LINE \
--to=yjwei@nanjing-fnst.com \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox