libzbc
Data Structures | Macros | Enumerations | Functions
Libzbc

Data Structures

struct  zbc_zone
 Zone information data structure. More...
 
struct  zbc_zone_domain
 Zone domain descriptor. More...
 
struct  zbc_realm_item
 Zone realm item. More...
 
struct  zbc_zone_realm
 Zone realm descriptor. More...
 
struct  zbc_actv_res
 Zone Activation Results record. More...
 
struct  zbc_zd_dev_control
 Zone Domains device control structure. More...
 
struct  zbc_device_info
 Device information data structure. More...
 
struct  zbc_err_ext
 Detailed error information data structure. More...
 
struct  zbc_errno
 
struct  zbc_zoned_blk_dev_stats
 Zoned Block Device Statistics. More...
 

Macros

#define zbc_zone_type(z)   ((int)(z)->zbz_type)
 Get a zone type.
 
#define zbc_zone_conventional(z)   ((z)->zbz_type == ZBC_ZT_CONVENTIONAL)
 Test if a zone type is conventional.
 
#define zbc_zone_sequential_req(z)   ((z)->zbz_type == ZBC_ZT_SEQUENTIAL_REQ)
 Test if a zone type is sequential write required.
 
#define zbc_zone_sequential_pref(z)   ((z)->zbz_type == ZBC_ZT_SEQUENTIAL_PREF)
 Test if a zone type is sequential write preferred.
 
#define zbc_zone_sobr(z)   ((z)->zbz_type == ZBC_ZT_SEQ_OR_BEF_REQ)
 Test if a zone type is sequential or before required (SOBR)
 
#define zbc_zone_sequential(z)
 Test if a zone type is sequential write required or preferred. More...
 
#define zbc_zone_gap(z)   ((z)->zbz_type == ZBC_ZT_GAP)
 Test if a zone type is gap.
 
#define zbc_zone_condition(z)   ((int)(z)->zbz_condition)
 Get a zone condition.
 
#define zbc_zone_not_wp(z)   ((z)->zbz_condition == ZBC_ZC_NOT_WP)
 Test if a zone condition is "not write pointer zone".
 
#define zbc_zone_empty(z)   ((z)->zbz_condition == ZBC_ZC_EMPTY)
 Test if a zone condition is empty.
 
#define zbc_zone_imp_open(z)   ((z)->zbz_condition == ZBC_ZC_IMP_OPEN)
 Test if a zone condition is implicit open.
 
#define zbc_zone_exp_open(z)   ((z)->zbz_condition == ZBC_ZC_EXP_OPEN)
 Test if a zone condition is explicit open.
 
#define zbc_zone_is_open(z)
 Test if a zone condition is explicit or implicit open. More...
 
#define zbc_zone_closed(z)   ((z)->zbz_condition == ZBC_ZC_CLOSED)
 Test if a zone condition is closed.
 
#define zbc_zone_full(z)   ((z)->zbz_condition == ZBC_ZC_FULL)
 Test if a zone condition is full.
 
#define zbc_zone_rdonly(z)   ((z)->zbz_condition == ZBC_ZC_RDONLY)
 Test if a zone condition is read-only.
 
#define zbc_zone_offline(z)   ((z)->zbz_condition == ZBC_ZC_OFFLINE)
 Test if a zone condition is offline.
 
#define zbc_zone_inactive(z)   ((z)->zbz_condition == ZBC_ZC_INACTIVE)
 Test if a zone condition is inactive.
 
#define zbc_zone_rwp_recommended(z)
 Test if a zone has the reset recommended flag set. More...
 
#define zbc_zone_non_seq(z)   ((z)->zbz_attributes & ZBC_ZA_NON_SEQ)
 Test if a zone has the non-sequential write resource allocated flag set.
 
#define zbc_zone_start(z)   ((unsigned long long)(z)->zbz_start)
 Get a zone start 512B sector.
 
#define zbc_zone_length(z)   ((unsigned long long)(z)->zbz_length)
 Get a zone number of 512B sectors.
 
#define zbc_zone_wp(z)   ((unsigned long long)(z)->zbz_write_pointer)
 Get a zone write pointer 512B sector position.
 
#define ZBC_RESTRICT_ZONE_ACTIVATE   0x01 /* No activate/deactivate */
 
#define ZBC_RESTRICT_WP_RESET   0x02 /* No write pointer reset */
 
#define ZBC_NR_ZONE_TYPES   4
 
#define zbc_actv_res_type(r)   ((int)(r)->zbe_type)
 Get activation results record type.
 
#define zbc_actv_res_conventional(r)   ((r)->zbe_type == ZBC_ZT_CONVENTIONAL)
 Test if activation results record type is conventional.
 
#define zbc_actv_res_seq_req(r)   ((r)->zbe_type == ZBC_ZT_SEQUENTIAL_REQ)
 Test if activation results record type is sequential write required.
 
#define zbc_actv_res_seq_pref(r)   ((r)->zbe_type == ZBC_ZT_SEQUENTIAL_PREF)
 Test if activation results record type is sequential write preferred.
 
#define zbc_actv_res_sobr(r)   ((r)->zbe_type == ZBC_ZT_SEQ_OR_BEF_REQ)
 Test if activation record type is sequential or before required (SOBR)
 
#define zbc_actv_res_nonseq(r)
 Test if activation results record type is conventional of SOBR. More...
 
#define zbc_actv_res_seq(r)
 Test if activation record type is sequential write required or preferred. More...
 
#define ZBC_DEVICE_INFO_LENGTH   32
 
#define ZBC_NOT_REPORTED   ((uint32_t)0xFFFFFFFF)
 
#define ZBC_NO_LIMIT   ((uint32_t)0xFFFFFFFF)
 
#define zbc_lba2sect(info, lba)   (((lba) * (info)->zbd_lblock_size) >> 9)
 Convert LBA value to 512-bytes sector. More...
 
#define zbc_lba2sect_end(info, lba)   ((((lba + 1) * (info)->zbd_lblock_size) >> 9) - 1)
 
#define zbc_sect2lba(info, sect)   (((sect) << 9) / (info)->zbd_lblock_size)
 Convert 512-bytes sector value to LBA. More...
 
#define zbc_reporting_options   zbc_zone_reporting_options
 
#define ZBC_RO_ALL   ZBC_RZ_RO_ALL
 
#define ZBC_RO_EMPTY   ZBC_RZ_RO_EMPTY
 
#define ZBC_RO_IMP_OPEN   ZBC_RZ_RO_IMP_OPEN
 
#define ZBC_RO_EXP_OPEN   ZBC_RZ_RO_EXP_OPEN
 
#define ZBC_RO_CLOSED   ZBC_RZ_RO_CLOSED
 
#define ZBC_RO_FULL   ZBC_RZ_RO_FULL
 
#define ZBC_RO_RDONLY   ZBC_RZ_RO_RDONLY
 
#define ZBC_RO_OFFLINE   ZBC_RZ_RO_OFFLINE
 
#define ZBC_RO_INACTIVE   ZBC_RZ_RO_INACTIVE
 
