source: rtems/cpukit/libfs/src/imfs/imfs_creat.c @ 72d2ec4d

4.104.114.95
Last change on this file since 72d2ec4d was 72d2ec4d, checked in by Chris Johns <chrisj@…>, on 07/03/08 at 01:37:38

2008-07-03 Chris Johns <chrisj@…>

  • cpukit/libcsupport/include/chain.h: Removed. Use the SAPI interface that is supported.
  • cpukit/libcsupport/Makefile.am, cpukit/libcsupport/preinstall.am: Remove chain.h header references.
  • cpukit/sapi/include/rtems/chain.h, cpukit/sapi/inline/rtems/chain.inl: New. A supported chains interface.
  • cpukit/sapi/Makefile.am, cpukit/sapi/preinstall.am: Updated to include the new chains interface.
  • cpukit/libfs/src/imfs/imfs.h, cpukit/libfs/src/imfs/imfs_creat.c, cpukit/libfs/src/imfs/imfs_debug.c, cpukit/libfs/src/imfs/imfs_directory.c, cpukit/libfs/src/imfs/imfs_fsunmount.c, cpukit/libfs/src/imfs/imfs_getchild.c, cpukit/libfs/src/imfs/imfs_load_tar.c, cpukit/libfs/src/imfs/imfs_rmnod.c, cpukit/libfs/src/imfs/memfile.c, cpukit/libfs/src/nfsclient/src/nfs.c, cpukit/libcsupport/include/rtems/libio.h, cpukit/libcsupport/src/malloc_deferred.c, cpukit/libcsupport/src/mount.c, cpukit/libcsupport/src/privateenv.c, cpukit/libcsupport/src/unmount.c: Change to the new chains interface.
  • cpukit/libcsupport/src/malloc_boundary.c: Remove warning.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  IMFS_create_node()
3 *
4 *  Routine to create a new in memory file system node.
5 *
6 *  COPYRIGHT (c) 1989-1999.
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 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <assert.h>
21#include <stdlib.h>
22#include <string.h>
23#include "imfs.h"
24#include <rtems/libio_.h>
25
26IMFS_jnode_t *IMFS_create_node(
27  rtems_filesystem_location_info_t *parent_loc,
28  IMFS_jnode_types_t                type,
29  const char                       *name,
30  mode_t                            mode,
31  const IMFS_types_union           *info
32)
33{
34  IMFS_jnode_t        *node;
35  struct timeval       tv;
36  IMFS_jnode_t        *parent = NULL;
37  IMFS_fs_info_t      *fs_info;
38
39  if ( parent_loc != NULL )
40    parent = parent_loc->node_access;
41
42  /*
43   *  Allocate an IMFS jnode
44   */
45
46  node = calloc( 1, sizeof( IMFS_jnode_t ) );
47  if ( !node )
48    return NULL;
49
50  /*
51   *  Fill in the basic information
52   */
53
54  node->st_nlink = 1;
55  node->type     = type;
56  strncpy( node->name, name, IMFS_NAME_MAX );
57
58  /*
59   *  Fill in the mode and permission information for the jnode structure.
60   */
61
62  node->st_mode = mode & ~rtems_filesystem_umask;
63
64#if defined(RTEMS_POSIX_API)
65  node->st_uid = geteuid();
66  node->st_gid = getegid();
67#else
68  node->st_uid = 0;
69  node->st_gid = 0;
70#endif
71
72  /*
73   *  Now set all the times.
74   */
75
76  gettimeofday( &tv, 0 );
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
82  /*
83   *  Set the type specific information
84   */
85
86  switch (type) {
87    case IMFS_DIRECTORY:
88      rtems_chain_initialize_empty(&node->info.directory.Entries);
89      break;
90
91    case IMFS_HARD_LINK:
92      node->info.hard_link.link_node = info->hard_link.link_node;
93      break;
94
95    case IMFS_SYM_LINK:
96      node->info.sym_link.name = info->sym_link.name;
97      break;
98
99    case IMFS_DEVICE:
100      node->info.device.major = info->device.major;
101      node->info.device.minor = info->device.minor;
102      break;
103
104    case IMFS_LINEAR_FILE:
105      node->info.linearfile.size      = 0;
106      node->info.linearfile.direct    = 0;
107
108    case IMFS_MEMORY_FILE:
109      node->info.file.size            = 0;
110      node->info.file.indirect        = 0;
111      node->info.file.doubly_indirect = 0;
112      node->info.file.triply_indirect = 0;
113      break;
114
115    default:
116      assert(0);
117      break;
118  }
119
120  /*
121   *  If this node has a parent, then put it in that directory list.
122   */
123
124  if ( parent ) {
125    rtems_chain_append( &parent->info.directory.Entries, &node->Node );
126    node->Parent = parent;
127
128    fs_info = parent_loc->mt_entry->fs_info;
129    node->st_ino = ++fs_info->ino_count;
130  }
131
132
133  return node;
134}
Note: See TracBrowser for help on using the repository browser.