pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

Difference between
modified post e8c5cb by Anonymous on Fri 6th Dec 2024 14:28
original post b37 by Anonymous on Fri 6th Dec 2024 10:31
Download diff
Show old version | new version | both versions

    
1-
From e7b5a3ac981727e4585288bd66d1a9b2dea045dc Mon Sep 17 00:00:00 2001
1+
From 767e1aa096bacd4dd600d46ccaaefbc47ba863bf Mon Sep 17 00:00:00 2001
22
From: Roland Mainz <roland.mainz@nrubsig.org>
3-
Date: Fri, 6 Dec 2024 10:58:48 +0100
3+
Date: Fri, 6 Dec 2024 15:22:23 +0100
44
Subject: [PATCH] mount.nfs4: Add support for nfs://-URLs
55
66
Add support for RFC 2224-style nfs://-URLs as alternative to the
77
traditional hostname:/path+-o port=<tcp-port> notation,
88
providing standardised, extensible, single-string, crossplatform,
99
portable, Character-Encoding independent (e.g. mount point with
1010
Japanese, Chinese, French etc. characters) and ASCII-compatible
1111
descriptions of NFSv4 server resources (exports).
1212
1313
Reviewed-by: Martin Wege <martin.l.wege@gmail.com>
14+
Signed-off-by: Marvin Wenzel <marvin.wenzel@rovema.de>
1415
Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
1516
---
1617
 utils/mount/Makefile.am  |   3 +-
18+
 utils/mount/mount.c      |   3 +
1719
 utils/mount/nfs4mount.c  |  69 +++++++-
1820
 utils/mount/nfsmount.c   |  93 ++++++++--
1921
 utils/mount/parse_dev.c  |  67 ++++++--
2022
 utils/mount/stropts.c    |  96 ++++++++++-
2123
 utils/mount/urlparser1.c | 358 +++++++++++++++++++++++++++++++++++++++
2224
 utils/mount/urlparser1.h |  60 +++++++
2325
 utils/mount/utils.c      | 155 +++++++++++++++++
2426
 utils/mount/utils.h      |  23 +++
25-
 9 files changed, 887 insertions(+), 37 deletions(-)
27+
 10 files changed, 890 insertions(+), 37 deletions(-)
2628
 create mode 100644 utils/mount/urlparser1.c
2729
 create mode 100644 utils/mount/urlparser1.h
2830
2931
diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
3032
index 83a8ee1c..0e4cab3e 100644
3133
--- a/utils/mount/Makefile.am
3234
+++ b/utils/mount/Makefile.am
3335
@@ -13,7 +13,8 @@ sbin_PROGRAMS	= mount.nfs
3436
 EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS)
3537
 mount_common = error.c network.c token.c \
3638
 		    parse_opt.c parse_dev.c \
3739
-		    nfsmount.c nfs4mount.c stropts.c\
3840
+		    nfsmount.c nfs4mount.c \
3941
+		    urlparser1.c urlparser1.h stropts.c \
4042
 		    mount_constants.h error.h network.h token.h \
4143
 		    parse_opt.h parse_dev.h \
4244
 		    nfs4_mount.h stropts.h version.h \
43-
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
45+
diff --git a/utils/mount/mount.c b/utils/mount/mount.c
44-
index 0fe142a7..8e4fbf30 100644
46+
index b98f9e00..2ce6209d 100644
45-
--- a/utils/mount/nfs4mount.c
47+
--- a/utils/mount/mount.c
46-
+++ b/utils/mount/nfs4mount.c
48+
+++ b/utils/mount/mount.c
47-
@@ -50,8 +50,10 @@
49+
@@ -29,6 +29,7 @@
48-
 #include "mount_constants.h"
50+
 #include <string.h>
49-
 #include "nfs4_mount.h"
51+
 #include <errno.h>
50-
 #include "nfs_mount.h"
52+
 #include <fcntl.h>
51-
+#include "urlparser1.h"
53+
+#include <locale.h>
52-
 #include "error.h"
54+
 #include <sys/mount.h>
53-
 #include "network.h"
55+
 #include <getopt.h>
54-
+#include "utils.h"
56+
 #include <mntent.h>
57+
@@ -386,6 +387,8 @@ int main(int argc, char *argv[])
5560
56-
 #if defined(VAR_LOCK_DIR)
61+
+	(void)setlocale(LC_ALL, "");
57-
 #define DEFAULT_DIR VAR_LOCK_DIR