#define ZBC_RO_RWP_RECOMMENDED   ZBC_RZ_RO_RWP_RECMND
 
#define ZBC_RO_NON_SEQ   ZBC_RZ_RO_NON_SEQ
 
#define ZBC_RO_GAP   ZBC_RZ_RO_GAP
 
#define ZBC_RO_NOT_WP   ZBC_RZ_RO_NOT_WP
 
#define ZBC_RO_PARTIAL   ZBC_RZ_RO_PARTIAL
 

Enumerations

enum  zbc_zone_type {
  ZBC_ZT_UNKNOWN = 0x00, ZBC_ZT_CONVENTIONAL = 0x01, ZBC_ZT_SEQUENTIAL_REQ = 0x02, ZBC_ZT_SEQUENTIAL_PREF = 0x03,
  ZBC_ZT_SEQ_OR_BEF_REQ = 0x04, ZBC_ZT_GAP = 0x05
}
 Zone type definitions. More...
 
enum  zbc_zone_condition {
  ZBC_ZC_NOT_WP = 0x00, ZBC_ZC_EMPTY = 0x01, ZBC_ZC_IMP_OPEN = 0x02, ZBC_ZC_EXP_OPEN = 0x03,
  ZBC_ZC_CLOSED = 0x04, ZBC_ZC_INACTIVE = 0x05, ZBC_ZC_RDONLY = 0x0d, ZBC_ZC_FULL = 0x0e,
  ZBC_ZC_OFFLINE = 0x0f
}
 Zone condition definitions. More...
 
enum  zbc_zone_attributes { ZBC_ZA_RWP_RECOMMENDED = 0x0001, ZBC_ZA_NON_SEQ = 0x0002 }
 Zone attributes definitions. More...
 
enum  zbc_zone_domain_flags { ZBC_ZDF_SHIFTING_BOUNDARIES = 1 << 0, ZBC_ZDF_VALID_ZONE_TYPE = 1 << 1 }
 Zone domain flags.
 
enum  zbc_dev_type { ZBC_DT_UNKNOWN = 0x00, ZBC_DT_SCSI = 0x02, ZBC_DT_ATA = 0x03 }
 Device type definitions. More...
 
enum  zbc_dev_model {
  ZBC_DM_DRIVE_UNKNOWN = 0x00, ZBC_DM_HOST_AWARE = 0x01, ZBC_DM_HOST_MANAGED = 0x02, ZBC_DM_DEVICE_MANAGED = 0x03,
  ZBC_DM_STANDARD = 0x04
}
 Device model definitions. More...
 
enum  zbc_dev_flags {
  ZBC_UNRESTRICTED_READ = 0x00000001, ZBC_ZONE_REALMS_SUPPORT = 0x00000002, ZBC_ZONE_DOMAINS_SUPPORT = 0x00000004, ZBC_URSWRZ_SET_SUPPORT = 0x00000008,
  ZBC_MAXACT_SET_SUPPORT = 0x00000010, ZBC_REPORT_REALMS_SUPPORT = 0x00000020, ZBC_ZA_CONTROL_SUPPORT = 0x00000080, ZBC_NOZSRC_SUPPORT = 0x000000100,
  ZBC_CONV_ZONE_SUPPORT = 0x00000200, ZBC_SEQ_REQ_ZONE_SUPPORT = 0x00000400, ZBC_SEQ_PREF_ZONE_SUPPORT = 0x00000800, ZBC_SOBR_ZONE_SUPPORT = 0x00001000,
  ZBC_GAP_ZONE_SUPPORT = 0x00002000, ZBC_CONV_REALMS_SHIFTING = 0x00004000, ZBC_SEQ_REQ_REALMS_SHIFTING = 0x00008000, ZBC_SEQ_PREF_REALMS_SHIFTING = 0x00010000,
  ZBC_SOBR_REALMS_SHIFTING = 0x00020000, ZBC_ZONE_OP_COUNT_SUPPORT = 0x00040000, ZBC_STANDARD_RPT_REALMS = 0x00080000
}
 Device flags definitions. More...
 
enum  zbc_sk {
  ZBC_SK_NOT_READY = 0x2, ZBC_SK_MEDIUM_ERROR = 0x3, ZBC_SK_HARDWARE_ERROR = 0x4, ZBC_SK_ILLEGAL_REQUEST = 0x5,
  ZBC_SK_DATA_PROTECT = 0x7, ZBC_SK_ABORTED_COMMAND = 0xB
}
 SCSI Sense keys definitions. More...
 
enum  zbc_asc_ascq {
  ZBC_ASC_INVALID_FIELD_IN_CDB = 0x2400, ZBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE = 0x2100, ZBC_ASC_UNALIGNED_WRITE_COMMAND = 0x2104, ZBC_ASC_WRITE_BOUNDARY_VIOLATION = 0x2105,
  ZBC_ASC_ATTEMPT_TO_READ_INVALID_DATA = 0x2106, ZBC_ASC_READ_BOUNDARY_VIOLATION = 0x2107, ZBC_ASC_ZONE_IS_READ_ONLY = 0x2708, ZBC_ASC_ZONE_IS_OFFLINE = 0x2C0E,
  ZBC_ASC_INSUFFICIENT_ZONE_RESOURCES = 0x550E, ZBC_ASC_ZONE_IS_INACTIVE = 0x2C12, ZBC_ASC_ATTEMPT_TO_ACCESS_GAP_ZONE = 0x2109, ZBC_ASC_READ_ERROR = 0x1100,
  ZBC_ASC_WRITE_ERROR = 0x0C00, ZBC_ASC_FORMAT_IN_PROGRESS = 0x0404, ZBC_ASC_PARAMETER_LIST_LENGTH_ERROR = 0x1a00, ZBC_ASC_INVALID_FIELD_IN_PARAMETER_LIST = 0x2600,
  ZBC_ASC_INTERNAL_TARGET_FAILURE = 0x4400, ZBC_ASC_INVALID_COMMAND_OPERATION_CODE = 0x2000, ZBC_ASC_ZONE_RESET_WP_RECOMMENDED = 0x2A16
}
 SCSI Additional sense codes and qualifiers definitions. More...
 
enum  zbc_oflags { ZBC_O_DRV_BLOCK = 0x00000000, ZBC_O_DRV_SCSI = 0x02000000, ZBC_O_DRV_ATA = 0x04000000 }
 ZBC device open flags. More...
 
enum  zbc_zone_reporting_options {
  ZBC_RZ_RO_ALL = 0x00, ZBC_RZ_RO_EMPTY = 0x01, ZBC_RZ_RO_IMP_OPEN = 0x02, ZBC_RZ_RO_EXP_OPEN = 0x03,
  ZBC_RZ_RO_CLOSED = 0x04, ZBC_RZ_RO_FULL = 0x05, ZBC_RZ_RO_RDONLY = 0x06, ZBC_RZ_RO_OFFLINE = 0x07,
  ZBC_RZ_RO_INACTIVE = 0x08, ZBC_RZ_RO_RWP_RECMND = 0x10, ZBC_RZ_RO_NON_SEQ = 0x11, ZBC_RZ_RO_GAP = 0x3e,
  ZBC_RZ_RO_NOT_WP = 0x3f, ZBC_RZ_RO_PARTIAL = 0x80
}
 REPORT ZONES reporting options definitions. More...
 
