/* @(#)src/common/kernel/base/vx_aioctl.h	3.51.19.4 06/07/99 17:53:42 -  */
/* #ident "@(#)vxfs:src/common/kernel/base/vx_aioctl.h	3.51.19.4" */

/*
 * Copyright (c) 1998 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
 * UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
 * LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
 * IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
 * OR DISCLOSURE.
 *
 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
 * TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
 * OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
 * EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
 *
 * 		RESTRICTED RIGHTS LEGEND
 * USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
 * SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
 * (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
 * COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
 * 		VERITAS SOFTWARE
 * 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043
 */

#ifndef	_FS_VXFS_VX_ADMIN_H
#define	_FS_VXFS_VX_ADMIN_H

/*
 * Admin group ioctls
 *
 * VX_GETFSOPT definition on hpux 10.20 and 11.0 (based on vxfs 3.1) belongs
 * to admin ioctl group. This old definition must be supported for backward
 * compatibility.
 */

#define	VX_GETFSOPT_OLD		0		/* HPUX get fs options */
#define	VX_SNAPREAD		1		/* read a snapshot FS */
#define	VX_SETROOTFSOPT		2		/* set mountflags */
#define	VX_UPGRADE		3		/* upgrade to version n */
#define	VX_CHGQUOTA		4		/* change fileset quota */
#define	VX_READINFO		5		/* get vx_info struct */
#define	VX_READTRANTABLE	6		/* get vx_trantable struct */
#define	VX_READTRANINFO		7		/* get vx_traninfo struct */
#define	VX_REORG		8		/* reorganize normal files */
#define	VX_STRUCTREORG		9		/* reorganize struct files */
#define	VX_REORGLK		10		/* file system reorg lock */
#define	VX_EXCLUSION		11		/* manage exclusion zones */
#define	VX_MAKEFSET		12		/* make a new fileset */
#define	VX_REMFSET		13		/* remove a fileset */
#define	VX_UNUSED1		14		/* unused */
#define	VX_RENAMEFSET		15		/* rename a fileset */
#define	VX_EXPAND		16		/* expand FS */
#define	VX_SHRINK		17		/* shrink FS */
#define	VX_CLONEFSET		18		/* clone a fileset */
#define	VX_SETFEATURES		19		/* set fileset features */
#define	VX_CLRFEATURES		20		/* clear fileset features */
#define	VX_STATFSET		21		/* stat a fileset */
#define	VX_UNUSED2		22		/* unused */
#define	VX_DIRSORT		23		/* directory sort */
#define	VX_CONVNODATA		24		/* convert clone to nodata */
#define	VX_QUOTACTL		25		/* quota ioctl */
#define	VX_SET_TUNEFS		26		/* Download tuning info */
#define	VX_GET_TUNEFS		27		/* Upload tuning info */
#define	VX_FSDISABLE		28		/* Disable file system */
#define VX_FBMAP		29		/* bmap ioctl for bli */
#define	VX_CVIEW		30		/* set/unset context */
#define VX_CLONECNTL		31		/* set/clear clone cntl flags */
#define VX_CONV_TYPED		32		/* Convert to typed */
#define VX_CONV_TYPED_STRUCT	33		/* structural file convert */

struct vx_dirsort {
	vx_u32_t	dir_fsetidx;	/* fileset index */
	vx_u32_t	dir_iltype;	/* inode address space */
	vx_ino_t	dir_inode;	/* inode number */
	vx_off_t	dir_off;	/* offset within directory in bytes */
	vx_daddr_t	dir_bno[2];	/* original block numbers */
	caddr_t		dir_ibuf[2];	/* original content of blocks */
	caddr_t		dir_obuf[2];	/* new contents of blocks */
	vx_u32_t	dir_olen[2];	/* new lengths of blocks */
};

/*
 * Structure for VX_SNAPREAD ioctl
 */

