From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/6] NFS: Clean up NFSROOT command line parsing
Date: Fri, 10 Sep 2010 16:03:30 -0400 [thread overview]
Message-ID: <20100910200330.13167.80707.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20100910200001.13167.61153.stgit@seurat.1015granger.net>
Clean up: To reduce confusion, rename nfs_root_name as nfs_root_parms,
as this buffer contains more than just the name of the remote server.
Introduce documenting comments around nfs_root_setup().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfs/nfsroot.c | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index df101d9..169b679 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -99,7 +99,7 @@
#define NFS_ROOT "/tftpboot/%s"
/* Parameters passed from the kernel command line */
-static char nfs_root_name[256] __initdata = "";
+static char nfs_root_parms[256] __initdata = "";
/* Address of NFS server */
static __be32 servaddr __initdata = 0;
@@ -369,7 +369,7 @@ static int __init root_nfs_init(void)
* be able to use the client IP address for the remote root
* directory (necessary for pure RARP booting).
*/
- if (root_nfs_name(nfs_root_name) < 0 ||
+ if (root_nfs_name(nfs_root_parms) < 0 ||
root_nfs_addr() < 0)
return -1;
@@ -380,23 +380,37 @@ static int __init root_nfs_init(void)
return 0;
}
-
/*
* Parse NFS server and directory information passed on the kernel
* command line.
+ *
+ * nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
+ *
+ * If there is a "%s" token in the <root-dir> string, it is replaced
+ * by the ASCII-representation of the client's IP address.
*/
static int __init nfs_root_setup(char *line)
{
ROOT_DEV = Root_NFS;
+
if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
- strlcpy(nfs_root_name, line, sizeof(nfs_root_name));
+ strlcpy(nfs_root_parms, line, sizeof(nfs_root_parms));
} else {
- int n = strlen(line) + sizeof(NFS_ROOT) - 1;
- if (n >= sizeof(nfs_root_name))
- line[sizeof(nfs_root_name) - sizeof(NFS_ROOT) - 2] = '\0';
- sprintf(nfs_root_name, NFS_ROOT, line);
+ size_t n = strlen(line) + sizeof(NFS_ROOT) - 1;
+ if (n >= sizeof(nfs_root_parms))
+ line[sizeof(nfs_root_parms) - sizeof(NFS_ROOT) - 2] = '\0';
+ sprintf(nfs_root_parms, NFS_ROOT, line);
}
- root_server_addr = root_nfs_parse_addr(nfs_root_name);
+
+ /*
+ * Extract the IP address of the NFS server containing our
+ * root file system, if one was specified.
+ *
+ * Note: root_nfs_parse_addr() removes the server-ip from
+ * nfs_root_parms, if it exists.
+ */
+ root_server_addr = root_nfs_parse_addr(nfs_root_parms);
+
return 1;
}
next prev parent reply other threads:[~2010-09-10 20:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-10 20:03 [PATCH 0/6] Replace NFSROOT mount option parsing Chuck Lever
2010-09-10 20:03 ` [PATCH 1/6] NFS: Remove \t from mount debugging message Chuck Lever
2010-09-10 20:03 ` Chuck Lever [this message]
2010-09-10 20:03 ` [PATCH 3/6] NFS: Use super.c for NFSROOT mount option parsing Chuck Lever
2010-09-10 20:03 ` [PATCH 4/6] NFS: Clean up nfsroot.c Chuck Lever
2010-09-10 20:04 ` [PATCH 5/6] NFS: Allow NFSROOT debugging messages to be enabled dynamically Chuck Lever
2010-09-10 20:04 ` [PATCH 6/6] SUNRPC: Remove rpcb_getport_sync() Chuck Lever
2010-09-17 21:44 ` [PATCH 0/6] Replace NFSROOT mount option parsing Trond Myklebust
-- strict thread matches above, loose matches on Subject: below --
2010-05-11 17:15 [PATCH 0/6] Update NFSROOT to use text-based mounts Chuck Lever
[not found] ` <20100511170754.2167.72681.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2010-05-11 17:16 ` [PATCH 2/6] NFS: Clean up NFSROOT command line parsing Chuck Lever
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=20100910200330.13167.80707.stgit@seurat.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@netapp.com \
/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;
as well as URLs for NNTP newsgroup(s).