enum  zbc_zone_op { ZBC_OP_RESET_ZONE = 0x01, ZBC_OP_OPEN_ZONE = 0x02, ZBC_OP_CLOSE_ZONE = 0x03, ZBC_OP_FINISH_ZONE = 0x04 }
 Zone operation codes definitions. More...
 
enum  zbc_zone_op_flags { ZBC_OP_ALL_ZONES = 0x0000001 }
 Zone operation flag definitions. More...
 
enum  zbc_domain_report_options { ZBC_RZD_RO_ALL = 0x00, ZBC_RZD_RO_ALL_ACTIVE = 0x01, ZBC_RZD_RO_ACTIVE = 0x02, ZBC_RZD_RO_INACTIVE = 0x03 }
 REPORT ZONE DOMAINS reporting options definitions. More...
 
enum  zbc_realm_report_options { ZBC_RR_RO_ALL = 0x00, ZBC_RR_RO_SOBR = 0x01, ZBC_RR_RO_SWR = 0x02, ZBC_RR_RO_SWP = 0x03 }
 REPORT REALMS reporting options definitions. More...
 

Functions

void zbc_set_log_level (char const *log_level)
 Set the library log level. More...
 
const char * zbc_zone_type_str (enum zbc_zone_type type)
 returns a string describing a zone type More...
 
const char * zbc_zone_condition_str (enum zbc_zone_condition cond)
 Returns a string describing a zone condition. More...
 
uint64_t zbc_zone_domain_start_lba (struct zbc_device *dev, struct zbc_zone_domain *d)
 Get zone domain start logical block.
 
uint64_t zbc_zone_domain_end_lba (struct zbc_device *dev, struct zbc_zone_domain *d)
 Get zone domain end logical block.
 
uint64_t zbc_zone_domain_high_sect (struct zbc_device *dev, struct zbc_zone_domain *d)
 Get zone domain highest 512B sector.
 
uint64_t zbc_realm_start_lba (struct zbc_device *dev, struct zbc_zone_realm *r, unsigned int dom_id)
 Get realm start logical block for a particular domain.
 
uint64_t zbc_realm_end_lba (struct zbc_device *dev, struct zbc_zone_realm *r, unsigned int dom_id)
 Get realm end logical block for a particular domain.
 
uint64_t zbc_realm_high_sector (struct zbc_device *dev, struct zbc_zone_realm *r, unsigned int dom_id)
 Get realm highest 512B sector for a particular domain.
 
const char * zbc_device_type_str (enum zbc_dev_type type)
 Returns a device type name. More...
 
const char * zbc_device_model_str (enum zbc_dev_model model)
 Returns a device zone model name. More...
 
void zbc_errno_ext (struct zbc_device *dev, struct zbc_err_ext *err, size_t size)
 Get detailed error code of last operation. More...
 
void zbc_errno (struct zbc_device *dev, struct zbc_errno *err)
 Get legacy error code of last operation. More...
 
const char * zbc_sk_str (enum zbc_sk sk)
 Returns a string describing a sense key. More...
 
const char * zbc_asc_ascq_str (enum zbc_asc_ascq asc_ascq)
 Returns a string describing a sense code. More...
 
char const * zbc_version (void)
 return libzbc version as a string.
 
int zbc_device_is_zoned (const char *filename, bool unused, struct zbc_device_info *info)
 Test if a device is a zoned block device. More...
 
int zbc_open (const char *filename, int flags, struct zbc_device **dev)
 Open a ZBC device. More...
 
int zbc_close (struct zbc_device *dev)
 Close a ZBC device. More...
 
void zbc_get_device_info (struct zbc_device *dev, struct zbc_device_info *info)
 Get a ZBC device information. More...
 
void zbc_print_device_info (struct zbc_device_info *info, FILE *out)
 Print a device information. More...
 
int zbc_report_zones (struct zbc_device *dev, uint64_t sector, enum zbc_zone_reporting_options ro, struct zbc_zone *zones, unsigned int *nr_zones)
 Get zone information. More...
 
int zbc_list_zones (struct zbc_device *dev, uint64_t sector, enum zbc_zone_reporting_options ro, struct zbc_zone **zones, unsigned int *nr_zones)
 Get zone information. More...
 
int zbc_zone_operation (struct zbc_device *dev, uint64_t sector, enum zbc_zone_op op, unsigned int flags)
 Execute an operation on a zone. More...
 
int zbc_zone_group_op (struct zbc_device *dev, uint64_t sector, unsigned int count, enum zbc_zone_op op, unsigned int flags)
 Execute an operation on a group of zones. More...
 
int zbc_report_domains (struct zbc_device *dev, uint64_t sector, enum zbc_domain_report_options ro, struct zbc_zone_domain *domains, unsigned int nr_domains)
 Get zone domain information. More...
 
int zbc_list_domains (struct zbc_device *dev, uint64_t sector, enum zbc_domain_report_options ro, struct zbc_zone_domain **pdomains, unsigned int *pnr_domains)
 List zone domain information. More...
 
int zbc_report_realms (struct zbc_device *dev, uint64_t sector, enum zbc_realm_report_options ro, struct zbc_zone_realm *realms, unsigned int *nr_realms)
 Get zone realm information. More...
 
int zbc_list_zone_realms (struct zbc_device *dev, uint64_t sector, enum zbc_realm_report_options ro, struct zbc_zone_realm **prealms, unsigned int *pnr_realms)
 List zone realm information. More...
 
int zbc_zone_activate (struct zbc_device *dev, bool zsrc, bool all, bool use_32_byte_cdb, uint64_t start_zone, unsigned int nr_zones, unsigned int domain_id, struct zbc_actv_res *actv_recs, unsigned int *nr_actv_recs)
 Activate the specified zones at a new zone domain. More...
 
int zbc_zone_query (struct zbc_device *dev, bool zsrc, bool all, bool use_32_byte_cdb, uint64_t start_zone, unsigned int nr_zones, unsigned int domain_id, struct zbc_actv_res *actv_recs, unsigned int *nr_actv_recs)
 Query about possible results of zone activation. More...
 
int zbc_get_nr_actv_records (struct zbc_device *dev, bool zsrc, bool all, bool use_32_byte_cdb, uint64_t start_zone, unsigned int nr_zones, unsigned int domain_id)
 Return the expected number of activation records. More...
 
int zbc_zone_query_list (struct zbc_device *dev, bool zsrc, bool all, bool use_32_byte_cdb, uint64_t start_zone, unsigned int nr_zones, unsigned int domain_id, struct zbc_actv_res **pactv_recs, unsigned int *pnr_actv_recs)
 Query about possible activation results of a number of zones. More...
 
