aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfsroot.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-09-17 10:54:37 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-09-17 10:54:37 -0400
commit60ac03685bf513f9d9b6e8e098018b35309ed326 (patch)
tree6a5c2b0d93eb212515a782eb946d16dfad363e8c /fs/nfs/nfsroot.c
parented58b2917be24fc8603128e32d50a1378afe66e1 (diff)
NFS: Clean up NFSROOT command line parsing
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> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfsroot.c')
-rw-r--r--fs/nfs/nfsroot.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index df101d9f546a..169b67907a65 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -99,7 +99,7 @@
99#define NFS_ROOT "/tftpboot/%s" 99#define NFS_ROOT "/tftpboot/%s"
100 100
101/* Parameters passed from the kernel command line */ 101/* Parameters passed from the kernel command line */
102static char nfs_root_name[256] __initdata = ""; 102static char nfs_root_parms[256] __initdata = "";
103 103
104/* Address of NFS server */ 104/* Address of NFS server */
105static __be32 servaddr __initdata = 0; 105static __be32 servaddr __initdata = 0;
@@ -369,7 +369,7 @@ static int __init root_nfs_init(void)
369 * be able to use the client IP address for the remote root 369 * be able to use the client IP address for the remote root
370 * directory (necessary for pure RARP booting). 370 * directory (necessary for pure RARP booting).
371 */ 371 */
372 if (root_nfs_name(nfs_root_name) < 0 || 372 if (root_nfs_name(nfs_root_parms) < 0 ||
373 root_nfs_addr() < 0) 373 root_nfs_addr() < 0)
374 return -1; 374 return -1;
375 375
@@ -380,23 +380,37 @@ static int __init root_nfs_init(void)
380 return 0; 380 return 0;
381} 381}
382 382
383
384/* 383/*
385 * Parse NFS server and directory information passed on the kernel 384 * Parse NFS server and directory information passed on the kernel
386 * command line. 385 * command line.
386 *
387 * nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
388 *
389 * If there is a "%s" token in the <root-dir> string, it is replaced
390 * by the ASCII-representation of the client's IP address.
387 */ 391 */
388static int __init nfs_root_setup(char *line) 392static int __init nfs_root_setup(char *line)
389{ 393{
390 ROOT_DEV = Root_NFS; 394 ROOT_DEV = Root_NFS;
395
391 if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) { 396 if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
392 strlcpy(nfs_root_name, line, sizeof(nfs_root_name)); 397 strlcpy(nfs_root_parms, line, sizeof(nfs_root_parms));
393 } else { 398 } else {
394 int n = strlen(line) + sizeof(NFS_ROOT) - 1; 399 size_t n = strlen(line) + sizeof(NFS_ROOT) - 1;
395 if (n >= sizeof(nfs_root_name)) 400 if (n >= sizeof(nfs_root_parms))
396 line[sizeof(nfs_root_name) - sizeof(NFS_ROOT) - 2] = '\0'; 401 line[sizeof(nfs_root_parms) - sizeof(NFS_ROOT) - 2] = '\0';
397 sprintf(nfs_root_name, NFS_ROOT, line); 402 sprintf(nfs_root_parms, NFS_ROOT, line);
398 } 403 }
399 root_server_addr = root_nfs_parse_addr(nfs_root_name); 404
405 /*
406 * Extract the IP address of the NFS server containing our
407 * root file system, if one was specified.
408 *
409 * Note: root_nfs_parse_addr() removes the server-ip from
410 * nfs_root_parms, if it exists.
411 */
412 root_server_addr = root_nfs_parse_addr(nfs_root_parms);
413
400 return 1; 414 return 1;
401} 415}
402 416