Changed IMFS to use IMFS_NAME_MAX as the maximum length of a basename

rather then NAME_MAX.  NAME_MAX is 255 and that lets IMFS chew up memory
too fast.  Perhaps in the future, the places in IMFS that put a maximum
length name string on the stack and the jnode structure does not include
a maximu length name string can be fixed so this is not a problem.
This commit is contained in:
Joel Sherrill
1999-02-24 20:58:47 +00:00
parent 32a98d216b
commit 3cf8394af5
31 changed files with 123 additions and 87 deletions

View File

@@ -32,12 +32,16 @@
Chain_Control rtems_filesystem_mount_table_control; Chain_Control rtems_filesystem_mount_table_control;
#include "imfs.h"
/* XXX this structure should be in an IMFS specific file */
/* XXX this structure should use real constants */
rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = {
5, /* link_max */ 5, /* link_max */
6, /* max_canon */ 6, /* max_canon */
7, /* max_input */ 7, /* max_input */
255, /* name_max */ IMFS_NAME_MAX, /* name_max */
255, /* path_max */ 255, /* path_max */
2, /* pipe_buf */ 2, /* pipe_buf */
1, /* posix_async_io */ 1, /* posix_async_io */

View File

@@ -125,26 +125,32 @@ typedef union {
IMFS_memfile_t file; IMFS_memfile_t file;
} IMFS_types_union; } IMFS_types_union;
/*
* Maximum length of a "basename" of an IMFS file/node.
*/
#define IMFS_NAME_MAX 32
/* /*
* The control structure for an IMFS jnode. * The control structure for an IMFS jnode.
*/ */
struct IMFS_jnode_tt { struct IMFS_jnode_tt {
Chain_Node Node; /* for chaining them together */ Chain_Node Node; /* for chaining them together */
IMFS_jnode_t *Parent; /* Parent node */ IMFS_jnode_t *Parent; /* Parent node */
char name[NAME_MAX+1]; /* "basename" */ char name[IMFS_NAME_MAX+1]; /* "basename" */
mode_t st_mode; /* File mode */ mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Link count */ nlink_t st_nlink; /* Link count */
ino_t st_ino; /* inode */ ino_t st_ino; /* inode */
uid_t st_uid; /* User ID of owner */ uid_t st_uid; /* User ID of owner */
gid_t st_gid; /* Group ID of owner */ gid_t st_gid; /* Group ID of owner */
time_t st_atime; /* Time of last access */ time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */ time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */ time_t st_ctime; /* Time of last status change */
IMFS_jnode_types_t type; /* Type of this entry */ IMFS_jnode_types_t type; /* Type of this entry */
IMFS_types_union info; IMFS_types_union info;
}; };
#define IMFS_update_atime( _jnode ) \ #define IMFS_update_atime( _jnode ) \

View File