int zbc_zone_activation_ctl (struct zbc_device *dev, struct zbc_zd_dev_control *ctl, bool set)
 Read or change persistent XMR device settings. More...
 
int zbc_get_zbd_stats (struct zbc_device *dev, struct zbc_zoned_blk_dev_stats *stats)
 Get Zoned Block Device statistics. More...
 
ssize_t zbc_pread (struct zbc_device *dev, void *buf, size_t count, uint64_t offset)
 Read sectors from a device. More...
 
ssize_t zbc_pwrite (struct zbc_device *dev, const void *buf, size_t count, uint64_t offset)
 Write sectors to a device. More...
 
ssize_t zbc_preadv (struct zbc_device *dev, const struct iovec *iov, int iovcnt, uint64_t offset)
 Read sectors from a device using multiple buffers. More...
 
ssize_t zbc_pwritev (struct zbc_device *dev, const struct iovec *iov, int iovcnt, uint64_t offset)
 Write sectors to a device usig multiple buffers. More...
 
int zbc_map_iov (const void *buf, size_t sectors, struct iovec *iov, int iovcnt, size_t iovlen)
 Map a buffer to an I/O vector. More...
 
int zbc_flush (struct zbc_device *dev)
 Flush a device write cache. More...
 

Detailed Description

Macro Definition Documentation

#define zbc_actv_res_nonseq (   r)
Value:
#define zbc_actv_res_sobr(r)
Test if activation record type is sequential or before required (SOBR)
Definition: zbc.h:807
#define zbc_actv_res_conventional(r)
Test if activation results record type is conventional.
Definition: zbc.h:798

Test if activation results record type is conventional of SOBR.

#define zbc_actv_res_seq (   r)
Value:
#define zbc_actv_res_seq_pref(r)
Test if activation results record type is sequential write preferred.
Definition: zbc.h:804
#define zbc_actv_res_seq_req(r)
Test if activation results record type is sequential write required.
Definition: zbc.h:801

Test if activation record type is sequential write required or preferred.

#define ZBC_DEVICE_INFO_LENGTH   32

Vendor ID string maximum length.

#define zbc_lba2sect (   info,
  lba 
)    (((lba) * (info)->zbd_lblock_size) >> 9)

Convert LBA value to 512-bytes sector.

Returns
A number of 512B sectors.
#define ZBC_NO_LIMIT   ((uint32_t)0xFFFFFFFF)

"no limit" value for the number of explicitly open sequential write required zones in the device information (zbd_max_nr_open_seq_req).

#define ZBC_NOT_REPORTED   ((uint32_t)0xFFFFFFFF)

"not reported" value for the number of zones limits in the device information (zbd_opt_nr_non_seq_write_seq_pref and zbd_max_nr_open_seq_req).

#define ZBC_NR_ZONE_TYPES   4

The number of domain slots in a realm. Each slot corresponds to a zone domain with a distinctive zone type.

#define ZBC_RESTRICT_ZONE_ACTIVATE   0x01 /* No activate/deactivate */

Realm restriction bits. These are realm attributes that are reported by the device to indicate that certain operations are not allowed for zones associated with the realm. There are currently activation/deactivation restrictions that can be reported as well as restrictions on write pointer reset.

#define zbc_sect2lba (   info,
  sect 
)    (((sect) << 9) / (info)->zbd_lblock_size)

Convert 512-bytes sector value to LBA.

Returns
A number of logical blocks.
#define zbc_zone_is_open (   z)
Value:
#define zbc_zone_exp_open(z)
Test if a zone condition is explicit open.
Definition: zbc.h:293
#define zbc_zone_imp_open(z)
Test if a zone condition is implicit open.
Definition: zbc.h:290

Test if a zone condition is explicit or implicit open.

