source: rtems/c/src/exec/libcsupport/src/mknod.c @ d71fcab

4.104.114.84.95
Last change on this file since d71fcab was d71fcab, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 18:44:40

Added call to freenod to let each filesystem free its own internal
node used to manage file access.

  • Property mode set to 100644
File size: 1.6 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-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  $Id$
17 */
18
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <fcntl.h>
22#include <unistd.h>
23#include <errno.h>
24#include <stdlib.h>
25
26#include "libio_.h"
27
28int mknod(
29  const char *pathname,
30  mode_t      mode,
31  dev_t       dev
32)
33{
34  rtems_filesystem_location_info_t    temp_loc;
35  int                                 i;
36  const char                         *name_start;
37  int                                 result;
38
39  if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) )
40    set_errno_and_return_minus_one( EINVAL );
41 
42  if ( S_ISFIFO(mode) )
43    set_errno_and_return_minus_one( ENOTSUP );
44
45  rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
46
47  result = (*temp_loc.ops->evalformake)(
48    &pathname[i],
49    &temp_loc,
50    &name_start
51  );
52  if ( result != 0 )
53    return -1;
54
55  if ( !temp_loc.ops->mknod ) {
56    if ( temp_loc.ops->freenod )
57      (*temp_loc.ops->freenod)( &temp_loc );
58    set_errno_and_return_minus_one( ENOTSUP );
59  }
60
61  result =  (*temp_loc.ops->mknod)( name_start, mode, dev, &temp_loc );
62  if ( temp_loc.ops->freenod )
63    (*temp_loc.ops->freenod)( &temp_loc );
64
65  return result;
66}
Note: See TracBrowser for help on using the repository browser.