source: rtems/cpukit/libcsupport/src/mknod.c @ bf61751c

4.104.114.84.95
Last change on this file since bf61751c was bf61751c, checked in by Jennifer Averett <Jennifer.Averett@…>, on 10/23/02 at 18:10:27

2002-10-23 <strauman@…>

  • src/mount.c per PR290, add check for ops->node_type_h
  • src/mknod.c per PR291, remove erroneous call to freenod
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[07a3253d]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 *
[08311cc3]8 *  COPYRIGHT (c) 1989-1999.
[07a3253d]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
[9c49db4]18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
[07a3253d]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
[3ba74c73]29#include <rtems/libio_.h>
[a02224e]30#include <rtems/seterr.h>
[07a3253d]31
32int 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) ) )
[a02224e]44    rtems_set_errno_and_return_minus_one( EINVAL );
[07a3253d]45 
46  if ( S_ISFIFO(mode) )
[a02224e]47    rtems_set_errno_and_return_minus_one( ENOTSUP );
[07a3253d]48
49  rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
50
[9c3fa30]51  if ( !temp_loc.ops->evalformake_h ) {
[a02224e]52    rtems_set_errno_and_return_minus_one( ENOTSUP );
[dd19c0b]53  }
54
[9c3fa30]55  result = (*temp_loc.ops->evalformake_h)(
[07a3253d]56    &pathname[i],
57    &temp_loc,
58    &name_start
59  );
60  if ( result != 0 )
61    return -1;
62
[9c3fa30]63  if ( !temp_loc.ops->mknod_h ) {
[dd0f326]64    rtems_filesystem_freenode( &temp_loc );
[a02224e]65    rtems_set_errno_and_return_minus_one( ENOTSUP );
[d71fcab]66  }
[07a3253d]67
[9c3fa30]68  result =  (*temp_loc.ops->mknod_h)( name_start, mode, dev, &temp_loc );
[dd0f326]69
70  rtems_filesystem_freenode( &temp_loc );
[d71fcab]71
72  return result;
[07a3253d]73}
Note: See TracBrowser for help on using the repository browser.