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 | |
| 2 | 2 | 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 | |
| 4 | 4 | Subject: [PATCH] mount.nfs4: Add support for nfs://-URLs | |
| 5 | 5 | ||
| 6 | 6 | Add support for RFC 2224-style nfs://-URLs as alternative to the | |
| 7 | 7 | traditional hostname:/path+-o port=<tcp-port> notation, | |
| 8 | 8 | providing standardised, extensible, single-string, crossplatform, | |
| 9 | 9 | portable, Character-Encoding independent (e.g. mount point with | |
| 10 | 10 | Japanese, Chinese, French etc. characters) and ASCII-compatible | |
| 11 | 11 | descriptions of NFSv4 server resources (exports). | |
| 12 | 12 | ||
| 13 | 13 | Reviewed-by: Martin Wege <martin.l.wege@gmail.com> | |
| 14 | + | Signed-off-by: Marvin Wenzel <marvin.wenzel@rovema.de> | |
| 14 | 15 | Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com> | |
| 15 | 16 | --- | |
| 16 | 17 | utils/mount/Makefile.am | 3 +- | |
| 18 | + | utils/mount/mount.c | 3 + | |
| 17 | 19 | utils/mount/nfs4mount.c | 69 +++++++- | |
| 18 | 20 | utils/mount/nfsmount.c | 93 ++++++++-- | |
| 19 | 21 | utils/mount/parse_dev.c | 67 ++++++-- | |
| 20 | 22 | utils/mount/stropts.c | 96 ++++++++++- | |
| 21 | 23 | utils/mount/urlparser1.c | 358 +++++++++++++++++++++++++++++++++++++++ | |
| 22 | 24 | utils/mount/urlparser1.h | 60 +++++++ | |
| 23 | 25 | utils/mount/utils.c | 155 +++++++++++++++++ | |
| 24 | 26 | utils/mount/utils.h | 23 +++ | |
| 25 | - | 9 files changed, 887 insertions(+), 37 deletions(-) | |
| 27 | + | 10 files changed, 890 insertions(+), 37 deletions(-) | |
| 26 | 28 | create mode 100644 utils/mount/urlparser1.c | |
| 27 | 29 | create mode 100644 utils/mount/urlparser1.h | |
| 28 | 30 | ||
| 29 | 31 | diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am | |
| 30 | 32 | index 83a8ee1c..0e4cab3e 100644 | |
| 31 | 33 | --- a/utils/mount/Makefile.am | |
| 32 | 34 | +++ b/utils/mount/Makefile.am | |
| 33 | 35 | @@ -13,7 +13,8 @@ sbin_PROGRAMS = mount.nfs | |
| 34 | 36 | EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS) | |
| 35 | 37 | mount_common = error.c network.c token.c \ | |
| 36 | 38 | parse_opt.c parse_dev.c \ | |
| 37 | 39 | - nfsmount.c nfs4mount.c stropts.c\ | |
| 38 | 40 | + nfsmount.c nfs4mount.c \ | |
| 39 | 41 | + urlparser1.c urlparser1.h stropts.c \ | |
| 40 | 42 | mount_constants.h error.h network.h token.h \ | |
| 41 | 43 | parse_opt.h parse_dev.h \ | |
| 42 | 44 | 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[]) | |
| 55 | 60 | ||
| 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]); | |
| 61 | 64 | ||
| 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" | |
| 75 | 78 | ||
| 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]; | |
| 84 | 96 | + | |
| 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¶m2=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; | |
| 96 | 107 | + | |
| 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¶m2=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; | |
| 106 | 119 | + | |
| 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.
nrubsig.kpaste.net RSS