struct vx_snapread {
	caddr_t		sr_buf;		/* address of read buffer */
	daddr_t		sr_off;		/* offset in DEV_BSIZE blocks */
	vx_u32_t	sr_len;		/* bytes to read (DEV_BSIZE multiple) */
};

/*
 * Structure for VX_REORGLK ioctl
 */

struct vx_reorg_lock {
	vx_u32_t	rl_cmd;			/* set/clear/query */
	pid_t		rl_lpid;		/* lock holder pid */
	char		rl_path[MAXPATHLEN];	/* path for lock file */
};

#define	VX_RLK_SET	1		/* establish reorg lock */
#define	VX_RLK_CLEAR	2		/* release reorg lock */
#define	VX_RLK_QUERY	3		/* query lock ownership */

/*
 * Structure for VX_EXCLUSION ioctl
 */

struct vx_exclusion {
	vx_u32_t	ec_cmd;		/* set/clear zone */
	vx_devid_t	ec_dev;		/* device for zone */
	vx_daddr_t	ec_start;	/* starting block of zone */
	vx_daddr_t	ec_len;		/* length in blocks */
};

#define	VX_EXC_SET	1		/* set reorg zone */
#define	VX_EXC_CLEAR	2		/* clear reorg zone */

/*
 * Data structures passed to the mount system call.  The first is
 * used for a normal mount, the second is used for a fileset mount or
 * a snapshot mount.
 */

struct vx_mountargs1 {
	vx_u32_t	msize;		/* size of structure */
	vx_u32_t	mflags;		/* mount flags -- see below */
	char		*primaryspec;	/* block special file of
					   primary file system */
};

struct vx_mountargs3 {
	vx_u32_t	msize;		/* size of structure */
	vx_u32_t	mflags;		/* mount flags -- see below */
	char		*primaryspec;	/* block special file of
					   primary file system */
	vx_u32_t	snapsize;	/* size in 512-byte blocks of snapshot*/
};

struct vx_mountargs5 {
	vx_u32_t	msize;		/* size of structure */
	vx_u32_t	mflags;		/* mount flags -- see below */
	char		*primaryspec;	/* block special file of
					   primary file system */
	vx_u32_t	snapsize;	/* size in 512-byte blocks of snapshot*/
	char		*aggrname;	/* name of aggregate */
	char		*fsetname;	/* name of fileset */
};

struct vx_mountargs7 {
	vx_u32_t	msize;		/* size of structure */
	vx_u32_t	mflags;		/* mount flags--see below */
	char		*primaryspec;	/* block special file of
					   primary file system */
	vx_u32_t	snapsize;	/* size in 512-byte blocks of snapshot*/
	char		*aggrname;	/* name of aggregate */
	char		*fsetname;	/* name of fileset */
	vx_u32_t	vxldversion;	/* VXLD log version */
	char		*logname;	/* VXLD device name */
};

/*
 * Mount options for vxfs only.
 *
 * The VX_MS_CACHE_DIRECT and VX_MS_CACHE_DSYNC options also imply an
 * fsync for all files on last close.
 */

#define	VX_MS_MASK		0xf1f1f0ff /* mask of valid flags */

#define	VX_MS_NOLOG		0x00000001 /* no logging */
#define	VX_MS_BLKCLEAR		0x00000002 /* guarantee cleared storage */
#define	VX_MS_SNAPSHOT		0x00000004 /* shadow mount */
#define	VX_MS_NODATAINLOG	0x00000008 /* disable logged writes */
#define	VX_MS_DELAYLOG		0x00000010 /* unix semantics */
#define	VX_MS_TMPLOG		0x00000020 /* temporary file system semantics */
#define	VX_MS_FILESET		0x00000040 /* this is a fileset mount */
#define	VX_MS_VXLDLOG		0x00000080 /* vxld logging requested */

