source: rtems/cpukit/libmisc/shell/main_mount.c @ 55d883d

4.104.115
Last change on this file since 55d883d was 29e92b0, checked in by Chris Johns <chrisj@…>, on 05/31/10 at 13:56:37

2010-05-31 Chris Johns <chrisj@…>

  • libcsupport/Makefile.am: Add mount-mgr.c.
  • libcsupport/src/mount-mgr.c: New.
  • include/rtems/fs.h: Added rtems_filesystem_location_mount.
  • libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New mount interface. It is similar to Linux.
  • libcsupport/include/rtems/libio_.h: Remove the init_fs_mount_table call.
  • libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use the new mount call. Remove setting the root node in the global pathloc. Mount does this now.
  • libcsupport/src/privateenv.c: Remove the hack to set the root mount table entry in the environment.
  • libcsupport/src/unmount.cL Free the target string.
  • libblock/src/bdpart-mount.c: New mount API.
  • libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c, libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/miniimfs_init.c, libfs/src/nfsclient/src/librtemsNfs.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h, libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h, libnetworking/rtems/tftp.h: New mount_h API.
  • libfs/src/devfs/devfs_eval.c: Local include of extern ops.
  • libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount me call and fixed the initialisation to happen when mounting.
  • libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount filesystem files.
  • libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to the new mount table values.
  • libmisc/shell/main_mount_ftp.c, libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c, libmisc/shell/main_mount_tftp.c: Removed.
  • libmisc/shell/main_mount.c: Use the new mount API. Also access the file system table for the file system types.
  • libnetworking/lib/tftpDriver.c: Updated to the new mount API. Fixed to allow mounting from any mount point. Also can now have more than file system mounted.
  • sapi/include/confdefs.h: Add file system configuration support.
  • Property mode set to 100644
File size: 3.1 KB
Line 
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>
27#include <rtems/libio.h>
28#include "internal.h"
29
30int rtems_shell_main_mount(
31  int   argc,
32  char *argv[]
33)
34{
35  rtems_filesystem_options_t options = RTEMS_FILESYSTEM_READ_WRITE;
36  char*                      type = NULL;
37  char*                      source = NULL;
38  char*                      target = NULL;
39  char*                      fsoptions = NULL;
40  int                        arg;
41
42  for (arg = 1; arg < argc; arg++) {
43    if (argv[arg][0] == '-') {
44      if (argv[arg][1] == 't') {
45        arg++;
46        if (arg == argc) {
47          fprintf(
48            stderr,
49            "%s: -t needs a type of file-system;; see -L.\n",
50            argv[0]
51          );
52          return 1;
53        }
54        type = argv[arg];
55      } else if (argv[arg][1] == 'r') {
56        options = RTEMS_FILESYSTEM_READ_ONLY;
57      } else if (argv[arg][1] == 'L') {
58        const rtems_filesystem_table_t* fs;
59        fs = rtems_filesystem_table_first();
60        printf ("File systems: ");
61        while (fs) {
62          printf ("%s ", fs->type);
63          fs = rtems_filesystem_table_next(fs);
64        }
65        printf ("\n");
66        return 0;
67      } else if (argv[arg][1] == 'o') {
68        arg++;
69        if (arg == argc) {
70          fprintf(
71            stderr,
72            "%s: -o needs a list if filesystem options.\n",
73            argv[0]
74          );
75          return 1;
76        }
77        fsoptions = argv[arg];
78      } else {
79        fprintf (stderr, "unknown option: %s\n", argv[arg]);
80        return 1;
81      }
82    } else {
83      if (!source)
84        source = argv[arg];
85      else if (!target)
86        target = argv[arg];
87      else {
88        fprintf (
89          stderr, "mount: source and mount only require: %s\n", argv[arg]);
90        return 1;
91      }
92    }
93  }
94
95  if (!type) {
96    fprintf (stderr, "mount: no file-system; see the -L option\n");
97    return 1;
98  }
99
100  if (!source) {
101    fprintf (stderr, "mount: no source\n");
102    return 1;
103  }
104
105  if (!target) {
106    fprintf (stderr, "mount: no mount point\n");
107    return 1;
108  }
109
110  /*
111   * Mount the disk.
112   */
113
114  if (mount (source, target, type, options, fsoptions) < 0) {
115    fprintf (stderr, "error: %s\n", strerror(errno));
116    return 1;
117  }
118
119  printf ("mounted %s -> %s\n", source, target);
120
121  return 0;
122}
123
124rtems_shell_cmd_t rtems_shell_MOUNT_Command = {
125  "mount",                                     /* name */
126  "mount [-t type] [-r] [-L] source target",   /* usage */
127  "files",                                     /* topic */
128  rtems_shell_main_mount,                      /* command */
129  NULL,                                        /* alias */
130  NULL                                         /* next */
131};
Note: See TracBrowser for help on using the repository browser.