// uknfs/Config.uk menuconfig LIBNFS bool "libnfs: NFS (Network Filesystem)" default n select LIBNOLIBC if !HAVE_LIBC select LIBUKTIME if !HAVE_LIBC select LIBVFSCORE
if LIBNFS config LIBNFS_AUTOMOUNT bool "Automatically mount a network filesystem" default y
config LIBNFS_SERVADDR string "Default nfs server ip address" default "" help IP address of the nfs server you want to mount
config LIBNFS_SERVPATH string "Default path of nfs server" default "" help Directory path of the nfs server you want to mount
config LIBNFS_MOUNTPATH string "Default mount path of local unikraft" default "/mnt/nfs" help Where do you want to mount nfs? The default path is "/mnt/nfs"
config LIBNFS_FLAGS hex "Default nfs mount flags" default 0x0 help Mount flags.
config LIBNFS_OPTS string "Default nfs mount options" default "" help Usually a comma-separated list of additional mount options that are directly interpreted by the target filesystem. endif
if (mi->flags & MULTIBOOT_INFO_CMDLINE) { mi_cmdline = (char *)(__u64)mi->cmdline;
if (strlen(mi_cmdline) > sizeof(cmdline) - 1) uk_pr_err("Command line too long, truncated\n"); strncpy(cmdline, mi_cmdline, sizeof(cmdline)); } else { /* Use image name as cmdline to provide argv[0] */ uk_pr_debug("No command line present\n"); strncpy(cmdline, CONFIG_UK_NAME, sizeof(cmdline)); }
// lib/uklibparam/param.c structparam_args { /* Reference to the start of the library */ char *lib; /* Reference to the start of the parameter */ char *param; /* Reference to the start of the value */ char *value; /* length of the library name */ __u32 lib_len; /* length of the parameter */ __u32 param_len; /* length of the value */ __u32 value_len; };
structuk_param { /* The name of the param */ constchar *name; /* Type information for the param */ const __u8 param_type; /* Type information for the variable size param */ const __u8 param_size; /* Define a reference to location of the parameter */ __uptr addr; };
intuk_libparam_parse(constchar *progname, int argc, char **argv) { int keindex = 0; int rc = 0, cnt = 0, args_read, i; structparam_argspargs = {0}; structuk_lib_section *section =NULL; structuk_param *param =NULL; // 获取参数的数量 keindex = kernel_arg_range_fetch(argc, argv); // 遍历每一个参数 while (cnt < keindex) { args_read = 0; /* Fetch the argument from the input */ rc = kernel_arg_fetch(&argv[cnt], (keindex - cnt), &pargs, &args_read); cnt += args_read; /* Fetch library for the argument */ rc = kernel_lib_fetch(&pargs, §ion); /* Fetch the parameter for the argument */ rc = kernel_parse_arg(&pargs, section, ¶m); // 去除参数周围的引号 rc = kernel_value_sanitize(&pargs); // 将参数传给unikraft对应的全局变量 rc = kernel_args_set(&pargs, param); }
/* Replacing the -- with progname */ argv[keindex] = DECONST(char *, progname);