mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 13:31:41 +08:00
IMFS: Simplify ino generation
The type of ino_t is unsigned long, so it can store a pointer. Avoid a potential integer overflow.
This commit is contained in:
@@ -244,7 +244,6 @@ struct IMFS_jnode_tt {
|
||||
mode_t st_mode; /* File mode */
|
||||
unsigned short reference_count;
|
||||
nlink_t st_nlink; /* Link count */
|
||||
ino_t st_ino; /* inode */
|
||||
|
||||
uid_t st_uid; /* User ID of owner */
|
||||
gid_t st_gid; /* Group ID of owner */
|
||||
@@ -372,7 +371,6 @@ static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode )
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ino_t ino_count;
|
||||
const IMFS_node_control *node_controls [IMFS_TYPE_COUNT];
|
||||
} IMFS_fs_info_t;
|
||||
|
||||
@@ -960,6 +958,11 @@ static inline bool IMFS_is_hard_link( mode_t mode )
|
||||
return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK;
|
||||
}
|
||||
|
||||
static inline ino_t IMFS_node_to_ino( const IMFS_jnode_t *node )
|
||||
{
|
||||
return (ino_t) node;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,6 @@ IMFS_jnode_t *IMFS_allocate_node(
|
||||
node->stat_atime = (time_t) tv.tv_sec;
|
||||
node->stat_mtime = (time_t) tv.tv_sec;
|
||||
node->stat_ctime = (time_t) tv.tv_sec;
|
||||
node->st_ino = ++fs_info->ino_count;
|
||||
|
||||
initialized_node = (*node->control->node_initialize)( node, arg );
|
||||
if ( initialized_node == NULL ) {
|
||||
|
||||
@@ -73,7 +73,7 @@ ssize_t imfs_dir_read(
|
||||
/* Move the entry to the return buffer */
|
||||
dir_ent->d_off = current_entry;
|
||||
dir_ent->d_reclen = sizeof( *dir_ent );
|
||||
dir_ent->d_ino = imfs_node->st_ino;
|
||||
dir_ent->d_ino = IMFS_node_to_ino( imfs_node );
|
||||
dir_ent->d_namlen = strlen( imfs_node->name );
|
||||
memcpy( dir_ent->d_name, imfs_node->name, dir_ent->d_namlen + 1 );
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ int IMFS_stat(
|
||||
buf->st_dev = rtems_filesystem_make_dev_t_from_pointer( fs_info );
|
||||
buf->st_mode = the_jnode->st_mode;
|
||||
buf->st_nlink = the_jnode->st_nlink;
|
||||
buf->st_ino = the_jnode->st_ino;
|
||||
buf->st_ino = IMFS_node_to_ino( the_jnode );
|
||||
buf->st_uid = the_jnode->st_uid;
|
||||
buf->st_gid = the_jnode->st_gid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user