#define FLAG_HLINKED (1<<5) /* receiver/generator */
#define FLAG_HLINK_FIRST (1<<6) /* receiver/generator */
#define FLAG_HLINK_LAST (1<<7) /* receiver/generator */
-#define FLAG_LENGTH64 (1<<8) /* sender/receiver/generator */
+#define FLAG_HLINK_DONE (1<<8) /* receiver/generator */
+#define FLAG_LENGTH64 (1<<9) /* sender/receiver/generator */
+
+#define BITS_SET(val,bits) (((val) & (bits)) == (bits))
+#define BITS_SETnUNSET(val,onbits,offbits) (((val) & ((onbits)|(offbits))) == (onbits))
/* update this if you make incompatible changes */
#define PROTOCOL_VERSION 30
#define GID_NONE ((gid_t)-1)
-#define HL_CHECK_MASTER 0
-#define HL_SKIP 1
-
-struct hlist {
- int32 next;
- int32 hlindex;
- unsigned short dest_used;
-};
-
struct file_struct {
union flist_extras {
uid_t uid; /* The user ID number */
uid_t gid; /* The group ID number or GID_NONE */
struct idev *idev; /* The hard-link info during matching */
struct hlist *hlist; /* The hard-link info after matching */
+ int32 num; /* A signed number */
uint32 unum; /* An unsigned number */
} extras[1];
time_t modtime; /* When the item was last modified */
#define REQ_EXTRA(f,ndx) ((f)->extras - (ndx - 1))
#define OPT_EXTRA(f,bump) ((f)->extras - flist_extra_cnt - (bump))
+
#define LEN64_BUMP(f) ((f)->flags & FLAG_LENGTH64 ? 1 : 0)
#define HLINK_BUMP(f) (F_IS_HLINKED(f) ? 1 : 0)
#define F_UID(f) REQ_EXTRA(f, preserve_uid)->uid
#define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid
-/* These are per-entry optional and mutally exclusive: */
-#define F_IDEV(f) OPT_EXTRA(f, LEN64_BUMP(f))->idev
-#define F_HLIST(f) OPT_EXTRA(f, LEN64_BUMP(f))->hlist
+/* These items are per-entry optional and mutally exclusive: */
+#define F_HL_IDEV(f) OPT_EXTRA(f, LEN64_BUMP(f))->idev
+#define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
-/* These are per-entry optional, but always both or neither:
- * (Note: a device doesn't need to use LEN64_BUMP(f).) */
-#define F_DMAJOR(f) OPT_EXTRA(f, HLINK_BUMP(f))->unum
-#define F_DMINOR(f) OPT_EXTRA(f, HLINK_BUMP(f) + 1)->unum
+/* 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) ((const char*)OPT_EXTRA(f, LEN64_BUMP(f) + SUM_EXTRA_CNT - 1))
+#define F_SUM(f) ((const char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \
+ + SUM_EXTRA_CNT - 1))
-/* A couple bool-type utility functions: */
-#define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
+/* Some utility defines: */
#define F_IS_ACTIVE(f) F_BASENAME(f)[0]
+#define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
+#define F_NOT_HLINK_FIRST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_FIRST)
+#define F_NOT_HLINK_LAST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_LAST)
+
+#define DEV_MAJOR(a) (a)[0]
+#define DEV_MINOR(a) (a)[1]
/*
* Start the flist array at FLIST_START entries and grow it
#define FILE_EXTENT (256 * 1024)
#define HLINK_EXTENT (128 * 1024)
-#define WITH_HLINK 1
-#define WITHOUT_HLINK 0
-
struct file_list {
struct file_struct **files;
alloc_pool_t file_pool;
- alloc_pool_t hlink_pool;
int count, malloced;
int low, high; /* 0-relative index values excluding empties */
};