source: rtems/c/src/lib/libc/mknod.c @ 2782e69

4.104.114.84.95
Last change on this file since 2782e69 was dd0f326, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 19:10:46

Added rtems_filesystem_freenode() macro and added calls at appropriate
places to make sure memory allocated for filesystem specifif nodes
gets freed.

  • Property mode set to 100644
File size: 1.5 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    rtems_filesystem_freenode( &temp_loc );
57    set_errno_and_return_minus_one( ENOTSUP );
58  }
59
60  result =  (*temp_loc.ops->mknod)( name_start, mode, dev, &temp_loc );
61
62  rtems_filesystem_freenode( &temp_loc );
63
64  return result;
65}
Note: See TracBrowser for help on using the repository browser.