lofi.h revision a19609f85693e4e7d7e744d836a4e87193c934e4
/*
* 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
* 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
*/
/*
*/
#ifndef _SYS_LOFI_H
#define _SYS_LOFI_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* /dev names:
*/
#define LOFI_DRIVER_NAME "lofi"
#define LOFI_CTL_NODE "ctl"
#define LOFI_BLOCK_NAME LOFI_DRIVER_NAME
#define SEGHDR 1
#define COMPRESSED 1
#define UNCOMPRESSED 0
#define MAXALGLEN 36
/*
*
* Use is:
*
* lofi must be opened exclusively. Access is controlled by permissions on
* the device, which is 644 by default. Write-access is required for ioctls
* that change state, but only read-access is required for the ioctls that
* return information. Basically, only root can add and remove files, but
* non-root can look at the current lists.
*
* ioctl usage:
*
* kernel ioctls
*
* strcpy(li.li_filename, "somefilename");
* ioctl(ld, LOFI_MAP_FILE, &li);
* newminor = li.li_minor;
*
* strcpy(li.li_filename, "somefilename");
* ioctl(ld, LOFI_UNMAP_FILE, &li);
*
* strcpy(li.li_filename, "somefilename");
* li.li_minor = minor_number;
* ioctl(ld, LOFI_MAP_FILE_MINOR, &li);
*
* li.li_minor = minor_number;
* ioctl(ld, LOFI_UNMAP_FILE_MINOR, &li);
*
* li.li_minor = minor_number;
* ioctl(ld, LOFI_GET_FILENAME, &li);
* filename = li.li_filename;
* encrypted = li.li_crypto_enabled;
*
* strcpy(li.li_filename, "somefilename");
* ioctl(ld, LOFI_GET_MINOR, &li);
* minor = li.li_minor;
*
* li.li_minor = 0;
* ioctl(ld, LOFI_GET_MAXMINOR, &li);
* maxminor = li.li_minor;
*
* strcpy(li.li_filename, "somefilename");
* li.li_minor = 0;
* ioctl(ld, LOFI_CHECK_COMPRESSED, &li);
*
* If the 'li_force' flag is set for any of the LOFI_UNMAP_* commands, then if
* the device is busy, the underlying vnode will be closed, and any subsequent
* operations will fail. It will behave as if the device had been forcibly
* removed, so the DKIOCSTATE ioctl will return DKIO_DEV_GONE. When the device
* is last closed, it will be torn down.
*
* If the 'li_cleanup' flag is set for any of the LOFI_UNMAP_* commands, then
* if the device is busy, it is marked for removal at the next time it is
* no longer held open by anybody. When the device is last closed, it will be
* torn down.
*
* Oh, and last but not least: these ioctls are totally private and only
* for use by lofiadm(1M).
*
*/
typedef enum iv_method {
IVM_NONE, /* no iv needed, iv is null */
IVM_ENC_BLKNO /* iv is logical block no. encrypted */
} iv_method_t;
struct lofi_ioctl {
char li_filename[MAXPATHLEN];
/* the following fields are required for compression support */
char li_algorithm[MAXALGLEN];
/* the following fields are required for encryption support */
};
/*
* file types that might be usable with lofi, maybe. Only regular
* files are documented though.
*/
#define S_ISLOFIABLE(mode) \
#if defined(_KERNEL)
/*
* Cache decompressed data segments for the compressed lofi images.
*
* To avoid that we have to decompress data of a compressed
* segment multiple times when accessing parts of the segment's
* data we cache the uncompressed data, using a simple linked list.
*/
struct lofi_comp_cache {
};
#define V_ISLOFIABLE(vtype) \
/*
* Pre-allocated memory buffers for the purpose of compression
*/
struct compbuf {
void *buf;
int inuse;
};
/*
* Need exactly 6 bytes to identify encrypted lofi image
*/
extern const char lofi_crypto_magic[6];
#define LOFI_CRYPTO_VERSION ((uint16_t)0)
/*
* Crypto metadata for encrypted lofi images
* The fields here only satisfy initial implementation requirements.
*/
struct crypto_meta {
/* second header block is not defined at this time */
};
struct lofi_state {
int ls_openflag;
/* the following fields are required for compression support */
int ls_comp_algorithm_index; /* idx into compress_table */
char ls_comp_algorithm[MAXALGLEN];
/* pre-allocated list of buffers for compressed segment data */
struct compbuf *ls_comp_bufs;
/* lock and anchor for compressed segment caching */
/* the following fields are required for encryption support */
struct crypto_meta ls_crypto;
};
#endif /* _KERNEL */
/*
* Common signature for all lofi compress functions
*/
/*
* Information about each compression function
*/
typedef struct lofi_compress_info {
int l_level;
char *l_name; /* algorithm name */
enum lofi_compress {
LOFI_COMPRESS_GZIP = 0,
LOFI_COMPRESS_GZIP_6 = 1,
LOFI_COMPRESS_GZIP_9 = 2,
LOFI_COMPRESS_LZMA = 3,
};
#ifdef __cplusplus
}
#endif
#endif /* _SYS_LOFI_H */