diff options
author | Chris Johns <chrisj@rtems.org> | 2010-02-19 03:23:11 +0000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2010-02-19 03:23:11 +0000 |
commit | cca94a248bd6ce791b34e9bf3a704b535df3e5ef (patch) | |
tree | 395109d3c6dffa253542ecb82be29e6e96cff2f6 /cpukit/libfs | |
parent | 2010-02-19 Chris Johns <chrisj@rtems.org> (diff) | |
download | rtems-cca94a248bd6ce791b34e9bf3a704b535df3e5ef.tar.bz2 |
2010-02-19 Chris Johns <chrisj@rtems.org>
* libblock/src/diskdevs.c: Create the devices as block devices.
* libmisc/shell/main_debugrfs.c, libmisc/shell/main_mkrfs.c,
libmisc/shell/main_mount_rfs.c: New.
* libmisc/shell/main_msdosfmt.c: Change the command to mkdos and
alias the old name.
* libmisc/shell/shellconfig.h, libmisc/Makefile.am: Add RFS
support.
* libfs/src/rfs/rtems-rfs-shell.c,
libfs/src/rfs/rtems-rfs-shell.h: Move the format command code into
the shell file.
Diffstat (limited to 'cpukit/libfs')
-rw-r--r-- | cpukit/libfs/src/rfs/rtems-rfs-shell.c | 93 | ||||
-rw-r--r-- | cpukit/libfs/src/rfs/rtems-rfs-shell.h | 11 |
2 files changed, 102 insertions, 2 deletions
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-shell.c b/cpukit/libfs/src/rfs/rtems-rfs-shell.c index b1d25c2c67..1bc979a1ea 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-shell.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-shell.c @@ -22,6 +22,7 @@ #include <rtems/rfs/rtems-rfs-group.h> #include <rtems/rfs/rtems-rfs-inode.h> #include <rtems/rfs/rtems-rfs-dir.h> +#include <rtems/rtems-rfs-format.h> #include <sys/statvfs.h> @@ -608,7 +609,7 @@ rtems_rfs_shell_usage (const char* arg) } int -rtems_rfs_shell_debugrfs (int argc, char *argv[]) +rtems_shell_debugrfs (int argc, char *argv[]) { const rtems_rfs_shell_cmd table[] = { @@ -664,3 +665,93 @@ rtems_rfs_shell_debugrfs (int argc, char *argv[]) return 1; } + +int +rtems_shell_rfs_format (int argc, char* argv[]) +{ + rtems_rfs_format_config config; + const char* driver = NULL; + int arg; + + memset (&config, 0, sizeof (rtems_rfs_format_config)); + + for (arg = 1; arg < argc; arg++) + { + if (argv[arg][0] == '-') + { + switch (argv[arg][1]) + { + case 'v': + config.verbose = true; + break; + + case 's': + arg++; + if (arg >= argc) + { + printf ("error: block size needs an argument\n"); + return 1; + } + config.block_size = strtoul (argv[arg], 0, 0); + break; + + case 'b': + arg++; + if (arg >= argc) + { + printf ("error: group block count needs an argument\n"); + return 1; + } + config.group_blocks = strtoul (argv[arg], 0, 0); + break; + + case 'i': + arg++; + if (arg >= argc) + { + printf ("error: group inode count needs an argument\n"); + return 1; + } + config.group_inodes = strtoul (argv[arg], 0, 0); + break; + + case 'I': + config.initialise_inodes = true; + break; + + case 'o': + arg++; + if (arg >= argc) + { + printf ("error: inode percentage overhead needs an argument\n"); + return 1; + } + config.inode_overhead = strtoul (argv[arg], 0, 0); + break; + + default: + printf ("error: invalid option: %s\n", argv[arg]); + return 1; + } + } + else + { + if (!driver) + driver = argv[arg]; + else + { + printf ("error: only one driver name allowed: %s\n", argv[arg]); + return 1; + } + } + } + + if (rtems_rfs_format (driver, &config) < 0) + { + printf ("error: format of %s failed: %s\n", + driver, strerror (errno)); + return 1; + } + + return 0; +} diff --git a/cpukit/libfs/src/rfs/rtems-rfs-shell.h b/cpukit/libfs/src/rfs/rtems-rfs-shell.h index 31a3dc8266..c07b7c3167 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-shell.h +++ b/cpukit/libfs/src/rfs/rtems-rfs-shell.h @@ -30,6 +30,15 @@ * @param argv The argument variables. * @return int The exit code for the command. A 0 is no error. */ -int rtems_rfs_shell_debugrfs (int argc, char *argv[]); +int rtems_shell_debugrfs (int argc, char *argv[]); + +/** + * The shell command for formatting an RFS file system. + * + * @param argc The argument count. + * @param argv The argument variables. + * @return int The exit code for the command. A 0 is no error. + */ +int rtems_shell_rfs_format (int argc, char* argv[]); #endif |