source: rtems/cpukit/libfs/src/imfs/imfs_handlers_directory.c @ ae55da72

4.115
Last change on this file since ae55da72 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  Operations Table for Directories for the IMFS
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
12#if HAVE_CONFIG_H
13  #include "config.h"
14#endif
15
16#include "imfs.h"
17
18#include <dirent.h>
19
20static size_t IMFS_directory_size( const IMFS_jnode_t *node )
21{
22  size_t size = 0;
23  const rtems_chain_control *chain = &node->info.directory.Entries;
24  const rtems_chain_node *current = rtems_chain_immutable_first( chain );
25  const rtems_chain_node *tail = rtems_chain_immutable_tail( chain );
26
27  while ( current != tail ) {
28    size += sizeof( struct dirent );
29    current = rtems_chain_immutable_next( current );
30  }
31
32  return size;
33}
34
35static int IMFS_stat_directory(
36  const rtems_filesystem_location_info_t *loc,
37  struct stat *buf
38)
39{
40  const IMFS_jnode_t *node = loc->node_access;
41
42  buf->st_size = IMFS_directory_size( node );
43
44  return IMFS_stat( loc, buf );
45}
46
47static const rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
48  rtems_filesystem_default_open,
49  rtems_filesystem_default_close,
50  imfs_dir_read,
51  rtems_filesystem_default_write,
52  rtems_filesystem_default_ioctl,
53  rtems_filesystem_default_lseek_directory,
54  IMFS_stat_directory,
55  rtems_filesystem_default_ftruncate_directory,
56  rtems_filesystem_default_fsync_or_fdatasync_success,
57  rtems_filesystem_default_fsync_or_fdatasync_success,
58  rtems_filesystem_default_fcntl
59};
60
61static IMFS_jnode_t *IMFS_node_initialize_directory(
62  IMFS_jnode_t *node,
63  const IMFS_types_union *info
64)
65{
66  rtems_chain_initialize_empty( &node->info.directory.Entries );
67
68  return node;
69}
70
71static bool IMFS_is_mount_point( const IMFS_jnode_t *node )
72{
73  return node->info.directory.mt_fs != NULL;
74}
75
76static IMFS_jnode_t *IMFS_node_remove_directory(
77  IMFS_jnode_t *node,
78  const IMFS_jnode_t *root_node
79)
80{
81  if ( !rtems_chain_is_empty( &node->info.directory.Entries ) ) {
82    errno = ENOTEMPTY;
83    node = NULL;
84  } else if ( node == root_node || IMFS_is_mount_point( node ) ) {
85    errno = EBUSY;
86    node = NULL;
87  }
88
89  return node;
90}
91
92const IMFS_node_control IMFS_node_control_directory = {
93  .imfs_type = IMFS_DIRECTORY,
94  .handlers = &IMFS_directory_handlers,
95  .node_initialize = IMFS_node_initialize_directory,
96  .node_remove = IMFS_node_remove_directory,
97  .node_destroy = IMFS_node_destroy_default
98};
Note: See TracBrowser for help on using the repository browser.