Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

PortingNotes

Alex Blewitt edited this page Dec 12, 2010 · 7 revisions
  1. summary Information about how to port new changes
  2. labels Porting

Introduction

There are a number of differences between OSX and OpenSolaris that make porting more of a challenge than in other environments (including FreeBSD).

vnode_t

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:

ZFS_IOC_* not defined

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).

In other words, this:

needs to become this:

Clone this wiki locally