OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [imfs_mknod.c] - Blame information for rev 228

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: imfs_mknod.c,v 1.2 2001-09-27 12:01:15 chris Exp $
14
 */
15
 
16
#include <sys/types.h>
17
#include <sys/stat.h>
18
#include <fcntl.h>
19
#include <unistd.h>
20
#include <errno.h>
21
#include <stdlib.h>
22
 
23
#include "imfs.h"
24
#include "libio_.h"
25
 
26
int IMFS_mknod(
27
  const char                        *token,      /* IN */
28
  mode_t                             mode,       /* IN */
29
  dev_t                              dev,        /* IN */
30
  rtems_filesystem_location_info_t  *pathloc     /* IN/OUT */
31
)
32
{
33
  IMFS_token_types   type = 0;
34
  IMFS_jnode_t      *new_node;
35
  int                result;
36
  char               new_name[ IMFS_NAME_MAX + 1 ];
37
  IMFS_types_union   info;
38
 
39
  IMFS_get_token( token, new_name, &result );
40
 
41
  /*
42
   *  Figure out what type of IMFS node this is.
43
   */
44
 
45
  if ( S_ISDIR(mode) )
46
    type = IMFS_DIRECTORY;
47
  else if ( S_ISREG(mode) )
48
    type = IMFS_MEMORY_FILE;
49
  else if ( S_ISBLK(mode) || S_ISCHR(mode) ) {
50
    type = IMFS_DEVICE;
51
    rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
52
  } else  {
53
    set_errno_and_return_minus_one( EINVAL );
54
  }
55
 
56
  /*
57
   *  Allocate and fill in an IMFS jnode
58
   */
59
 
60
  new_node = IMFS_create_node(
61
    pathloc,
62
    type,
63
    new_name,
64
    mode,
65
    &info
66
  );
67
 
68
  if ( !new_node )
69
    set_errno_and_return_minus_one( ENOMEM );
70
 
71
  return 0;
72
}
73
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.