source: rtems/cpukit/libcsupport/src/rmdir.c @ 7baa484

4.104.115
Last change on this file since 7baa484 was 7baa484, checked in by Chris Johns <chrisj@…>, on 06/12/09 at 01:53:33

2009-06-12 Chris Johns <chrisj@…>

  • libblock/src/bdbuf.c: Update comments.
  • libblock/src/bdpart.c, libblock/src/ide_part_table.c: Get the device from the rdev field of the stat buf.
  • libcsupport/include/rtems/libio.h: Add a path length to evalpath handler. Add parent locations to rmmod and unlink handlers.
  • libcsupport/include/rtems/libio_.h: Add a path length to rtems_filesystem_evaluate_path. Add rtems_filesystem_evaluate_relative_path, rtems_filesystem_dirname, and rtems_filesystem_prefix_separators. Remove rtems_filesystem_evaluate_parent.
  • libcsupport/src/base_fs.c, libcsupport/src/chdir.c, libcsupport/src/chmod.c, libcsupport/src/chown.c, libcsupport/src/chroot.c, libcsupport/src/fchdir.c, libcsupport/src/link.c, libcsupport/src/mount.c, libcsupport/src/open.c, libcsupport/src/privateenv.c, libcsupport/src/readlink.c, libcsupport/src/unmount.c, libcsupport/src/utime.c, libcsupport/src/unmount.c, libcsupport/src/utime.c, libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devstat.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_misc.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/ioman.c, libfs/src/pipe/pipe.c, libmisc/fsmount/fsmount.c, libnetworking/lib/ftpfs.c: Add the length parameter to the eval call.
  • libcsupport/src/eval.c: Add rtems_filesystem_prefix_separators, rtems_filesystem_dirname, rtems_filesystem_evaluate_relative_path. Add the length parameter to the eval call.
  • libcsupport/src/rmdir.c: Find the parent pathloc then the node pathloc from that node. Remove the call to find the parent given the node pathloc.
  • libcsupport/src/stat.c: Add the length parameter to the eval call. Set the device into the rdev field.
  • libcsupport/src/unlink.c: Find the parent pathloc then the node pathloc from that node. Remove the call to find the parent given the node pathloc.
  • libfs/src/dosfs/fat.c, libfs/src/dosfs/msdos_format.c: Get the disk device number from the stat rdev field.
  • libfs/src/dosfs/msdos.h: Add the length parameter to the eval call. Add the parent pathloc to the rmnod handler.
  • libfs/src/dosfs/msdos_dir.c: Add the parent pathloc to the rmnod handler.
  • libfs/src/dosfs/msdos_eval.c: Add the length parameter to the eval and token call.
  • libfs/src/imfs/imfs_directory.c: Add the parent pathloc to the rmnod handler.
  • libfs/src/imfs/imfs_fchmod.c: Do not test the mode flags for only the allowed flags. Add the missing flags spec'ed in the POSIX standard.
  • libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_rmnod.c, libfs/src/imfs/imfs_unlink.c, libfs/src/imfs/memfile.c: Add the parent node. Currently ignored in the IMFS.
  • libfs/src/imfs/imfs_stat.c: Return the device number in the rdev field.
  • libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_symlink.c : Add the length parameter to the token call.
  • libfs/src/nfsclient/src/nfs.c: Add the length parameter to the eval call and parent node to the rmnod and unlink command.
  • libmisc/shell/internal.h: Remove the libc mounter decl to make public.
  • libmisc/shell/main_mount.c: Add support for hooking external mount support for new file systems.
  • libmisc/shell/shell.h: Add helper functions for the mount command.
  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[07a3253d]1/*
2 *  rmdir() - POSIX 1003.1b - 5.2.2 - Remove a Directory
3 *
[08311cc3]4 *  COPYRIGHT (c) 1989-1999.
[07a3253d]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
[0eae36c7]9 *  http://www.rtems.com/license/LICENSE.
[07a3253d]10 *
11 *  $Id$
12 */
13
[9c49db4]14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
[07a3253d]18#include <sys/types.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <errno.h>
22#include <stdlib.h>
23
[3ba74c73]24#include <rtems/libio_.h>
[a02224e]25#include <rtems/seterr.h>
[07a3253d]26
27int rmdir(
28  const char *pathname
29)
30{
[7baa484]31  int                               parentpathlen;
32  const char                       *name;
33  rtems_filesystem_location_info_t  parentloc;
[07a3253d]34  rtems_filesystem_location_info_t  loc;
[7baa484]35  int                               i;
[07a3253d]36  int                               result;
[7baa484]37 
[07a3253d]38  /*
[7baa484]39   *  Get the parent node of the node we wish to remove. Find the parent path.
[07a3253d]40   */
41
[7baa484]42  parentpathlen = rtems_filesystem_dirname ( pathname );
[07a3253d]43
[7baa484]44  if ( parentpathlen == 0 )
45    rtems_filesystem_get_start_loc( pathname, &i, &parentloc );
46  else {
47    result = rtems_filesystem_evaluate_path(pathname, parentpathlen,
48                                            RTEMS_LIBIO_PERMS_WRITE,
49                                            &parentloc,
50                                            false );
51    if ( result != 0 )
52      return -1;
53  }
54
55  /*
56   * Start from the parent to find the node that should be under it.
57   */
58 
59  loc = parentloc;
60  name = pathname + parentpathlen;
61  name += rtems_filesystem_prefix_separators( name, strlen( name ) );
62 
63  result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
64                                                    0, &loc, false );
65  if ( result != 0 ) {
66    rtems_filesystem_freenode( &parentloc );
[de691e68]67    return -1;
68  }
69
[07a3253d]70  /*
71   * Verify you can remove this node as a directory.
72   */
73
[9c3fa30]74  if ( !loc.ops->node_type_h ){
[dd0f326]75    rtems_filesystem_freenode( &loc );
[7baa484]76    rtems_filesystem_freenode( &parentloc );
[a02224e]77    rtems_set_errno_and_return_minus_one( ENOTSUP );
[d71fcab]78  }
[07a3253d]79
[9c3fa30]80  if (  (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
[dd0f326]81    rtems_filesystem_freenode( &loc );
[7baa484]82    rtems_filesystem_freenode( &parentloc );
[a02224e]83    rtems_set_errno_and_return_minus_one( ENOTDIR );
[d71fcab]84  }
[07a3253d]85
86  /*
87   * Use the filesystems rmnod to remove the node.
88   */
89
[9c3fa30]90  if ( !loc.handlers->rmnod_h ){
[dd0f326]91    rtems_filesystem_freenode( &loc );
[7baa484]92    rtems_filesystem_freenode( &parentloc );
[a02224e]93    rtems_set_errno_and_return_minus_one( ENOTSUP );
[d71fcab]94  }
[07a3253d]95
[7baa484]96  result =  (*loc.handlers->rmnod_h)( &parentloc, &loc );
[d71fcab]97
[dd0f326]98  rtems_filesystem_freenode( &loc );
[7baa484]99  rtems_filesystem_freenode( &parentloc );
[50f32b11]100
[d71fcab]101  return result;
[07a3253d]102}
Note: See TracBrowser for help on using the repository browser.