/* @(#)src/common/cmd/vxfs/include/vxfsutil.h	3.1.59.1 09/09/03 18:39:38 */
/* #ident "@(#)vxfs:src/common/cmd/vxfs/include/vxfsutil.h	3.1.59.1" */

/*
 * (c) Copyright 1991-2004 VERITAS Software Corporation. All rights reserved.
 */

#ifndef	_VXFSUTIL_H
#define	_VXFSUTIL_H

#ifndef STATIC
#define STATIC	static
#endif

#define	NAMELEN		256

#define MNT_LOCAL		0x01
#define MNT_PRIMARY		0x02
#define MNT_SECONDARY		0x04

/*
 * Fields within vx_inode which can be externally visible
 */

struct vx_ioffsets {
	unsigned int	ioff_dev;	/* offset of i_dev within vx_inode */
	unsigned int	ioff_dev_sz;	/* size of i_dev field in bytes */
	unsigned int	ioff_number;	/* offset of i_number within vx_inode */
	unsigned int	ioff_number_sz;	/* size of i_number field in bytes */
	unsigned int	ioff_nlink;	/* offset of i_nlink within vx_inode */
	unsigned int	ioff_nlink_sz;	/* size of i_nlink field in bytes */
	unsigned int	ioff_size;	/* offset of i_size within vx_inode */
	unsigned int	ioff_size_sz;	/* size of i_size field in bytes */
};

struct vxfsu_bc_counters {
	uint64_t	vxi_bawrite;		/*vx_bawrite called */
	uint64_t	vxi_bcache_curkbyte;	/* vxfs bcache cur memory */
	uint64_t	vxi_bcache_maxkbyte;	/* vxfs bcache max memory */
	uint64_t	vxi_bcache_recycleage;	/* avg. age of recycled buf */
	uint64_t	vxi_bc_chunksteal;	/* number of chunks reused */
	uint64_t	vxi_bc_hits;		/* vxfs buffer cache hits */
	uint64_t	vxi_bc_lookups;		/* vxfs buffer cache lookup*/
	uint64_t	vxi_bc_reuse;		/* count of buffer reuse */
	uint64_t	vxi_bc_subflush;	/* internal bcache flushing */
	uint64_t	vxi_bc_waits;		/* wait for buffer lock */
	uint64_t	vxi_bdwrite;		/* vx_bdwrite called */
	uint64_t	vxi_bdwrite_tflush;	/* tranflush on
							vx_bdwrite call */
	uint64_t	vxi_bread;		/* vx_breada called */
	uint64_t	vxi_brelse;		/* vx_brelse called */
	uint64_t	vxi_brelse_tflush;	/* tranflush on vx_brelse call*/
	uint64_t	vxi_bwrite;		/* vx_bwrite called */
};

struct vxfsu_dnlc_counters {
	uint64_t	vxi_dnlc_hit;		/* +ve hit in the dnlc */
	uint64_t	vxi_dnlc_enter;		/* +ve enter in the dnlc */
	uint64_t	vxi_dnlc_miss;		/* miss in the dnlc */
	uint64_t	vxi_dnlc_neg_hit;	/* -ve hit in the dnlc */
	uint64_t	vxi_dnlc_neg_enter;	/* -ve enter in the dnlc */
	uint64_t	vxi_dnlc_size;		/* number of entries in dnlc */
};

typedef struct vx_cfs_mountinfo {
	unsigned int	cmi_type;	/* LOCAL | PRIMARY | SECONDARY */
	unsigned int	cmi_pri_node;	/* nodeid of primary */
	char	cmi_nodename[NAMELEN];
} vx_cfs_mountinfo_t;

#define FSAP_NAMESZ	64
#define FSAP_MAXDEVS	256
#define FSDEV_NAMESZ	32

struct fsap_info {
	char		ap_name[FSAP_NAMESZ];
	uint32_t	ap_flags;
	uint32_t	ap_order;
	uint32_t	ap_ndevs;
	char		ap_devs[FSAP_MAXDEVS][FSDEV_NAMESZ];
};

/*
 * Policy flags.
 */

#define FSAP_ORDER_ASGIVEN	0x0000	/* in the order given */
#define FSAP_ORDER_LEASTFULL	0x0001	/* use least full (by blocks) first */
#define FSAP_ORDER_ROUNDROBIN	0x0002	/* round-robin (roughly) */

/*
 * Policy define operation flags (vxfs_ap_define argument).
 */

#define FSAP_CREATE		0x0001	/* create policy if it does not exist */
#define FSAP_UNSPECIFIED	0

/*
 * Policy definition flag (ap_flags).
 */

#define FSAP_ANYUSER		0x0001	/* any user can assign policy */

/*
 * Per file policy assignment flag (vxfs_ap_assign_file argument).
 */

#define FSAP_INHERIT		0x0001	/* policy is inherited */

struct fsdev_info {
	int		dev_id;
	uint64_t	dev_size;
	uint64_t	dev_free;
	uint64_t	dev_avail;
	char		dev_name[FSDEV_NAMESZ];
};

extern int vxfs_vol_add(int, char *, uint64_t);
extern int vxfs_vol_remove(int, char *);
extern int vxfs_vol_resize(int, char *, uint64_t);
extern int vxfs_vol_stat(int, char *, struct fsdev_info *);
extern int vxfs_vol_enumerate(int, int *, struct fsdev_info *);
extern int vxfs_vol_encapsulate(char *, char *, uint64_t);
extern int vxfs_vol_deencapsulate(char *);

extern int vxfs_ap_define(int, struct fsap_info *, uint32_t);
extern int vxfs_ap_remove(int, char *);
extern int vxfs_ap_query(int, struct fsap_info *);
extern int vxfs_ap_query_file(int, char *, char *, uint32_t *);
extern int vxfs_ap_assign_file(int, char *, char *, uint32_t);
extern int vxfs_ap_query_ckpt(int, char *, char *, char *);
extern int vxfs_ap_assign_ckpt(int, char *, char *, char *);
extern int vxfs_ap_query_fs(int, char *, char *);
extern int vxfs_ap_assign_fs(int, char *, char *);
extern int vxfs_ap_enforce_file(int, char *, char *);
extern int vxfs_ap_enumerate(int, int *, struct fsap_info *);

extern int vxfs_nattr_open(int, char *, int, int);
extern int vxfs_nattr_unlink(int, char *);
extern int vxfs_nattr_link(int, char *, char *);
extern int vxfs_nattr_rename(int, char *, char *);
extern int vxfs_nattr_utimes(int, char *, struct timeval *);

extern int vxfs_fcl_sync(char *, uint64_t *);
extern int vxfs_inotopath(char *, uint64_t, int, char ***, int *);
extern int vxfs_get_mntinfo(struct vx_cfs_mountinfo *, size_t, char *);
extern int vxfs_get_ioffsets(struct vx_ioffsets *, size_t);

extern int vxfsu_get_ioffsets(struct vx_ioffsets *, size_t);
extern int vxfsu_get_ioffsets(struct vx_ioffsets *, size_t);
extern int vxfsu_get_bc_counters(struct vxfsu_bc_counters *, size_t);
extern int vxfsu_get_dnlc_counters(struct vxfsu_dnlc_counters *, size_t);

#endif /* _VXFSUTIL_H */
