This is what I did to make tux3.h compile in kernel.  It should give
an idea of the kinds of changes we will be running into.

Daniel
--- /src/tux3/tux3.h	2008-11-15 01:37:37.000000000 -0800
+++ fs/tux3/tux3.h	2008-11-15 01:27:16.000000000 -0800
@@ -1,17 +1,9 @@
 #ifndef TUX3_H
 #define TUX3_H
 
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include <byteswap.h>
-#include <sys/time.h>
-#include <time.h>
-#include "err.h"
+typedef loff_t block_t;
+
 #include "trace.h"
-#include "buffer.h"
 
 #ifdef __CHECKER__
 #define __force		__attribute__((force))
@@ -20,16 +12,13 @@
 #define __force
 #define __bitwise__
 #endif
+
 #ifdef __CHECK_ENDIAN__
 #define __bitwise __bitwise__
 #else
 #define __bitwise
 #endif
 
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
 typedef long long L; // widen for printf on 64 bit systems
 
 #define PACKED __attribute__ ((packed))
@@ -44,26 +33,6 @@
 typedef u64 tuxkey_t;
 typedef int fd_t;
 
-/* Bitmaps */
-
-// !!! change to bit zero at high end of byte, consistent with big endian !!! //
-// Careful about bitops on kernel port - need to reverse on le arch, maybe some be too.
-
-static inline int get_bit(unsigned char *bitmap, unsigned bit)
-{
-	return bitmap[bit >> 3] & (1 << (bit & 7));
-}
-
-static inline void set_bit(unsigned char *bitmap, unsigned bit)
-{
-	bitmap[bit >> 3] |= 1 << (bit & 7);
-}
-
-static inline void reset_bit(unsigned char *bitmap, unsigned bit)
-{
-	bitmap[bit >> 3] &= ~(1 << (bit & 7));
-}
-
 /* Endian support */
 
 typedef u16 __bitwise be_u16;
@@ -72,32 +41,32 @@
 
 static inline u16 from_be_u16(be_u16 val)
 {
-	return bswap_16((__force u16)val);
+	return __be16_to_cpu(val);
 }
 
 static inline u32 from_be_u32(be_u32 val)
 {
-	return bswap_32((__force u32)val);
+	return __be32_to_cpu(val);
 }
 
 static inline u64 from_be_u64(be_u64 val)
 {
-	return bswap_64((__force u64)val);
+	return __be64_to_cpu(val);
 }
 
 static inline be_u16 to_be_u16(u16 val)
 {
-	return (__force be_u16)bswap_16(val);
+	return __cpu_to_le16(val);
 }
 
 static inline be_u32 to_be_u32(u32 val)
 {
-	return (__force be_u32)bswap_32(val);
+	return __cpu_to_le32(val);
 }
 
 static inline be_u64 to_be_u64(u64 val)
 {
-	return (__force be_u64)bswap_64(val);
+	return __cpu_to_le64(val);
 }
 
 static inline void *encode16(void *at, unsigned val)
@@ -208,23 +177,6 @@
 	unsigned freeatom, atomgen;
 };
 
-struct inode {
-	struct sb *sb;
-	struct map *map;
-	struct btree btree;
-	inum_t inum;
-	unsigned i_version, present;
-	u64 i_size, i_mtime, i_ctime, i_atime;
-	unsigned i_mode, i_uid, i_gid, i_links;
-	struct xcache *xcache;
-};
-
-struct file {
-	struct inode *f_inode;
-	unsigned f_version;
-	loff_t f_pos;
-};
-
 typedef void vleaf;
 
 #define BTREE struct btree *btree
@@ -250,21 +202,20 @@
  */
 #define TIME_ATTR_SHIFT 16
 
-static inline fixed32 tuxtimeval(unsigned sec, unsigned usec)
+static inline fixed32 tuxtimeval(unsigned sec, unsigned nsec)
 {
-	return ((u64)sec << 32) + ((u64)usec << 32) / 1000000;
+	return ((u64)sec << 32) + ((u64)nsec << 32) / 1000000000;
 }
 
 static inline fixed32 tuxtime(void)
 {
-	struct timeval now;
-	gettimeofday(&now, NULL);
-	return tuxtimeval(now.tv_sec, now.tv_usec);
+	struct timespec now = current_kernel_time();
+	return tuxtimeval(now.tv_sec, now.tv_nsec);
 }
 
 static inline unsigned billionths(fixed32 val)
 {
-	return ((((val & 0xffffffff) * 1000000) + 0x80000000) >> 32) * 1000;
+	return (((val & 0xffffffff) * 1000000000) + 0x80000000) >> 32;
 }
 
 static inline u32 high32(fixed32 val)
@@ -272,7 +223,7 @@
 	return val >> 32;
 }
 
-struct iattr {
+struct tux_iattr {
 	u64 isize, mtime, ctime, atime;
 	unsigned mode, uid, gid, links;
 };
@@ -304,7 +255,15 @@
 	XATTR_BIT = 1 << XATTR_ATTR,
 };
 
-unsigned atsize[MAX_ATTRS];
+static unsigned atsize[MAX_ATTRS] = {
+	[MODE_OWNER_ATTR] = 12,
+	[CTIME_SIZE_ATTR] = 14,
+	[DATA_BTREE_ATTR] = 8,
+	[LINK_COUNT_ATTR] = 4,
+	[MTIME_ATTR] = 6,
+	[IDATA_ATTR] = 2,
+	[XATTR_ATTR] = 4,
+};
 
 struct xattr { u16 atom, size; char body[]; };
 struct xcache { u16 size, maxsize; struct xattr xattrs[]; };
@@ -319,9 +278,10 @@
 	return (void *)xcache + xcache->size;
 }
 
-void *encode_kind(void *attrs, unsigned kind, unsigned version)
+static inline void *encode_kind(void *attrs, unsigned kind, unsigned version)
 {
 	return encode16(attrs, (kind << 12) | version);
 }
 
+struct inode *tux3_get_inode(struct super_block *sb, int mode, dev_t dev);
 #endif
_______________________________________________
Tux3 mailing list
[email protected]
http://tux3.org/cgi-bin/mailman/listinfo/tux3

Reply via email to