source: rtems/c/src/exec/libfs/src/imfs/imfs_link.c @ d6b1d73

4.104.114.84.95
Last change on this file since d6b1d73 was d6b1d73, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/01 at 14:05:14

2001-01-22 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/imfs/config.h
  • src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/imfs/.cvsignore: Add config.h and stamp-h
  • src/imfs/*.c: Add config.h support.
  • 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-1999.
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
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <errno.h>
23#include "imfs.h"
24#include <rtems/libio_.h>
25
26int IMFS_link(
27  rtems_filesystem_location_info_t  *to_loc,      /* IN */
28  rtems_filesystem_location_info_t  *parent_loc,  /* IN */
29  const char                        *token        /* IN */
30)
31{
32  IMFS_types_union   info;
33  IMFS_jnode_t      *new_node;
34  char               new_name[ IMFS_NAME_MAX + 1 ];
35  int                i;
36
37  /*
38   *  Verify this node can be linked to.
39   */
40
41  info.hard_link.link_node = to_loc->node_access;
42  if ( info.hard_link.link_node->st_nlink >= LINK_MAX )
43    set_errno_and_return_minus_one( EMLINK );
44 
45  /*
46   * Remove any separators at the end of the string.
47   */
48
49  IMFS_get_token( token, new_name, &i );
50
51  /*
52   *  Create a new link node.
53   */
54
55  new_node = IMFS_create_node(
56    parent_loc,
57    IMFS_HARD_LINK,
58    new_name,
59    ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
60    &info
61  );
62
63  if ( !new_node )
64    set_errno_and_return_minus_one( ENOMEM );
65
66  /*
67   * Increment the link count of the node being pointed to.
68   */
69
70  info.hard_link.link_node->st_nlink++;
71  IMFS_update_ctime( info.hard_link.link_node );
72
73  return 0;
74}
75
Note: See TracBrowser for help on using the repository browser.