Tutorial: How to Build and Install UFS-LINUX on Fedora 11 x86_64

Mr. Teo En Ming (Zhang Enming) space.time.universe at gmail.com
Wed Nov 18 05:36:39 UTC 2009


The project's official webpage is at

http://sourceforge.net/projects/ufs-linux/

ufs-tools is an userspace tool to support FreeBSD's UFS/UFS2
filesystems on Linux. It is a port of libufs2 from FreeBSD.

Download the latest source tarball as at 2004-01-13 10:34:33 GMT.

Download link: http://sourceforge.net/projects/ufs-linux/files/ufs-tools/0.1/ufs-tools-0.1.tar.bz2/download

After completing the download, extract the source tarball.

$ tar xfvj ufs-tools-0.1.tar.bz2

Change directory into the ufs-tools source tree.

$ cd ufs-tools-0.1

$ cd libufs

Apply the following patch to Makefile.

$ patch < Makefile-fc11.patch

File Makefile-fc11.patch:

<CODE>
Patch by Mr. Teo En Ming (Zhang Enming) to allow ufs-linux to compile
and install on Fedora 11 x86_64
Email: space.time.universe at gmail.com
MSN: teoenming at hotmail.com
Mobile Phone: +65-8369-2618
Location: Bedok Reservoir Road, Singapore
Date: 18 November 2009 Wednesday SGT

--- Makefile    2004-01-12 20:30:15.000000000 +0800
+++ Makefile.new        2009-11-17 22:08:55.533049112 +0800
@@ -4,16 +4,16 @@
 LIBUFS="_LIBUFS"

 all : block cgroup inode type sblock
-       cc  -shared -o libufs.so  block.o cgroup.o inode.o type.o sblock.o
+       cc -fPIC -shared -o libufs.so  block.o cgroup.o inode.o type.o sblock.o
 block : block.c
-       cc -c block.c  -I${INCLUDE} -D${LIBUFS}
+       cc -fPIC -c block.c  -I${INCLUDE} -D${LIBUFS}
 cgroup : cgroup.c
-       cc -c cgroup.c  -I${INCLUDE} -D${LIBUFS}
+       cc -fPIC -c cgroup.c  -I${INCLUDE} -D${LIBUFS}
 inode : inode.c
-       cc -c inode.c  -I${INCLUDE} -D${LIBUFS}
+       cc -fPIC -c inode.c  -I${INCLUDE} -D${LIBUFS}
 type : type.c
-       cc -c type.c  -I${INCLUDE} -D${LIBUFS}
+       cc -fPIC -c type.c  -I${INCLUDE} -D${LIBUFS}
 sblock : sblock.c
-       cc -c sblock.c  -I${INCLUDE} -D${LIBUFS}
+       cc -fPIC -c sblock.c  -I${INCLUDE} -D${LIBUFS}
 clean :
       rm *.o *.so
</CODE>

Compile the libufs2 library.

$ make

$ cd ../include/ufs/

Apply the following patch to types.h C header file.

$ patch < types-fc11.h.patch

File types-fc11.h.patch:

<CODE>
Patch by Mr. Teo En Ming (Zhang Enming) to allow ufs-linux to compile
and install on Fedora 11 x86_64
Email: space.time.universe at gmail.com
MSN: teoenming at hotmail.com
Mobile Phone: +65-8369-2618
Location: Bedok Reservoir Road, Singapore
Date: 18 November 2009 Wednesday SGT

--- types.h     2004-01-12 17:45:13.000000000 +0800
+++ types.h.new 2009-11-17 22:17:45.248047379 +0800
@@ -5,9 +5,6 @@
 typedef unsigned __int8 __u8;
 typedef signed __int8 __s8;

-typedef signed   __int64 __s64;
-typedef unsigned __int64 __u64;
-
 typedef        signed   __int16        __s16;
 typedef        unsigned __int16        __u16;

@@ -32,8 +29,10 @@
 typedef        int32_t __s32;
 typedef        uint32_t __u32;