#define zbc_zone_rwp_recommended (   z)
Value:
((z)->zbz_attributes & \
Definition: zbc.h:196

Test if a zone has the reset recommended flag set.

#define zbc_zone_sequential (   z)
Value:
#define zbc_zone_sequential_pref(z)
Test if a zone type is sequential write preferred.
Definition: zbc.h:268
#define zbc_zone_sequential_req(z)
Test if a zone type is sequential write required.
Definition: zbc.h:265

Test if a zone type is sequential write required or preferred.

Enumeration Type Documentation

SCSI Additional sense codes and qualifiers definitions.

SCSI Additional sense codes and additional sense code qualifiers inspected in case of command error.

Enumerator
ZBC_ASC_INVALID_FIELD_IN_CDB 

Invalid field in CDB

ZBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 

Logical block address out of range

ZBC_ASC_UNALIGNED_WRITE_COMMAND 

Unaligned write command

ZBC_ASC_WRITE_BOUNDARY_VIOLATION 

write boundary violation

ZBC_ASC_ATTEMPT_TO_READ_INVALID_DATA 

Attempt to read invalid data

ZBC_ASC_READ_BOUNDARY_VIOLATION 

Read boundary violation

ZBC_ASC_ZONE_IS_READ_ONLY 

Zone is in the read-only condition

ZBC_ASC_ZONE_IS_OFFLINE 

Zone is offline

ZBC_ASC_INSUFFICIENT_ZONE_RESOURCES 

Insufficient zone resources

ZBC_ASC_ZONE_IS_INACTIVE 

Zone is inactive

ZBC_ASC_ATTEMPT_TO_ACCESS_GAP_ZONE 

Attempt to access GAP zone

ZBC_ASC_READ_ERROR 

Read error

ZBC_ASC_WRITE_ERROR 

Write error

ZBC_ASC_FORMAT_IN_PROGRESS 

Format in progress

ZBC_ASC_PARAMETER_LIST_LENGTH_ERROR 

Parameter list length error

ZBC_ASC_INVALID_FIELD_IN_PARAMETER_LIST 

Invalid field in parameter list

ZBC_ASC_INTERNAL_TARGET_FAILURE 

Internal target failure

ZBC_ASC_INVALID_COMMAND_OPERATION_CODE 

Invalid command operation code

ZBC_ASC_ZONE_RESET_WP_RECOMMENDED 

Zone reset WP recommended

Device flags definitions.

Defines device information flags.

Enumerator
ZBC_UNRESTRICTED_READ 

Indicates that a device has unrestricted read operation, i.e. that read commands spanning a zone write pointer or two consecutive zones of the same type will not result in an error.

ZBC_ZONE_REALMS_SUPPORT 

Indicates that the device supports Zone Realms command set to allow zones on the device to be activated both as CMR and SMR.

ZBC_ZONE_DOMAINS_SUPPORT 

Indicates that the device supports Zone Domains command set to allow zones on the device to be activated both as CMR and SMR.

ZBC_URSWRZ_SET_SUPPORT 

Indicates that modification of the URSWRZ setting is supported.

ZBC_MAXACT_SET_SUPPORT 

Indicates that modification of MAXIMUM ACTIVATION is supported by device.

ZBC_REPORT_REALMS_SUPPORT 

Indicates that REPORT REALMS command is supported by device.

ZBC_ZA_CONTROL_SUPPORT 

Indicates that setting FSNOZ value is supported by device.

ZBC_NOZSRC_SUPPORT 

Indicates that NOZSRC bit in ZONE ACTIVATE/QUERY is supported by device.

ZBC_CONV_ZONE_SUPPORT 

Indicates that Conventional zone type is supported by device.

ZBC_SEQ_REQ_ZONE_SUPPORT 

Indicates that Sequential Write Required zone type is supported.

ZBC_SEQ_PREF_ZONE_SUPPORT 

Indicates that Sequential Write Preferred zone type is supported.

ZBC_SOBR_ZONE_SUPPORT 

Indicates that Sequential Or Before Required zone type is supported.

ZBC_GAP_ZONE_SUPPORT 

Indicates that Gap zone type is supported, i.e. gaps are possible between domains.

ZBC_CONV_REALMS_SHIFTING 

Indicates that the Conventional domain has shifting realm boundaries.

ZBC_SEQ_REQ_REALMS_SHIFTING 

Indicates that the Sequential Write Required domain has shifting realm boundaries.

ZBC_SEQ_PREF_REALMS_SHIFTING 

Indicates that the Sequential Write Preferred domain has shifting realm boundaries.

ZBC_SOBR_REALMS_SHIFTING 

Indicates that the Sequential Or Before Required domain has shifting realm boundaries.

ZBC_ZONE_OP_COUNT_SUPPORT 

Indicates that the device supports ZAC-2 zone operation counts.

ZBC_STANDARD_RPT_REALMS 

Indicates that the device supports the standard ZAC-2 REPORT REALMS data layout.

Device model definitions.

Indicates the ZBC/ZAC device zone model, i.e host-aware, host-managed, device-managed or standard. Note that these last two models are not handled by libzbc (the device will be treated as a regular block device as it should).

  • Host-managed: device type 14h
  • Host-aware: device type 0h and zoned field equal to 01b
  • Device-managed: device type 0h and zoned field equal to 10b
  • Standard: device type 0h (standard block device)
Enumerator
ZBC_DM_DRIVE_UNKNOWN 

Unknown drive model.

ZBC_DM_HOST_AWARE 

Host-aware drive model: the device type/signature is 0x00 and the ZONED field of the block device characteristics VPD page B1h is 01b.

ZBC_DM_HOST_MANAGED 

Host-managed drive model: the device type/signature is 0x14/0xabcd.

ZBC_DM_DEVICE_MANAGED 

Drive-managed drive model: the device type/signature is 0x00 and the ZONED field of the block device characteristics VPD page B1h is 10b.

ZBC_DM_STANDARD 

Standard block device: the device type/signature is 0x00 and the ZONED field of the block device characteristics VPD page B1h is 00b.

Device type definitions.

Each type correspond to a different internal backend driver.

Enumerator
ZBC_DT_UNKNOWN 

Unknown drive type.

ZBC_DT_SCSI 

SCSI device.

ZBC_DT_ATA 

ATA device.

REPORT ZONE DOMAINS reporting options definitions.

Used to filter the zone information returned by the execution of a REPORT ZONE DOMAINS command.

enum zbc_oflags

ZBC device open flags.

These flags can be combined together and passed to zbc_open to change that function default behavior. This is in particular useful for ATA devices to force using the ATA backend driver to bypass any SAT layer that may result in the SCSI backend driver being used.

Enumerator
ZBC_O_DRV_SCSI 

Allow use of the SCSI backend driver

ZBC_O_DRV_ATA 

Allow use of the ATA backend driver

REPORT REALMS reporting options definitions.

Used to filter the zone information returned by the execution of a REPORT REALMS command.

enum zbc_sk

SCSI Sense keys definitions.

SCSI sense keys inspected in case of command error.

Enumerator
ZBC_SK_NOT_READY 

Not ready

ZBC_SK_MEDIUM_ERROR 

Medium error

ZBC_SK_HARDWARE_ERROR 

Hardware Error

ZBC_SK_ILLEGAL_REQUEST 

Illegal request

ZBC_SK_DATA_PROTECT 

Data protect

ZBC_SK_ABORTED_COMMAND 

Aborted command

Zone attributes definitions.

Defines the attributes of a zone. Attributes validity depend on the zone type and device model.

Enumerator
ZBC_ZA_RWP_RECOMMENDED 

Reset write pointer recommended: a write pointer zone for which the device determined that a RESET WRITE POINTER command execution is recommended. The drive level condition resulting in this attribute being set depend on the drive model/vendor and not defined by the ZBC/ZAC specifications.

ZBC_ZA_NON_SEQ 

Non-Sequential Write Resources Active: indicates that a sequential write preferred zone (host-aware devices only) was written at a random LBA (not at the write pointer position). The drive may reset this attribute at any time after the random write operation completion.

Zone condition definitions.

A zone condition is determined by the zone type and the ZBC zone state machine, i.e. the operations performed on the zone.

Enumerator
ZBC_ZC_NOT_WP 

Not a write pointer zone (i.e. a conventional zone).

ZBC_ZC_EMPTY 

Empty sequential zone (zone not written too since last reset).

ZBC_ZC_IMP_OPEN 

Implicitly open zone (i.e. a write command was issued to the zone).

ZBC_ZC_EXP_OPEN 

Explicitly open zone (a write pointer zone was open using the OPEN ZONE command).

ZBC_ZC_CLOSED 

Closed zone (a write pointer zone that was written to and closed using the CLOSE ZONE command).

ZBC_ZC_INACTIVE 

Inactive zone: an unmapped zone of a Zone Domains device.

ZBC_ZC_RDONLY 

Read-only zone: any zone that can only be read.

ZBC_ZC_FULL 

Full zone (write pointer zones only).

ZBC_ZC_OFFLINE 

Offline zone: unusable zone.

Zone operation codes definitions.

Encode the operation to perform on a zone.

Enumerator
ZBC_OP_RESET_ZONE 

Reset zone write pointer.

ZBC_OP_OPEN_ZONE 

Open a zone.

ZBC_OP_CLOSE_ZONE 

Close a zone.

ZBC_OP_FINISH_ZONE 

Finish a zone.

Zone operation flag definitions.

Control the behavior of zone operations. Flags defined here can be or'ed together and passed to the functions zbc_open_zone, zbc_close_zone, zbc_finish_zone and link zbc_reset_zone.

Enumerator
ZBC_OP_ALL_ZONES 

Operate on all possible zones.

REPORT ZONES reporting options definitions.

Used to filter the zone information returned by the execution of a REPORT ZONES command. Filtering is based on the value of the reporting option and on the condition of the zones at the time of the execution of the REPORT ZONES command.

ZBC_RZ_RO_PARTIAL is not a filter: this reporting option can be combined (or'ed) with any other filter option to limit the number of reported zone information to the size of the REPORT ZONES command buffer.

Enumerator
ZBC_RZ_RO_ALL 

List all of the zones in the device.

ZBC_RZ_RO_EMPTY 

List the zones with a Zone Condition of ZBC_ZC_EMPTY.

ZBC_RZ_RO_IMP_OPEN 

List the zones with a Zone Condition of ZBC_ZC_IMP_OPEN.

ZBC_RZ_RO_EXP_OPEN 

List the zones with a Zone Condition of ZBC_ZC_EXP_OPEN.

ZBC_RZ_RO_CLOSED 

List the zones with a Zone Condition of ZBC_ZC_CLOSED.

ZBC_RZ_RO_FULL 

List the zones with a Zone Condition of ZBC_ZC_FULL.

ZBC_RZ_RO_RDONLY 

List the zones with a Zone Condition of ZBC_ZC_RDONLY.

ZBC_RZ_RO_OFFLINE 

List the zones with a Zone Condition of ZBC_ZC_OFFLINE.

ZBC_RZ_RO_INACTIVE 

List the zones with a Zone Condition of ZBC_ZC_INACTIVE.

ZBC_RZ_RO_RWP_RECMND 

List the zones with a zone attribute ZBC_ZA_RWP_RECOMMENDED set.

ZBC_RZ_RO_NON_SEQ 

List the zones with a zone attribute ZBC_ZA_NON_SEQ set.

ZBC_RZ_RO_GAP 

List all of the zones in the device, except zones with a Zone Type of GAP.

ZBC_RZ_RO_NOT_WP 

List of the zones with a Zone Condition of ZBC_ZC_NOT_WP.

ZBC_RZ_RO_PARTIAL 

Partial report flag.

Zone type definitions.

Indicates the type of a zone.

Enumerator
ZBC_ZT_UNKNOWN 

Unknown zone type.

ZBC_ZT_CONVENTIONAL 

Conventional zone.

ZBC_ZT_SEQUENTIAL_REQ 

Sequential write required zone: a write pointer zone that must be written sequentially (host-managed drives only).

ZBC_ZT_SEQUENTIAL_PREF 

Sequential write preferred zone: a write pointer zone that can be written randomly (host-aware drives only).

ZBC_ZT_SEQ_OR_BEF_REQ 

Sequential or before required zone: requires additional initialization to become close to a regular conventional, but it can be activated from SMR quickly.

ZBC_ZT_GAP 

Gap zone. Gaps are allowed between zone domains.

Function Documentation

const char* zbc_asc_ascq_str ( enum zbc_asc_ascq  asc_ascq)

Returns a string describing a sense code.

Parameters
[in]asc_ascqSense code and sense code qualifier
Returns
A string describing a sense code and sense code qualifier.
int zbc_close ( struct zbc_device *  dev)

Close a ZBC device.

Parameters
[in]devDevice handle obtained with zbc_open

Performs the equivalent to close(2) for a ZBC device open using zbc_open.

Returns
Can return any error that close(2) may return.
int zbc_device_is_zoned ( const char *  filename,
bool  unused,
struct zbc_device_info info 
)

Test if a device is a zoned block device.

Parameters
[in]filenamePath to the device file
[in]unusedPreviously used to allow emulation mode
[in]infoAddress where to store the device information

Test if a device supports the ZBC/ZAC command set. If info is not NULL and the device is identified as a zoned block device, the device information is returned at the address specified by info.

Returns
Returns a negative error code if the device test failed. 1 is returned if the device is identified as a zoned zoned block device. Otherwise, 0 is returned.
const char* zbc_device_model_str ( enum zbc_dev_model  model)

Returns a device zone model name.

Parameters
[in]modelDevice model
Returns
A string describing a device model.
const char* zbc_device_type_str ( enum zbc_dev_type  type)

Returns a device type name.

Parameters
[in]typeDevice type
Returns
A string describing the interface type of a device.
void zbc_errno ( struct zbc_device *  dev,
struct zbc_errno err 
)

Get legacy error code of last operation.

Parameters
[in]devDevice handle obtained with zbc_open
[out]errAddress where to return the error report

Returns at the address specified by err a detailed error report of the last command executed. The error report is composed of the SCSI sense key, sense code and sense code qualifier. For successful commands, all three information are set to 0.

The values returned here are the same as the first two fields returned by zbc_errno_ext().

void zbc_errno_ext ( struct zbc_device *  dev,
struct zbc_err_ext err,
size_t  size 
)

Get detailed error code of last operation.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sizeNumber of bytes of error report to return
[out]errAddress where to return the error report

Returns at the address specified by err a detailed error report of the last command executed. If size >= sizeof(struct zbc_err) then the entire zbc_err structure is returned; otherwise the first size bytes are returned.

For successful commands, all fields are set to 0.

int zbc_flush ( struct zbc_device *  dev)

Flush a device write cache.

Parameters
[in]devDevice handle obtained with zbc_open

This is the equivalent to fsync/fdatasunc but it operates at the device cache level.

Returns
Returns 0 on success and -EIO in case of error.
void zbc_get_device_info ( struct zbc_device *  dev,
struct zbc_device_info info 
)

Get a ZBC device information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]infoAddress of the information structure to fill

Get information about an open device. The info parameter is used to return a device information. info must be allocated by the caller.

int zbc_get_nr_actv_records ( struct zbc_device *  dev,
bool  zsrc,
bool  all,
bool  use_32_byte_cdb,
uint64_t  start_zone,
unsigned int  nr_zones,
unsigned int  domain_id 
)

Return the expected number of activation records.

Parameters
[in]devDevice handle obtained with zbc_open
[in]zsrcIf set, the nr_zones argument is valid
[in]allIf set, try to activate all zones
[in]use_32_byte_cdbIf true, use 32-byte SCSI command
[in]start_zone512B sector of the first zone to activate
[in]nr_zonesThe total number of zones to activate
[in]domain_idZone domain to activate
int zbc_get_zbd_stats ( struct zbc_device *  dev,
struct zbc_zoned_blk_dev_stats stats 
)

Get Zoned Block Device statistics.

Parameters
[in]devDevice handle obtained with zbc_open
[in]statsPoints to zbc_zoned_blk_dev_stats structure allocated by the caller
Returns
Returns -EIO if an error happened when communicating with the device. Returns -ENXIO if the device or the driver doesn't support ZBD statistics.
int zbc_list_domains ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_domain_report_options  ro,
struct zbc_zone_domain **  pdomains,
unsigned int *  pnr_domains 
)

