Add the NSH df command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5007 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f5544c80cf
commit
5528942d9c
@ -268,3 +268,5 @@
|
|||||||
* apps/nshlib/nsh_mntcmds.c: Separated mount-related commands out of
|
* apps/nshlib/nsh_mntcmds.c: Separated mount-related commands out of
|
||||||
nsh_fscmds.c. Extended to the mount command so that if no arguments
|
nsh_fscmds.c. Extended to the mount command so that if no arguments
|
||||||
are provided, then the current mountpoints are enumerated.
|
are provided, then the current mountpoints are enumerated.
|
||||||
|
* apps/nshlib/nsh_mntcmds.c: Add an NSH df command to list the
|
||||||
|
properties of mounted file systems.
|
||||||
|
@ -308,6 +308,22 @@ o dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]
|
|||||||
brw-rw-rw- 0 ram0
|
brw-rw-rw- 0 ram0
|
||||||
nsh> dd if=/dev/ram0 of=/dev/null
|
nsh> dd if=/dev/ram0 of=/dev/null
|
||||||
|
|
||||||
|
o df
|
||||||
|
|
||||||
|
Show the state of each mounted volume
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
nsh> mount
|
||||||
|
/etc type romfs
|
||||||
|
/tmp type vfat
|
||||||
|
nsh> df
|
||||||
|
Block Number
|
||||||
|
Size Blocks Used Available Mounted on
|
||||||
|
64 6 6 0 /etc
|
||||||
|
512 985 2 983 /tmp
|
||||||
|
nsh>
|
||||||
|
|
||||||
o echo [<string|$name> [<string|$name>...]]
|
o echo [<string|$name> [<string|$name>...]]
|
||||||
|
|
||||||
Copy the sequence of strings and expanded environment variables to
|
Copy the sequence of strings and expanded environment variables to
|
||||||
@ -808,6 +824,7 @@ Command Dependencies on Configuration Settings
|
|||||||
cd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
|
cd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
cp CONFIG_NFILE_DESCRIPTORS > 0
|
cp CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
dd CONFIG_NFILE_DESCRIPTORS > 0
|
dd CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
df !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3)
|
||||||
echo --
|
echo --
|
||||||
exec --
|
exec --
|
||||||
exit --
|
exit --
|
||||||
@ -858,18 +875,19 @@ settings. All of these settings make the configuration of NSH potentially compl
|
|||||||
also allow it to squeeze into very small memory footprints.
|
also allow it to squeeze into very small memory footprints.
|
||||||
|
|
||||||
CONFIG_NSH_DISABLE_CAT, CONFIG_NSH_DISABLE_CD, CONFIG_NSH_DISABLE_CP,
|
CONFIG_NSH_DISABLE_CAT, CONFIG_NSH_DISABLE_CD, CONFIG_NSH_DISABLE_CP,
|
||||||
CONFIG_NSH_DISABLE_DD, CONFIG_NSH_DISABLE_ECHO, CONFIG_NSH_DISABLE_EXEC,
|
CONFIG_NSH_DISABLE_DD, CONFIG_NSH_DISABLE_DF, CONFIG_NSH_DISABLE_ECHO,
|
||||||
CONFIG_NSH_DISABLE_EXIT, CONFIG_NSH_DISABLE_FREE, CONFIG_NSH_DISABLE_GET,
|
CONFIG_NSH_DISABLE_EXEC, CONFIG_NSH_DISABLE_EXIT, CONFIG_NSH_DISABLE_FREE,
|
||||||
CONFIG_NSH_DISABLE_HELP, CONFIG_NSH_DISABLE_IFCONFIG, CONFIG_NSH_DISABLE_KILL,
|
CONFIG_NSH_DISABLE_GET, CONFIG_NSH_DISABLE_HELP, CONFIG_NSH_DISABLE_IFCONFIG,
|
||||||
CONFIG_NSH_DISABLE_LOSETUP, CONFIG_NSH_DISABLE_LS, CONFIG_NSH_DISABLE_MB,
|
CONFIG_NSH_DISABLE_KILL, CONFIG_NSH_DISABLE_LOSETUP, CONFIG_NSH_DISABLE_LS,
|
||||||
CONFIG_NSH_DISABLE_MKDIR, CONFIG_NSH_DISABLE_MKFATFS, CONFIG_NSH_DISABLE_MKFIFO,
|
CONFIG_NSH_DISABLE_MB, CONFIG_NSH_DISABLE_MKDIR, CONFIG_NSH_DISABLE_MKFATFS,
|
||||||
CONFIG_NSH_DISABLE_MKRD, CONFIG_NSH_DISABLE_MH, CONFIG_NSH_DISABLE_MOUNT,
|
CONFIG_NSH_DISABLE_MKFIFO, CONFIG_NSH_DISABLE_MKRD, CONFIG_NSH_DISABLE_MH,
|
||||||
CONFIG_NSH_DISABLE_MW, CONFIG_NSH_DISABLE_MV, CONFIG_NSH_DISABLE_NFSMOUNT,
|
CONFIG_NSH_DISABLE_MOUNT, CONFIG_NSH_DISABLE_MW, CONFIG_NSH_DISABLE_MV,
|
||||||
CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PING, CONFIG_NSH_DISABLE_PUT,
|
CONFIG_NSH_DISABLE_NFSMOUNT, CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PING,
|
||||||
CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RMDIR,
|
CONFIG_NSH_DISABLE_PUT, CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_RM,
|
||||||
CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SLEEP,
|
CONFIG_NSH_DISABLE_RMDIR, CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH,
|
||||||
CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT, CONFIG_NSH_DISABLE_UNSET,
|
CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT,
|
||||||
CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD
|
CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET,
|
||||||
|
CONFIG_NSH_DISABLE_XD
|
||||||
|
|
||||||
NSH-Specific Configuration Settings
|
NSH-Specific Configuration Settings
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -508,6 +508,9 @@ void nsh_usbtrace(void);
|
|||||||
int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
# endif
|
# endif
|
||||||
# ifdef CONFIG_FS_READABLE
|
# ifdef CONFIG_FS_READABLE
|
||||||
|
# ifndef CONFIG_NSH_DISABLE_DF
|
||||||
|
int cmd_df(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
# endif
|
||||||
# ifndef CONFIG_NSH_DISABLE_MOUNT
|
# ifndef CONFIG_NSH_DISABLE_MOUNT
|
||||||
int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
# endif
|
# endif
|
||||||
|
@ -76,12 +76,34 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: df_handler
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
|
||||||
|
static int df_handler(FAR const char *mountpoint,
|
||||||
|
FAR struct statfs *statbuf, FAR void *arg)
|
||||||
|
{
|
||||||
|
FAR struct nsh_vtbl_s *vtbl = (FAR struct nsh_vtbl_s *)arg;
|
||||||
|
|
||||||
|
DEBUGASSERT(mountpoint && statbuf && vtbl);
|
||||||
|
|
||||||
|
nsh_output(vtbl, "%6ld %8ld %8ld %8ld %s\n",
|
||||||
|
statbuf->f_bsize, statbuf->f_blocks,
|
||||||
|
statbuf->f_blocks - statbuf->f_bavail, statbuf->f_bavail,
|
||||||
|
mountpoint);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mount_handler
|
* Name: mount_handler
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
#ifndef CONFIG_NSH_DISABLE_MOUNT
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
|
||||||
static int mount_handler(FAR const char *mountpoint,
|
static int mount_handler(FAR const char *mountpoint,
|
||||||
FAR struct statfs *statbuf, FAR void *arg)
|
FAR struct statfs *statbuf, FAR void *arg)
|
||||||
{
|
{
|
||||||
@ -133,31 +155,44 @@ static int mount_handler(FAR const char *mountpoint,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mount_show
|
* Name: mount_show
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
#ifndef CONFIG_NSH_DISABLE_MOUNT
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
|
||||||
static inline int mount_show(FAR struct nsh_vtbl_s *vtbl, FAR const char *progname)
|
static inline int mount_show(FAR struct nsh_vtbl_s *vtbl, FAR const char *progname)
|
||||||
{
|
{
|
||||||
return foreach_mountpoint(mount_handler, (FAR void *)vtbl);
|
return foreach_mountpoint(mount_handler, (FAR void *)vtbl);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cmd_df
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_DF)
|
||||||
|
int cmd_df(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, " Block Number\n");
|
||||||
|
nsh_output(vtbl, " Size Blocks Used Available Mounted on\n");
|
||||||
|
|
||||||
|
return foreach_mountpoint(df_handler, (FAR void *)vtbl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_mount
|
* Name: cmd_mount
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
#ifndef CONFIG_NSH_DISABLE_MOUNT
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
|
||||||
int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *source;
|
char *source;
|
||||||
@ -247,15 +282,13 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_nfsmount
|
* Name: cmd_nfsmount
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
defined(CONFIG_NET) && defined(CONFIG_NFS)
|
defined(CONFIG_NET) && defined(CONFIG_NFS) && !defined(CONFIG_NSH_DISABLE_NFSMOUNT)
|
||||||
#ifndef CONFIG_NSH_DISABLE_NFSMOUNT
|
|
||||||
int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct nfs_args data;
|
struct nfs_args data;
|
||||||
@ -354,14 +387,13 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_umount
|
* Name: cmd_umount
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
#ifndef CONFIG_NSH_DISABLE_UMOUNT
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_UMOUNT)
|
||||||
int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *fullpath = nsh_getfullpath(vtbl, argv[1]);
|
char *fullpath = nsh_getfullpath(vtbl, argv[1]);
|
||||||
@ -378,7 +410,7 @@ int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
nsh_freefullpath(fullpath);
|
nsh_freefullpath(fullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -163,13 +163,18 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
{ "date", cmd_date, 1, 3, "[-s \"MMM DD HH:MM:SS YYYY\"]" },
|
{ "date", cmd_date, 1, 3, "[-s \"MMM DD HH:MM:SS YYYY\"]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_NSH_DISABLE_DD)
|
||||||
# ifndef CONFIG_NSH_DISABLE_DD
|
|
||||||
{ "dd", cmd_dd, 3, 6, "if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]" },
|
{ "dd", cmd_dd, 3, 6, "if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]" },
|
||||||
# endif
|
# endif
|
||||||
# if defined(CONFIG_SYSLOG) && defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && \
|
||||||
|
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_DF)
|
||||||
|
{ "df", cmd_df, 1, 1, NULL },
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SYSLOG) && \
|
||||||
|
defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
|
||||||
{ "dmesg", cmd_dmesg, 1, 1, NULL },
|
{ "dmesg", cmd_dmesg, 1, 1, NULL },
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_DISABLE_ECHO
|
#ifndef CONFIG_NSH_DISABLE_ECHO
|
||||||
|
Loading…
Reference in New Issue
Block a user