source: rtems/cpukit/libcsupport/src/link.c @ 183af89

4.115
Last change on this file since 183af89 was 2563410, checked in by Sebastian Huber <sebastian.huber@…>, on 03/13/12 at 08:22:11

Filesystem: Rename defines

o Removed RTEMS_LIBIO_PERMS_SEARCH.
o Renamed RTEMS_LIBIO_PERMS_READ in RTEMS_FS_PERMS_READ.
o Renamed RTEMS_LIBIO_PERMS_WRITE in RTEMS_FS_PERMS_WRITE.
o Renamed RTEMS_LIBIO_PERMS_EXEC in RTEMS_FS_PERMS_EXEC.
o Renamed RTEMS_LIBIO_FOLLOW_HARD_LINK in RTEMS_FS_FOLLOW_HARD_LINK.
o Renamed RTEMS_LIBIO_FOLLOW_SYM_LINK in RTEMS_FS_FOLLOW_SYM_LINK.
o Renamed RTEMS_LIBIO_MAKE in RTEMS_FS_MAKE.
o Renamed RTEMS_LIBIO_EXCLUSIVE in RTEMS_FS_EXCLUSIVE.
o Renamed RTEMS_LIBIO_ACCEPT_RESIDUAL_DELIMITERS in

RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS.

o Renamed RTEMS_LIBIO_REJECT_TERMINAL_DOT in
RTEMS_FS_REJECT_TERMINAL_DOT.

  • Property mode set to 100644
File size: 1.6 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 <unistd.h>
19
20#include <rtems/libio_.h>
21
22int link( const char *path1, const char *path2 )
23{
24  int rv = 0;
25  rtems_filesystem_eval_path_context_t ctx_1;
26  rtems_filesystem_eval_path_context_t ctx_2;
27  int eval_flags_1 = RTEMS_FS_FOLLOW_LINK;
28  int eval_flags_2 = RTEMS_FS_FOLLOW_LINK
29    | RTEMS_FS_MAKE
30    | RTEMS_FS_EXCLUSIVE;
31  const rtems_filesystem_location_info_t *currentloc_1 =
32    rtems_filesystem_eval_path_start( &ctx_1, path1, eval_flags_1 );
33  const rtems_filesystem_location_info_t *currentloc_2 =
34    rtems_filesystem_eval_path_start( &ctx_2, path2, eval_flags_2 );
35
36  rv = rtems_filesystem_location_exists_in_same_fs_instance_as(
37    currentloc_1,
38    currentloc_2
39  );
40  if ( rv == 0 ) {
41    rv = (*currentloc_2->ops->link_h)(
42      currentloc_2,
43      currentloc_1,
44      rtems_filesystem_eval_path_get_token( &ctx_2 ),
45      rtems_filesystem_eval_path_get_tokenlen( &ctx_2 )
46    );
47  }
48
49  rtems_filesystem_eval_path_cleanup( &ctx_1 );
50  rtems_filesystem_eval_path_cleanup( &ctx_2 );
51
52  return rv;
53}
54
55/*
56 *  _link_r
57 *
58 *  This is the Newlib dependent reentrant version of link().
59 */
60
61#if defined(RTEMS_NEWLIB)
62
63#include <reent.h>
64
65int _link_r(
66  struct _reent *ptr __attribute__((unused)),
67  const char    *path1,
68  const char    *path2
69)
70{
71  return link( path1, path2 );
72}
73#endif
Note: See TracBrowser for help on using the repository browser.