List zone domain information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorThe starting sector for report
[in]roDomain reporting options
[out]domainsArray of zone domain descriptors
[out]nr_domainsNumber of domains in the array domains

Similar to zbc_report_domains, but also allocates an appropriately sized array of zone domain descriptors and returns the address of the array at the address specified by domains. The size of the array allocated and filled is returned at the address specified by nr_domains. Freeing of the memory used by the array of domain descriptors allocated by this function is the responsibility of the caller.

Returns
Returns -EIO if an error happened when communicating with the device. Returns -ENOMEM if memory could not be allocated for domains.
int zbc_list_zone_realms ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_realm_report_options  ro,
struct zbc_zone_realm **  prealms,
unsigned int *  pnr_realms 
)

List zone realm information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorThe starting sector of the first realm to report
[in]roRealm reporting options
[out]prealmsPointer to an array of zone realm descriptors
[out]pnr_realmsPoints to the number of realms in realms

Similar to zbc_report_realms, but also allocates an appropriately sized array of zone realm descriptors and returns the address of the array at the address specified by realms. The size of the array allocated and filled is returned at the address specified by nr_realms. Freeing of the memory used by the array of realm descriptors allocated by this function is the responsibility of the caller.

Returns
Returns -EIO if an error happened when communicating with the device. Returns -ENOMEM if memory could not be allocated for realms.
int zbc_list_zones ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_zone_reporting_options  ro,
struct zbc_zone **  zones,
unsigned int *  nr_zones 
)

