source: rtems/cpukit/libfs/src/imfs/imfs_mknod.c @ d6b1d73

4.104.114.84.95
Last change on this file since d6b1d73 was d6b1d73, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/01 at 14:05:14

2001-01-22 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/imfs/config.h
  • src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/imfs/.cvsignore: Add config.h and stamp-h
  • src/imfs/*.c: Add config.h support.
  • 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-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.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <sys/types.h>
21#include <sys/stat.h>
22#include <fcntl.h>
23#include <unistd.h>
24#include <errno.h>
25#include <stdlib.h>
26
27#include "imfs.h"
28#include <rtems/libio_.h>
29
30int IMFS_mknod(
31  const char                        *token,      /* IN */
32  mode_t                             mode,       /* IN */
33  dev_t                              dev,        /* IN */
34  rtems_filesystem_location_info_t  *pathloc     /* IN/OUT */
35)
36{
37  IMFS_token_types   type = 0;
38  IMFS_jnode_t      *new_node;
39  int                result;
40  char               new_name[ IMFS_NAME_MAX + 1 ];
41  IMFS_types_union   info;
42 
43  IMFS_get_token( token, new_name, &result );
44
45  /*
46   *  Figure out what type of IMFS node this is.
47   */
48
49  if ( S_ISDIR(mode) )
50    type = IMFS_DIRECTORY;
51  else if ( S_ISREG(mode) )
52    type = IMFS_MEMORY_FILE;
53  else if ( S_ISBLK(mode) || S_ISCHR(mode) ) {
54    type = IMFS_DEVICE;
55    rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
56  } else  {
57    set_errno_and_return_minus_one( EINVAL );
58  }
59 
60  /*
61   *  Allocate and fill in an IMFS jnode
62   */
63
64  new_node = IMFS_create_node(
65    pathloc,
66    type,
67    new_name,
68    mode,
69    &info
70  );
71
72  if ( !new_node )
73    set_errno_and_return_minus_one( ENOMEM );
74
75  return 0;
76}
77
Note: See TracBrowser for help on using the repository browser.