source: rtems/cpukit/libcsupport/src/link.c @ 98b785e

4.115
Last change on this file since 98b785e was 92119ed, checked in by Jennifer Averett <Jennifer.Averett@…>, on 07/01/10 at 15:12:38

2010-07-01 Jennifer Averett <Jennifer.Averett@…>

  • libcsupport/src/chdir.c, libcsupport/src/chmod.c, libcsupport/src/chown.c, libcsupport/src/close.c, libcsupport/src/eval.c, libcsupport/src/fchdir.c, libcsupport/src/fchmod.c, libcsupport/src/fchown.c, libcsupport/src/fcntl.c, libcsupport/src/fdatasync.c, libcsupport/src/freenode.c, libcsupport/src/fstat.c, libcsupport/src/fsync.c, libcsupport/src/ftruncate.c, libcsupport/src/ioctl.c, libcsupport/src/link.c, libcsupport/src/lseek.c, libcsupport/src/mknod.c, libcsupport/src/mount.c, libcsupport/src/open.c, libcsupport/src/read.c, libcsupport/src/readlink.c, libcsupport/src/readv.c, libcsupport/src/rmdir.c, libcsupport/src/stat.c, libcsupport/src/statvfs.c, libcsupport/src/symlink.c, libcsupport/src/unlink.c, libcsupport/src/unmount.c, libcsupport/src/write.c: Removed filesystem checks for NULL methods checks from the main posix rountines. These are now required to have at a miminum default routines in the tables.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
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.rtems.com/license/LICENSE.
10 *
11 *  $Id$
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
25int 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, strlen( existing ),
41                                           0, &existing_loc, true );
42  if ( result != 0 )
43     return -1;
44
45  /*
46   * Get the parent of the node we are creating.
47   */
48
49  rtems_filesystem_get_start_loc( new, &i, &parent_loc );
50
51  result = (*parent_loc.ops->evalformake_h)( &new[i], &parent_loc, &name_start );
52  if ( result != 0 ) {
53    rtems_filesystem_freenode( &existing_loc );
54    rtems_set_errno_and_return_minus_one( result );
55  }
56
57  /*
58   *  Check to see if the caller is trying to link across file system
59   *  boundaries.
60   */
61
62  if ( parent_loc.mt_entry != existing_loc.mt_entry ) {
63    rtems_filesystem_freenode( &existing_loc );
64    rtems_filesystem_freenode( &parent_loc );
65    rtems_set_errno_and_return_minus_one( EXDEV );
66  }
67
68  result = (*parent_loc.ops->link_h)( &existing_loc, &parent_loc, name_start );
69
70  rtems_filesystem_freenode( &existing_loc );
71  rtems_filesystem_freenode( &parent_loc );
72
73  return result;
74}
75
76/*
77 *  _link_r
78 *
79 *  This is the Newlib dependent reentrant version of link().
80 */
81
82#if defined(RTEMS_NEWLIB)
83
84#include <reent.h>
85
86int _link_r(
87  struct _reent *ptr __attribute__((unused)),
88  const char    *existing,
89  const char    *new
90)
91{
92  return link( existing, new );
93}
94#endif
Note: See TracBrowser for help on using the repository browser.