4.104.114.84.95
Last change
on this file since 74e0ba5 was
74e0ba5,
checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/02 at 12:05:36
|
2002-01-07 Ralf Corsepius <corsepiu@…>
- src/imfs/imfs_load_tar.c: Add include <sys/types.h>.
Add include <sys/stat.h>. Add include <fcntl.h>.
- src/imfs/imfs_rmnod.c: Add include <stdlib.h>.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[94b357c2] | 1 | /* |
---|
| 2 | * IMFS Node Removal Handler |
---|
| 3 | * |
---|
| 4 | * This file contains the handler used to remove a node when a file type |
---|
| 5 | * does not require special actions. |
---|
| 6 | * |
---|
[08311cc3] | 7 | * COPYRIGHT (c) 1989-1999. |
---|
[94b357c2] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 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 | |
---|
[d6b1d73] | 17 | #if HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
[74e0ba5] | 21 | #include <stdlib.h> |
---|
| 22 | |
---|
[94b357c2] | 23 | #include <rtems.h> |
---|
| 24 | #include <rtems/libio.h> |
---|
[c058578] | 25 | #include <rtems/libio_.h> |
---|
[94b357c2] | 26 | |
---|
| 27 | #include "imfs.h" |
---|
| 28 | |
---|
| 29 | /* |
---|
| 30 | * IMFS_rmnod |
---|
| 31 | */ |
---|
| 32 | |
---|
| 33 | int IMFS_rmnod( |
---|
| 34 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
| 35 | ) |
---|
| 36 | { |
---|
| 37 | IMFS_jnode_t *the_jnode; |
---|
| 38 | |
---|
| 39 | the_jnode = (IMFS_jnode_t *) pathloc->node_access; |
---|
| 40 | |
---|
| 41 | /* |
---|
| 42 | * Take the node out of the parent's chain that contains this node |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | if ( the_jnode->Parent != NULL ) { |
---|
| 46 | Chain_Extract( (Chain_Node *) the_jnode ); |
---|
| 47 | the_jnode->Parent = NULL; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /* |
---|
| 51 | * Decrement the link counter and see if we can free the space. |
---|
| 52 | */ |
---|
| 53 | |
---|
| 54 | the_jnode->st_nlink--; |
---|
| 55 | IMFS_update_ctime( the_jnode ); |
---|
| 56 | |
---|
| 57 | /* |
---|
| 58 | * The file cannot be open and the link must be less than 1 to free. |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) { |
---|
| 62 | |
---|
| 63 | /* |
---|
[089ad91d] | 64 | * Is rtems_filesystem_current this node? |
---|
[94b357c2] | 65 | */ |
---|
| 66 | |
---|
| 67 | if ( rtems_filesystem_current.node_access == pathloc->node_access ) |
---|
| 68 | rtems_filesystem_current.node_access = NULL; |
---|
| 69 | |
---|
| 70 | /* |
---|
| 71 | * Free memory associated with a memory file. |
---|
| 72 | */ |
---|
| 73 | |
---|
| 74 | free( the_jnode ); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | return 0; |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
Note: See
TracBrowser
for help on using the repository browser.