source: rtems/c/src/lib/libc/link.c @ a68e6b9

4.104.114.84.95
Last change on this file since a68e6b9 was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

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.5 KB
Line 
1/*
2 *  link() - POSIX 1003.1b - 5.3.4 - Create a new link
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems.h>
16#include <rtems/libio.h>
17#include <errno.h>
18
19#include "libio_.h"
20
21int link(
22  const char *existing,
23  const char *new
24)
25{
26  rtems_filesystem_location_info_t    existing_loc;
27  rtems_filesystem_location_info_t    parent_loc;
28  int                                 i;
29  int                                 result;
30  const char                         *name_start;
31
32  /*
33   * Get the node we are linking to.
34   */
35  result = rtems_filesystem_evaluate_path( existing, 0, &existing_loc, TRUE );
36  if ( result != 0 )
37     return -1;
38
39  /*
40   * Get the parent of the node we are creating.
41   */
42
43  rtems_filesystem_get_start_loc( new, &i, &parent_loc );
44  result = (*parent_loc.ops->evalformake)( &new[i], &parent_loc, &name_start );
45  if ( result != 0 )
46     set_errno_and_return_minus_one( result );
47
48  /*
49   *  Check to see if the caller is trying to link across file system
50   *  boundaries.
51   */
52
53  if ( parent_loc.mt_entry != existing_loc.mt_entry )
54    set_errno_and_return_minus_one( EXDEV );
55
56  if ( !parent_loc.ops->link )
57    set_errno_and_return_minus_one( ENOTSUP );
58
59  return (*parent_loc.ops->link)( &existing_loc, &parent_loc, name_start );
60}
Note: See TracBrowser for help on using the repository browser.