[syslinux:pathbased] fs: get rid of enum inode_mode

syslinux-bot for H. Peter Anvin hpa at zytor.com
Tue Mar 9 16:00:20 PST 2010


Commit-ID:  16b6c207e7c68982ae7e51e51c51773df67a910d
Gitweb:     http://syslinux.zytor.com/commit/16b6c207e7c68982ae7e51e51c51773df67a910d
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 9 Mar 2010 15:48:24 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 9 Mar 2010 15:48:24 -0800

fs: get rid of enum inode_mode

Replace enum inode_mode with the equivalent enum dirent_type.


---
 core/fs/chdir.c           |    2 +-
 core/fs/ext2/ext2.c       |   27 +++++++--------------------
 core/fs/fat/fat.c         |    6 +++---
 core/fs/fs.c              |    4 ++--
 core/fs/iso9660/iso9660.c |    4 ++--
 core/include/fs.h         |   13 -------------
 6 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/core/fs/chdir.c b/core/fs/chdir.c
index d5ef3f9..bfce9bc 100644
--- a/core/fs/chdir.c
+++ b/core/fs/chdir.c
@@ -43,7 +43,7 @@ int chdir(const char *src)
 	return rv;
 
     file = handle_to_file(rv);
-    if (file->inode->mode != I_DIR) {
+    if (file->inode->mode != DT_DIR) {
 	_close_file(file);
 	return -1;
     }
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index cbc0378..716670c 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -12,15 +12,15 @@
 /*
  * Convert an ext2 file type to the global values
  */
-static enum inode_mode ext2_cvt_type(unsigned int d_file_type)
+static enum dirent_type ext2_cvt_type(unsigned int d_file_type)
 {
-    static const enum inode_mode inode_type[] = {
-	I_UNKNOWN, I_FILE, I_DIR, I_CHR,
-	I_BLK, I_FIFO, I_SOCK, I_SYMLINK,
+    static const enum dirent_type inode_type[] = {
+	DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR,
+	DT_BLK, DT_FIFO, DT_SOCK, DT_LNK,
     };
 
     if (d_file_type > sizeof inode_type / sizeof *inode_type)
-	return I_UNKNOWN;
+	return DT_UNKNOWN;
     else
 	return inode_type[d_file_type];
 }
@@ -144,21 +144,9 @@ ext2_get_inode(struct fs_info *fs, int inr)
 	(data + block_off * EXT2_SB(fs)->s_inode_size);
 }
 
-static inline int get_inode_mode(int mode)
-{
-    mode >>= S_IFSHIFT;
-    if (mode == T_IFDIR)
-	mode = I_DIR;
-    else if (mode == T_IFLNK)
-	mode = I_SYMLINK;
-    else
-	mode = I_FILE; /* we treat others as FILE */
-    return mode;
-}
-
 static void fill_inode(struct inode *inode, const struct ext2_inode *e_inode)
 {
-    inode->mode    = get_inode_mode(e_inode->i_mode);
+    inode->mode    = IFTODT(e_inode->i_mode);
     inode->size    = e_inode->i_size;
     inode->atime   = e_inode->i_atime;
     inode->ctime   = e_inode->i_ctime;
@@ -167,8 +155,7 @@ static void fill_inode(struct inode *inode, const struct ext2_inode *e_inode)
     inode->blocks  = e_inode->i_blocks;
     inode->flags   = e_inode->i_flags;
     inode->file_acl = e_inode->i_file_acl;
-    memcpy(PVT(inode)->i_block, e_inode->i_block,
-	   EXT2_N_BLOCKS * sizeof(uint32_t *));
+    memcpy(PVT(inode)->i_block, e_inode->i_block, sizeof PVT(inode)->i_block);
 }
 
 static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index ee48f73..97997d5 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -426,9 +426,9 @@ static inline sector_t first_sector(struct fs_info *fs,
 static inline int get_inode_mode(uint8_t attr)
 {
     if (attr == FAT_ATTR_DIRECTORY)
-	return I_DIR;
+	return DT_DIR;
     else
-	return I_FILE;
+	return DT_REG;
 }
 
 
@@ -564,7 +564,7 @@ static struct inode *vfat_iget_root(struct fs_info *fs)
     PVT(inode)->start_cluster = FAT_SB(fs)->root_cluster;
     inode->size = root_size ? root_size << fs->sector_shift : ~0;
     PVT(inode)->start = PVT(inode)->here = FAT_SB(fs)->root;
-    inode->mode = I_DIR;
+    inode->mode = DT_DIR;
 
     return inode;
 }
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 8d94690..6ea74bf 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -210,7 +210,7 @@ int searchdir(const char *name)
 		inode = this_fs->fs_ops->iget(part, parent);
 		if (!inode)
 		    goto err;
-		if (inode->mode == I_SYMLINK) {
+		if (inode->mode == DT_LNK) {
 		    char *linkbuf, *q;
 		    int name_len = echar ? strlen(p) : 0;
 		    int total_len = inode->size + name_len + 2;
@@ -255,7 +255,7 @@ int searchdir(const char *name)
 		if (!echar)
 		    break;
 
-		if (inode->mode != I_DIR)
+		if (inode->mode != DT_DIR)
 		    goto err;
 
 		parent = inode;
diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c
index bd5f406..9f2e5d2 100644
--- a/core/fs/iso9660/iso9660.c
+++ b/core/fs/iso9660/iso9660.c
@@ -187,9 +187,9 @@ iso_find_entry(const char *dname, struct inode *inode)
 static inline int get_inode_mode(uint8_t flags)
 {
     if (flags & 0x02)
-	return I_DIR;
+	return DT_DIR;
     else
-	return I_FILE;
+	return DT_REG;
 }
 
 static struct inode *iso_get_inode(struct fs_info *fs,
diff --git a/core/include/fs.h b/core/include/fs.h
index fb12ce3..f1d35bb 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -73,19 +73,6 @@ struct fs_ops {
     int      (*next_extent)(struct inode *, uint32_t);
 };
 
-/* XXX: merge this with enum dirent_types */
-enum inode_mode {
-    I_UNKNOWN	=  0,
-    I_FIFO	=  1,
-    I_CHR	=  2,
-    I_DIR	=  4,
-    I_BLK	=  6,
-    I_FILE	=  8,
-    I_SYMLINK	= 10,
-    I_SOCK	= 12,
-    I_WHT	= 14,
-};
-
 /*
  * Extent structure: contains the mapping of some chunk of a file
  * that is contiguous on disk.



More information about the Syslinux-commits mailing list