source: rtems/c/src/lib/libc/mknod.c @ 72650fcb

4.104.114.84.95
Last change on this file since 72650fcb was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

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

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
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 *  $Id$
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
31int mknod(
32  const char *pathname,
33  mode_t      mode,
34  dev_t       dev
35)
36{
37  rtems_filesystem_location_info_t    temp_loc;
38  int                                 i;
39  const char                         *name_start;
40  int                                 result;
41
42  if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) )
43    set_errno_and_return_minus_one( EINVAL );
44 
45  if ( S_ISFIFO(mode) )
46    set_errno_and_return_minus_one( ENOTSUP );
47
48  rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
49
50  if ( !temp_loc.ops->evalformake_h ) {
51    rtems_filesystem_freenode( &temp_loc );
52    set_errno_and_return_minus_one( ENOTSUP );
53  }
54
55  result = (*temp_loc.ops->evalformake_h)(
56    &pathname[i],
57    &temp_loc,
58    &name_start
59  );
60  if ( result != 0 )
61    return -1;
62
63  if ( !temp_loc.ops->mknod_h ) {
64    rtems_filesystem_freenode( &temp_loc );
65    set_errno_and_return_minus_one( ENOTSUP );
66  }
67
68  result =  (*temp_loc.ops->mknod_h)( name_start, mode, dev, &temp_loc );
69
70  rtems_filesystem_freenode( &temp_loc );
71
72  return result;
73}
Note: See TracBrowser for help on using the repository browser.