source: rtems/c/src/lib/libc/imfs_mknod.c @ 2782e69

4.104.114.84.95
Last change on this file since 2782e69 was ec2328ee, checked in by Jennifer Averett <Jennifer.Averett@…>, on 03/31/99 at 23:24:57

Removed asserts that shouldn't be called and commented case where this
indicates an internal error.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  IMFS_mknod
3 *
4 *  Routine to create a node in the IMFS file system.
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <errno.h>
22#include <stdlib.h>
23
24#include "imfs.h"
25#include "libio_.h"
26
27int IMFS_mknod(
28  const char                        *token,      /* IN */
29  mode_t                             mode,       /* IN */
30  dev_t                              dev,        /* IN */
31  rtems_filesystem_location_info_t  *pathloc     /* IN/OUT */
32)
33{
34  IMFS_token_types   type = 0;
35  IMFS_jnode_t      *new_node;
36  int                result;
37  char               new_name[ IMFS_NAME_MAX + 1 ];
38  IMFS_types_union   info;
39 
40  IMFS_get_token( token, new_name, &result );
41
42  /*
43   *  Figure out what type of IMFS node this is.
44   */
45
46  if ( S_ISDIR(mode) )
47    type = IMFS_DIRECTORY;
48  else if ( S_ISREG(mode) )
49    type = IMFS_MEMORY_FILE;
50  else if ( S_ISBLK(mode) || S_ISCHR(mode) ) {
51    type = IMFS_DEVICE;
52    rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
53  } else  {
54    set_errno_and_return_minus_one( EINVAL );
55  }
56 
57  /*
58   *  Allocate and fill in an IMFS jnode
59   */
60
61  new_node = IMFS_create_node(
62    pathloc,
63    type,
64    new_name,
65    mode,
66    &info
67  );
68
69  if ( !new_node )
70    set_errno_and_return_minus_one( ENOMEM );
71
72  return 0;
73}
74
Note: See TracBrowser for help on using the repository browser.