shithub: lwext4

Download patch

ref: 3bf6bcf4999ba59d843ff69256e03d1c6b411158
parent: 79bc1a343033f4b91363683d1bedb8726bb30385
author: gkostka <[email protected]>
date: Sat Nov 21 13:32:54 EST 2015

Style & indentation improvements in ext4 part 3

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -227,7 +227,7 @@
 		}
 
 		/*New empty directory. Two links (. and ..) */
-		ext4_inode_set_links_count(child->inode, 2);
+		ext4_inode_set_links_cnt(child->inode, 2);
 		ext4_fs_inode_links_count_inc(parent);
 		child->dirty = true;
 		parent->dirty = true;
@@ -315,7 +315,7 @@
 	 * ext4_inode_set_change_inode_time(child_inode_ref->inode,
 	 *     (uint32_t) now);
 	 */
-	if (ext4_inode_get_links_count(child_inode_ref->inode)) {
+	if (ext4_inode_get_links_cnt(child_inode_ref->inode)) {
 		ext4_fs_inode_links_count_dec(child_inode_ref);
 		child_inode_ref->dirty = true;
 	}
@@ -1076,8 +1076,8 @@
 		goto Finish;
 
 	/*Link count is zero, the inode should be freed. */
-	if (!ext4_inode_get_links_count(child.inode)) {
-		ext4_inode_set_deletion_time(child.inode, 0xFFFFFFFF);
+	if (!ext4_inode_get_links_cnt(child.inode)) {
+		ext4_inode_set_del_time(child.inode, -1L);
 		/*Turncate*/
 		ext4_block_cache_write_back(mp->fs.bdev, 1);
 		/*Truncate may be IO heavy. Do it writeback cache mode.*/
@@ -1769,7 +1769,7 @@
 		return r;
 	}
 
-	ext4_inode_set_modification_time(inode_ref.inode, mtime);
+	ext4_inode_set_modif_time(inode_ref.inode, mtime);
 	inode_ref.dirty = true;
 
 	ext4_fs_put_inode_ref(&inode_ref);
@@ -2184,7 +2184,7 @@
 	ext4_file f;
 
 	struct ext4_mountpoint *mp = ext4_get_mount(path);
-	struct ext4_inode_ref current;
+	struct ext4_inode_ref act;
 	struct ext4_inode_ref child;
 	struct ext4_dir_iterator it;
 
@@ -2202,6 +2202,8 @@
 
 	EXT4_MP_LOCK(mp);
 
+	struct ext4_fs *const fs = &mp->fs;
+
 	/*Check if exist.*/
 	r = ext4_generic_open(&f, path, "r", false, &inode_up, &name_off);
 	if (r != EOK) {
@@ -2219,15 +2221,15 @@
 
 	do {
 		/*Load directory node.*/
-		r = ext4_fs_get_inode_ref(&f.mp->fs, inode_current, &current);
+		r = ext4_fs_get_inode_ref(fs, inode_current, &act);
 		if (r != EOK) {
 			break;
 		}
 
 		/*Initialize iterator.*/
-		r = ext4_dir_iterator_init(&it, &current, 0);
+		r = ext4_dir_iterator_init(&it, &act, 0);
 		if (r != EOK) {
-			ext4_fs_put_inode_ref(&current);
+			ext4_fs_put_inode_ref(&act);
 			break;
 		}
 
@@ -2240,20 +2242,18 @@
 
 			/*Get up directory inode when ".." entry*/
 			if ((it.curr->name_length == 2) &&
-			    ext4_is_dots(it.curr->name,
-					 it.curr->name_length)) {
+			    ext4_is_dots(it.curr->name, it.curr->name_length)) {
 				inode_up = ext4_dir_entry_ll_get_inode(it.curr);
 			}
 
 			/*If directory or file entry,  but not "." ".." entry*/
-			if (!ext4_is_dots(it.curr->name,
-					  it.curr->name_length)) {
+			if (!ext4_is_dots(it.curr->name, it.curr->name_length)) {
 
 				/*Get child inode reference do unlink
 				 * directory/file.*/
-				r = ext4_fs_get_inode_ref(&f.mp->fs,
-				        ext4_dir_entry_ll_get_inode(it.curr),
-				        &child);
+				uint32_t cinode;
+				cinode = ext4_dir_entry_ll_get_inode(it.curr);
+				r = ext4_fs_get_inode_ref(fs, cinode, &child);
 				if (r != EOK)
 					break;
 
@@ -2268,7 +2268,7 @@
 					/*Has directory children. Go into this
 					 * directory.*/
 					inode_up = inode_current;
-					inode_current = ext4_dir_entry_ll_get_inode(it.curr);
+					inode_current = cinode;
 					depth++;
 					ext4_fs_put_inode_ref(&child);
 					break;
@@ -2276,7 +2276,7 @@
 
 				/*No children in child directory or file. Just
 				 * unlink.*/
-				r = ext4_unlink(f.mp, &current, &child,
+				r = ext4_unlink(f.mp, &act, &child,
 						(char *)it.curr->name,
 						it.curr->name_length);
 				if (r != EOK) {
@@ -2284,9 +2284,8 @@
 					break;
 				}
 
-				ext4_inode_set_deletion_time(child.inode,
-							     0xFFFFFFFF);
-				ext4_inode_set_links_count(child.inode, 0);
+				ext4_inode_set_del_time(child.inode, -1L);
+				ext4_inode_set_links_cnt(child.inode, 0);
 				child.dirty = true;
 				/*Turncate*/
 				r = ext4_fs_truncate_inode(&child, 0);
@@ -2311,7 +2310,7 @@
 
 		if (dir_end) {
 			/*Directory iterator reached last entry*/
-			ext4_has_children(&has_children, &current);
+			ext4_has_children(&has_children, &act);
 			if (!has_children) {
 				inode_current = inode_up;
 				if (depth)
@@ -2329,7 +2328,7 @@
 				/* In this place all directories should be
 				 * unlinked.
 				 * Last unlink from root of current directory*/
-				r = ext4_unlink(f.mp, &parent, &current,
+				r = ext4_unlink(f.mp, &parent, &act,
 						(char *)path, len);
 				if (r != EOK) {
 					ext4_fs_put_inode_ref(&parent);
@@ -2336,21 +2335,18 @@
 					goto End;
 				}
 
-				if (ext4_inode_get_links_count(current.inode) ==
-				    2) {
-					ext4_inode_set_deletion_time(
-					    current.inode, 0xFFFFFFFF);
-					ext4_inode_set_links_count(
-					    current.inode, 0);
-					current.dirty = true;
+				if (ext4_inode_get_links_cnt(act.inode) == 2) {
+					ext4_inode_set_del_time(act.inode, -1L);
+					ext4_inode_set_links_cnt(act.inode, 0);
+					act.dirty = true;
 					/*Turncate*/
-					r = ext4_fs_truncate_inode(&current, 0);
+					r = ext4_fs_truncate_inode(&act, 0);
 					if (r != EOK) {
 						ext4_fs_put_inode_ref(&parent);
 						goto End;
 					}
 
-					r = ext4_fs_free_inode(&current);
+					r = ext4_fs_free_inode(&act);
 					if (r != EOK) {
 						ext4_fs_put_inode_ref(&parent);
 						goto End;
@@ -2365,7 +2361,7 @@
 
 	End:
 		ext4_dir_iterator_fini(&it);
-		ext4_fs_put_inode_ref(&current);
+		ext4_fs_put_inode_ref(&act);
 		dir_end = false;
 
 		/*When something goes wrong. End loop.*/
@@ -2462,8 +2458,7 @@
 
 	ext4_dir_iterator_next(&it);
 
-	d->next_off =
-	    it.curr ? it.curr_off : EXT4_DIR_ENTRY_OFFSET_TERM;
+	d->next_off = it.curr ? it.curr_off : EXT4_DIR_ENTRY_OFFSET_TERM;
 
 	ext4_dir_iterator_fini(&it);
 	ext4_fs_put_inode_ref(&dir);
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -871,14 +871,14 @@
 	}
 	ext4_inode_set_mode(&fs->sb, inode, mode);
 
-	ext4_inode_set_links_count(inode, 0);
+	ext4_inode_set_links_cnt(inode, 0);
 	ext4_inode_set_uid(inode, 0);
 	ext4_inode_set_gid(inode, 0);
 	ext4_inode_set_size(inode, 0);
 	ext4_inode_set_access_time(inode, 0);
 	ext4_inode_set_change_inode_time(inode, 0);
-	ext4_inode_set_modification_time(inode, 0);
-	ext4_inode_set_deletion_time(inode, 0);
+	ext4_inode_set_modif_time(inode, 0);
+	ext4_inode_set_del_time(inode, 0);
 	ext4_inode_set_blocks_count(&fs->sb, inode, 0);
 	ext4_inode_set_flags(inode, 0);
 	ext4_inode_set_generation(inode, 0);
@@ -1671,9 +1671,9 @@
 {
 	uint16_t link;
 	bool is_dx;
-	link = ext4_inode_get_links_count(inode_ref->inode);
+	link = ext4_inode_get_links_cnt(inode_ref->inode);
 	link++;
-	ext4_inode_set_links_count(inode_ref->inode, link);
+	ext4_inode_set_links_cnt(inode_ref->inode, link);
 
 	is_dx = ext4_sb_feature_com(&inode_ref->fs->sb, EXT4_FCOM_DIR_INDEX) &&
 		ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_INDEX);
@@ -1680,7 +1680,7 @@
 
 	if (is_dx && link > 1) {
 		if (link >= EXT4_LINK_MAX || link == 2) {
-			ext4_inode_set_links_count(inode_ref->inode, 1);
+			ext4_inode_set_links_cnt(inode_ref->inode, 1);
 
 			uint32_t v;
 			v = ext4_get32(&inode_ref->fs->sb, features_read_only);
@@ -1692,16 +1692,16 @@
 
 void ext4_fs_inode_links_count_dec(struct ext4_inode_ref *inode_ref)
 {
-	uint16_t links = ext4_inode_get_links_count(inode_ref->inode);
+	uint16_t links = ext4_inode_get_links_cnt(inode_ref->inode);
 	if (!ext4_inode_is_type(&inode_ref->fs->sb, inode_ref->inode,
 				EXT4_INODE_MODE_DIRECTORY)) {
 		if (links > 0)
-			ext4_inode_set_links_count(inode_ref->inode, links - 1);
+			ext4_inode_set_links_cnt(inode_ref->inode, links - 1);
 		return;
 	}
 
 	if (links > 2)
-		ext4_inode_set_links_count(inode_ref->inode, links - 1);
+		ext4_inode_set_links_cnt(inode_ref->inode, links - 1);
 }
 
 /**
--- a/lwext4/ext4_inode.c
+++ b/lwext4/ext4_inode.c
@@ -149,22 +149,22 @@
 	inode->change_inode_time = to_le32(time);
 }
 
-uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode)
+uint32_t ext4_inode_get_modif_time(struct ext4_inode *inode)
 {
 	return to_le32(inode->modification_time);
 }
 
-void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time)
+void ext4_inode_set_modif_time(struct ext4_inode *inode, uint32_t time)
 {
 	inode->modification_time = to_le32(time);
 }
 
-uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode)
+uint32_t ext4_inode_get_del_time(struct ext4_inode *inode)
 {
 	return to_le32(inode->deletion_time);
 }
 
-void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time)
+void ext4_inode_set_del_time(struct ext4_inode *inode, uint32_t time)
 {
 	inode->deletion_time = to_le32(time);
 }
@@ -178,11 +178,11 @@
 	inode->gid = to_le32(gid);
 }
 
-uint16_t ext4_inode_get_links_count(struct ext4_inode *inode)
+uint16_t ext4_inode_get_links_cnt(struct ext4_inode *inode)
 {
 	return to_le16(inode->links_count);
 }
-void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt)
+void ext4_inode_set_links_cnt(struct ext4_inode *inode, uint16_t cnt)
 {
 	inode->links_count = to_le16(cnt);
 }
--- a/lwext4/ext4_inode.h
+++ b/lwext4/ext4_inode.h
@@ -118,25 +118,25 @@
  * @param inode I-node
  * @return Time of the last content modification (POSIX)
  */
-uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
+uint32_t ext4_inode_get_modif_time(struct ext4_inode *inode);
 
 /**@brief Set time, when i-node content was last modified.
  * @param inode I-node
  * @param time  Time of the last content modification (POSIX)
  */
-void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
+void ext4_inode_set_modif_time(struct ext4_inode *inode, uint32_t time);
 
 /**@brief Get time, when i-node was deleted.
  * @param inode I-node
  * @return Time of the delete action (POSIX)
  */
-uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
+uint32_t ext4_inode_get_del_time(struct ext4_inode *inode);
 
 /**@brief Set time, when i-node was deleted.
  * @param inode I-node
  * @param time  Time of the delete action (POSIX)
  */
-void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);
+void ext4_inode_set_del_time(struct ext4_inode *inode, uint32_t time);
 
 /**@brief Get ID of the i-node owner's group.
  * @param inode I-node to load gid from
@@ -154,13 +154,13 @@
  * @param inode I-node to load number of links from
  * @return Number of links to i-node
  */
-uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
+uint16_t ext4_inode_get_links_cnt(struct ext4_inode *inode);
 
 /**@brief Set number of links to i-node.
  * @param inode I-node to set number of links to
  * @param count Number of links to i-node
  */
-void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
+void ext4_inode_set_links_cnt(struct ext4_inode *inode, uint16_t cnt);
 
 /**@brief Get number of 512-bytes blocks used for i-node.
  * @param sb    Superblock
--- a/lwext4/ext4_mkfs.c
+++ b/lwext4/ext4_mkfs.c
@@ -607,8 +607,8 @@
 	if (r != EOK)
 		return r;
 
-	ext4_inode_set_links_count(root.inode, 3);
-	ext4_inode_set_links_count(child.inode, 2);
+	ext4_inode_set_links_cnt(root.inode, 3);
+	ext4_inode_set_links_cnt(child.inode, 2);
 
 	child.dirty = true;
 	root.dirty = true;