source: rtems/cpukit/libmisc/shell/main_mount.c @ 955a34b5

4.10
Last change on this file since 955a34b5 was 955a34b5, checked in by Sebastian Huber <sebastian.huber@…>, on 07/01/10 at 15:18:06

2010-07-01 Sebastian Huber <sebastian.huber@…>

  • libcsupport/include/rtems/libio_.h: Removed rtems_filesystem_mount_table_control.
  • libcsupport/include/rtems/libio.h, libcsupport/src/mount-mgr.c, libcsupport/src/mount.c libcsupport/src/statvfs.c, libcsupport/src/unmount.c, libmisc/shell/main_mount.c: Documentation. Removed rtems_filesystem_mounts_first() and rtems_filesystem_mounts_next(). Added rtems_filesystem_mount_iterate(). Changed return type of rtems_filesystem_iterate(). Removed rtems_filesystem_nodes_equal().

2010-07-01 Sebastian Huber <sebastian.huber@…>

  • libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/librtemsNfs.h: Renamed rtems_nfsfs_initialize() in rtems_nfs_initialize().
  • sapi/include/confdefs.h: Reflect changes above. Renamed *_miniIMFS in *_MINIIMFS. Renamed *_NFSFS in *_NFS.
  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[2eeb648c]1/*
2 *   Shell Command Implmentation
3 *
4 *  Author: Fernando RUIZ CASAS
5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <stdio.h>
20#include <unistd.h>
21#include <string.h>
22#include <errno.h>
23
24#include <rtems.h>
25#include <rtems/shell.h>
26#include <rtems/shellconfig.h>
[29e92b0]27#include <rtems/libio.h>
[2eeb648c]28#include "internal.h"
29
[00bf6744]30static bool print_filesystem(const rtems_filesystem_table_t *entry, void *arg)
31{
32  printf("%s ", entry->type);
33
[955a34b5]34  return false;
[00bf6744]35}
36
[dfe0e58]37int rtems_shell_main_mount(
38  int   argc,
39  char *argv[]
40)
[2eeb648c]41{
42  rtems_filesystem_options_t options = RTEMS_FILESYSTEM_READ_WRITE;
[29e92b0]43  char*                      type = NULL;
44  char*                      source = NULL;
45  char*                      target = NULL;
46  char*                      fsoptions = NULL;
[2eeb648c]47  int                        arg;
[7baa484]48
[dfe0e58]49  for (arg = 1; arg < argc; arg++) {
50    if (argv[arg][0] == '-') {
51      if (argv[arg][1] == 't') {
[2eeb648c]52        arg++;
[dfe0e58]53        if (arg == argc) {
54          fprintf(
55            stderr,
56            "%s: -t needs a type of file-system;; see -L.\n",
57            argv[0]
58          );
[2eeb648c]59          return 1;
60        }
[29e92b0]61        type = argv[arg];
[dfe0e58]62      } else if (argv[arg][1] == 'r') {
[2eeb648c]63        options = RTEMS_FILESYSTEM_READ_ONLY;
[dfe0e58]64      } else if (argv[arg][1] == 'L') {
[29e92b0]65        printf ("File systems: ");
[00bf6744]66        rtems_filesystem_iterate(print_filesystem, NULL);
[29e92b0]67        printf ("\n");
68        return 0;
69      } else if (argv[arg][1] == 'o') {
70        arg++;
71        if (arg == argc) {
72          fprintf(
73            stderr,
74            "%s: -o needs a list if filesystem options.\n",
75            argv[0]
76          );
77          return 1;
78        }
79        fsoptions = argv[arg];
[dfe0e58]80      } else {
81        fprintf (stderr, "unknown option: %s\n", argv[arg]);
[2eeb648c]82        return 1;
83      }
[dfe0e58]84    } else {
[29e92b0]85      if (!source)
86        source = argv[arg];
87      else if (!target)
88        target = argv[arg];
[dfe0e58]89      else {
90        fprintf (
[29e92b0]91          stderr, "mount: source and mount only require: %s\n", argv[arg]);
[2eeb648c]92        return 1;
93      }
94    }
95  }
96
[29e92b0]97  if (!type) {
[dfe0e58]98    fprintf (stderr, "mount: no file-system; see the -L option\n");
[2eeb648c]99    return 1;
100  }
[0893220]101
[29e92b0]102  if (!source) {
103    fprintf (stderr, "mount: no source\n");
[2eeb648c]104    return 1;
105  }
[0893220]106
[29e92b0]107  if (!target) {
[dfe0e58]108    fprintf (stderr, "mount: no mount point\n");
[2eeb648c]109    return 1;
110  }
[0893220]111
[2eeb648c]112  /*
113   * Mount the disk.
114   */
[0893220]115
[29e92b0]116  if (mount (source, target, type, options, fsoptions) < 0) {
117    fprintf (stderr, "error: %s\n", strerror(errno));
[2eeb648c]118    return 1;
[29e92b0]119  }
[2eeb648c]120
[29e92b0]121  printf ("mounted %s -> %s\n", source, target);
[0893220]122
[2eeb648c]123  return 0;
124}
125
[55216fa]126rtems_shell_cmd_t rtems_shell_MOUNT_Command = {
[29e92b0]127  "mount",                                     /* name */
128  "mount [-t type] [-r] [-L] source target",   /* usage */
129  "files",                                     /* topic */
130  rtems_shell_main_mount,                      /* command */
131  NULL,                                        /* alias */
132  NULL                                         /* next */
[2eeb648c]133};
Note: See TracBrowser for help on using the repository browser.