#define	VX_MS_CACHE_MASK	0x0001f000 /* mask of valid mincache flags */
#define	VX_MS_CACHE_DIRECT	0x00001000 /* async writes handled VX_DIRECT */
#define	VX_MS_CACHE_DSYNC	0x00002000 /* async writes handled VX_DSYNC */
#define	VX_MS_CACHE_CLOSESYNC	0x00004000 /* all files fsynced on last close */
#define	VX_MS_CACHE_TMPCACHE	0x00008000 /* fast caching semantics */
#define	VX_MS_CACHE_UNBUFFERED	0x00010000 /* unbuffered I/O */

#define	VX_MS_OSYNC_MASK	0x01f00000 /* mask of valid convosync flags */
#define	VX_MS_OSYNC_DIRECT	0x00100000 /* O_SYNC writes handled VX_DIRECT */
#define	VX_MS_OSYNC_DSYNC	0x00200000 /* O_SYNC writes handled VX_DSYNC */
#define	VX_MS_OSYNC_CLOSESYNC	0x00400000 /* O_SYNC writes handled async and
					      all files fsynced on last close */
#define	VX_MS_OSYNC_DELAY	0x00800000 /* O_SYNC writes handled delayed */
#define	VX_MS_OSYNC_UNBUFFERED	0x01000000 /* unbuffered I/O */

#define	VX_MS_LARGEFILES	0x10000000 /* mount for large file support */
#define	VX_MS_NOLARGEFILES	0x20000000 /* mount with no largefile support */
#define	VX_MS_QIO_ON		0x40000000 /* quick i/o enabled for this fs */
#define VX_MS_FSO_ON		0x80000000 /* FSO: enable for this fs */

/*
 * Fileset statistics.
 */

struct vx_stfset {
	struct vx_timeval32	stf_ctime;	/* creation time */
	struct vx_timeval32	stf_mtime;	/* modification time */
	vx_u32_t		stf_index;	/* fileset index */
	vx_u32_t		stf_features;	/* feature bits */
	vx_u32_t		stf_flags;	/* flags field from FSI */
	vx_u32_t		stf_ninodes;	/* number of inodes */
	vx_u32_t		stf_nblocks;	/* number of blocks */
	vx_u32_t		stf_read;	/* number of reads */
	vx_u32_t		stf_write;	/* number of writes */
	vx_u32_t		stf_push;	/* number of pushes */
	vx_u32_t		stf_pull;	/* number of pulls */
	vx_u32_t		stf_move;	/* number of moves */
	vx_u32_t		stf_move_all;	/* number of move alls */
	vx_u32_t		stf_merge_all;	/* number of merge alls */
	vx_u32_t		stf_logged_push;  /* num of logged pushes */
	vx_u32_t		stf_clone_enospc; /* num of enospc on writes */
	vx_u32_t		stf_overlay_bmap; /* num of overlay bmaps */
	vx_u32_t		stf_nextix;	/* next in clone chain */
	vx_u32_t		stf_previx;	/* prev in clone chain */
	char		stf_name[FSETNAMESZ];	/* name of fileset */
	char		stf_nname[FSETNAMESZ];	/* next in clone chain */
	char		stf_pname[FSETNAMESZ];	/* prev in clone chain */
};

/*
 * Flags
 */

#define VX_STF_ROOT		0x00000001	/* default root fileset */
#define VX_STF_MOUNTED		0x00000002	/* fset mounted */
#define VX_STF_RDONLY		0x00000004	/* can only mount rdonly */
#define VX_STF_BAD		0x00000008	/* fset is unloadable */
#define VX_STF_NODATA		0x00000010	/* clone fset with nodata */
#define VX_STF_REMOVABLE	0x00000020	/* clone may self-destruct */
#define VX_STF_NOMOUNT		0x00000040	/* clone can't be mounted */
#define VX_STF_CONTEXT		0x00000080	/* fset is context view */

/*
 * Generic fset arguments for ioctls
 */

