Thursday, June 22, 2006

Massive cleanup, libzfs almost compiling

Today I did a massive cleanup of the source code.

As of now, there's a new library called libsolcompat that implements or translates all necessary Solaris-specific functions into glibc functions (yes, FreeBSD will require some work here).

This massive cleanup also means that all #includes will be exactly the same between the original source files and the Linux port! :)

This was achieved by overriding some glibc system headers with a local header, with the help of a gcc-specific preprocessor directive called #include_next. This directive allows one to include the overriden system header, while adding some functionality to it.

You can see a trivial example of this in the libsolcompat string.h, where a Solaris-specific function called strlcpy() was added.

With this new file structure in place, it is now much easier to port new files.

This also means libzfs is almost fully compiling. There are only a few functions left to be ported, which don't seem too difficult. However, getting it to work correctly will still require some work, as there are some differences between a real filesystem and a FUSE filesystem (I don't think mount(2) will work, ioctls must be replaced by UNIX sockets, etc), and between Solaris and Linux, obviously (some /dev/dsk references are still in place, etc).


Anonymous said...

Mount works with fuse:
ln -s /bin/fusefs /sbin/mount.fusefs
mount -t fusefs /mnt/fusefs

Anonymous said...

He said mount(2), not mount(8).

man 2 mount
man 8 mount

Anonymous said...


FreeBSD has strlcpy(), which originated on OpenBSD and was adopted by Solaris too.

Anonymous said...

mount(8) uses mount(2), and the previous example shows how to make mount(2) work with FUSE.