Get zone information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorSector from which to report zones
[in]roReporting options
[out]zonesThe array of zone information filled
[out]nr_zonesNumber of zones in the array zones

Similar to zbc_report_zones, but also allocates an appropriately sized array of zone information structures and return the address of the array at the address specified by zones. The size of the array allocated and filled is returned at the address specified by nr_zones. Freeing of the memory used by the array of zone information structures allocated by this function is the responsibility of the caller.

Returns
Returns -EIO if an error happened when communicating with the device. Returns -ENOMEM if memory could not be allocated for zones.
int zbc_map_iov ( const void *  buf,
size_t  sectors,
struct iovec *  iov,
int  iovcnt,
size_t  iovlen 
)

Map a buffer to an I/O vector.

Parameters
[in]bufData buffer to map
[in]sectorsSize of buf in 512B sectors unit
[in]iovArray of I/O vectors to which buf will be mapped
[in]iovcntThe maximum number of entries in the iov array
[in]iovlenThe maximum size of a single I/O vector entry in 512B sectors.

Map the buffer buf to a set of I/O vectors of size iovlen. This is a utility function that is called by libzbc tools and test programs. It can be handy to library users as well.

Returns
the number of I/O vectors mapped or a negative error code in case of error
int zbc_open ( const char *  filename,
int  flags,
struct zbc_device **  dev 
)

Open a ZBC device.

Parameters
[in]filenamePath to a device file
[in]flagsDevice access mode flags
[out]devOpaque ZBC device handle

Opens the device pointed by filename, and returns a handle to it at the address specified by dev if the device is a zoned block device supporting the ZBC or ZAC command set. flags specifies the device access mode flags.O_RDONLY, O_WRONLY and O_RDWR can be specified. Other POSIX defined O_xxx flags are ignored. Additionally, if filename specifies the path to a zoned block device file or an emulated device, O_DIRECT can also be specified (this is mandatory to avoid unaligned write errors with zoned block device files). flags can also be or'ed with one or more of the ZBC_O_DRV_xxx flags in order to restrict the possible backend device drivers that libzbc will try when opening the device.

Returns
If the device is not a zoned block device, -ENXIO will be returned. Any other error code returned by open(2) can be returned as well.
ssize_t zbc_pread ( struct zbc_device *  dev,
void *  buf,
size_t  count,
uint64_t  offset 
)

Read sectors from a device.

Parameters
[in]devDevice handle obtained with zbc_open
[in]bufCaller supplied buffer to read into
[in]countNumber of 512B sectors to read
[in]offsetOffset where to start reading (512B sector unit)

This is the equivalent of the standard system call pread(2) that operates on a ZBC device handle and uses 512B sector unit addressing for the amount of data and the position on the device of the data to read. Attempting to read data across zone boundaries or after the write pointer position of a write pointer zone is possible only if the device allows unrestricted reads. This is indicated by the device information structure flags field, using the flag ZBC_UNRESTRICTED_READ. The range of 512B sectors to read, starting at offset and spanning count 512B sectors must be aligned on logical blocks boundaries. That is, for a 4K logical block size device, count and offset must be multiples of 8.

Returns
Any error returned by pread(2) can be returned. On success, the number of 512B sectors read is returned.
ssize_t zbc_preadv ( struct zbc_device *  dev,
const struct iovec *  iov,
int  iovcnt,
uint64_t  offset 
)

Read sectors from a device using multiple buffers.

Parameters
[in]devDevice handle obtained with zbc_open
[in]iovCaller supplied read buffers to read into. Read buffer length is specified in 512B sectors
[in]iovcntNumber of iov buffers
[in]offsetOffset where to start reading (512B sector unit)

This is the equivalent of the standard system call preadv(2) and behaves otherwise as described in zbc_pread. The call reads iovcnt buffers from the file associated with zbc_open into the buffers described by iov ("scatter input").

void zbc_print_device_info ( struct zbc_device_info info,
FILE *  out 
)

Print a device information.

Parameters
[in]infoThe information to print
[in]outFile stream to print to

Print the content of info to the file stream out.

ssize_t zbc_pwrite ( struct zbc_device *  dev,
const void *  buf,
size_t  count,
uint64_t  offset 
)

Write sectors to a device.

Parameters
[in]devDevice handle obtained with zbc_open
[in]bufCaller supplied buffer to write from
[in]countNumber of 512B sectors to write
[in]offsetOffset where to start writing (512B sector unit)

This is the equivalent of the standard system call pwrite(2) that operates on a ZBC device handle, and uses 512B sector unit addressing for the amount of data and the position on the device of the data to write. On a host-aware device, any range of 512B sector is acceptable. On a host-managed device, the range os sectors to write can span several conventional zones but cannot span conventional and sequential write required zones. When writing to a sequential write required zone, offset must specify the current write pointer position of the zone. The range of 512B sectors to write, starting at offset and spanning count 512B sectors must be aligned on physical blocks boundaries. That is, for a 4K physical block size device, count and offset must be multiples of 8.

Returns
Any error returned by write(2) can be returned. On success, the number of logical blocks written is returned.
ssize_t zbc_pwritev ( struct zbc_device *  dev,
const struct iovec *  iov,
int  iovcnt,
uint64_t  offset 
)

Write sectors to a device usig multiple buffers.

Parameters
[in]devDevice handle obtained with zbc_open
[in]iovCaller supplied write buffers to write from. Write buffer length is specified in 512B sectors
[in]iovcntNumber of iov buffers
[in]offsetOffset where to start writing (512B sector unit)

This is the equivalent of the standard system call pwritev(2) and behaves otherwise as described in zbc_pwrite. The call writes iovcnt buffers from the file associated with zbc_open from the buffers described by iov ("gather output").

int zbc_report_domains ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_domain_report_options  ro,
struct zbc_zone_domain domains,
unsigned int  nr_domains 
)

Get zone domain information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorThe starting sector for the report
[in]roDomain reporting options
[in]domainsPointer to the array of domain descriptors to fill
[in]nr_domainsNumber of domain descriptors in the array domains

Get zone domain information from a Zone Domains device. The domains array must be allocated by the caller and nr_domains must contain the size of the allocated array (the number of descriptors in the array). The number of returned domains may depend on the chosen reporting options.

Returns
Returns -EIO if an error happened when communicating with the device. Upon success, returns the total number of records that the device is reporting. This number may potentially exceed nr_domains. In this case, only nr_domains records in the input buffer are filled.
int zbc_report_realms ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_realm_report_options  ro,
struct zbc_zone_realm realms,
unsigned int *  nr_realms 
)

