source: rtems/cpukit/libcsupport/src/rmdir.c @ d71fcab

4.104.114.84.95
Last change on this file since d71fcab was d71fcab, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 18:44:40

Added call to freenod to let each filesystem free its own internal
node used to manage file access.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  rmdir() - POSIX 1003.1b - 5.2.2 - Remove a Directory
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 <sys/types.h>
16#include <fcntl.h>
17#include <unistd.h>
18#include <errno.h>
19#include <stdlib.h>
20
21#include "libio_.h"
22
23int rmdir(
24  const char *pathname
25)
26{
27  rtems_filesystem_location_info_t  loc;
28  int                               result;
29
30  /*
31   *  Get the node where we wish to go.
32   */
33
34  result = rtems_filesystem_evaluate_path( pathname, 0, &loc, FALSE );
35  if ( result != 0 )
36     return -1;
37
38  /*
39   * Verify you can remove this node as a directory.
40   */
41
42  if ( !loc.ops->node_type ){
43    if ( loc.ops->freenod )
44      (*loc.ops->freenod)( &loc );
45    set_errno_and_return_minus_one( ENOTSUP );
46  }
47
48  if (  (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
49    if ( loc.ops->freenod )
50      (*loc.ops->freenod)( &loc );
51    set_errno_and_return_minus_one( ENOTDIR );
52  }
53
54  /*
55   * Use the filesystems rmnod to remove the node.
56   */
57
58  if ( !loc.ops->rmnod ){
59    if ( loc.ops->freenod )
60      (*loc.ops->freenod)( &loc );
61    set_errno_and_return_minus_one( ENOTSUP );
62  }
63
64  result =  (*loc.ops->rmnod)( &loc ); 
65
66  if ( loc.ops->freenod )
67    (*loc.ops->freenod)( &loc );
68 
69  return result;
70}
Note: See TracBrowser for help on using the repository browser.