mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-17 15:32:21 +08:00
NSH: Extend mount command to include mount options argument. From Ken Petit
This commit is contained in:
@@ -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).
|
||||
|
@@ -701,7 +701,7 @@ o mkrd [-m <minor>] [-s <sector-size>] <nsectors>
|
||||
/tmp:
|
||||
nsh>
|
||||
|
||||
o mount [-t <fstype> <block-device> <dir-path>]
|
||||
o mount [-t <fstype> [-o <options>] <block-device> <dir-path>]
|
||||
|
||||
The mount command performs one of two different operations. If no
|
||||
parameters are provided on the command line after the mount command,
|
||||
|
@@ -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 <fstype> [<block-device>] <mount-point>" },
|
||||
{ "mount", cmd_mount, 5, 7, "-t <fstype> [-o <options>] [<block-device>] <mount-point>" },
|
||||
# else
|
||||
{ "mount", cmd_mount, 1, 5, "[-t <fstype> [<block-device>] <mount-point>]" },
|
||||
{ "mount", cmd_mount, 1, 7, "[-t <fstype> [-o <options>] [<block-device>] <mount-point>]" },
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user