summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-01-31 21:27:01 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-02-04 19:31:55 +0100
commit924cbd4f42c8284899523903934d5db785919fdc (patch)
tree5e253e3620c49ae0e6c773c9d6abb6c0c16bba7d
parent95308caf587391f267de052260991e687db68a36 (diff)
downloadrtems-924cbd4f42c8284899523903934d5db785919fdc.tar.bz2
IMFS: Simplify ino generation
The type of ino_t is unsigned long, so it can store a pointer. Avoid a potential integer overflow.
-rw-r--r--cpukit/libfs/src/imfs/imfs.h7
-rw-r--r--cpukit/libfs/src/imfs/imfs_creat.c1
-rw-r--r--cpukit/libfs/src/imfs/imfs_directory.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_stat.c2
4 files changed, 7 insertions, 5 deletions
diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h
index c296bffc06..f258ae05a7 100644
--- a/cpukit/libfs/src/imfs/imfs.h
+++ b/cpukit/libfs/src/imfs/imfs.h
@@ -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;
+}
+
/** @} */
/**
diff --git a/cpukit/libfs/src/imfs/imfs_creat.c b/cpukit/libfs/src/imfs/imfs_creat.c
index e6dceae658..7d60e66888 100644
--- a/cpukit/libfs/src/imfs/imfs_creat.c
+++ b/cpukit/libfs/src/imfs/imfs_creat.c
@@ -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 ) {
diff --git a/cpukit/libfs/src/imfs/imfs_directory.c b/cpukit/libfs/src/imfs/imfs_directory.c
index fc35b01813..5769e0741b 100644
--- a/cpukit/libfs/src/imfs/imfs_directory.c
+++ b/cpukit/libfs/src/imfs/imfs_directory.c
@@ -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 );
diff --git a/cpukit/libfs/src/imfs/imfs_stat.c b/cpukit/libfs/src/imfs/imfs_stat.c
index 3d07fe8092..c0298b16d8 100644
--- a/cpukit/libfs/src/imfs/imfs_stat.c
+++ b/cpukit/libfs/src/imfs/imfs_stat.c
@@ -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;