73 #include <linux/types.h>
74 #include <linux/string.h>
76 #include <linux/nfs.h>
77 #include <linux/nfs_fs.h>
78 #include <linux/utsname.h>
84 #define NFSDBG_FACILITY NFSDBG_ROOT
87 #define NFS_ROOT "/tftpboot/%s"
90 #define NFS_DEF_OPTIONS "vers=2,udp,rsize=4096,wsize=4096"
93 static char nfs_root_parms[256]
__initdata =
"";
118 __setup(
"nfsrootdebug", nfs_root_debug);
134 if (line[0] ==
'/' || line[0] ==
',' || (line[0] >=
'0' && line[0] <=
'9')) {
135 strlcpy(nfs_root_parms, line,
sizeof(nfs_root_parms));
138 if (n >=
sizeof(nfs_root_parms))
139 line[
sizeof(nfs_root_parms) -
sizeof(
NFS_ROOT) - 2] =
'\0';
155 __setup(
"nfsroot=", nfs_root_setup);
158 const size_t destlen)
160 if (
strlcpy(dest, src, destlen) > destlen)
165 static int __init root_nfs_cat(
char *dest,
const char *src,
166 const size_t destlen)
170 if (len && dest[len - 1] !=
',')
171 if (
strlcat(dest,
",", destlen) > destlen)
174 if (
strlcat(dest, src, destlen) > destlen)
185 static int __init root_nfs_parse_options(
char *incoming,
char *exppath,
186 const size_t exppathlen)
193 p =
strsep(&incoming,
",");
194 if (*p !=
'\0' &&
strcmp(p,
"default") != 0)
195 if (root_nfs_copy(exppath, p, exppathlen))
202 if (incoming !=
NULL && *incoming !=
'\0')
203 if (root_nfs_cat(nfs_root_options, incoming,
204 sizeof(nfs_root_options)))
222 const size_t tmplen =
sizeof(nfs_export_path);
230 dprintk(
"Root-NFS: DHCPv4 option 17: %s\n",
233 goto out_optionstoolong;
236 if (cmdline[0] !=
'\0') {
237 dprintk(
"Root-NFS: nfsroot=%s\n", cmdline);
238 if (root_nfs_parse_options(cmdline, tmp, tmplen))
239 goto out_optionstoolong;
246 snprintf(mand_options,
sizeof(mand_options),
"nolock,addr=%pI4",
248 if (root_nfs_cat(nfs_root_options, mand_options,
249 sizeof(nfs_root_options)))
250 goto out_optionstoolong;
262 len =
snprintf(nfs_export_path,
sizeof(nfs_export_path),
263 tmp, utsname()->nodename);
264 if (len > (
int)
sizeof(nfs_export_path))
265 goto out_devnametoolong;
266 len =
snprintf(nfs_root_device,
sizeof(nfs_root_device),
267 "%pI4:%s", &servaddr, nfs_export_path);
268 if (len > (
int)
sizeof(nfs_root_device))
269 goto out_devnametoolong;
303 if (root_nfs_data(nfs_root_parms) < 0)
306 *root_device = nfs_root_device;
307 *root_data = nfs_root_options;