nshlib: mount command no long uses the non-standard OS interface foreach_mountpoint(). No simply cats /proc/fs/mount when there are no arguments to the mount command.

This commit is contained in:
Gregory Nutt 2017-10-26 12:17:03 -06:00
parent a8bf5718f5
commit 20076688c2
2 changed files with 12 additions and 48 deletions

View File

@ -261,45 +261,6 @@ static int df_man_readable_handler(FAR const char *mountpoint,
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) &&
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_DF) */
/****************************************************************************
* Name: mount_handler
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static int mount_handler(FAR const char *mountpoint,
FAR struct statfs *statbuf, FAR void *arg)
{
FAR struct nsh_vtbl_s *vtbl = (FAR struct nsh_vtbl_s *)arg;
FAR const char *fstype;
DEBUGASSERT(mountpoint && statbuf && vtbl);
/* Get the file system type */
fstype = get_fstype(statbuf);
nsh_output(vtbl, " %s type %s\n", mountpoint, fstype);
return OK;
}
#endif
#endif
/****************************************************************************
* Name: mount_show
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static inline int mount_show(FAR struct nsh_vtbl_s *vtbl, FAR const char *progname)
{
return foreach_mountpoint(mount_handler, (FAR void *)vtbl);
}
#endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -350,19 +311,20 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
int option;
int ret;
/* The mount command behaves differently if no parameters are provided */
/* The mount command behaves differently if no parameters are provided. */
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
#ifdef NSH_HAVE_CATFILE
if (argc < 2)
{
return mount_show(vtbl, argv[0]);
return nsh_catfile(vtbl, argv[0],
CONFIG_NSH_PROC_MOUNTPOINT "/fs/mount");
}
#endif
/* Get the mount options. NOTE: getopt() is not thread safe nor re-entrant.
* To keep its state proper for the next usage, it is necessary to parse to
* the end of the line even if an error occurs. If an error occurs, this
* logic just sets 'badarg' and continues.
/* Get the mount options. NOTE: getopt() is not thread safe nor re-
* entrant. To keep its state proper for the next usage, it is necessary
* to parse to the end of the line even if an error occurs. If an error
* occurs, this logic just sets 'badarg' and continues.
*/
while ((option = getopt(argc, argv, ":o:t:")) != ERROR)

View File

@ -684,7 +684,8 @@ int cmd_route(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
if (!ipv6)
#endif
{
return nsh_catfile(vtbl, argv[0], "/proc/net/route/ipv4");
return nsh_catfile(vtbl, argv[0],
CONFIG_NSH_PROC_MOUNTPOINT "/net/route/ipv4");
}
#endif
@ -693,7 +694,8 @@ int cmd_route(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
else
#endif
{
return nsh_catfile(vtbl, argv[0], "/proc/net/route/ipv6");
return nsh_catfile(vtbl, argv[0],
CONFIG_NSH_PROC_MOUNTPOINT "/net/route/ipv6");
}
#endif