pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

Difference between
modified post b37 by Anonymous on Fri 6th Dec 2024 10:31
original post 398f8 by Anonymous on Sat 2nd Nov 2024 13:39
Download diff
Show old version | new version | both versions

    
1-
diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
1+
From e7b5a3ac981727e4585288bd66d1a9b2dea045dc Mon Sep 17 00:00:00 2001
2-
index 5ff1148c..ad1d0884 100644
2+
From: Roland Mainz <roland.mainz@nrubsig.org>
3-
--- a/utils/mount/Makefile.am
3+
Date: Fri, 6 Dec 2024 10:58:48 +0100
4-
+++ b/utils/mount/Makefile.am
4+
Subject: [PATCH] mount.nfs4: Add support for nfs://-URLs
5-
@@ -13,7 +13,8 @@ sbin_PROGRAMS	= mount.nfs
5+
6-
 EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS)
6+
Add support for RFC 2224-style nfs://-URLs as alternative to the
7-
 mount_common = error.c network.c token.c \
7+
traditional hostname:/path+-o port=<tcp-port> notation,
8-
 		    parse_opt.c parse_dev.c \
8+
providing standardised, extensible, single-string, crossplatform,
9-
-		    nfsmount.c nfs4mount.c stropts.c\
9+
portable, Character-Encoding independent (e.g. mount point with
10-
+		    nfsmount.c nfs4mount.c \
10+
Japanese, Chinese, French etc. characters) and ASCII-compatible
11-
+		    urlparser1.c urlparser1.h stropts.c \
11+
descriptions of NFSv4 server resources (exports).
12-
 		    mount_constants.h error.h network.h token.h \
12+
13-
 		    parse_opt.h parse_dev.h \
13+
Reviewed-by: Martin Wege <martin.l.wege@gmail.com>
14-
 		    nfs4_mount.h stropts.h version.h \
14+
Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
15-
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
15+
---
16-
index 0fe142a7..8e4fbf30 100644
16+
 utils/mount/Makefile.am  |   3 +-
17-
--- a/utils/mount/nfs4mount.c
17+
 utils/mount/nfs4mount.c  |  69 +++++++-
18-
+++ b/utils/mount/nfs4mount.c
18+
 utils/mount/nfsmount.c   |  93 ++++++++--
19-
@@ -50,8 +50,10 @@
19+
 utils/mount/parse_dev.c  |  67 ++++++--
20-
 #include "mount_constants.h"
20+
 utils/mount/stropts.c    |  96 ++++++++++-
21-
 #include "nfs4_mount.h"
21+
 utils/mount/urlparser1.c | 358 +++++++++++++++++++++++++++++++++++++++
22-
 #include "nfs_mount.h"
22+
 utils/mount/urlparser1.h |  60 +++++++
23-
+#include "urlparser1.h"
23+
 utils/mount/utils.c      | 155 +++++++++++++++++
24-
 #include "error.h"
24+
 utils/mount/utils.h      |  23 +++
25-
 #include "network.h"
25+
 9 files changed, 887 insertions(+), 37 deletions(-)
26-
+#include "utils.h"
26+
 create mode 100644 utils/mount/urlparser1.c
27+
 create mode 100644 utils/mount/urlparser1.h
2728
28-
 #if defined(VAR_LOCK_DIR)
29+
diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
29-
 #define DEFAULT_DIR VAR_LOCK_DIR
30+
index 83a8ee1c..0e4cab3e 100644
30-
@@ -182,7 +184,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
31+
--- a/utils/mount/Makefile.am
31-
 	int num_flavour = 0;
32+
+++ b/utils/mount/Makefile.am
32-
 	int ip_addr_in_opts = 0;
33+
@@ -13,7 +13,8 @@ sbin_PROGRAMS	= mount.nfs
33-
34+
 EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS)
34-
-	char *hostname, *dirname, *old_opts;
35+
 mount_common = error.c network.c token.c \
35-
+	char *hostname, *dirname, *mb_dirname = NULL, *old_opts;
36+
 		    parse_opt.c parse_dev.c \
36-
 	char new_opts[1024];