62+
+
58-
@@ -182,7 +184,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
63+
 	progname = basename(argv[0]);
6164
62-
-	char *hostname, *dirname, *old_opts;
65+
 	nfs_mount_data_version = discover_nfs_mount_data_version(&string);
63-
+	char *hostname, *dirname, *mb_dirname = NULL, *old_opts;
66+
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
64-
 	char new_opts[1024];
67+
index 0fe142a7..8e4fbf30 100644
65-
 	char *opt, *opteq;
68+
--- a/utils/mount/nfs4mount.c
66-
 	char *s;
69+
+++ b/utils/mount/nfs4mount.c
67-
@@ -192,15 +194,66 @@ int nfs4mount(const char *spec, const char *node, int flags,
70+
@@ -50,8 +50,10 @@
68-
 	int retry;
71+
 #include "mount_constants.h"
69-
 	int retval = EX_FAIL;
72+
 #include "nfs4_mount.h"
70-
 	time_t timeout, t;
73+
 #include "nfs_mount.h"
71-
+	int nfs_port = NFS_PORT;
74+
+#include "urlparser1.h"
72-
+	parsed_nfs_url pnu;
75+
 #include "error.h"
73-
+
76+
 #include "network.h"
74-
+	(void)memset(&pnu, 0, sizeof(parsed_nfs_url));
77+
+#include "utils.h"
7578
76-
 	if (strlen(spec) >= sizeof(hostdir)) {
79+
 #if defined(VAR_LOCK_DIR)
77-
 		nfs_error(_("%s: excessively long host:dir argument\n"),
80+
 #define DEFAULT_DIR VAR_LOCK_DIR
78-
 				progname);
81+
@@ -182,7 +184,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
79-
 		goto fail;
82+
 	int num_flavour = 0;
80-
 	}
83+
 	int ip_addr_in_opts = 0;
81-
-	strcpy(hostdir, spec);
84+
82-
-	if (parse_devname(hostdir, &hostname, &dirname))
85+
-	char *hostname, *dirname, *old_opts;
83-
-		goto fail;
86+
+	char *hostname, *dirname, *mb_dirname = NULL, *old_opts;
87+
 	char new_opts[1024];
8496
+
85-
+	/*
97+
+	(void)memset(&pnu, 0, sizeof(parsed_nfs_url));
86-
+	 * Support nfs://-URLS per RFC 2224 ("NFS URL
98+
87-
+	 * SCHEME", see https://www.rfc-editor.org/rfc/rfc2224.html),
99+
 	if (strlen(spec) >= sizeof(hostdir)) {
88-
+	 * including custom port (nfs://hostname@port/path/...)
100+
 		nfs_error(_("%s: excessively long host:dir argument\n"),
89-
+	 * and URL parameter (e.g. nfs://.../?param1=val1&param2=val2
101+
 				progname);
90-
+	 * support
102+
 		goto fail;
91-
+	 */
103+
 	}
92-
+	if (is_spec_nfs_url(spec)) {
104+
-	strcpy(hostdir, spec);
93-
+		if (!mount_parse_nfs_url(spec, &pnu)) {
105+
-	if (parse_devname(hostdir, &hostname, &dirname))
94-
+			goto fail;
106+
-		goto fail;
96107
+
97-
+		/*
108+
+	/*
98-
+		 * |pnu.uctx->path| is in UTF-8, but we need the data
109+
+	 * Support nfs://-URLS per RFC 2224 ("NFS URL
99-
+		 * in the current local locale's encoding, as mount(2)
110+
+	 * SCHEME", see https://www.rfc-editor.org/rfc/rfc2224.html),
100-
+		 * does not have something like a |MS_UTF8_SPEC| flag
111+
+	 * including custom port (nfs://hostname@port/path/...)
101-
+		 * to indicate that the input path is in UTF-8,
112+
+	 * and URL parameter (e.g. nfs://.../?param1=val1&param2=val2
102-
+		 * independently of the current locale
113+
+	 * support
103-
+		 */
114+
+	 */
104-
+		hostname = pnu.uctx->hostport.hostname;
115+
+	if (is_spec_nfs_url(spec)) {
105-
+		dirname = mb_dirname = utf8str2mbstr(pnu.uctx->path);
116+
+		if (!mount_parse_nfs_url(spec, &pnu)) {
117+
+			goto fail;
106119
+
120+
+		/*

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