diff --git a/ChangeLog.txt b/ChangeLog.txt index bf5466233..8b43d785b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1459,4 +1459,5 @@ (2015-11-23). * apps/nshlib: Like bash, NSH set command should strip off any leading or trailing whitespace (2015-11-23). - + * apps/nshlib: The mount commands now accepts mount options (currently + needed only for the hostfs file system). From Ken Petit (2015-11-25). diff --git a/nshlib/README.txt b/nshlib/README.txt index e720ebf76..b91ad0cc3 100644 --- a/nshlib/README.txt +++ b/nshlib/README.txt @@ -701,7 +701,7 @@ o mkrd [-m ] [-s ] /tmp: nsh> -o mount [-t ] +o mount [-t [-o ] ] The mount command performs one of two different operations. If no parameters are provided on the command line after the mount command, diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index b8b08c60e..abaa4b10a 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -306,9 +306,9 @@ static const struct cmdmap_s g_cmdmap[] = #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) # ifndef CONFIG_NSH_DISABLE_MOUNT #if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) - { "mount", cmd_mount, 5, 5, "-t [] " }, + { "mount", cmd_mount, 5, 7, "-t [-o ] [] " }, # else - { "mount", cmd_mount, 1, 5, "[-t [] ]" }, + { "mount", cmd_mount, 1, 7, "[-t [-o ] [] ]" }, # endif # endif #endif diff --git a/nshlib/nsh_mntcmds.c b/nshlib/nsh_mntcmds.c index 10d341ca9..95aedbb55 100644 --- a/nshlib/nsh_mntcmds.c +++ b/nshlib/nsh_mntcmds.c @@ -151,6 +151,12 @@ static const char* get_fstype(FAR struct statfs *statbuf) break; #endif +#ifdef CONFIG_FS_HOSTFS + case HOSTFS_MAGIC: + fstype = "hostfs"; + break; +#endif + default: fstype = "Unrecognized"; break; @@ -339,6 +345,7 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) FAR const char *target; FAR char *fulltarget; FAR const char *filesystem = NULL; + FAR const char *options = NULL; bool badarg = false; int option; int ret; @@ -358,7 +365,7 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * logic just sets 'badarg' and continues. */ - while ((option = getopt(argc, argv, ":t:")) != ERROR) + while ((option = getopt(argc, argv, ":o:t:")) != ERROR) { switch (option) { @@ -366,6 +373,10 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) filesystem = optarg; break; + case 'o': + options = optarg; + break; + case ':': nsh_output(vtbl, g_fmtargrequired, argv[0]); badarg = true; @@ -451,7 +462,7 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /* Perform the mount */ - ret = mount(fullsource, fulltarget, filesystem, 0, NULL); + ret = mount(fullsource, fulltarget, filesystem, 0, options); if (ret < 0) { nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);