source: rtems/cpukit/libfs/src/imfs/imfs_creat.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  IMFS_create_node()
3 *
4 *  Routine to create a new in memory file system node.
5 *
6 *  COPYRIGHT (c) 1989-2010.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 */
13
14#if HAVE_CONFIG_H
15  #include "config.h"
16#endif
17
18#include "imfs.h"
19
20#include <stdlib.h>
21#include <string.h>
22
23IMFS_jnode_t *IMFS_allocate_node(
24  IMFS_fs_info_t *fs_info,
25  const IMFS_node_control *node_control,
26  const char *name,
27  size_t namelen,
28  mode_t mode,
29  const IMFS_types_union *info
30)
31{
32  IMFS_jnode_t        *node;
33  struct timeval       tv;
34
35  if ( namelen > IMFS_NAME_MAX ) {
36    errno = ENAMETOOLONG;
37
38    return NULL;
39  }
40
41  gettimeofday( &tv, 0 );
42
43  /*
44   *  Allocate an IMFS jnode
45   */
46  node = calloc( 1, sizeof( IMFS_jnode_t ) );
47  if ( !node ) {
48    errno = ENOMEM;
49
50    return NULL;
51  }
52
53  /*
54   *  Fill in the basic information
55   */
56  node->reference_count = 1;
57  node->st_nlink = 1;
58  memcpy( node->name, name, namelen );
59  node->name [namelen] = '\0';
60  node->control = node_control;
61
62  /*
63   *  Fill in the mode and permission information for the jnode structure.
64   */
65  node->st_mode = mode;
66  #if defined(RTEMS_POSIX_API)
67    node->st_uid = geteuid();
68    node->st_gid = getegid();
69  #else
70    node->st_uid = 0;
71    node->st_gid = 0;
72  #endif
73
74  /*
75   *  Now set all the times.
76   */
77
78  node->stat_atime  = (time_t) tv.tv_sec;
79  node->stat_mtime  = (time_t) tv.tv_sec;
80  node->stat_ctime  = (time_t) tv.tv_sec;
81  node->st_ino = ++fs_info->ino_count;
82
83  return (*node->control->node_initialize)( node, info );
84}
85
86/*
87 *  Create an IMFS filesystem node of an arbitrary type that is NOT
88 *  the root directory node.
89 */
90IMFS_jnode_t *IMFS_create_node_with_control(
91  const rtems_filesystem_location_info_t *parentloc,
92  const IMFS_node_control *node_control,
93  const char *name,
94  size_t namelen,
95  mode_t mode,
96  const IMFS_types_union *info
97)
98{
99  IMFS_fs_info_t *fs_info = parentloc->mt_entry->fs_info;
100  IMFS_jnode_t *node = IMFS_allocate_node(
101    fs_info,
102    node_control,
103    name,
104    namelen,
105    mode,
106    info
107  );
108
109  if ( node != NULL ) {
110    IMFS_jnode_t *parent = parentloc->node_access;
111
112    /*
113     *  This node MUST have a parent, so put it in that directory list.
114     */
115    IMFS_assert( parent != NULL );
116    IMFS_add_to_directory( parent, node );
117  }
118
119  return node;
120}
121
Note: See TracBrowser for help on using the repository browser.