source: rtems/c/src/lib/libc/imfs_gtkn.c @ ee733965

4.104.114.84.95
Last change on this file since ee733965 was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  IMFS_get_token
3 *
4 *  Routine to get a token (name or separator) from the path
5 *  the length of the token is returned in token_len.
6 *
7 *  COPYRIGHT (c) 1989-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright assigned to U.S. Government, 1994.
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.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <stdlib.h>
19#include "imfs.h"
20#include "libio_.h"
21
22IMFS_token_types IMFS_get_token(
23  const char       *path,
24  char             *token,
25  int              *token_len
26)
27{
28  int               i = 0;
29  IMFS_token_types  type = IMFS_NAME;
30
31  /*
32   *  Copy a name into token.  (Remember NULL is a token.)
33   */
34
35  while ( !IMFS_is_separator( path[i] ) && (i <= NAME_MAX) ) {
36
37     token[i] = path[i];
38
39     if (i == NAME_MAX)
40       return IMFS_INVALID_TOKEN;
41
42     if ( !IMFS_is_valid_name_char( token[i] ) )
43       type = IMFS_INVALID_TOKEN;   
44
45     i++;
46  }
47
48  /*
49   *  Copy a seperator into token.
50   */
51
52  if ( i == 0 ) {
53    token[i] = path[i];
54
55    if ( token[i] != '\0' ) {
56      i++;
57      type = IMFS_CURRENT_DIR;
58    } else {
59      type = IMFS_NO_MORE_PATH;
60    }
61  } else if (token[ i-1 ] != '\0') {
62    token[i] = '\0';
63  }
64
65  /*
66   *  Set token_len to the number of characters copied.
67   */
68
69  *token_len = i;
70
71  /*
72   *  If we copied something that was not a seperator see if
73   *  it was a special name.
74   */
75
76  if ( type == IMFS_NAME ) {
77    if ( strcmp( token, "..") == 0 )
78      type = IMFS_UP_DIR;
79    else if ( strcmp( token, "." ) == 0 )
80      type = IMFS_CURRENT_DIR;
81  }
82
83  return type;
84}
Note: See TracBrowser for help on using the repository browser.