ref: b220675fe53ccc0077952a145ba8d96f93d5fe7f
parent: 8b65ecdeb12b5bc7d47964188207a0251c6933b5
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Nov 6 06:41:30 EST 2020
update plan 9 port
--- a/include/ext4.h
+++ b/include/ext4.h
@@ -53,6 +53,10 @@
#include <ext4_blockdev.h>
+#ifdef __plan9__
+#pragma incomplete struct ext4_mountpoint
+#endif
+
/********************************OS LOCK INFERFACE***************************/
/**@brief OS dependent lock interface.*/
--- a/include/ext4_bcache.h
+++ b/include/ext4_bcache.h
@@ -52,20 +52,6 @@
{.lb_id = 0, .data = 0}
/**@brief Single block descriptor*/
-struct ext4_block {
- /**@brief Logical block ID*/
- uint64_t lb_id;
-
- /**@brief Buffer */
- struct ext4_buf *buf;
-
- /**@brief Data buffer.*/
- uint8_t *data;
-};
-
-struct ext4_bcache;
-
-/**@brief Single block descriptor*/
struct ext4_buf {
/**@brief Flags*/
int flags;
@@ -114,6 +100,18 @@
void *end_write_arg;
};
+/**@brief Single block descriptor*/
+struct ext4_block {
+ /**@brief Logical block ID*/
+ uint64_t lb_id;
+
+ /**@brief Buffer */
+ struct ext4_buf *buf;
+
+ /**@brief Data buffer.*/
+ uint8_t *data;
+};
+
/**@brief Block cache descriptor*/
struct ext4_bcache {
@@ -148,9 +146,13 @@
SLIST_HEAD(ext4_buf_dirty, ext4_buf) dirty_list;
};
+#ifdef __plan9__
+#pragma incomplete struct ext4_buf
+#endif
+
/**@brief buffer state bits
*
- * - BC♡UPTODATE: Buffer contains valid data.
+ * - BC_UPTODATE: Buffer contains valid data.
* - BC_DIRTY: Buffer is dirty.
* - BC_FLUSH: Buffer will be immediately flushed,
* when no one references it.
--- a/include/ext4_blockdev.h
+++ b/include/ext4_blockdev.h
@@ -131,6 +131,10 @@
void *journal;
};
+#ifdef __plan9__
+#pragma incomplete struct ext4_blockdev
+#endif
+
/**@brief Static initialization of the block device.*/
#define EXT4_BLOCKDEV_STATIC_INSTANCE(__name, __bsize, __bcnt, __open, __bread,\
__bwrite, __close, __lock, __unlock) \
@@ -153,8 +157,6 @@
}
/**@brief Block device initialization.
- * @param bdev block device descriptor
- * @param bg_bsize logical block size
* @param bdev block device descriptor
* @return standard error code*/
int ext4_block_init(struct ext4_blockdev *bdev);
--- a/include/ext4_fs.h
+++ b/include/ext4_fs.h
@@ -85,6 +85,9 @@
bool dirty;
};
+#ifdef __plan9__
+#pragma incomplete struct ext4_fs
+#endif
/**@brief Convert block address to relative index in block group.
* @param sb Superblock pointer
--- a/include/ext4_hash.h
+++ b/include/ext4_hash.h
@@ -52,7 +52,6 @@
const uint32_t *seed;
};
-
/**@brief Directory entry name hash function.
* @param name entry name
* @param len entry name length
--- a/include/ext4_inode.h
+++ b/include/ext4_inode.h
@@ -51,6 +51,10 @@
#include <stdint.h>
+#ifdef __plan9__
+#pragma incomplete struct ext4_extent_header
+#endif
+
/**@brief Get mode of the i-node.
* @param sb Superblock
* @param inode I-node to load mode from
--- a/include/ext4_misc.h
+++ b/include/ext4_misc.h
@@ -145,6 +145,10 @@
((size_t)(&(((type *)0)->field)))
#endif
+#ifndef USED
+#define USED(x) (void)(x)
+#endif
+
#ifdef __cplusplus
}
#endif
--- a/include/ext4_trans.h
+++ b/include/ext4_trans.h
@@ -44,7 +44,6 @@
#include <ext4_config.h>
#include <ext4_types.h>
-
/**@brief Mark a buffer dirty and add it to the current transaction.
* @param buf buffer
* @return standard error code*/
--- a/include/ext4_types.h
+++ b/include/ext4_types.h
@@ -64,10 +64,10 @@
#define UUID_SIZE 16
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/*
@@ -182,10 +182,10 @@
uint32_t checksum; /* crc32c(superblock) */
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
#define EXT4_SUPERBLOCK_MAGIC 0xEF53
@@ -325,6 +325,12 @@
/* On-disk itable initialized to zero */
#define EXT4_BLOCK_GROUP_ITABLE_ZEROED 0x0004
+#ifdef __plan9__
+#pragma pack on
+#else
+#pragma pack(push, 1)
+#endif
+
/*
* Structure of a blocks group descriptor
*/
@@ -355,6 +361,11 @@
uint32_t reserved; /* Padding */
};
+#ifdef __plan9__
+#pragma pack off
+#else
+#pragma pack(pop)
+#endif
#define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32
#define EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE 64
@@ -373,10 +384,10 @@
#define EXT4_INODE_INDIRECT_BLOCK_COUNT \
(EXT4_INODE_BLOCKS - EXT4_INODE_DIRECT_BLOCK_COUNT)
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/*
@@ -430,10 +441,10 @@
uint32_t version_hi; /* High 32 bits for 64-bit version */
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
#define EXT4_INODE_MODE_FIFO 0x1000
@@ -495,10 +506,10 @@
#define EXT4_DIRENTRY_DIR_CSUM 0xDE
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
union ext4_dir_en_internal {
@@ -584,10 +595,10 @@
uint32_t checksum; /* crc32c(uuid+inum+dirblock) */
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
#define EXT4_DIRENT_TAIL(block, blocksize) \
@@ -642,10 +653,10 @@
#define JBD_SUPERBLOCK_V2 4
#define JBD_REVOKE_BLOCK 5
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/*
@@ -657,10 +668,10 @@
uint32_t sequence;
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
/*
@@ -675,10 +686,10 @@
#define JBD_CHECKSUM_BYTES (32 / sizeof(uint32_t))
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/*
@@ -727,10 +738,10 @@
uint32_t blocknr_high; /* most-significant high 32bits. */
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
/* Definitions for the journal tag flags word: */
@@ -739,10 +750,10 @@
#define JBD_FLAG_DELETED 4 /* block deleted by this transaction */
#define JBD_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/* Tail of descriptor block, for checksumming */
@@ -764,19 +775,19 @@
uint32_t checksum;
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
#define JBD_USERS_MAX 48
#define JBD_USERS_SIZE (UUID_SIZE * JBD_USERS_MAX)
-#ifndef __plan9__
-#pragma pack(push, 1)
-#else
+#ifdef __plan9__
#pragma pack on
+#else
+#pragma pack(push, 1)
#endif
/*
@@ -830,10 +841,10 @@
/* 0x0400 */
};
-#ifndef __plan9__
-#pragma pack(pop)
-#else
+#ifdef __plan9__
#pragma pack off
+#else
+#pragma pack(pop)
#endif
#define JBD_SUPERBLOCK_SIZE sizeof(struct jbd_sb)
--- a/include/plan9/generated/ext4_config.h
+++ b/include/plan9/generated/ext4_config.h
@@ -1,5 +1,5 @@
-#ifndef __plan9_generated_ext4_config_h__
-#define __plan9_generated_ext4_config_h__
+#ifndef __plan9__
+#define __plan9__
#include <u.h>
#include <libc.h>
@@ -9,8 +9,6 @@
typedef u32int uint32_t;
typedef u64int uint64_t;
-typedef s8int int8_t;
-typedef s16int int16_t;
typedef s32int int32_t;
typedef s64int int64_t;
@@ -20,6 +18,7 @@
typedef enum { false, true } bool;
#define NULL nil
+#define USED USED
#define CONFIG_HAVE_OWN_ERRNO 1
#define CONFIG_HAVE_OWN_ASSERT 0
@@ -33,10 +32,8 @@
#define CONFIG_EXT4_MOUNTPOINTS_COUNT 32
#define CONFIG_BLOCK_DEV_CACHE_SIZE 1024
#define CONFIG_JOURNALING_ENABLE 1
-
-/* thanks, but no GNU/GPL */
-#define CONFIG_EXTENTS_ENABLE 0
-#define CONFIG_XATTR_ENABLE 0
+#define CONFIG_EXTENTS_ENABLE 1
+#define CONFIG_XATTR_ENABLE 1
#if defined(__amd64__) || defined(__386__)
#define CONFIG_UNALIGNED_ACCESS 1