diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-09-17 10:54:37 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:54:37 -0400 |
commit | 60ac03685bf513f9d9b6e8e098018b35309ed326 (patch) | |
tree | 6a5c2b0d93eb212515a782eb946d16dfad363e8c /fs/nfs/nfsroot.c | |
parent | ed58b2917be24fc8603128e32d50a1378afe66e1 (diff) | |
download | linux-stable-60ac03685bf513f9d9b6e8e098018b35309ed326.tar.gz linux-stable-60ac03685bf513f9d9b6e8e098018b35309ed326.tar.bz2 linux-stable-60ac03685bf513f9d9b6e8e098018b35309ed326.zip |
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.c | 32 |
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 @@ #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; } |