-typedef uint64_t  __s64;
-typedef int64_t   __u64;
+#if defined TYPESH >= 1
+typedef uint64_t  __u64;
+typedef int64_t   __s64;
+#endif

 /*
 typedef int32_t ufs1_daddr_t;
</CODE>

Go back to the top level ufs-linux source directory.

$ cd ../..

Apply the following set of 3 patches.

$ patch < Makefile-fc11.patch

File Makefile-fc11.patch:

<CODE>
Patch by Mr. Teo En Ming (Zhang Enming) to allow ufs-linux to compile
and install on Fedora 11 x86_64
Email: space.time.universe at gmail.com
MSN: teoenming at hotmail.com
Mobile Phone: +65-8369-2618
Location: Bedok Reservoir Road, Singapore
Date: 18 November 2009 Wednesday SGT

--- Makefile    2004-01-12 17:45:13.000000000 +0800
+++ Makefile.new        2009-11-17 22:22:35.798046895 +0800
@@ -6,8 +6,8 @@
 all : mkufs mkfs
       cc  -o mkufs  mkufs.o mkfs.o  libufs/libufs.so
 mkufs : mkufs.c
-       cc -c mkufs.c  -I${INCLUDE} ${CFLGS}
+       cc -fno-builtin-exit -c mkufs.c  -I${INCLUDE} ${CFLGS}
 mkfs : mkfs.c
-       cc -c mkfs.c  -I${INCLUDE} ${CFLGS}
+       cc -fno-builtin-exit -c mkfs.c  -I${INCLUDE} ${CFLGS}
 clean:
       rm *.o mkufs
</CODE>

$ patch < mkfs-fc11.c.patch

File mkfs-fc11.c.patch:

<CODE>
Patch by Mr. Teo En Ming (Zhang Enming) to allow ufs-linux to compile
and install on Fedora 11 x86_64
Email: space.time.universe at gmail.com
MSN: teoenming at hotmail.com
Mobile Phone: +65-8369-2618
Location: Bedok Reservoir Road, Singapore
Date: 18 November 2009 Wednesday SGT

--- mkfs.c      2004-01-12 17:45:13.000000000 +0800
+++ mkfs.c.new  2009-11-17 22:14:57.970921921 +0800
@@ -57,6 +57,7 @@
 #include <sys/ioctl.h>
 #include <grp.h>

+#define        TYPESH  1
 #include"ufs/types.h"
 #include"ufs/misc.h"
 #include"ufs/dinode.h"    /* Taken from FreeBSD */
@@ -1043,6 +1044,7 @@
 * For the regression test, return predictable random values.
 * Otherwise use a true random number generator.
 */
+u_int32_t arc4random();
 static u_int32_t
 newfs_random(void)
 {
</CODE>

$ patch < mkufs-fc11.c.patch

File mkufs-fc11.c.patch:

<CODE>
Patch by Mr. Teo En Ming (Zhang Enming) to allow ufs-linux to compile
and install on Fedora 11 x86_64
Email: space.time.universe at gmail.com
MSN: teoenming at hotmail.com
Mobile Phone: +65-8369-2618
Location: Bedok Reservoir Road, Singapore
Date: 18 November 2009 Wednesday SGT

--- mkufs.c     2004-01-13 13:36:35.000000000 +0800
+++ mkufs.c.new 2009-11-17 22:10:11.942046997 +0800
@@ -103,6 +103,7 @@
 static void rewritelabel(char *s, struct disklabel *lp);
 static void usage(void);
 static void errx(int n,char *fmt, ...);
+static void err(int n,char *fmt, ...);


 /*---------------------------------------------------------*/
</CODE>

Compile the mkufs binary utility.

$ make

Install the library and binary.

$ sudo cp libufs/libufs.so /lib64

$ sudo cp mkufs /sbin

Now you have UFS2 support on Linux.


More information about the freebsd-amd64 mailing list