OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [unlink.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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.OARcorp.com/rtems/license.html.
10
 *
11
 *  unlink.c,v 1.9 2002/01/04 18:29:37 joel Exp
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
 
23
int 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
  if ( !loc.ops->node_type_h ) {
39
    rtems_filesystem_freenode( &loc );
40
    rtems_set_errno_and_return_minus_one( ENOTSUP );
41
  }
42
 
43
  if (  (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
44
    rtems_filesystem_freenode( &loc );
45
    rtems_set_errno_and_return_minus_one( EISDIR );
46
  }
47
 
48
  if ( !loc.ops->unlink_h ) {
49
    rtems_filesystem_freenode( &loc );
50
    rtems_set_errno_and_return_minus_one( ENOTSUP );
51
  }
52
 
53
  result = (*loc.ops->unlink_h)( &loc );
54
 
55
  rtems_filesystem_freenode( &loc );
56
 
57
  return result;
58
}
59
 
60
/*
61
 *  _unlink_r
62
 *
63
 *  This is the Newlib dependent reentrant version of unlink().
64
 */
65
 
66
#if defined(RTEMS_NEWLIB)
67
 
68
#include <reent.h>
69
 
70
int _unlink_r(
71
  struct _reent *ptr,
72
  const char    *path
73
)
74
{
75
  return unlink( path );
76
}
77
#endif
78
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.