source: rtems/cpukit/libcsupport/src/base_fs.c @ 7baa484

4.104.115
Last change on this file since 7baa484 was 7baa484, checked in by Chris Johns <chrisj@…>, on 06/12/09 at 01:53:33

2009-06-12 Chris Johns <chrisj@…>

  • libblock/src/bdbuf.c: Update comments.
  • libblock/src/bdpart.c, libblock/src/ide_part_table.c: Get the device from the rdev field of the stat buf.
  • libcsupport/include/rtems/libio.h: Add a path length to evalpath handler. Add parent locations to rmmod and unlink handlers.
  • libcsupport/include/rtems/libio_.h: Add a path length to rtems_filesystem_evaluate_path. Add rtems_filesystem_evaluate_relative_path, rtems_filesystem_dirname, and rtems_filesystem_prefix_separators. Remove rtems_filesystem_evaluate_parent.
  • libcsupport/src/base_fs.c, libcsupport/src/chdir.c, libcsupport/src/chmod.c, libcsupport/src/chown.c, libcsupport/src/chroot.c, libcsupport/src/fchdir.c, libcsupport/src/link.c, libcsupport/src/mount.c, libcsupport/src/open.c, libcsupport/src/privateenv.c, libcsupport/src/readlink.c, libcsupport/src/unmount.c, libcsupport/src/utime.c, libcsupport/src/unmount.c, libcsupport/src/utime.c, libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devstat.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_misc.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/ioman.c, libfs/src/pipe/pipe.c, libmisc/fsmount/fsmount.c, libnetworking/lib/ftpfs.c: Add the length parameter to the eval call.
  • libcsupport/src/eval.c: Add rtems_filesystem_prefix_separators, rtems_filesystem_dirname, rtems_filesystem_evaluate_relative_path. Add the length parameter to the eval call.
  • libcsupport/src/rmdir.c: Find the parent pathloc then the node pathloc from that node. Remove the call to find the parent given the node pathloc.
  • libcsupport/src/stat.c: Add the length parameter to the eval call. Set the device into the rdev field.
  • libcsupport/src/unlink.c: Find the parent pathloc then the node pathloc from that node. Remove the call to find the parent given the node pathloc.
  • libfs/src/dosfs/fat.c, libfs/src/dosfs/msdos_format.c: Get the disk device number from the stat rdev field.
  • libfs/src/dosfs/msdos.h: Add the length parameter to the eval call. Add the parent pathloc to the rmnod handler.
  • libfs/src/dosfs/msdos_dir.c: Add the parent pathloc to the rmnod handler.
  • libfs/src/dosfs/msdos_eval.c: Add the length parameter to the eval and token call.
  • libfs/src/imfs/imfs_directory.c: Add the parent pathloc to the rmnod handler.
  • libfs/src/imfs/imfs_fchmod.c: Do not test the mode flags for only the allowed flags. Add the missing flags spec'ed in the POSIX standard.
  • libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_rmnod.c, libfs/src/imfs/imfs_unlink.c, libfs/src/imfs/memfile.c: Add the parent node. Currently ignored in the IMFS.
  • libfs/src/imfs/imfs_stat.c: Return the device number in the rdev field.
  • libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_symlink.c : Add the length parameter to the token call.
  • libfs/src/nfsclient/src/nfs.c: Add the length parameter to the eval call and parent node to the rmnod and unlink command.
  • libmisc/shell/internal.h: Remove the libc mounter decl to make public.
  • libmisc/shell/main_mount.c: Add support for hooking external mount support for new file systems.
  • libmisc/shell/shell.h: Add helper functions for the mount command.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  Base file system initialization
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems.h>
19#include <rtems/libio.h>
20#include <rtems/libio_.h>
21
22/*
23 *  Default mode for created files.
24 */
25
26
27/*
28 *  rtems_filesystem_initialize
29 *
30 *  Initialize the foundation of the file system.  This is specified
31 *  by the structure rtems_filesystem_mount_table.  The usual
32 *  configuration is a single instantiation of the IMFS or miniIMFS with
33 *  a single "/dev" directory in it.
34 */
35
36void rtems_filesystem_initialize( void )
37{
38#if !defined(RTEMS_UNIX)
39  int                                   status;
40  rtems_filesystem_mount_table_entry_t *entry;
41  const rtems_filesystem_mount_table_t *mt;
42  rtems_filesystem_location_info_t      loc;
43
44  /*
45   *  Set the default umask to "022".
46   */
47
48  rtems_filesystem_umask = 022;
49
50
51  init_fs_mount_table();
52
53  /*
54   *  mount the first filesystem.
55   */
56
57  if ( rtems_filesystem_mount_table_size == 0 )
58    rtems_fatal_error_occurred( 0xABCD0001 );
59
60  mt = &rtems_filesystem_mount_table[0];
61
62  status = mount(
63     &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
64
65  if ( status == -1 )
66    rtems_fatal_error_occurred( 0xABCD0002 );
67
68  rtems_filesystem_link_counts = 0;
69
70  /* setup the 'current' and 'root' directories
71   *
72   * NOTE: cloning the pathlocs is not strictly
73   *       necessary. Since we implicitely let
74   *       all threads that don't call
75   *       libio_set_private_env() share the same
76   *       (initial) 'root' and 'current' locs,
77   *       we (also implicitely) assume that the
78   *       root filesystem doesn't care about
79   *       reference counts.
80   *       I just inserted the code snippet below
81   *       to remind everybody of the fact by
82   *       making it more explicit...
83   *       Ideally, every thread would have to
84   *       call either share_private_env() or
85   *       set_private_env() - but then: that's
86   *       gonna hit performance.
87   *
88   *       Till Straumann, 10/25/2002
89   */
90  rtems_filesystem_root        = entry->mt_fs_root;
91  /* Clone the root pathloc */
92  rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
93  rtems_filesystem_root        = loc;
94  /* One more clone for the current node */
95  rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
96  rtems_filesystem_current     = loc;
97
98  /* Note: the global_env's refcnt doesn't matter
99   * as the global env is never released
100   */
101
102
103  /*
104   *  Traditionally RTEMS devices are under "/dev" so install this directory.
105   *
106   *  If the mkdir() fails, we can't print anything so just fatal error.
107   *
108   *  NOTE: UNIX root is 755 and owned by root/root (0/0).  It is actually
109   *        created that way by the IMFS.
110   */
111
112  status = mkdir( "/dev", 0777);
113  if ( status != 0 )
114    rtems_fatal_error_occurred( 0xABCD0003 );
115
116  /*
117   *  You can't mount another filesystem properly until the mount point
118   *  it will be mounted onto is created.  Moreover, if it is going to
119   *  use a device, then it is REALLY unfair to attempt this
120   *  before device drivers are initialized.  So we return via a base
121   *  filesystem image and nothing auto-mounted at this point.
122   */
123
124#endif
125}
Note: See TracBrowser for help on using the repository browser.