nshlib/nsh_fscmds.c: Add the -r option which can be used to specify the number of entries in the FAT12/FAT16 root directory.
This commit is contained in:
parent
b6410136b7
commit
2c2fc512d6
@ -745,7 +745,7 @@ o mkdir <path>
|
||||
drw-rw-rw- 0 TMP/
|
||||
nsh>
|
||||
|
||||
o mkfatfs [-F <fatsize>] <block-driver>
|
||||
o mkfatfs [-F <fatsize>] [-r <rootdirentries>] <block-driver>
|
||||
|
||||
Format a fat file system on the block device specified by <block-driver>
|
||||
path. The FAT size may be provided as an option. Without the <fatsize>
|
||||
@ -753,6 +753,14 @@ o mkfatfs [-F <fatsize>] <block-driver>
|
||||
historical reasons, if you want the FAT32 format, it must be explicitly
|
||||
specified on the command line.
|
||||
|
||||
The -r option may be specified to select the the number of entries in
|
||||
the root directory. Typical values for small volumes would be 112 or 224;
|
||||
512 should be used for large volumes, such as hard disks or very large
|
||||
SD cards. The default is 512 entries in all cases.
|
||||
|
||||
The reported number of root directory entries used with FAT32 is zero
|
||||
because the FAT32 root directory is a cluster chain.
|
||||
|
||||
NSH provides this command to access the mkfatfs() NuttX API.
|
||||
This block device must reside in the NuttX pseudo file system and
|
||||
must have been created by some call to register_blockdriver() (see
|
||||
|
@ -305,7 +305,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
||||
defined(CONFIG_FSUTILS_MKFATFS)
|
||||
# ifndef CONFIG_NSH_DISABLE_MKFATFS
|
||||
{ "mkfatfs", cmd_mkfatfs, 2, 4, "[-F <fatsize>] <block-driver>" },
|
||||
{ "mkfatfs", cmd_mkfatfs, 2, 6, "[-F <fatsize>] [-r <rootdirentries>] <block-driver>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -1220,7 +1220,7 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
/* mkfatfs [-F <fatsize>] <block-driver> */
|
||||
|
||||
badarg = false;
|
||||
while ((option = getopt(argc, argv, ":F:")) != ERROR)
|
||||
while ((option = getopt(argc, argv, ":F:r:")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@ -1234,6 +1234,15 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
fmt.ff_rootdirentries = atoi(optarg);
|
||||
if (fmt.ff_rootdirentries < 0)
|
||||
{
|
||||
nsh_output(vtbl, g_fmtargrange, argv[0]);
|
||||
badarg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ':':
|
||||
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||
badarg = true;
|
||||
|
Loading…
Reference in New Issue
Block a user