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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [mknod.c] - Blame information for rev 1771

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

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  mknod()
3
 *
4
 *  This routine is not defined in the POSIX 1003.1b standard but is
5
 *  commonly supported on most UNIX and POSIX systems.  It is the
6
 *  foundation for creating file system objects.
7
 *
8
 *  COPYRIGHT (c) 1989-1999.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *
11
 *  The license and distribution terms for this file may be
12
 *  found in the file LICENSE in this distribution or at
13
 *  http://www.OARcorp.com/rtems/license.html.
14
 *
15
 *  mknod.c,v 1.10 2002/01/04 18:29:36 joel Exp
16
 */
17
 
18
#if HAVE_CONFIG_H
19
#include "config.h"
20
#endif
21
 
22
#include <sys/types.h>
23
#include <sys/stat.h>
24
#include <fcntl.h>
25
#include <unistd.h>
26
#include <errno.h>
27
#include <stdlib.h>
28
 
29
#include <rtems/libio_.h>
30
#include <rtems/seterr.h>
31
 
32
int mknod(
33
  const char *pathname,
34
  mode_t      mode,
35
  dev_t       dev
36
)
37
{
38
  rtems_filesystem_location_info_t    temp_loc;
39
  int                                 i;
40
  const char                         *name_start;
41
  int                                 result;
42
 
43
  if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) )
44
    rtems_set_errno_and_return_minus_one( EINVAL );
45
 
46
  if ( S_ISFIFO(mode) )
47
    rtems_set_errno_and_return_minus_one( ENOTSUP );
48
 
49
  rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
50
 
51
  if ( !temp_loc.ops->evalformake_h ) {
52
    rtems_filesystem_freenode( &temp_loc );
53
    rtems_set_errno_and_return_minus_one( ENOTSUP );
54
  }
55
 
56
  result = (*temp_loc.ops->evalformake_h)(
57
    &pathname[i],
58
    &temp_loc,
59
    &name_start
60
  );
61
  if ( result != 0 )
62
    return -1;
63
 
64
  if ( !temp_loc.ops->mknod_h ) {
65
    rtems_filesystem_freenode( &temp_loc );
66
    rtems_set_errno_and_return_minus_one( ENOTSUP );
67
  }
68
 
69
  result =  (*temp_loc.ops->mknod_h)( name_start, mode, dev, &temp_loc );
70
 
71
  rtems_filesystem_freenode( &temp_loc );
72
 
73
  return result;
74
}

powered by: WebSVN 2.1.0

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