shithub: lwext4

Download patch

ref: d69ffabcc83a63783f589fdcb7dfb15728aa12f6
parent: dacdc92bd3e9e87916481fb6ce6dd17de7d64f8d
author: gkostka <kostka.grzegorz@gmail.com>
date: Sat Nov 21 12:21:11 EST 2015

Refactoring: directrory entry prefix: EXT4_DIRENTRY* -> EXT4_DE*

--- a/fs_test/common/test_lwext4.c
+++ b/fs_test/common/test_lwext4.c
@@ -44,21 +44,21 @@
 static char *entry_to_str(uint8_t type)
 {
 	switch (type) {
-	case EXT4_DIRENTRY_UNKNOWN:
+	case EXT4_DE_UNKNOWN:
 		return "[unk] ";
-	case EXT4_DIRENTRY_REG_FILE:
+	case EXT4_DE_REG_FILE:
 		return "[fil] ";
-	case EXT4_DIRENTRY_DIR:
+	case EXT4_DE_DIR:
 		return "[dir] ";
-	case EXT4_DIRENTRY_CHRDEV:
+	case EXT4_DE_CHRDEV:
 		return "[cha] ";
-	case EXT4_DIRENTRY_BLKDEV:
+	case EXT4_DE_BLKDEV:
 		return "[blk] ";
-	case EXT4_DIRENTRY_FIFO:
+	case EXT4_DE_FIFO:
 		return "[fif] ";
-	case EXT4_DIRENTRY_SOCK:
+	case EXT4_DE_SOCK:
 		return "[soc] ";
-	case EXT4_DIRENTRY_SYMLINK:
+	case EXT4_DE_SYMLINK:
 		return "[sym] ";
 	default:
 		break;
--- a/fs_test/lwext4_server.c
+++ b/fs_test/lwext4_server.c
@@ -1107,22 +1107,22 @@
 static char *entry_to_str(uint8_t type)
 {
 	switch (type) {
-	case EXT4_DIRENTRY_UNKNOWN:
-		return "[UNK] ";
-	case EXT4_DIRENTRY_REG_FILE:
-		return "[FIL] ";
-	case EXT4_DIRENTRY_DIR:
-		return "[DIR] ";
-	case EXT4_DIRENTRY_CHRDEV:
-		return "[CHA] ";
-	case EXT4_DIRENTRY_BLKDEV:
-		return "[BLK] ";
-	case EXT4_DIRENTRY_FIFO:
-		return "[FIF] ";
-	case EXT4_DIRENTRY_SOCK:
-		return "[SOC] ";
-	case EXT4_DIRENTRY_SYMLINK:
-		return "[SYM] ";
+	case EXT4_DE_UNKNOWN:
+		return "[unk] ";
+	case EXT4_DE_REG_FILE:
+		return "[fil] ";
+	case EXT4_DE_DIR:
+		return "[dir] ";
+	case EXT4_DE_CHRDEV:
+		return "[cha] ";
+	case EXT4_DE_BLKDEV:
+		return "[blk] ";
+	case EXT4_DE_FIFO:
+		return "[fif] ";
+	case EXT4_DE_SOCK:
+		return "[soc] ";
+	case EXT4_DE_SYMLINK:
+		return "[sym] ";
 	default:
 		break;
 	}
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -613,8 +613,8 @@
 		if (!len) {
 			/*If root open was request.*/
 			if (is_goal &&
-			    ((ftype == EXT4_DIRENTRY_DIR) ||
-			     (ftype == EXT4_DIRENTRY_UNKNOWN)))
+			    ((ftype == EXT4_DE_DIR) ||
+			     (ftype == EXT4_DE_UNKNOWN)))
 				break;
 
 			r = ENOENT;
@@ -635,7 +635,7 @@
 			/*O_CREAT allows create new entry*/
 			struct ext4_inode_ref child_ref;
 			r = ext4_fs_alloc_inode(fs, &child_ref,
-					is_goal ? ftype : EXT4_DIRENTRY_DIR);
+					is_goal ? ftype : EXT4_DE_DIR);
 			if (r != EOK)
 				break;
 
@@ -683,7 +683,7 @@
 			r = ENOENT;
 			break;
 		}
-		if (ftype != EXT4_DIRENTRY_UNKNOWN) {
+		if (ftype != EXT4_DE_UNKNOWN) {
 			bool df = imode != ext4_fs_correspond_inode_mode(ftype);
 			if (df && is_goal) {
 				r = ENOENT;
@@ -749,9 +749,9 @@
 		return EINVAL;
 
 	if (file_expect == true)
-		filetype = EXT4_DIRENTRY_REG_FILE;
+		filetype = EXT4_DE_REG_FILE;
 	else
-		filetype = EXT4_DIRENTRY_DIR;
+		filetype = EXT4_DE_DIR;
 
 	return ext4_generic_open2(f, path, iflags, filetype, parent_inode,
 				  name_off);
@@ -911,7 +911,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDONLY, EXT4_DIRENTRY_UNKNOWN,
+	r = ext4_generic_open2(&f, path, O_RDONLY, EXT4_DE_UNKNOWN,
 			       &parent_inode, &name_off);
 	if (r != EOK)
 		goto Finish;
@@ -960,7 +960,7 @@
 	EXT4_MP_LOCK(mp);
 
 	r = ext4_generic_open2(&f, path, O_RDONLY,
-			EXT4_DIRENTRY_UNKNOWN,
+			EXT4_DE_UNKNOWN,
 			&parent_inode, &name_off);
 	if (r != EOK)
 		goto Finish;
@@ -1045,7 +1045,7 @@
 
 	EXT4_MP_LOCK(mp);
 	r = ext4_generic_open2(&f, path, O_RDWR,
-			       EXT4_DIRENTRY_UNKNOWN,
+			       EXT4_DE_UNKNOWN,
 			       &parent_inode, &name_off);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
@@ -1117,7 +1117,7 @@
 	EXT4_MP_LOCK(mp);
 
 	r = ext4_generic_open2(&f, path, O_RDONLY,
-			       EXT4_DIRENTRY_UNKNOWN,
+			       EXT4_DE_UNKNOWN,
 			       NULL, NULL);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
@@ -1170,7 +1170,7 @@
 	if (!mp)
 		return ENOENT;
 
-        filetype = EXT4_DIRENTRY_REG_FILE;
+        filetype = EXT4_DE_REG_FILE;
 
 	EXT4_MP_LOCK(mp);
 	ext4_block_cache_write_back(mp->fs.bdev, 1);
@@ -1647,7 +1647,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DIRENTRY_UNKNOWN, 0, 0);
+	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
 		return r;
@@ -1682,7 +1682,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DIRENTRY_UNKNOWN, 0, 0);
+	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
 		return r;
@@ -1717,7 +1717,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DIRENTRY_UNKNOWN, 0, 0);
+	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
 		return r;
@@ -1751,7 +1751,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DIRENTRY_UNKNOWN, 0, 0);
+	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
 		return r;
