OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [link.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  link() - POSIX 1003.1b - 5.3.4 - Create a new link
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  link.c,v 1.11 2002/01/04 18:29:36 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <rtems.h>
19
#include <rtems/libio.h>
20
#include <errno.h>
21
 
22
#include <rtems/libio_.h>
23
#include <rtems/seterr.h>
24
 
25
int link(
26
  const char *existing,
27
  const char *new
28
)
29
{
30
  rtems_filesystem_location_info_t    existing_loc;
31
  rtems_filesystem_location_info_t    parent_loc;
32
  int                                 i;
33
  int                                 result;
34
  const char                         *name_start;
35
 
36
  /*
37
   * Get the node we are linking to.
38
   */
39
 
40
  result = rtems_filesystem_evaluate_path( existing, 0, &existing_loc, TRUE );
41
  if ( result != 0 )
42
     return -1;
43
 
44
  /*
45
   * Get the parent of the node we are creating.
46
   */
47
 
48
  rtems_filesystem_get_start_loc( new, &i, &parent_loc );
49
 
50
  if ( !parent_loc.ops->evalformake_h ) {
51
    rtems_filesystem_freenode( &existing_loc );
52
    rtems_set_errno_and_return_minus_one( ENOTSUP );
53
  }
54
 
55
  result = (*parent_loc.ops->evalformake_h)( &new[i], &parent_loc, &name_start );
56
  if ( result != 0 ) {
57
    rtems_filesystem_freenode( &existing_loc );
58
    rtems_set_errno_and_return_minus_one( result );
59
  }
60
 
61
  /*
62
   *  Check to see if the caller is trying to link across file system
63
   *  boundaries.
64
   */
65
 
66
  if ( parent_loc.mt_entry != existing_loc.mt_entry ) {
67
    rtems_filesystem_freenode( &existing_loc );
68
    rtems_filesystem_freenode( &parent_loc );
69
    rtems_set_errno_and_return_minus_one( EXDEV );
70
  }
71
 
72
  if ( !parent_loc.ops->link_h ) {
73
    rtems_filesystem_freenode( &existing_loc );
74
    rtems_filesystem_freenode( &parent_loc );
75
    rtems_set_errno_and_return_minus_one( ENOTSUP );
76
  }
77
 
78
  result = (*parent_loc.ops->link_h)( &existing_loc, &parent_loc, name_start );
79
 
80
  rtems_filesystem_freenode( &existing_loc );
81
  rtems_filesystem_freenode( &parent_loc );
82
 
83
  return result;
84
}
85
 
86
/*
87
 *  _link_r
88
 *
89
 *  This is the Newlib dependent reentrant version of link().
90
 */
91
 
92
#if defined(RTEMS_NEWLIB)
93
 
94
#include <reent.h>
95
 
96
int _link_r(
97
  struct _reent *ptr,
98
  const char    *existing,
99
  const char    *new
100
)
101
{
102
  return link( existing, new );
103
}
104
#endif
105
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.