mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-28 07:20:16 +00:00
The object memfile.o was being included in the miniIMFS even though it
should not have been. This required that IMFS_rmnod be split into three separate (per file type) routines to avoid dependencies. In the end, a miniIMFS application is 6K smaller than one using the full IMFS.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include "libio_.h"
|
||||
|
||||
#include "imfs.h"
|
||||
|
||||
@@ -213,3 +214,58 @@ int device_lseek(
|
||||
*
|
||||
* This IMFS_stat() is used.
|
||||
*/
|
||||
|
||||
/*
|
||||
* device_rmnod
|
||||
*/
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_mknod(
|
||||
const char *path, /* IN */
|
||||
mode_t mode, /* IN */
|
||||
@@ -353,92 +349,123 @@ int memfile_ftruncate(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t length /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_fstat(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
struct stat *buf /* OUT */
|
||||
);
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int memfile_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int memfile_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int memfile_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int memfile_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int device_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int device_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int device_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int device_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_utime(
|
||||
rtems_filesystem_location_info_t *pathloc, /* IN */
|
||||
time_t actime, /* IN */
|
||||
time_t modtime /* IN */
|
||||
);
|
||||
|
||||
int IMFS_fchmod(
|
||||
rtems_filesystem_location_info_t *loc,
|
||||
mode_t mode
|
||||
|
||||
@@ -269,4 +269,80 @@ int imfs_dir_fstat(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* IMFS_dir_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
|
||||
NULL, /* fsync */
|
||||
NULL, /* fdatasync */
|
||||
NULL, /* fcntl */
|
||||
IMFS_rmnod
|
||||
device_rmnod
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
imfs_dir_rmnod
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
memfile_rmnod
|
||||
};
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* IMFS_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1998.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* Copyright assigned to U.S. Government, 1994.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "libio_.h"
|
||||
#include "imfs.h"
|
||||
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
if ( the_jnode->type == IMFS_DIRECTORY ) {
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
if ( the_jnode->type == IMFS_MEMORY_FILE )
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ int IMFS_unlink(
|
||||
node->info.hard_link.link_node->st_nlink --;
|
||||
IMFS_update_ctime( node->info.hard_link.link_node );
|
||||
if ( node->info.hard_link.link_node->st_nlink < 1) {
|
||||
result = IMFS_rmnod( &the_link );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
result = IMFS_rmnod( loc );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -29,26 +29,6 @@
|
||||
|
||||
#define MEMFILE_STATIC
|
||||
|
||||
/*
|
||||
* Set of operations handlers for operations on memfile entities.
|
||||
*/
|
||||
|
||||
rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
memfile_open,
|
||||
memfile_close,
|
||||
memfile_read,
|
||||
memfile_write,
|
||||
memfile_ioctl,
|
||||
memfile_lseek,
|
||||
IMFS_stat,
|
||||
IMFS_fchmod,
|
||||
memfile_ftruncate,
|
||||
NULL, /* fpathconf */
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl
|
||||
};
|
||||
|
||||
/*
|
||||
* Prototypes of private routines
|
||||
*/
|
||||
@@ -1056,3 +1036,62 @@ fflush(stdout);
|
||||
memfile_blocks_allocated--;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* memfile_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
|
||||
NULL, /* XXX IMFS_unlink, */
|
||||
IMFS_node_type,
|
||||
IMFS_mknod,
|
||||
NULL, /* XXX IMFS_rmnod, */
|
||||
NULL, /* XXX IMFS_chown, */
|
||||
NULL, /* XXX IMFS_freenodinfo, */
|
||||
NULL, /* XXX IMFS_mount, */
|
||||
|
||||
@@ -25,7 +25,7 @@ BASE_FS_C_PIECES = base_fs mount unmount ioman libio libio_sockets eval \
|
||||
|
||||
IMFS_C_PIECES = imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
|
||||
imfs_fsunmount imfs_gtkn imfs_init imfs_initsupp imfs_link imfs_mknod \
|
||||
imfs_mount imfs_fchmod imfs_rmnod imfs_unlink imfs_unmount imfs_utime \
|
||||
imfs_mount imfs_fchmod imfs_unlink imfs_unmount imfs_utime \
|
||||
imfs_ntype imfs_stat imfs_getchild memfile deviceio imfs_handlers_device \
|
||||
imfs_handlers_directory imfs_handlers_memfile imfs_debug imfs_symlink \
|
||||
imfs_readlink imfs_fdatasync imfs_fcntl miniimfs_init
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include "libio_.h"
|
||||
|
||||
#include "imfs.h"
|
||||
|
||||
@@ -213,3 +214,58 @@ int device_lseek(
|
||||
*
|
||||
* This IMFS_stat() is used.
|
||||
*/
|
||||
|
||||
/*
|
||||
* device_rmnod
|
||||
*/
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_mknod(
|
||||
const char *path, /* IN */
|
||||
mode_t mode, /* IN */
|
||||
@@ -353,92 +349,123 @@ int memfile_ftruncate(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t length /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_fstat(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
struct stat *buf /* OUT */
|
||||
);
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int memfile_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int memfile_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int memfile_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int memfile_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int device_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int device_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int device_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int device_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_utime(
|
||||
rtems_filesystem_location_info_t *pathloc, /* IN */
|
||||
time_t actime, /* IN */
|
||||
time_t modtime /* IN */
|
||||
);
|
||||
|
||||
int IMFS_fchmod(
|
||||
rtems_filesystem_location_info_t *loc,
|
||||
mode_t mode
|
||||
|
||||
@@ -269,4 +269,80 @@ int imfs_dir_fstat(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* IMFS_dir_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
|
||||
NULL, /* fsync */
|
||||
NULL, /* fdatasync */
|
||||
NULL, /* fcntl */
|
||||
IMFS_rmnod
|
||||
device_rmnod
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
imfs_dir_rmnod
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
memfile_rmnod
|
||||
};
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* IMFS_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1998.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* Copyright assigned to U.S. Government, 1994.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "libio_.h"
|
||||
#include "imfs.h"
|
||||
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
if ( the_jnode->type == IMFS_DIRECTORY ) {
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
if ( the_jnode->type == IMFS_MEMORY_FILE )
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ int IMFS_unlink(
|
||||
node->info.hard_link.link_node->st_nlink --;
|
||||
IMFS_update_ctime( node->info.hard_link.link_node );
|
||||
if ( node->info.hard_link.link_node->st_nlink < 1) {
|
||||
result = IMFS_rmnod( &the_link );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
result = IMFS_rmnod( loc );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -29,26 +29,6 @@
|
||||
|
||||
#define MEMFILE_STATIC
|
||||
|
||||
/*
|
||||
* Set of operations handlers for operations on memfile entities.
|
||||
*/
|
||||
|
||||
rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
memfile_open,
|
||||
memfile_close,
|
||||
memfile_read,
|
||||
memfile_write,
|
||||
memfile_ioctl,
|
||||
memfile_lseek,
|
||||
IMFS_stat,
|
||||
IMFS_fchmod,
|
||||
memfile_ftruncate,
|
||||
NULL, /* fpathconf */
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl
|
||||
};
|
||||
|
||||
/*
|
||||
* Prototypes of private routines
|
||||
*/
|
||||
@@ -1056,3 +1036,62 @@ fflush(stdout);
|
||||
memfile_blocks_allocated--;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* memfile_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
|
||||
NULL, /* XXX IMFS_unlink, */
|
||||
IMFS_node_type,
|
||||
IMFS_mknod,
|
||||
NULL, /* XXX IMFS_rmnod, */
|
||||
NULL, /* XXX IMFS_chown, */
|
||||
NULL, /* XXX IMFS_freenodinfo, */
|
||||
NULL, /* XXX IMFS_mount, */
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include "libio_.h"
|
||||
|
||||
#include "imfs.h"
|
||||
|
||||
@@ -213,3 +214,58 @@ int device_lseek(
|
||||
*
|
||||
* This IMFS_stat() is used.
|
||||
*/
|
||||
|
||||
/*
|
||||
* device_rmnod
|
||||
*/
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_mknod(
|
||||
const char *path, /* IN */
|
||||
mode_t mode, /* IN */
|
||||
@@ -353,92 +349,123 @@ int memfile_ftruncate(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t length /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int imfs_dir_fstat(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
struct stat *buf /* OUT */
|
||||
);
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int memfile_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int memfile_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int memfile_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int memfile_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int memfile_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int device_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int device_close(
|
||||
rtems_libio_t *iop /* IN */
|
||||
);
|
||||
|
||||
int device_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int device_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int device_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int device_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
int IMFS_utime(
|
||||
rtems_filesystem_location_info_t *pathloc, /* IN */
|
||||
time_t actime, /* IN */
|
||||
time_t modtime /* IN */
|
||||
);
|
||||
|
||||
int IMFS_fchmod(
|
||||
rtems_filesystem_location_info_t *loc,
|
||||
mode_t mode
|
||||
|
||||
@@ -269,4 +269,80 @@ int imfs_dir_fstat(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* IMFS_dir_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
|
||||
NULL, /* fsync */
|
||||
NULL, /* fdatasync */
|
||||
NULL, /* fcntl */
|
||||
IMFS_rmnod
|
||||
device_rmnod
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
imfs_dir_rmnod
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl,
|
||||
IMFS_rmnod
|
||||
memfile_rmnod
|
||||
};
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* IMFS_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1998.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* Copyright assigned to U.S. Government, 1994.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "libio_.h"
|
||||
#include "imfs.h"
|
||||
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
if ( the_jnode->type == IMFS_DIRECTORY ) {
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
|
||||
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
|
||||
set_errno_and_return_minus_one( ENOTEMPTY );
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
|
||||
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
*/
|
||||
|
||||
if ( the_jnode->info.directory.mt_fs != NULL )
|
||||
set_errno_and_return_minus_one( EBUSY );
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
if ( the_jnode->type == IMFS_MEMORY_FILE )
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ int IMFS_unlink(
|
||||
node->info.hard_link.link_node->st_nlink --;
|
||||
IMFS_update_ctime( node->info.hard_link.link_node );
|
||||
if ( node->info.hard_link.link_node->st_nlink < 1) {
|
||||
result = IMFS_rmnod( &the_link );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
result = IMFS_rmnod( loc );
|
||||
result = (*loc->handlers->rmnod)( &the_link );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -29,26 +29,6 @@
|
||||
|
||||
#define MEMFILE_STATIC
|
||||
|
||||
/*
|
||||
* Set of operations handlers for operations on memfile entities.
|
||||
*/
|
||||
|
||||
rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
|
||||
memfile_open,
|
||||
memfile_close,
|
||||
memfile_read,
|
||||
memfile_write,
|
||||
memfile_ioctl,
|
||||
memfile_lseek,
|
||||
IMFS_stat,
|
||||
IMFS_fchmod,
|
||||
memfile_ftruncate,
|
||||
NULL, /* fpathconf */
|
||||
NULL, /* fsync */
|
||||
IMFS_fdatasync,
|
||||
IMFS_fcntl
|
||||
};
|
||||
|
||||
/*
|
||||
* Prototypes of private routines
|
||||
*/
|
||||
@@ -1056,3 +1036,62 @@ fflush(stdout);
|
||||
memfile_blocks_allocated--;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* memfile_rmnod
|
||||
*
|
||||
* This routine is available from the optable to remove a node
|
||||
* from the IMFS file system.
|
||||
*/
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
the_jnode = (IMFS_jnode_t *) pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Take the node out of the parent's chain that contains this node
|
||||
*/
|
||||
|
||||
if ( the_jnode->Parent != NULL ) {
|
||||
Chain_Extract( (Chain_Node *) the_jnode );
|
||||
the_jnode->Parent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the link counter and see if we can free the space.
|
||||
*/
|
||||
|
||||
the_jnode->st_nlink--;
|
||||
IMFS_update_ctime( the_jnode );
|
||||
|
||||
/*
|
||||
* The file cannot be open and the link must be less than 1 to free.
|
||||
*/
|
||||
|
||||
if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
|
||||
|
||||
/*
|
||||
* Is the rtems_filesystem_current is this node?
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_current.node_access == pathloc->node_access )
|
||||
rtems_filesystem_current.node_access = NULL;
|
||||
|
||||
/*
|
||||
* Free memory associated with a memory file.
|
||||
*/
|
||||
|
||||
IMFS_memfile_remove( the_jnode );
|
||||
|
||||
free( the_jnode );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
|
||||
NULL, /* XXX IMFS_unlink, */
|
||||
IMFS_node_type,
|
||||
IMFS_mknod,
|
||||
NULL, /* XXX IMFS_rmnod, */
|
||||
NULL, /* XXX IMFS_chown, */
|
||||
NULL, /* XXX IMFS_freenodinfo, */
|
||||
NULL, /* XXX IMFS_mount, */
|
||||
|
||||
Reference in New Issue
Block a user