@@ -1785,7 +1785,7 @@
 
 	EXT4_MP_LOCK(mp);
 
-	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DIRENTRY_UNKNOWN, 0, 0);
+	r = ext4_generic_open2(&f, path, O_RDWR, EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK) {
 		EXT4_MP_UNLOCK(mp);
 		return r;
@@ -1891,7 +1891,7 @@
 	if (!mp)
 		return ENOENT;
 
-	filetype = EXT4_DIRENTRY_SYMLINK;
+	filetype = EXT4_DE_SYMLINK;
 
 	EXT4_MP_LOCK(mp);
 	ext4_block_cache_write_back(mp->fs.bdev, 1);
@@ -1922,7 +1922,7 @@
 	if (!buf)
 		return EINVAL;
 
-	filetype = EXT4_DIRENTRY_SYMLINK;
+	filetype = EXT4_DE_SYMLINK;
 
 	EXT4_MP_LOCK(mp);
 	ext4_block_cache_write_back(mp->fs.bdev, 1);
@@ -1962,7 +1962,7 @@
 
 	EXT4_MP_LOCK(mp);
 	r = ext4_generic_open2(&f, path, O_RDWR,
-				EXT4_DIRENTRY_UNKNOWN, 0, 0);
+				EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK)
 		goto Finish;
 	inode = f.inode;
@@ -2011,7 +2011,7 @@
 
 	EXT4_MP_LOCK(mp);
 	r = ext4_generic_open2(&f, path, O_RDWR,
-				EXT4_DIRENTRY_UNKNOWN, 0, 0);
+				EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK)
 		goto Finish;
 	inode = f.inode;
@@ -2099,7 +2099,7 @@
 
 	EXT4_MP_LOCK(mp);
 	r = ext4_generic_open2(&f, path, O_RDWR,
-				EXT4_DIRENTRY_UNKNOWN, 0, 0);
+				EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK)
 		goto Finish;
 	inode = f.inode;
@@ -2155,7 +2155,7 @@
 
 	EXT4_MP_LOCK(mp);
 	r = ext4_generic_open2(&f, path, O_RDWR,
-				EXT4_DIRENTRY_UNKNOWN, 0, 0);
+				EXT4_DE_UNKNOWN, 0, 0);
 	if (r != EOK)
 		goto Finish;
 	inode = f.inode;
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -300,13 +300,13 @@
 	/* Set type of entry */
 	switch (ext4_inode_type(sb, child->inode)) {
 	case EXT4_INODE_MODE_DIRECTORY:
-		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DIRENTRY_DIR);
+		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DE_DIR);
 		break;
 	case EXT4_INODE_MODE_FILE:
