source: rtems/c/src/lib/libc/imfs_link.c @ 6693a68

4.104.114.84.95
Last change on this file since 6693a68 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_link
3 *
4 *  The following rouine creates a new link node under parent with the
5 *  name given in name.  The link node is set to point to the node at
6 *  to_loc.
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 <errno.h>
20#include "imfs.h"
21#include "libio_.h"
22
23int IMFS_link(
24  rtems_filesystem_location_info_t  *to_loc,      /* IN */
25  rtems_filesystem_location_info_t  *parent_loc,  /* IN */
26  const char                        *token        /* IN */
27)
28{
29  IMFS_types_union   info;
30  IMFS_jnode_t      *new_node;
31  char               new_name[ IMFS_NAME_MAX + 1 ];
32  int                i;
33
34  /*
35   *  Verify this node can be linked to.
36   */
37
38  info.hard_link.link_node = to_loc->node_access;
39  if ( info.hard_link.link_node->st_nlink >= LINK_MAX )
40    set_errno_and_return_minus_one( EMLINK );
41 
42  /*
43   * Remove any separators at the end of the string.
44   */
45
46  IMFS_get_token( token, new_name, &i );
47
48  /*
49   *  Create a new link node.
50   */
51
52  new_node = IMFS_create_node(
53    parent_loc,
54    IMFS_HARD_LINK,
55    new_name,
56    ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
57    &info
58  );
59
60  if ( !new_node )
61    set_errno_and_return_minus_one( ENOMEM );
62
63  /*
64   * Increment the link count of the node being pointed to.
65   */
66
67  info.hard_link.link_node->st_nlink++;
68  IMFS_update_ctime( info.hard_link.link_node );
69
70  return 0;
71}
72
Note: See TracBrowser for help on using the repository browser.