source: rtems/c/src/libfs/src/imfs/imfs_mknod.c @ 3cf8394

4.104.114.84.95
Last change on this file since 3cf8394 was 3cf8394, checked in by Joel Sherrill <joel.sherrill@…>, on 02/24/99 at 20:58:47

Changed IMFS to use IMFS_NAME_MAX as the maximum length of a basename
rather then NAME_MAX. NAME_MAX is 255 and that lets IMFS chew up memory
too fast. Perhaps in the future, the places in IMFS that put a maximum
length name string on the stack and the jnode structure does not include
a maximu length name string can be fixed so this is not a problem.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  IMFS_mknod
3 *
4 *  Routine to create a node in the IMFS file system.
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <errno.h>
22#include <stdlib.h>
23#include <assert.h>
24
25#include "imfs.h"
26#include "libio_.h"
27
28int IMFS_mknod(
29  const char                        *token,      /* IN */
30  mode_t                             mode,       /* IN */
31  dev_t                              dev,        /* IN */
32  rtems_filesystem_location_info_t  *pathloc     /* IN/OUT */
33)
34{
35  IMFS_token_types   type = 0;
36  IMFS_jnode_t      *new_node;
37  int                result;
38  char               new_name[ IMFS_NAME_MAX + 1 ];
39  IMFS_types_union   info;
40 
41  IMFS_get_token( token, new_name, &result );
42
43  /*
44   *  Figure out what type of IMFS node this is.
45   */
46
47  if ( S_ISDIR(mode) )
48    type = IMFS_DIRECTORY;
49  else if ( S_ISREG(mode) )
50    type = IMFS_MEMORY_FILE;
51  else if ( S_ISBLK(mode) || S_ISCHR(mode) ) {
52    type = IMFS_DEVICE;
53    rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
54  } else  {
55    assert( 0 );
56    set_errno_and_return_minus_one( EINVAL );
57  }
58 
59  /*
60   *  Allocate and fill in an IMFS jnode
61   */
62
63  new_node = IMFS_create_node(
64    pathloc,
65    type,
66    new_name,
67    mode,
68    &info
69  );
70
71  if ( !new_node )
72    set_errno_and_return_minus_one( ENOMEM );
73
74  return 0;
75}
76
Note: See TracBrowser for help on using the repository browser.