#ifndef _G_MULTIPATH_H_
#define _G_MULTIPATH_H_
#define G_MULTIPATH_CLASS_NAME "MULTIPATH"
#define G_MULTIPATH_VERSION 1
#define G_MULTIPATH_MAGIC "GEOM::MULTIPATH"
#include <sys/endian.h>
#ifdef _KERNEL
struct g_multipath_softc {
struct g_provider * sc_pp;
struct g_consumer * sc_active;
struct mtx sc_mtx;
char sc_name[16];
char sc_uuid[40];
off_t sc_size;
int sc_opened;
int sc_stopping;
int sc_ndisks;
int sc_active_active;
};
#endif
struct g_multipath_metadata {
char md_magic[16];
char md_uuid[40];
char md_name[16];
uint32_t md_version;
uint32_t md_sectorsize;
uint64_t md_size;
uint8_t md_active_active;
};
static __inline void
multipath_metadata_encode(const struct g_multipath_metadata *, u_char *);
static __inline void
multipath_metadata_decode(u_char *, struct g_multipath_metadata *);
static __inline void
multipath_metadata_encode(const struct g_multipath_metadata *md, u_char *data)
{
bcopy(md->md_magic, data, sizeof(md->md_magic));
data += sizeof(md->md_magic);
bcopy(md->md_uuid, data, sizeof(md->md_uuid));
data += sizeof(md->md_uuid);
bcopy(md->md_name, data, sizeof(md->md_name));
data += sizeof(md->md_name);
le32enc(data, md->md_version);
data += sizeof(md->md_version);
le32enc(data, md->md_sectorsize);
data += sizeof(md->md_sectorsize);
le64enc(data, md->md_size);
data += sizeof(md->md_size);
*data = md->md_active_active;
}
static __inline void
multipath_metadata_decode(u_char *data, struct g_multipath_metadata *md)
{
bcopy(data, md->md_magic, sizeof(md->md_magic));
data += sizeof(md->md_magic);
bcopy(data, md->md_uuid, sizeof(md->md_uuid));
data += sizeof(md->md_uuid);
bcopy(data, md->md_name, sizeof(md->md_name));
data += sizeof(md->md_name);
md->md_version = le32dec(data);
data += sizeof(md->md_version);
md->md_sectorsize = le32dec(data);
data += sizeof(md->md_sectorsize);
md->md_size = le64dec(data);
data += sizeof(md->md_size);
md->md_active_active = *data;
}
#endif