Get zone realm information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]roRealm reporting options
[in]sectorThe starting sector of the first realm to report
[in]realmsPointer to the array of realm descriptors to fill
[out]nr_realmsNumber of realm descriptors in the array realms

Get zone realm information from an XMR device. The realms array must be allocated by the caller and nr_realms must point to the size of the allocated array (the number of descriptors in the array). The number of returned realm records may depend on the chosen reporting options.

Returns
Returns -EIO if an error happened when communicating with the device.
int zbc_report_zones ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_zone_reporting_options  ro,
struct zbc_zone zones,
unsigned int *  nr_zones 
)

Get zone information.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorSector from which to report zones
[in]roReporting options
[in]zonesPointer to the array of zone information to fill
[out]nr_zonesNumber of zones in the array zones

Get zone information matching the sector and ro arguments and return the information obtained in the array zones and the number of zone information obtained at the address specified by nr_zones. The array zones must be allocated by the caller and nr_zones must point to the size of the allocated array (number of zone information structures in the array). The first zone reported will be the zone containing or after sector.

Returns
Returns -EIO if an error happened when communicating with the device.
void zbc_set_log_level ( char const *  log_level)

Set the library log level.

Parameters
[in]log_levelLibrary log level

Set the library log level using the level name specified by log_level. Log level are incremental: each level includes the levels preceding it. Valid log level names are: "none" : Silent operation (no messages) "warning" : Print device level standard compliance problems "error" : Print messages related to unexpected errors "info" : Print normal information messages "debug" : Verbose output describing internally executed commands The default level is "warning".

const char* zbc_sk_str ( enum zbc_sk  sk)

Returns a string describing a sense key.

Parameters
[in]skSense key
Returns
A string describing a sense key.
int zbc_zone_activate ( struct zbc_device *  dev,
bool  zsrc,
bool  all,
bool  use_32_byte_cdb,
uint64_t  start_zone,
unsigned int  nr_zones,
unsigned int  domain_id,
struct zbc_actv_res actv_recs,
unsigned int *  nr_actv_recs 
)

Activate the specified zones at a new zone domain.

Parameters
[in]devDevice handle obtained with zbc_open
[in]zsrcIf set, the nr_zones argument is valid
[in]allIf set, try to activate all zones
[in]use_32_byte_cdbIf true, use ZONE ACTIVATE(32)
[in]start_zone512B sector of the first zone to activate
[in]nr_zonesThe total number of zones to activate
[in]domain_idZone domain to activate
[out]actv_recsArray of activation results records
[out]nr_actv_recsThe number of activation results records
int zbc_zone_activation_ctl ( struct zbc_device *  dev,
struct zbc_zd_dev_control ctl,
bool  set 
)

Read or change persistent XMR device settings.

Parameters
[in]devDevice handle obtained with zbc_open
[in]ctlContains all supported variables to control
[in]setIf false, just get the settings, otherwise set

Typically, to set values, this function is called with set = false first to get the current values, then the caller modifies the members of ctl that need to be modified and then calls this function again with set = true.

const char* zbc_zone_condition_str ( enum zbc_zone_condition  cond)

Returns a string describing a zone condition.

Parameters
[in]condZone condition
Returns
A string describing a zone condition.
int zbc_zone_group_op ( struct zbc_device *  dev,
uint64_t  sector,
unsigned int  count,
enum zbc_zone_op  op,
unsigned int  flags 
)

Execute an operation on a group of zones.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorThe first sector of the first target zone
[in]countThe number of zones to process (0 still means one zone)
[in]opThe operation to perform
[in]flagsZone operation flags

Execute an operation on one or more zones of dev starting at the sector specified by sector. The target zones must be write pointer zones, that is, their type must be ZBC_ZT_SEQUENTIAL_REQ or ZBC_ZT_SEQUENTIAL_PREF. The validity of the operation (reset, open, close or finish) depends on the condition of the target group of zones. See zbc_reset_zone, zbc_open_zone, zbc_close_zone and zbc_finish_zone for details. If ZBC_OP_ALL_ZONES is set in flags then sector is ignored and the operation is executed on all possible zones.

Returns
Returns -EIO if an error happened when communicating with the device.
int zbc_zone_operation ( struct zbc_device *  dev,
uint64_t  sector,
enum zbc_zone_op  op,
unsigned int  flags 
)

Execute an operation on a zone.

Parameters
[in]devDevice handle obtained with zbc_open
[in]sectorFirst sector of the target zone
[in]opThe operation to perform
[in]flagsZone operation flags

Execute an operation on the zone of dev starting at the sector specified by sector. The target zone must be a write pointer zone, that is, its type must be ZBC_ZT_SEQUENTIAL_REQ or ZBC_ZT_SEQUENTIAL_PREF. The validity of the operation (reset, open, close or finish) depends on the condition of the target zone. See zbc_reset_zone, zbc_open_zone, zbc_close_zone and zbc_finish_zone for details. If ZBC_OP_ALL_ZONES is set in flags then sector is ignored and the operation is executed on all possible zones.

Returns
Returns -EIO if an error happened when communicating with the device.
int zbc_zone_query ( struct zbc_device *  dev,
bool  zsrc,
bool  all,
bool  use_32_byte_cdb,
uint64_t  start_zone,
unsigned int  nr_zones,
unsigned int  domain_id,
struct zbc_actv_res actv_recs,
unsigned int *  nr_actv_recs 
)

Query about possible results of zone activation.

Parameters
[in]devDevice handle obtained with zbc_open
[in]zsrcIf set, the nr_zones argument is valid
[in]allIf set, try to activate all zones
[in]use_32_byte_cdbIf true, use ZONE QUERY(32)
[in]start_zone512B sector of the first zone to activate
[in]nr_zonesThe total number of zones to activate
[in]domain_idZone domain to query about
[out]actv_recsArray of activation results records
[out]nr_actv_recsThe number of activation results records
int zbc_zone_query_list ( struct zbc_device *  dev,
bool  zsrc,
bool  all,
bool  use_32_byte_cdb,
uint64_t  start_zone,
unsigned int  nr_zones,
unsigned int  domain_id,
struct zbc_actv_res **  pactv_recs,
unsigned int *  pnr_actv_recs 
)

Query about possible activation results of a number of zones.

Parameters
[in]devDevice handle obtained with zbc_open
[in]zsrcIf set, the nr_zones argument is valid
[in]allIf set, try to activate all zones
[in]use_32_byte_cdbIf true, use ZONE QUERY(32)
[in]start_zone512B sector of the first zone to activate
[in]nr_zonesThe total number of zones to activate
[in]domain_idZone domain to query about
[out]actv_recsPoints to the returned activation records
[out]nr_actv_recsNumber of returned activation results records
const char* zbc_zone_type_str ( enum zbc_zone_type  type)

returns a string describing a zone type

Parameters
[in]typeZone type
Returns
A string describing a zone type.