-		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DIRENTRY_REG_FILE);
+		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DE_REG_FILE);
 		break;
 	case EXT4_INODE_MODE_SOFTLINK:
-		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DIRENTRY_SYMLINK);
+		ext4_dir_entry_ll_set_inode_type(sb, en, EXT4_DE_SYMLINK);
 		break;
 	default:
 		/* FIXME: right now we only support 3 inode type. */
--- a/lwext4/ext4_dir.h
+++ b/lwext4/ext4_dir.h
@@ -150,7 +150,7 @@
 	    (ext4_get32(sb, minor_rev_level) >= 5))
 		return de->in.inode_type;
 
-	return EXT4_DIRENTRY_UNKNOWN;
+	return EXT4_DE_UNKNOWN;
 }
 /**@brief Set i-node type of directory entry.
  * @param sb   Superblock
--- a/lwext4/ext4_dir_idx.c
+++ b/lwext4/ext4_dir_idx.c
@@ -416,7 +416,7 @@
 		uint16_t len = block_size - sizeof(struct ext4_dir_entry_tail);
 		ext4_dir_entry_ll_set_entry_length(be, len);
 		ext4_dir_entry_ll_set_name_length(sb, be, 0);
-		ext4_dir_entry_ll_set_inode_type(sb, be, EXT4_DIRENTRY_UNKNOWN);
+		ext4_dir_entry_ll_set_inode_type(sb, be, EXT4_DE_UNKNOWN);
 		ext4_dir_init_entry_tail(EXT4_DIRENT_TAIL(be, block_size));
 		ext4_dir_set_csum(dir, be);
 	} else {
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -812,11 +812,11 @@
 uint32_t ext4_fs_correspond_inode_mode(int filetype)
 {
 	switch (filetype) {
-	case EXT4_DIRENTRY_DIR:
+	case EXT4_DE_DIR:
 		return EXT4_INODE_MODE_DIRECTORY;
-	case EXT4_DIRENTRY_REG_FILE:
+	case EXT4_DE_REG_FILE:
 		return EXT4_INODE_MODE_FILE;
-	case EXT4_DIRENTRY_SYMLINK:
+	case EXT4_DE_SYMLINK:
 		return EXT4_INODE_MODE_SOFTLINK;
 	default:
 		/* FIXME: right now we only support 3 file type. */
@@ -832,7 +832,7 @@
 	bool is_dir;
 	uint16_t inode_size = ext4_get16(&fs->sb, inode_size);
 
-	is_dir = (filetype == EXT4_DIRENTRY_DIR);
+	is_dir = (filetype == EXT4_DE_DIR);
 
 	/* Allocate inode by allocation algorithm */
 	uint32_t index;
--- a/lwext4/ext4_mkfs.c
+++ b/lwext4/ext4_mkfs.c
@@ -530,12 +530,12 @@
 	int i;
 	struct ext4_inode_ref inode_ref;
 	for (i = 1; i < 12; ++i) {
-		int filetype = EXT4_DIRENTRY_REG_FILE;
+		int filetype = EXT4_DE_REG_FILE;
 
 		switch (i) {
 		case EXT4_ROOT_INO:
 		case EXT4_GOOD_OLD_FIRST_INO:
-			filetype = EXT4_DIRENTRY_DIR;
+			filetype = EXT4_DE_DIR;
 			break;
 		}
 
--- a/lwext4/ext4_types.h
+++ b/lwext4/ext4_types.h
@@ -474,14 +474,14 @@
 #define EXT4_DIRECTORY_FILENAME_LEN 255
 
 /**@brief   Directory entry types. */
-enum { EXT4_DIRENTRY_UNKNOWN = 0,
-       EXT4_DIRENTRY_REG_FILE,
-       EXT4_DIRENTRY_DIR,
-       EXT4_DIRENTRY_CHRDEV,
-       EXT4_DIRENTRY_BLKDEV,
-       EXT4_DIRENTRY_FIFO,
-       EXT4_DIRENTRY_SOCK,
-       EXT4_DIRENTRY_SYMLINK };
+enum { EXT4_DE_UNKNOWN = 0,
+       EXT4_DE_REG_FILE,
+       EXT4_DE_DIR,
+       EXT4_DE_CHRDEV,
+       EXT4_DE_BLKDEV,
+       EXT4_DE_FIFO,
+       EXT4_DE_SOCK,
+       EXT4_DE_SYMLINK };
 
 #define EXT4_DIRENTRY_DIR_CSUM 0xDE