--- /dev/null
+/*-
+ * Copyright (c) 2008-2009 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ * Persistent storage method
+ */
+
+#include "config.h"
+
+#include <stdint.h>
+#include <sys/param.h>
+
+#include "cache.h"
+#include "stevedore.h"
+
+#include "persistent.h"
+
+static void
+smp_init(struct stevedore *parent, int ac, char * const *av)
+{
+
+ (void)parent;
+ (void)ac;
+ (void)av;
+ assert(sizeof(struct smp_ident) == SMP_IDENT_SIZE);
+ assert(sizeof(struct smp_object) == SMP_OBJECT_SIZE);
+}
+
+struct stevedore smp_stevedore = {
+ .magic = STEVEDORE_MAGIC,
+ .name = "persistent",
+ .init = smp_init,
+ // .open = smf_open,
+ // .alloc = smf_alloc,
+ // .trim = smf_trim,
+ // .free = smf_free,
+};
--- /dev/null
+/*-
+ * Copyright (c) 2008-2009 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+/*
+ * Overall layout:
+ *
+ * struct smp_ident; Identification and geometry
+ * sha256[...] checksum of same
+ *
+ * struct smp_segment[N]; Segment table
+ * sha256[...] checksum of same
+ *
+ * banspace_1; First ban-space
+ * sha256[...] checksum of same
+ *
+ * banspace_2; Second ban-space
+ * sha256[...] checksum of same
+ *
+ * N segments {
+ * struct smp_object[M] Objects in segment
+ * sha256[...] checksum of same
+ * objspace
+ * }
+ */
+
+/*
+ * The identblock is located in the first sector of the storage space.
+ * This is written once and not subsequently modified in normal operation.
+ * It is immediately followed by a SHA256sum of the structure, as stored.
+ */
+
+struct smp_ident {
+ char ident[32]; /* Human readable ident
+ * so people and programs
+ * can tell what the file
+ * or device contains.
+ */
+
+ uint32_t byte_order; /* 0x12345678 */
+
+ uint32_t size; /* sizeof(struct smp_ident) */
+
+ uint32_t major_version;
+
+ uint32_t minor_version;
+
+ uint64_t mediasize; /* ... in bytes */
+
+ uint32_t granularity; /* smallest ... in bytes */
+
+ /* XXX: ptr to bans table */
+ /* XXX: ptr to segment table */
+};
+
+#define SMP_IDENT_SIZE (32 + 4 + 4 + 4 + 4 + 8 + 4 )
+
+/*
+ * A segment descriptor.
+ */
+
+struct smp_segment {
+ uint64_t offset;
+ uint64_t length;
+};
+
+#define SMP_SEGMENT_SIZE (8+8)
+
+/*
+ * Ban description
+ */
+
+struct smp_ban {
+ double ttl;
+ uint16_t length;
+ uint8_t valid;
+};
+
+/*
+ * An object descriptor
+ */
+
+struct smp_object {
+ unsigned char hash[32];
+ double ttl;
+ double ban;
+ uint64_t offset;
+ uint64_t len;
+};
+
+#define SMP_OBJECT_SIZE (32 + 8 + 8 + 8 + 8)