37+
-		    nfsmount.c nfs4mount.c stropts.c\
37-
 	char *opt, *opteq;
38+
+		    nfsmount.c nfs4mount.c \
38-
 	char *s;
39+
+		    urlparser1.c urlparser1.h stropts.c \
39-
@@ -192,15 +194,66 @@ int nfs4mount(const char *spec, const char *node, int flags,
40+
 		    mount_constants.h error.h network.h token.h \
40-
 	int retry;
41+
 		    parse_opt.h parse_dev.h \
41-
 	int retval = EX_FAIL;
42+
 		    nfs4_mount.h stropts.h version.h \
42-
 	time_t timeout, t;
43+
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
43-
+	int nfs_port = NFS_PORT;
44+
index 0fe142a7..8e4fbf30 100644
44-
+	parsed_nfs_url pnu;
45+
--- a/utils/mount/nfs4mount.c
45-
+
46+
+++ b/utils/mount/nfs4mount.c
46-
+	(void)memset(&pnu, 0, sizeof(parsed_nfs_url));
47+
@@ -50,8 +50,10 @@
48+
 #include "mount_constants.h"
4755
48-
 	if (strlen(spec) >= sizeof(hostdir)) {
56+
 #if defined(VAR_LOCK_DIR)
49-
 		nfs_error(_("%s: excessively long host:dir argument\n"),
57+
 #define DEFAULT_DIR VAR_LOCK_DIR
50-
 				progname);
58+
@@ -182,7 +184,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
51-
 		goto fail;
59+
 	int num_flavour = 0;
52-
 	}
60+
 	int ip_addr_in_opts = 0;
53-
-	strcpy(hostdir, spec);
61+
54-
-	if (parse_devname(hostdir, &hostname, &dirname))
62+
-	char *hostname, *dirname, *old_opts;
55-
-		goto fail;
63+
+	char *hostname, *dirname, *mb_dirname = NULL, *old_opts;
64+
 	char new_opts[1024];
5673
+
57-
+	/*
74+
+	(void)memset(&pnu, 0, sizeof(parsed_nfs_url));
58-
+	 * Support nfs://-URLS per RFC 2224 ("NFS URL
75+
59-
+	 * SCHEME", see https://www.rfc-editor.org/rfc/rfc2224.html),
76+
 	if (strlen(spec) >= sizeof(hostdir)) {
60-
+	 * including custom port (nfs://hostname@port/path/...)
77+
 		nfs_error(_("%s: excessively long host:dir argument\n"),
61-
+	 * and URL parameter (e.g. nfs://.../?param1=val1&param2=val2
78+
 				progname);
62-
+	 * support
79+
 		goto fail;
63-
+	 */
80+
 	}
64-
+	if (is_spec_nfs_url(spec)) {
81+
-	strcpy(hostdir, spec);
65-
+		if (!mount_parse_nfs_url(spec, &pnu)) {
82+
-	if (parse_devname(hostdir, &hostname, &dirname))
66-
+			goto fail;
83+
-		goto fail;
6884
+
69-
+		/*
85+
+	/*
70-
+		 * |pnu.uctx->path| is in UTF-8, but we need the data
86+
+	 * Support nfs://-URLS per RFC 2224 ("NFS URL
71-
+		 * in the current local locale's encoding, as mount(2)
87+
+	 * SCHEME", see https://www.rfc-editor.org/rfc/rfc2224.html),
72-
+		 * does not have something like a |MS_UTF8_SPEC| flag
88+
+	 * including custom port (nfs://hostname@port/path/...)
73-
+		 * to indicate that the input path is in UTF-8,
89+
+	 * and URL parameter (e.g. nfs://.../?param1=val1&param2=val2
74-
+		 * independently of the current locale
90+
+	 * support
75-
+		 */
91+
+	 */
76-
+		hostname = pnu.uctx->hostport.hostname;
92+
+	if (is_spec_nfs_url(spec)) {
77-
+		dirname = mb_dirname = utf8str2mbstr(pnu.uctx->path);
93+
+		if (!mount_parse_nfs_url(spec, &pnu)) {
94+
+			goto fail;
7896
+
97+
+		/*

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at