-
Notifications
You must be signed in to change notification settings - Fork 4
PortingNotes
- summary Information about how to port new changes
- labels Porting
There are a number of differences between OSX and OpenSolaris that make porting more of a challenge than in other environments (including FreeBSD).
Mac OSX defines a `vnode_t` to be a pointer to a `struct vnode *`; but in OpenSolaris, a `vnode_t` is a pointer to a `struct vnode`. This was previously handled by Issue 27 and a set of `#ifdef` around the types - but this grows to be a porting problem generally.
To solve this problem, `zfs_context.h` defines a `#def` to replace `vnode_t` on the fly with `struct vnode`. That way, we're source compatible at the point of use. However, this then breaks Mac OSX libraries like `ubc.h` and `mount.h` which (understandably) need to use the right type.
This means we need to (conditionally) replace any system headers, including:
|| *Original code* || *Replacement* || || `#include <sys/mount.h></sys/mount.h>` || `#include <maczfs/maczfs_mount.h></maczfs/maczfs_mount.h>` || || `#include <sys/file.h></sys/file.h>` || `#include <maczfs/maczfs_file.h></maczfs/maczfs_file.h>` || || `#include <sys/ubc.h></sys/ubc.h>` || `#include <maczfs/maczfs_ubc.h></maczfs/maczfs_ubc.h>` || || `#include <libc.h></libc.h>` || `#include <maczfs/maczfs_libc.h></maczfs/maczfs_libc.h>` ||
For ease of subsequent modification, the code should be conditioned as follows:
For various weird and whacky reasons, MacZFS needs to have `zfs_cmd_t` defined before the IOCs are defined (see IOCTL). The net effect of this is any import that uses `libzfs_impl.h` needs to have `libzfs_ioctl.h` before it (assuming it uses the `ZFS_IOC_` constants). See Issue 57.
In other words, this:
needs to become this:
Mac OS X uses IO_APPEND in the kernel to denote appending, instead of FAPPEND. So various `#ifdef` are set up to call with the same parameters but a switch of flag name.
Instead of using bitwise flags (like `z_vfs->vfs_flag & VFS_RDONLY`) OSX uses functions in `mount.h` to achieve the same thing.
* `z_vfs->vfs_flag & VFS_RDONLY` is replaced with `vfs_isrdonly(z_vfs)` * `z_vfs->vfs_flag &= ~VFS_RDONLY` is replaced with `vfs_clearflags(z_vfs, MNT_RDONLY` (t steflags, where appropriate)