4.104.114.84.95
Last change
on this file since 94b357c2 was
94b357c2,
checked in by Joel Sherrill <joel.sherrill@…>, on 11/05/99 at 21:10:54
|
Unmount was failing as a side-effect of splitting the rmnod handler
and not handling every case properly.
|
-
Property mode set to
100644
|
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-1998. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <errno.h> |
---|
18 | #include <stdlib.h> |
---|
19 | |
---|
20 | #include "imfs.h" |
---|
21 | #include "libio_.h" |
---|
22 | |
---|
23 | int IMFS_unlink( |
---|
24 | rtems_filesystem_location_info_t *loc /* IN */ |
---|
25 | ) |
---|
26 | { |
---|
27 | IMFS_jnode_t *node; |
---|
28 | rtems_filesystem_location_info_t the_link; |
---|
29 | int result; |
---|
30 | |
---|
31 | node = loc->node_access; |
---|
32 | |
---|
33 | /* |
---|
34 | * Decrement the link counter of node pointed to and free the |
---|
35 | * space. |
---|
36 | */ |
---|
37 | |
---|
38 | /* |
---|
39 | * If this is the last last pointer to the node |
---|
40 | * free the node. |
---|
41 | */ |
---|
42 | |
---|
43 | if ( node->type == IMFS_HARD_LINK ) { |
---|
44 | |
---|
45 | if ( !node->info.hard_link.link_node ) |
---|
46 | set_errno_and_return_minus_one( EINVAL ); |
---|
47 | |
---|
48 | the_link = *loc; |
---|
49 | the_link.node_access = node->info.hard_link.link_node; |
---|
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 = (*loc->handlers->rmnod)( &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)( loc ); |
---|
70 | |
---|
71 | return result; |
---|
72 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.