+extern int file_extra_cnt;
+extern int uid_ndx;
+extern int gid_ndx;
+extern int acls_ndx;
+extern int xattrs_ndx;
+
+#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
+#define EXTRA_LEN (sizeof (union file_extras))
+#define PTR_EXTRA_LEN ((sizeof (char *) + EXTRA_LEN - 1) / EXTRA_LEN)
+#define DEV_EXTRA_CNT 2
+#define DIRNODE_EXTRA_CNT 3
+#define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)
+
+#define REQ_EXTRA(f,ndx) ((union file_extras*)(f) - (ndx))
+#define OPT_EXTRA(f,bump) ((union file_extras*)(f) - file_extra_cnt - 1 - (bump))
+
+#define LEN64_BUMP(f) ((f)->flags & FLAG_LENGTH64 ? 1 : 0)
+#define HLINK_BUMP(f) (F_IS_HLINKED(f) ? 1 : 0)
+#define ACL_BUMP(f) (acls_ndx ? 1 : 0)
+
+/* The length applies to all items. */
+#if SIZEOF_INT64 < 8
+#define F_LENGTH(f) ((int64)(f)->len32)
+#else
+#define F_LENGTH(f) ((int64)(f)->len32 + ((f)->flags & FLAG_LENGTH64 \
+ ? (int64)OPT_EXTRA(f, 0)->unum << 32 : 0))
+#endif
+
+/* If there is a symlink string, it is always right after the basename */
+#define F_SYMLINK(f) ((f)->basename + strlen((f)->basename) + 1)
+
+/* The sending side always has this available: */
+#define F_PATHNAME(f) (*(const char**)REQ_EXTRA(f, PTR_EXTRA_LEN))
+
+/* The receiving side always has this available: */
+#define F_DEPTH(f) REQ_EXTRA(f, 1)->num
+
+/* When the associated option is on, all entries will have these present: */
+#define F_OWNER(f) REQ_EXTRA(f, uid_ndx)->unum
+#define F_GROUP(f) REQ_EXTRA(f, gid_ndx)->unum
+#define F_ACL(f) REQ_EXTRA(f, acls_ndx)->num
+#define F_XATTR(f) REQ_EXTRA(f, xattrs_ndx)->num
+#define F_NDX(f) REQ_EXTRA(f, ic_ndx)->num
+
+/* These items are per-entry optional: */
+#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num /* non-dirs */
+#define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f))->num /* non-dirs */
+#define F_DIR_NODE_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) \
+ + DIRNODE_EXTRA_CNT - 1)->num) /* sender dirs */
+#define F_DIR_DEFACL(f) OPT_EXTRA(f, LEN64_BUMP(f))->unum /* receiver dirs */
+#define F_DIR_DEV_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) + ACL_BUMP(f) \
+ + DEV_EXTRA_CNT - 1)->unum) /* receiver dirs */
+
+/* This optional item might follow an F_HL_*() item.
+ * (Note: a device doesn't need to check LEN64_BUMP(f).) */
+#define F_RDEV_P(f) (&OPT_EXTRA(f, HLINK_BUMP(f) + 2 - 1)->unum)
+
+/* The sum is only present on regular files. */
+#define F_SUM(f) ((char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \
+ + SUM_EXTRA_CNT - 1))
+
+/* Some utility defines: */
+#define F_IS_ACTIVE(f) (f)->basename[0]
+#define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
+
+#define F_HLINK_NOT_FIRST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_FIRST)
+#define F_HLINK_NOT_LAST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_LAST)
+
+#define DEV_MAJOR(a) (a)[0]
+#define DEV_MINOR(a) (a)[1]
+
+#define DIR_PARENT(a) (a)[0]
+#define DIR_FIRST_CHILD(a) (a)[1]
+#define DIR_NEXT_SIBLING(a) (a)[2]
+
+/*
+ * Start the flist array at FLIST_START entries and grow it
+ * by doubling until FLIST_LINEAR then grow by FLIST_LINEAR
+ */
+#define FLIST_START (32 * 1024)
+#define FLIST_LINEAR (FLIST_START * 512)
+
+/*
+ * Extent size for allocation pools: A minimum size of 128KB
+ * is needed to mmap them so that freeing will release the
+ * space to the OS.
+ *
+ * Larger sizes reduce leftover fragments and speed free calls
+ * (when they happen). Smaller sizes increase the chance of
+ * freed allocations freeing whole extents.
+ */
+#define NORMAL_EXTENT (256 * 1024)
+#define SMALL_EXTENT (128 * 1024)