LVAR_ROUND = LVAR_PAD - 1
};
+static int root_limit(int rootgap, int blocksize, int size)
+{
+ int limit;
+ int nlimit;
+
+ limit = (blocksize - rootgap) / size;
+ nlimit = blocksize / size;
+ if (limit == nlimit)
+ limit--;
+ return limit;
+}
+
+static int lfix_root_limit(int blocksize, int size)
+{
+ return root_limit(sizeof(struct iam_lfix_root), blocksize, size);
+}
+
static void lfix_root(void *buf,
int blocksize, int keysize, int ptrsize, int recsize)
{
* limit itself + one pointer to the leaf.
*/
.count = cpu_to_le16(2),
- .limit = (blocksize - sizeof *root) / (keysize + ptrsize)
+ .limit = lfix_root_limit(blocksize, keysize + ptrsize)
};
entry = root + 1;
/* form leaf */
head = buf;
- *head = (struct iam_leaf_head) {
+ *head = (typeof(*head)) {
.ill_magic = cpu_to_le16(IAM_LEAF_HEADER_MAGIC),
/*
* Leaf contains an entry with the smallest possible key
};
}
+static int lvar_root_limit(int blocksize, int size)
+{
+ return root_limit(sizeof(struct lvar_root), blocksize, size);
+}
+
static void lvar_root(void *buf,
int blocksize, int keysize, int ptrsize, int recsize)
{
};
limit = (void *)(root + 1);
- *limit = (typeof(*limit)){
+ *limit = (typeof(*limit)) {
/*
* limit itself + one pointer to the leaf.
*/
.count = cpu_to_le16(2),
- .limit = (blocksize - sizeof *root) / isize
+ .limit = lvar_root_limit(blocksize, keysize + ptrsize)
};
entry = root + 1;
}
/*
- * Close file opened by iam_open.
+ * Close file opened by iam_open.
*/
int iam_close(int fd)
{