source:
rtems/c/src/exec/libfs/src/imfs/imfs_unlink.c
@
9c3fa30
Last change on this file since 9c3fa30 was 9c3fa30, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/00 at 20:19:23 | |
---|---|
|
|
File size: 1.6 KB |
Line | |
---|---|
1 | /* |
2 | * IMFS_unlink |
3 | * |
4 | * Routine to remove a link node from the tree. |
5 | * |
6 | * COPYRIGHT (c) 1989-1999. |
7 | * On-Line Applications Research Corporation (OAR). |
8 | * |
9 | * The license and distribution terms for this file may be |
10 | * found in the file LICENSE in this distribution or at |
11 | * http://www.OARcorp.com/rtems/license.html. |
12 | * |
13 | * $Id$ |
14 | */ |
15 | |
16 | #include <errno.h> |
17 | #include <stdlib.h> |
18 | |
19 | #include "imfs.h" |
20 | #include "libio_.h" |
21 | |
22 | int IMFS_unlink( |
23 | rtems_filesystem_location_info_t *loc /* IN */ |
24 | ) |
25 | { |
26 | IMFS_jnode_t *node; |
27 | rtems_filesystem_location_info_t the_link; |
28 | int result = 0; |
29 | |
30 | node = loc->node_access; |
31 | |
32 | /* |
33 | * Decrement the link counter of node pointed to and free the |
34 | * space. |
35 | */ |
36 | |
37 | /* |
38 | * If this is the last last pointer to the node |
39 | * free the node. |
40 | */ |
41 | |
42 | if ( node->type == IMFS_HARD_LINK ) { |
43 | |
44 | if ( !node->info.hard_link.link_node ) |
45 | set_errno_and_return_minus_one( EINVAL ); |
46 | |
47 | the_link = *loc; |
48 | the_link.node_access = node->info.hard_link.link_node; |
49 | IMFS_Set_handlers( &the_link ); |
50 | |
51 | /* |
52 | * If removing the last hard link to a node, then we need |
53 | * to remove the node that is a link and the node itself. |
54 | */ |
55 | |
56 | node->info.hard_link.link_node->st_nlink --; |
57 | IMFS_update_ctime( node->info.hard_link.link_node ); |
58 | if ( node->info.hard_link.link_node->st_nlink < 1) { |
59 | result = (*the_link.handlers->rmnod_h)( &the_link ); |
60 | if ( result != 0 ) |
61 | return -1; |
62 | } |
63 | } |
64 | |
65 | /* |
66 | * Now actually free the node we were asked to free. |
67 | */ |
68 | |
69 | result = (*loc->handlers->rmnod_h)( loc ); |
70 | |
71 | return result; |
72 | } |
73 |
Note: See TracBrowser
for help on using the repository browser.