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

4.11
Last change on this file since ae55da72 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on May 3, 2012 at 3:09:24 PM

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.7 KB
Line 
1/*
2 *  Link Operations Table 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 <stdlib.h>
19#include <string.h>
20
21static int IMFS_stat_link(
22  const rtems_filesystem_location_info_t *loc,
23  struct stat *buf
24)
25{
26  const IMFS_jnode_t *node = loc->node_access;
27
28  if ( IMFS_type( node ) != IMFS_HARD_LINK ) {
29    buf->st_size = strlen( node->info.sym_link.name );
30
31    return IMFS_stat( loc, buf );
32  } else {
33    rtems_filesystem_location_info_t targetloc = *loc;
34
35    targetloc.node_access = node->info.hard_link.link_node;
36    IMFS_Set_handlers( &targetloc );
37
38    return (targetloc.handlers->fstat_h)( &targetloc, buf );
39  }
40}
41
42static const rtems_filesystem_file_handlers_r IMFS_link_handlers = {
43  rtems_filesystem_default_open,
44  rtems_filesystem_default_close,
45  rtems_filesystem_default_read,
46  rtems_filesystem_default_write,
47  rtems_filesystem_default_ioctl,
48  rtems_filesystem_default_lseek,
49  IMFS_stat_link,
50  rtems_filesystem_default_ftruncate,
51  rtems_filesystem_default_fsync_or_fdatasync,
52  rtems_filesystem_default_fsync_or_fdatasync,
53  rtems_filesystem_default_fcntl
54};
55
56static IMFS_jnode_t *IMFS_node_initialize_hard_link(
57  IMFS_jnode_t *node,
58  const IMFS_types_union *info
59)
60{
61  node->info.hard_link.link_node = info->hard_link.link_node;
62
63  return node;
64}
65
66static IMFS_jnode_t *IMFS_node_remove_hard_link(
67  IMFS_jnode_t *node,
68  const IMFS_jnode_t *root_node
69)
70{
71  IMFS_jnode_t *target = node->info.hard_link.link_node;
72
73  if ( target->st_nlink == 1) {
74    target = (*target->control->node_remove)( target, root_node );
75    if ( target == NULL ) {
76      node = NULL;
77    }
78  } else {
79    --target->st_nlink;
80    IMFS_update_ctime( target );
81  }
82
83  return node;
84}
85
86const IMFS_node_control IMFS_node_control_hard_link = {
87  .imfs_type = IMFS_HARD_LINK,
88  .handlers = &IMFS_link_handlers,
89  .node_initialize = IMFS_node_initialize_hard_link,
90  .node_remove = IMFS_node_remove_hard_link,
91  .node_destroy = IMFS_node_destroy_default
92};
93
94static IMFS_jnode_t *IMFS_node_initialize_sym_link(
95  IMFS_jnode_t *node,
96  const IMFS_types_union *info
97)
98{
99  node->info.sym_link.name = info->sym_link.name;
100
101  return node;
102}
103
104static IMFS_jnode_t *IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
105{
106  free( node->info.sym_link.name );
107
108  return node;
109}
110
111const IMFS_node_control IMFS_node_control_sym_link = {
112  .imfs_type = IMFS_SYM_LINK,
113  .handlers = &IMFS_link_handlers,
114  .node_initialize = IMFS_node_initialize_sym_link,
115  .node_remove = IMFS_node_remove_default,
116  .node_destroy = IMFS_node_destroy_sym_link
117};
Note: See TracBrowser for help on using the repository browser.