shithub: lwext4

Download patch

ref: 61914c7ab8aa9e6b5c6c7af8acc214f1670db94e
parent: 4624a342d4f3b9d067407596506d517fb1bf6827
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Nov 6 05:49:57 EST 2020

finish(?) the port

--- a/src/ext4.c
+++ b/src/ext4.c
@@ -34,16 +34,8 @@
  * @brief Ext4 high level operations (file, directory, mountpoints...)
  */
 
-#include <ext4_config.h>
-#include <ext4_types.h>
-#include <ext4_misc.h>
-#include <ext4_errno.h>
-#include <ext4_oflags.h>
-#include <ext4_debug.h>
-
 #include <ext4.h>
 #include <ext4_trans.h>
-#include <ext4_blockdev.h>
 #include <ext4_fs.h>
 #include <ext4_dir.h>
 #include <ext4_inode.h>
@@ -2662,6 +2654,7 @@
 	return r;
 }
 
+#if CONFIG_XATTR_ENABLE
 int ext4_setxattr(const char *path, const char *name, size_t name_len,
 		  const void *data, size_t data_size)
 {
@@ -2888,6 +2881,7 @@
 	return r;
 
 }
+#endif
 
 /*********************************DIRECTORY OPERATION************************/
 
--- a/src/ext4_dir_idx.c
+++ b/src/ext4_dir_idx.c
@@ -1312,7 +1312,7 @@
 	/* Check if insert operation passed */
 	r = ext4_dir_try_insert_entry(&fs->sb, parent, &target_block, child,
 					name, name_len);
-	if (r != EOK)
+	if (r == EOK)
 		goto release_target_index;
 
 	/* Split entries to two blocks (includes sorting by hash value) */
@@ -1319,7 +1319,7 @@
 	struct ext4_block new_block;
 	r = ext4_dir_dx_split_data(parent, &hinfo, &target_block, dx_blk,
 				    &new_block);
-	if (r == EOK)
+	if (r != EOK)
 		goto release_target_index;
 
 	/* Where to save new entry */
--- a/src/ext4_extent.c
+++ b/src/ext4_extent.c
@@ -8,11 +8,7 @@
  * of the License, or (at your option) any later version.
  */
 
-#include <ext4_config.h>
-#include <ext4_types.h>
-#include <ext4_misc.h>
-#include <ext4_errno.h>
-#include <ext4_debug.h>
+#include <ext4.h>
 
 #include <ext4_blockdev.h>
 #include <ext4_trans.h>
@@ -71,8 +67,11 @@
     struct ext4_extent *extent;
 };
 
-
+#ifdef __plan9__
+#pragma pack on
+#else
 #pragma pack(push, 1)
+#endif
 
 /*
  * This is the extent tail on-disk structure.
@@ -125,8 +124,11 @@
     uint32_t generation;    /* generation of the tree */
 };
 
+#ifdef __plan9__
+#pragma pack off
+#else
 #pragma pack(pop)
-
+#endif
 
 #define EXT4_EXTENT_MAGIC 0xF30A
 
--- a/src/ext4_fs.c
+++ b/src/ext4_fs.c
@@ -809,7 +809,7 @@
 
 	/* Reset blocks array. For inode which is not directory or file, just
 	 * fill in blocks with 0 */
-	switch (ext4_inode_type(&fs->sb, inode_ref->inode)) {
+	switch (ext4_inode_type(&fs->sb, inode)) {
 	case EXT4_INODE_MODE_FILE:
 	case EXT4_INODE_MODE_DIRECTORY:
 		break;
@@ -1359,6 +1359,7 @@
 	ext4_fsblk_t current_block;
 
 	(void)extent_create;
+	(void)support_unwritten;
 #if CONFIG_EXTENT_ENABLE
 	/* Handle i-node using extents */
 	if ((ext4_sb_feature_incom(&fs->sb, EXT4_FINCOM_EXTENTS)) &&
--- a/src/ext4_mbr.c
+++ b/src/ext4_mbr.c
@@ -47,7 +47,11 @@
 
 #define MBR_SIGNATURE 0xAA55
 
+#ifdef __plan9__
+#pragma pack on
+#else
 #pragma pack(push, 1)
+#endif
 
 struct ext4_part_entry {
 	uint8_t status;
@@ -65,7 +69,11 @@
 	uint16_t signature;
 };
 
+#ifdef __plan9__
+#pragma pack off
+#else
 #pragma pack(pop)
+#endif
 
 int ext4_mbr_scan(struct ext4_blockdev *parent, struct ext4_mbr_bdevs *bdevs)
 {
--- a/src/ext4_trans.c
+++ b/src/ext4_trans.c
@@ -35,12 +35,7 @@
  * @brief Ext4 transaction buffer operations.
  */
 
-#include <ext4_config.h>
-#include <ext4_types.h>
-#include <ext4_misc.h>
-#include <ext4_errno.h>
-#include <ext4_debug.h>
-
+#include <ext4.h>
 #include <ext4_fs.h>
 #include <ext4_journal.h>
 
--- a/src/ext4_xattr.c
+++ b/src/ext4_xattr.c
@@ -87,7 +87,11 @@
 
 #define EXT4_ZERO_XATTR_VALUE ((void *)-1)
 
+#ifdef __plan9__
+#pragma pack on
+#else
 #pragma pack(push, 1)
+#endif
 
 struct ext4_xattr_header {
     uint32_t h_magic;   /* magic number for identification */
@@ -112,8 +116,11 @@
     uint32_t e_hash;        /* hash value of name and value */
 };
 
+#ifdef __plan9__
+#pragma pack off
+#else
 #pragma pack(pop)
-
+#endif
 
 #define NAME_HASH_SHIFT 5
 #define VALUE_HASH_SHIFT 16
--- a/src/mkfile
+++ b/src/mkfile
@@ -1,6 +1,6 @@
 </$objtype/mkfile
 
-CFLAGS=$CFLAGS -D__$objtype__ -p -I../include/plan9 -I../include
+CFLAGS=$CFLAGS -D__${objtype}__ -p -I../include -I../include/plan9
 LIB=liblwext4.a
 
 HFILES=\
@@ -16,6 +16,7 @@
 	../include/ext4_dir.h\
 	../include/ext4_dir_idx.h\
 	../include/ext4_errno.h\
+	../include/ext4_extent.h\
 	../include/ext4_fs.h\
 	../include/ext4_hash.h\
 	../include/ext4_ialloc.h\
@@ -28,6 +29,7 @@
 	../include/ext4_super.h\
 	../include/ext4_trans.h\
 	../include/ext4_types.h\
+	../include/ext4_xattr.h\
 	../include/misc/queue.h\
 	../include/misc/tree.h\
 	../include/plan9/generated/ext4_config.h\
@@ -58,6 +60,7 @@
 	ext4_debug.$O\
 	ext4_dir.$O\
 	ext4_dir_idx.$O\
+	ext4_extent.$O\
 	ext4_fs.$O\
 	ext4_hash.$O\
 	ext4_ialloc.$O\
@@ -67,6 +70,7 @@
 	ext4_mkfs.$O\
 	ext4_super.$O\
 	ext4_trans.$O\
+	ext4_xattr.$O\
 
 default:V: all