struct vx_fsetarg {
	char			*fa_devname;	/* device name */
	char			*fa_fsetname1;	/* 1st fileset name */
	char			*fa_fsetname2;	/* 2nd fileset name */
	vx_u32_t		fa_op;		/* control op */
	vx_u32_t		fa_misc1;	/* misc data field 1 */
	vx_u32_t		fa_misc2;	/* misc data field 2 */
	struct vx_stfset	*fa_stfset;	/* stat fset structure */
};

/*
 * Parameters for VX_FBMAP ioctl.
 */
struct vx_fbmaparg {
	vx_off_t		fb_reqoff;	/* request offset in bytes */
	vx_u32_t		fb_relfsetx;	/* relative view name */
	vx_off_t		fb_len;		/* section length in bytes */
	vx_u32_t		fb_flags;	/* misc. flags */
};

#define VX_FB_CHANGED		0x01
#define VX_FB_EXTENDED		0x02
#define VX_FB_HOLE		0x04

/*
 * Parameter structure for VX_QUOTACTL ioctl.
 */

struct vx_quotctl {
	vx_u32_t	cmd;
	vx_uid_t	uid;
	caddr_t		addr;
};

/*
 * VM/FS interface - structure for setting/getting tunefs info.
 */

struct vx_tune_fs {
	vx_u32_t	tf_read_preferred_io;	/* Preferred read size */
	vx_u32_t	tf_read_nstream;	/* no of reads to stream */
	vx_u32_t	tf_read_unit_io;	/* Less preferred read size */
	vx_u32_t	tf_write_preferred_io;	/* Preferred write size */
	vx_u32_t	tf_write_nstream;	/* no of writes to stream */
	vx_u32_t	tf_write_unit_io;	/* Less preferred write size */
	vx_u32_t	tf_pref_strength;	/* Strength of this hint */
	vx_u32_t	tf_breakup_size;	/* buffer breakup size */
	vx_u32_t	tf_align_offset;	/* adj for alignment calc  */
	vx_dev_t	tf_block_device;	/* Block device */
	vx_u32_t	tf_disc_direct_iosz;	/* Discovered direct i/o size */
	vx_u32_t	tf_max_direct_iosz;	/* Maximum dio simultaneously */
	vx_u32_t	tf_indir_size;		/* Indir size for ver 2 */
	vx_u32_t	tf_max_diskq;		/* Max concurrent pageouts
						   per file */
	vx_u32_t	tf_def_init_extent;	/* Extent size in blocks for
						   default initial alloc */
	vx_u32_t	tf_max_seqio_extent_size;/* Extent size in blocks for
						    max default clustering */
	vx_u32_t	tf_qio_cache;		/* enable read caching on
						   quick I/O files */
	vx_u32_t	tf_max_buf_data_size;	/* Buffer cache buffer size
						 *  for data. Valid only on
						 *  certain platforms.
						 */
};

/*
 * Parameter structure for VX_CVIEW ioctl.
 */

struct vx_cviewctl {
	vx_u32_t	cv_cmd;
	char		*cv_fsetname;
	char		*cv_mntpath;
};

#define	VX_CVIEW_SET	1
#define	VX_CVIEW_CLEAR	2

#ifdef	_KERNEL

struct vx_aioctl_info {
	vx_u32_t	aii_cmd;		/* ioctl identifier */
	int		(*aii_func) __P((struct vx_aioctl_info *,
					 struct vnode *, struct vx_genioctl *,
					 int, vx_rval_t *, vx_cred_t *));
						/* function to call */
	vx_u32_t	aii_rootino;		/* restrict to root inode */
	vx_u32_t	aii_clone_license;	/* clone license required */
	vx_u32_t	aii_full_license;	/* full license required */
	vx_u32_t	aii_may_freeze;		/* might have to freeze fs */
};

#endif	/* _KERNEL */

#endif /* _FS_VXFS_VX_ADMIN_H */
