| Current File : //usr/include/libfruid.h |
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _LIBFRUID_H
#define _LIBFRUID_H
#include <scsi/libses.h>
#include <libnvpair.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct fruid_hdl fruid_hdl_t;
typedef struct fruid_elem fruid_elem_t;
typedef enum fruid_elem_class {
FRUID_ELEM_SEG,
FRUID_ELEM_REC,
FRUID_ELEM_FLD
} fruid_elem_class_t;
typedef struct fruid_ops {
void *(*frop_init)(fruid_hdl_t *, void *);
void (*frop_fini)(fruid_hdl_t *, void *);
ssize_t (*frop_read)(fruid_hdl_t *, off64_t, void *, size_t);
ssize_t (*frop_write)(fruid_hdl_t *, off64_t, const void *, size_t);
int (*frop_peek)(fruid_hdl_t *, uint8_t, uint8_t *);
int (*frop_poke)(fruid_hdl_t *, uint8_t, uint8_t);
int (*frop_lock)(fruid_hdl_t *);
int (*frop_unlock)(fruid_hdl_t *);
} fruid_ops_t;
typedef struct fruid_fds {
int frsrc_ro; /* read-only descriptor */
int frsrc_rw; /* read-write descriptor */
} fruid_fds_t;
typedef struct fruid_buf {
const void *frsrc_buf; /* buffer pointer */
size_t frsrc_len; /* buffer length */
} fruid_buf_t;
typedef struct fruid_ses {
ses_snap_t *frsrc_snap; /* enclosure snapshot */
uint64_t frsrc_elem; /* element identifier */
ses_node_t *frsrc_node; /* node handle (or NULL) */
} fruid_ses_t;
extern const fruid_ops_t fruid_src_buf; /* arg is fruid_buf_t */
extern const fruid_ops_t fruid_src_file; /* arg is fruid_fds_t */
extern const fruid_ops_t fruid_src_null; /* arg is unused */
extern const fruid_ops_t fruid_src_scsi; /* arg is fruid_ses_t */
#define FRUID_VERSION 1
extern fruid_hdl_t *fruid_open(int, const char *, const fruid_ops_t *, void *);
extern void fruid_revert(fruid_hdl_t *);
extern void fruid_close(fruid_hdl_t *);
extern int fruid_errno(fruid_hdl_t *);
extern const char *fruid_errmsg(fruid_hdl_t *);
extern int fruid_conf(fruid_hdl_t *, const char *);
extern const char *fruid_kind(fruid_hdl_t *);
extern size_t fruid_size(fruid_hdl_t *);
extern nvlist_t *fruid_nvlist(fruid_hdl_t *);
extern int fruid_read(fruid_hdl_t *);
extern int fruid_write(fruid_hdl_t *);
extern int fruid_touch(fruid_hdl_t *);
extern int fruid_copy(fruid_hdl_t *, fruid_hdl_t *);
extern int fruid_insert_seg(fruid_hdl_t *,
const char *, uint_t, off64_t, size_t);
extern int fruid_insertat(fruid_hdl_t *,
fruid_elem_t *, const char *, const char *);
extern int fruid_insert(fruid_hdl_t *, const char *, const char *);
extern int fruid_delete(fruid_hdl_t *, fruid_elem_t *);
extern int fruid_modify(fruid_hdl_t *, fruid_elem_t *, const char *);
typedef int fruid_walk_f(fruid_hdl_t *, const fruid_elem_t *, void *);
extern int fruid_walk(fruid_hdl_t *, fruid_walk_f *, void *);
typedef struct fruid_attr {
fruid_hdl_t *frat_handle; /* element container */
const char *frat_name; /* element basename */
fruid_elem_class_t frat_class; /* element class */
uint_t frat_flags; /* element flags */
size_t frat_len; /* element length */
off64_t frat_off; /* element offset */
} fruid_attr_t;
#define FRUID_SEG_ENCRYPTED 0x80000000 /* segment is encrypted */
#define FRUID_SEG_NOCKSUM 0x40000000 /* segment checksum ignored */
#define FRUID_SEG_OPAQUE 0x20000000 /* segment is not tagged data */
#define FRUID_SEG_FIXED 0x10000000 /* segment cannot be moved */
#define FRUID_SEG_SVC_R 0x00004000 /* service read */
#define FRUID_SEG_SVC_W 0x00002000 /* service write */
#define FRUID_SEG_SVC_D 0x00001000 /* service delete */
#define FRUID_SEG_DOM_R 0x00000800 /* domain read */
#define FRUID_SEG_DOM_W 0x00000400 /* domain write */
#define FRUID_SEG_DOM_D 0x00000200 /* domain delete */
#define FRUID_SEG_OPS_R 0x00000100 /* operations read */
#define FRUID_SEG_OPS_W 0x00000080 /* operations write */
#define FRUID_SEG_OPS_D 0x00000040 /* operations delete */
#define FRUID_SEG_ENG_R 0x00000020 /* engineering read */
#define FRUID_SEG_ENG_W 0x00000010 /* engineering write */
#define FRUID_SEG_ENG_D 0x00000008 /* engineering delete */
#define FRUID_SEG_REP_R 0x00000004 /* repair depot read */
#define FRUID_SEG_REP_W 0x00000002 /* repair depot write */
#define FRUID_SEG_REP_D 0x00000001 /* repair depot delete */
#define FRUID_FLAGSTR_MAX 25 /* for fruid_flags2str */
extern char *fruid_flags2str(fruid_hdl_t *, uint_t, char *, size_t);
extern int fruid_str2flags(fruid_hdl_t *, uint_t *, const char *);
extern fruid_elem_t *fruid_lookup(fruid_hdl_t *, const char *);
extern fruid_elem_t *fruid_lookupv(fruid_hdl_t *, int, char *const *);
extern fruid_hdl_t *fruid_handle(const fruid_elem_t *);
extern int fruid_stat(const fruid_elem_t *, fruid_attr_t *);
extern ssize_t fruid_path(fruid_hdl_t *,
const fruid_elem_t *, char *, size_t);
extern ssize_t fruid_tostr(fruid_hdl_t *,
const fruid_elem_t *, char *, size_t);
#ifdef __cplusplus
}
#endif
#endif /* _LIBFRUID_H */