source: rtems/cpukit/libcsupport/src/_rename_r.c @ 9b4422a2

4.11
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on May 3, 2012 at 3:09:24 PM

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  _rename_r() - POSIX 1003.1b - 5.3.4 - Rename a file
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  Modifications to support reference counting in the file system are
8 *  Copyright (c) 2012 embedded brains GmbH.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#if defined(RTEMS_NEWLIB) && !defined(HAVE__RENAME_R)
20
21#include <stdio.h>
22
23#include <rtems/libio_.h>
24
25int _rename_r(
26  struct _reent *ptr __attribute__((unused)),
27  const char    *old,
28  const char    *new
29)
30{
31  int rv = 0;
32  rtems_filesystem_eval_path_context_t old_ctx;
33  int old_eval_flags = 0;
34  rtems_filesystem_location_info_t old_parentloc;
35  int old_parent_eval_flags = RTEMS_FS_PERMS_WRITE
36    | RTEMS_FS_FOLLOW_HARD_LINK;
37  const rtems_filesystem_location_info_t *old_currentloc =
38    rtems_filesystem_eval_path_start_with_parent(
39      &old_ctx,
40      old,
41      old_eval_flags,
42      &old_parentloc,
43      old_parent_eval_flags
44    );
45  rtems_filesystem_eval_path_context_t new_ctx;
46
47  /* FIXME: This is not POSIX conform */
48  int new_eval_flags = RTEMS_FS_FOLLOW_HARD_LINK
49    | RTEMS_FS_MAKE
50    | RTEMS_FS_EXCLUSIVE;
51
52  const rtems_filesystem_location_info_t *new_currentloc =
53    rtems_filesystem_eval_path_start( &new_ctx, new, new_eval_flags );
54
55  rv = rtems_filesystem_location_exists_in_same_fs_instance_as(
56    old_currentloc,
57    new_currentloc
58  );
59  if ( rv == 0 ) {
60    rv = (*new_currentloc->ops->rename_h)(
61      &old_parentloc,
62      old_currentloc,
63      new_currentloc,
64      rtems_filesystem_eval_path_get_token( &new_ctx ),
65      rtems_filesystem_eval_path_get_tokenlen( &new_ctx )
66    );
67  }
68
69  rtems_filesystem_eval_path_cleanup_with_parent( &old_ctx, &old_parentloc );
70  rtems_filesystem_eval_path_cleanup( &new_ctx );
71
72  return rv;
73}
74#endif
Note: See TracBrowser for help on using the repository browser.