source: rtems/cpukit/libcsupport/src/rmdir.c @ 50f32b11

4.104.114.84.95
Last change on this file since 50f32b11 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 *  rmdir() - POSIX 1003.1b - 5.2.2 - Remove a Directory
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 <sys/types.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <errno.h>
22#include <stdlib.h>
23
24#include <rtems/libio_.h>
25#include <rtems/seterr.h>
26
27int rmdir(
28  const char *pathname
29)
30{
31  rtems_filesystem_location_info_t  loc;
32  int                               result;
33
34  /*
35   *  Get the node where we wish to go.
36   */
37
38  result = rtems_filesystem_evaluate_path( pathname, 0, &loc, FALSE );
39  if ( result != 0 )
40     return -1;
41
42  result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
43  if (result != 0){
44    rtems_filesystem_freenode( &loc );
45    return -1;
46  }
47
48  /*
49   * Verify you can remove this node as a directory.
50   */
51
52  if ( !loc.ops->node_type_h ){
53    rtems_filesystem_freenode( &loc );
54    rtems_set_errno_and_return_minus_one( ENOTSUP );
55  }
56
57  if (  (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
58    rtems_filesystem_freenode( &loc );
59    rtems_set_errno_and_return_minus_one( ENOTDIR );
60  }
61
62  /*
63   * Use the filesystems rmnod to remove the node.
64   */
65
66  if ( !loc.handlers->rmnod_h ){
67    rtems_filesystem_freenode( &loc );
68    rtems_set_errno_and_return_minus_one( ENOTSUP );
69  }
70
71  result =  (*loc.handlers->rmnod_h)( &loc );
72
73  rtems_filesystem_freenode( &loc );
74
75  return result;
76}
Note: See TracBrowser for help on using the repository browser.