source: rtems/c/src/lib/libc/unlink.c @ 0cb7cb9

4.104.114.84.95
Last change on this file since 0cb7cb9 was dd0f326, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 19:10:46

Added rtems_filesystem_freenode() macro and added calls at appropriate
places to make sure memory allocated for filesystem specifif nodes
gets freed.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  unlink() - POSIX 1003.1b - 5.5.1 - Remove an existing link
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <errno.h>
16
17#include "libio_.h"
18
19int unlink(
20  const char *path
21)
22{
23  rtems_filesystem_location_info_t  loc;
24  int                               result;
25
26  /*
27   * Get the node to be unlinked.
28   */
29
30  result = rtems_filesystem_evaluate_path( path, 0, &loc, FALSE );
31  if ( result != 0 )
32     return -1;
33 
34  if ( !loc.ops->node_type ) {
35    rtems_filesystem_freenode( &loc );
36    set_errno_and_return_minus_one( ENOTSUP );
37  }
38
39  if (  (*loc.ops->node_type)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
40    rtems_filesystem_freenode( &loc );
41    set_errno_and_return_minus_one( EISDIR );
42  }
43
44  if ( !loc.ops->unlink ) {
45    rtems_filesystem_freenode( &loc );
46    set_errno_and_return_minus_one( ENOTSUP );
47  }
48
49  result = (*loc.ops->unlink)( &loc );
50
51  rtems_filesystem_freenode( &loc );
52 
53  return result;
54}
55
56/*
57 *  _unlink_r
58 *
59 *  This is the Newlib dependent reentrant version of unlink().
60 */
61
62#if defined(RTEMS_NEWLIB)
63
64#include <reent.h>
65
66int _unlink_r(
67  struct _reent *ptr,
68  const char    *path
69)
70{
71  return unlink( path );
72}
73#endif
74
Note: See TracBrowser for help on using the repository browser.