dda.h revision cee0fb94c0d4227de0a00efc162fb2739844b641
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DDA_H
#define _DDA_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Driver for Disk Archiving (dda)
*/
/* Begin: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif
/* version for cartridge and dda */
#define DDA_MAJOR_VERSION 0 /* dda driver major version */
#define DDA_MINOR_VERSION 23 /* dda driver minor version */
/* cartridge file names */
#define DDA_METADATA_FNAME "metadata" /* metadata file name */
#define DDA_INDEX_FNAME "index" /* index file name */
#define DDA_DATA_FNAME "data" /* data file name */
/* inquiry and mt config data */
#define DDA_VENDOR "SUNW "
#define DDA_PRODUCT "DISK_ARCHIVING "
#define DDA_VID DDA_VENDOR DDA_PRODUCT
#define DDA_ST_NAME "SUNW MMS disk archiving"
/*
* DM ioctls:
* cmd arg
* --- ---
* DDA_CMD_LOAD char path[PATH_MAX]
* DDA_CMD_NAME char path[PATH_MAX]
* DDA_CMD_CAPACITY dda_capacity_t *capacity
* DDA_CMD_WROTECT NULL
* returns 0 if WP flag on, else non 0
* DDA_CMD_BLKLMT dda_blklmt_t *blklmt
* DDA_CMD_SERIAL dda_serial_t serial
*/
#define DDA_IOC (('D' << 24) | ('D' << 16) | ('A' << 8))
#define DDA_CMD_LOAD (DDA_IOC | 1) /* load cartridge */
#define DDA_CMD_NAME (DDA_IOC | 2) /* get cartridge name */
#define DDA_CMD_CAPACITY (DDA_IOC | 3) /* get tape capacity/space */
#define DDA_CMD_WPROTECT (DDA_IOC | 4) /* get cartridge WP flag */
#define DDA_CMD_BLKLMT (DDA_IOC | 5) /* get block limits */
#define DDA_CMD_SERIAL (DDA_IOC | 6) /* drive serial number */
typedef char dda_serial_t[13]; /* drive serial number */
/* cartridge capacity */
typedef struct dda_capacity {
int64_t dda_capacity; /* tape capacity in bytes */
int64_t dda_space; /* unused tape bytes remaining to eom */
} dda_capacity_t;
/* read block limits */
typedef struct dda_blklmt {
int32_t dda_blkmax; /* maximum block length */
int32_t dda_blkmin; /* minimum block length */
} dda_blklmt_t;
/* versioning */
typedef struct dda_version {
int32_t dda_major; /* dda drive/media major version */
int32_t dda_minor; /* dda drive/media minor version */
} dda_version_t;
/* metadata flags */
#define DDA_FLAG_WPROTECT 0x1 /* cartridge write protect tab */
/* metadata file contents */
typedef struct dda_metadata {
dda_version_t dda_version; /* dda media version */
int64_t dda_capacity; /* tape capacity in bytes */
int32_t dda_sector; /* sector alignment */
int32_t dda_stripe; /* raid 5 stripe alignment */
int32_t dda_flags; /* cartridge flags */
int32_t dda_pad; /* padding */
} dda_metadata_t;
/* index file record */
typedef struct dda_index {
off64_t dda_offset; /* data file offset */
int32_t dda_blksize; /* data block size */
int32_t dda_pad; /* padding */
int64_t dda_blkcount; /* data block count */
int64_t dda_fmcount; /* file marks following data blocks */
int64_t dda_fileno; /* file mark number */
int64_t dda_lba; /* logical block address */
} dda_index_t;
/* End: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif
#ifdef _KERNEL
/* emulated tape drive data structure */
typedef struct dda {
char dda_path[PATH_MAX]; /* cartridge path */
short dda_status; /* sense key */
int32_t dda_resid; /* residual */
int64_t dda_blkno; /* block number */
off64_t dda_early_warn; /* early warning */
uint32_t dda_flags; /* operation flags */
struct vnode *dda_metadata_vp; /* metadata file */
dda_metadata_t dda_metadata; /* metatdata file data */
struct vnode *dda_index_vp; /* index file */
off64_t dda_index_offset; /* index file offset */
dda_index_t dda_index; /* index file record */
int64_t dda_pos; /* index record current block */
struct vnode *dda_data_vp; /* data file */
int dda_inst; /* driver instance (drive number) */
dda_serial_t dda_serial; /* serial number */
dev_info_t *dda_dip; /* driver instance info */
kmutex_t dda_mutex; /* serialize drive access */
int dda_loaded; /* media loaded */
pid_t dda_pid; /* process opened by */
cred_t *dda_cred; /* user credentials */
int dda_read_only; /* opened read only */
int32_t dda_rec_size; /* variable or fixed blocks */
int dda_ili; /* incorrect length indicator */
} dda_t;
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _DDA_H */