source: rtems/c/src/libfs/src/imfs/imfs_link.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 23, 1998 at 7:07:58 PM

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • 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[ 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.