source: rtems/cpukit/libfs/src/imfs/ioman.c @ 3b7c123

4.115
Last change on this file since 3b7c123 was 3b7c123, checked in by Sebastian Huber <sebastian.huber@…>, on 03/13/12 at 10:33:51

Filesystem: Reference counting for locations

o A new data structure rtems_filesystem_global_location_t was

introduced to be used for

o the mount point location in the mount table entry,
o the file system root location in the mount table entry,
o the root directory location in the user environment, and
o the current directory location in the user environment.

During the path evaluation global start locations are obtained to
ensure that the current file system instance will be not unmounted in
the meantime.

o The user environment uses now reference counting and is protected

from concurrent access.

o The path evaluation process was completely rewritten and simplified.

The IMFS, RFS, NFS, and DOSFS use now a generic path evaluation
method. Recursive calls in the path evaluation have been replaced
with iteration to avoid stack overflows. Only the evaluation of
symbolic links is recursive. No dynamic memory allocations and
intermediate buffers are used in the high level path evaluation. No
global locks are held during the file system instance specific path
evaluation process.

o Recursive symbolic link evaluation is now limited by

RTEMS_FILESYSTEM_SYMLOOP_MAX. Applications can retrieve this value
via sysconf().

o The device file system (devFS) uses now no global variables and

allocation from the workspace. Node names are allocated from the
heap.

o The upper layer lseek() performs now some parameter checks.
o The upper layer ftruncate() performs now some parameter checks.
o unmask() is now restricted to the RWX flags and protected from

concurrent access.

o The fchmod_h and rmnod_h file system node handlers are now a file

system operation.

o The unlink_h operation has been removed. All nodes are now destroyed

with the rmnod_h operation.

o New lock_h, unlock_h, clonenod_h, and are_nodes_equal_h file system

operations.

o The path evaluation and file system operations are now protected by

per file system instance lock and unlock operations.

o Fix and test file descriptor duplicate in fcntl().
o New test fstests/fsnofs01.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  This file emulates the old Classic RTEMS IO manager directives
3 *  which register and lookup names using the in-memory filesystem.
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  Modifications to support reference counting in the file system are
9 *  Copyright (c) 2012 embedded brains GmbH.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#if HAVE_CONFIG_H
19  #include "config.h"
20#endif
21
22#include <sys/stat.h>
23#include <string.h>
24
25#include <rtems/libio_.h>
26
27/*
28 *  rtems_io_register_name
29 *
30 *  This assumes that all registered devices are character devices.
31 */
32
33rtems_status_code rtems_io_register_name(
34  const char                *device_name,
35  rtems_device_major_number  major,
36  rtems_device_minor_number  minor
37)
38{
39  int    status;
40  dev_t  dev;
41
42  dev = rtems_filesystem_make_dev_t( major, minor );
43  status = mknod( device_name, 0777 | S_IFCHR, dev );
44
45  /* this is the only error returned by the old version */
46  if ( status )
47    return RTEMS_TOO_MANY;
48
49  return RTEMS_SUCCESSFUL;
50}
51
52rtems_status_code rtems_io_lookup_name(
53  const char           *name,
54  rtems_driver_name_t  *device_info
55)
56{
57  rtems_status_code sc = RTEMS_SUCCESSFUL;
58  struct stat st;
59  int rv = stat( name, &st );
60
61  if ( rv == 0 && S_ISCHR( st.st_mode ) ) {
62    device_info->device_name = name;
63    device_info->device_name_length = strlen( name );
64    device_info->major = rtems_filesystem_dev_major_t( st.st_rdev );
65    device_info->minor = rtems_filesystem_dev_minor_t( st.st_rdev );
66  } else {
67    sc = RTEMS_UNSATISFIED;
68  }
69
70  return sc;
71}
Note: See TracBrowser for help on using the repository browser.