@@ -51,7 +51,7 @@ IMFS_jnode_t *IMFS_create_node(
node->st_nlink = 1; node->st_nlink = 1;
node->type = type; node->type = type;
strncpy( node->name, name, NAME_MAX ); strncpy( node->name, name, IMFS_NAME_MAX );
/* /*
* Fill in the mode and permission information for the jnode structure. * Fill in the mode and permission information for the jnode structure.

View File

@@ -277,7 +277,7 @@ int IMFS_evaluate_for_make(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type; IMFS_token_types type;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int done = 0; int done = 0;
@@ -467,7 +467,7 @@ int IMFS_eval_path(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type = IMFS_CURRENT_DIR; IMFS_token_types type = IMFS_CURRENT_DIR;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int result; int result;

View File

@@ -32,11 +32,11 @@ IMFS_token_types IMFS_get_token(
* Copy a name into token. (Remember NULL is a token.) * Copy a name into token. (Remember NULL is a token.)
*/ */
while ( !IMFS_is_separator( path[i] ) && (i <= NAME_MAX) ) { while ( !IMFS_is_separator( path[i] ) && (i <= IMFS_NAME_MAX) ) {
token[i] = path[i]; token[i] = path[i];
if (i == NAME_MAX) if (i == IMFS_NAME_MAX)
return IMFS_INVALID_TOKEN; return IMFS_INVALID_TOKEN;
if ( !IMFS_is_valid_name_char( token[i] ) ) if ( !IMFS_is_valid_name_char( token[i] ) )

View File

@@ -28,7 +28,7 @@ int IMFS_link(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -35,7 +35,7 @@ int IMFS_mknod(
IMFS_token_types type = 0; IMFS_token_types type = 0;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
int result; int result;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
IMFS_types_union info; IMFS_types_union info;
IMFS_get_token( token, new_name, &result ); IMFS_get_token( token, new_name, &result );

View File

@@ -28,7 +28,7 @@ int IMFS_symlink(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -125,26 +125,32 @@ typedef union {
IMFS_memfile_t file; IMFS_memfile_t file;
} IMFS_types_union; } IMFS_types_union;
/*
* Maximum length of a "basename" of an IMFS file/node.
*/
#define IMFS_NAME_MAX 32
/* /*
* The control structure for an IMFS jnode. * The control structure for an IMFS jnode.
*/ */
struct IMFS_jnode_tt { struct IMFS_jnode_tt {
Chain_Node Node; /* for chaining them together */ Chain_Node Node; /* for chaining them together */
IMFS_jnode_t *Parent; /* Parent node */ IMFS_jnode_t *Parent; /* Parent node */
char name[NAME_MAX+1]; /* "basename" */ char name[IMFS_NAME_MAX+1]; /* "basename" */
mode_t st_mode; /* File mode */ mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Link count */ nlink_t st_nlink; /* Link count */
ino_t st_ino; /* inode */ ino_t st_ino; /* inode */
uid_t st_uid; /* User ID of owner */ uid_t st_uid; /* User ID of owner */
gid_t st_gid; /* Group ID of owner */ gid_t st_gid; /* Group ID of owner */
time_t st_atime; /* Time of last access */ time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */ time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */ time_t st_ctime; /* Time of last status change */
IMFS_jnode_types_t type; /* Type of this entry */ IMFS_jnode_types_t type; /* Type of this entry */
IMFS_types_union info; IMFS_types_union info;
}; };
#define IMFS_update_atime( _jnode ) \ #define IMFS_update_atime( _jnode ) \

View File

@@ -51,7 +51,7 @@ IMFS_jnode_t *IMFS_create_node(
node->st_nlink = 1; node->st_nlink = 1;
node->type = type; node->type = type;
strncpy( node->name, name, NAME_MAX ); strncpy( node->name, name, IMFS_NAME_MAX );
/* /*
* Fill in the mode and permission information for the jnode structure. * Fill in the mode and permission information for the jnode structure.

View File

@@ -277,7 +277,7 @@ int IMFS_evaluate_for_make(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type; IMFS_token_types type;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int done = 0; int done = 0;
@@ -467,7 +467,7 @@ int IMFS_eval_path(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type = IMFS_CURRENT_DIR; IMFS_token_types type = IMFS_CURRENT_DIR;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int result; int result;

View File

@@ -32,11 +32,11 @@ IMFS_token_types IMFS_get_token(
* Copy a name into token. (Remember NULL is a token.) * Copy a name into token. (Remember NULL is a token.)
*/ */
while ( !IMFS_is_separator( path[i] ) && (i <= NAME_MAX) ) { while ( !IMFS_is_separator( path[i] ) && (i <= IMFS_NAME_MAX) ) {
token[i] = path[i]; token[i] = path[i];
if (i == NAME_MAX) if (i == IMFS_NAME_MAX)
return IMFS_INVALID_TOKEN; return IMFS_INVALID_TOKEN;
if ( !IMFS_is_valid_name_char( token[i] ) ) if ( !IMFS_is_valid_name_char( token[i] ) )

View File

@@ -28,7 +28,7 @@ int IMFS_link(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -35,7 +35,7 @@ int IMFS_mknod(
IMFS_token_types type = 0; IMFS_token_types type = 0;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
int result; int result;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
IMFS_types_union info; IMFS_types_union info;
IMFS_get_token( token, new_name, &result ); IMFS_get_token( token, new_name, &result );

View File

@@ -28,7 +28,7 @@ int IMFS_symlink(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -32,12 +32,16 @@
Chain_Control rtems_filesystem_mount_table_control; Chain_Control rtems_filesystem_mount_table_control;
#include "imfs.h"
/* XXX this structure should be in an IMFS specific file */
/* XXX this structure should use real constants */
rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = {
5, /* link_max */ 5, /* link_max */
6, /* max_canon */ 6, /* max_canon */
7, /* max_input */ 7, /* max_input */
255, /* name_max */ IMFS_NAME_MAX, /* name_max */
255, /* path_max */ 255, /* path_max */
2, /* pipe_buf */ 2, /* pipe_buf */
1, /* posix_async_io */ 1, /* posix_async_io */

View File

@@ -125,26 +125,32 @@ typedef union {
IMFS_memfile_t file; IMFS_memfile_t file;
} IMFS_types_union; } IMFS_types_union;
/*
* Maximum length of a "basename" of an IMFS file/node.
*/
#define IMFS_NAME_MAX 32
/* /*
* The control structure for an IMFS jnode. * The control structure for an IMFS jnode.
*/ */
struct IMFS_jnode_tt { struct IMFS_jnode_tt {
Chain_Node Node; /* for chaining them together */ Chain_Node Node; /* for chaining them together */
IMFS_jnode_t *Parent; /* Parent node */ IMFS_jnode_t *Parent; /* Parent node */
char name[NAME_MAX+1]; /* "basename" */ char name[IMFS_NAME_MAX+1]; /* "basename" */
mode_t st_mode; /* File mode */ mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Link count */ nlink_t st_nlink; /* Link count */
ino_t st_ino; /* inode */ ino_t st_ino; /* inode */
uid_t st_uid; /* User ID of owner */ uid_t st_uid; /* User ID of owner */
gid_t st_gid; /* Group ID of owner */ gid_t st_gid; /* Group ID of owner */
time_t st_atime; /* Time of last access */ time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */ time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */ time_t st_ctime; /* Time of last status change */
IMFS_jnode_types_t type; /* Type of this entry */ IMFS_jnode_types_t type; /* Type of this entry */
IMFS_types_union info; IMFS_types_union info;
}; };
#define IMFS_update_atime( _jnode ) \ #define IMFS_update_atime( _jnode ) \

View File

@@ -51,7 +51,7 @@ IMFS_jnode_t *IMFS_create_node(
node->st_nlink = 1; node->st_nlink = 1;
node->type = type; node->type = type;
strncpy( node->name, name, NAME_MAX ); strncpy( node->name, name, IMFS_NAME_MAX );
/* /*
* Fill in the mode and permission information for the jnode structure. * Fill in the mode and permission information for the jnode structure.

View File

@@ -277,7 +277,7 @@ int IMFS_evaluate_for_make(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type; IMFS_token_types type;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int done = 0; int done = 0;
@@ -467,7 +467,7 @@ int IMFS_eval_path(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type = IMFS_CURRENT_DIR; IMFS_token_types type = IMFS_CURRENT_DIR;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int result; int result;

View File

@@ -32,11 +32,11 @@ IMFS_token_types IMFS_get_token(
* Copy a name into token. (Remember NULL is a token.) * Copy a name into token. (Remember NULL is a token.)
*/ */
while ( !IMFS_is_separator( path[i] ) && (i <= NAME_MAX) ) { while ( !IMFS_is_separator( path[i] ) && (i <= IMFS_NAME_MAX) ) {
token[i] = path[i]; token[i] = path[i];
if (i == NAME_MAX) if (i == IMFS_NAME_MAX)
return IMFS_INVALID_TOKEN; return IMFS_INVALID_TOKEN;
if ( !IMFS_is_valid_name_char( token[i] ) ) if ( !IMFS_is_valid_name_char( token[i] ) )

View File

@@ -28,7 +28,7 @@ int IMFS_link(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -35,7 +35,7 @@ int IMFS_mknod(
IMFS_token_types type = 0; IMFS_token_types type = 0;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
int result; int result;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
IMFS_types_union info; IMFS_types_union info;
IMFS_get_token( token, new_name, &result ); IMFS_get_token( token, new_name, &result );

View File

@@ -28,7 +28,7 @@ int IMFS_symlink(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -32,12 +32,16 @@
Chain_Control rtems_filesystem_mount_table_control; Chain_Control rtems_filesystem_mount_table_control;
#include "imfs.h"
/* XXX this structure should be in an IMFS specific file */
/* XXX this structure should use real constants */
rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = {
5, /* link_max */ 5, /* link_max */
6, /* max_canon */ 6, /* max_canon */
7, /* max_input */ 7, /* max_input */
255, /* name_max */ IMFS_NAME_MAX, /* name_max */
255, /* path_max */ 255, /* path_max */
2, /* pipe_buf */ 2, /* pipe_buf */
1, /* posix_async_io */ 1, /* posix_async_io */

View File

@@ -125,26 +125,32 @@ typedef union {
IMFS_memfile_t file; IMFS_memfile_t file;
} IMFS_types_union; } IMFS_types_union;
/*
* Maximum length of a "basename" of an IMFS file/node.
*/
#define IMFS_NAME_MAX 32
/* /*
* The control structure for an IMFS jnode. * The control structure for an IMFS jnode.
*/ */
struct IMFS_jnode_tt { struct IMFS_jnode_tt {
Chain_Node Node; /* for chaining them together */ Chain_Node Node; /* for chaining them together */
IMFS_jnode_t *Parent; /* Parent node */ IMFS_jnode_t *Parent; /* Parent node */
char name[NAME_MAX+1]; /* "basename" */ char name[IMFS_NAME_MAX+1]; /* "basename" */
mode_t st_mode; /* File mode */ mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Link count */ nlink_t st_nlink; /* Link count */
ino_t st_ino; /* inode */ ino_t st_ino; /* inode */
uid_t st_uid; /* User ID of owner */ uid_t st_uid; /* User ID of owner */
gid_t st_gid; /* Group ID of owner */ gid_t st_gid; /* Group ID of owner */
time_t st_atime; /* Time of last access */ time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */ time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */ time_t st_ctime; /* Time of last status change */
IMFS_jnode_types_t type; /* Type of this entry */ IMFS_jnode_types_t type; /* Type of this entry */
IMFS_types_union info; IMFS_types_union info;
}; };
#define IMFS_update_atime( _jnode ) \ #define IMFS_update_atime( _jnode ) \

View File

@@ -51,7 +51,7 @@ IMFS_jnode_t *IMFS_create_node(
node->st_nlink = 1; node->st_nlink = 1;
node->type = type; node->type = type;
strncpy( node->name, name, NAME_MAX ); strncpy( node->name, name, IMFS_NAME_MAX );
/* /*
* Fill in the mode and permission information for the jnode structure. * Fill in the mode and permission information for the jnode structure.

View File

@@ -277,7 +277,7 @@ int IMFS_evaluate_for_make(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type; IMFS_token_types type;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int done = 0; int done = 0;
@@ -467,7 +467,7 @@ int IMFS_eval_path(
int i = 0; int i = 0;
int len; int len;
IMFS_token_types type = IMFS_CURRENT_DIR; IMFS_token_types type = IMFS_CURRENT_DIR;
char token[ NAME_MAX + 1 ]; char token[ IMFS_NAME_MAX + 1 ];
rtems_filesystem_location_info_t newloc; rtems_filesystem_location_info_t newloc;
IMFS_jnode_t *node; IMFS_jnode_t *node;
int result; int result;

View File

@@ -32,11 +32,11 @@ IMFS_token_types IMFS_get_token(
* Copy a name into token. (Remember NULL is a token.) * Copy a name into token. (Remember NULL is a token.)
*/ */
while ( !IMFS_is_separator( path[i] ) && (i <= NAME_MAX) ) { while ( !IMFS_is_separator( path[i] ) && (i <= IMFS_NAME_MAX) ) {
token[i] = path[i]; token[i] = path[i];
if (i == NAME_MAX) if (i == IMFS_NAME_MAX)
return IMFS_INVALID_TOKEN; return IMFS_INVALID_TOKEN;
if ( !IMFS_is_valid_name_char( token[i] ) ) if ( !IMFS_is_valid_name_char( token[i] ) )

View File

@@ -28,7 +28,7 @@ int IMFS_link(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*

View File

@@ -35,7 +35,7 @@ int IMFS_mknod(
IMFS_token_types type = 0; IMFS_token_types type = 0;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
int result; int result;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
IMFS_types_union info; IMFS_types_union info;
IMFS_get_token( token, new_name, &result ); IMFS_get_token( token, new_name, &result );

View File

@@ -28,7 +28,7 @@ int IMFS_symlink(
{ {
IMFS_types_union info; IMFS_types_union info;
IMFS_jnode_t *new_node; IMFS_jnode_t *new_node;
char new_name[ NAME_MAX + 1 ]; char new_name[ IMFS_NAME_MAX + 1 ];
int i; int i;
/* /*