source: rtems/cpukit/libcsupport/src/unlink.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 50f32b11, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/18/04 at 06:05:35

Remove stray white spaces.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  unlink() - POSIX 1003.1b - 5.5.1 - Remove an existing 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 <errno.h>
19
20#include <rtems/libio_.h>
21#include <rtems/seterr.h>
22
23int unlink(
24  const char *path
25)
26{
27  rtems_filesystem_location_info_t  loc;
28  int                               result;
29
30  /*
31   * Get the node to be unlinked.
32   */
33
34  result = rtems_filesystem_evaluate_path( path, 0, &loc, FALSE );
35  if ( result != 0 )
36     return -1;
37
38  result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
39  if (result != 0){
40    rtems_filesystem_freenode( &loc );
41    return -1;
42  }
43
44  if ( !loc.ops->node_type_h ) {
45    rtems_filesystem_freenode( &loc );
46    rtems_set_errno_and_return_minus_one( ENOTSUP );
47  }
48
49  if (  (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
50    rtems_filesystem_freenode( &loc );
51    rtems_set_errno_and_return_minus_one( EISDIR );
52  }
53
54  if ( !loc.ops->unlink_h ) {
55    rtems_filesystem_freenode( &loc );
56    rtems_set_errno_and_return_minus_one( ENOTSUP );
57  }
58
59  result = (*loc.ops->unlink_h)( &loc );
60
61  rtems_filesystem_freenode( &loc );
62
63  return result;
64}
65
66/*
67 *  _unlink_r
68 *
69 *  This is the Newlib dependent reentrant version of unlink().
70 */
71
72#if defined(RTEMS_NEWLIB)
73
74#include <reent.h>
75
76int _unlink_r(
77  struct _reent *ptr,
78  const char    *path
79)
80{
81  return unlink( path );
82}
83#endif
Note: See TracBrowser for help on using the repository browser.