Exemplo n.º 1
0
void *Thread(void *parm)
{
	int rc;
	size_t dmMsgBufLen;
	dm_eventmsg_t *dmMsg;
	int bMounted = DM_FALSE;
	dm_eventtype_t type;
	dm_token_t token;
	dm_eventset_t events;
	dm_response_t response;

	do {
		/* Loop until message received (wait could be interrupted) */
		do {
			DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
			dmMsgBufLen = 0;

			rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf), dmMsgBuf, &dmMsgBufLen);
			DMLOG_PRINT(DMLVL_DEBUG, "... dm_get_events returned %d (errno %d)\n", rc, errno);
		} while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));

		if (rc) {
			DMLOG_PRINT(DMLVL_ERR, "dm_get_events failed with rc = %d, errno = %d\n", rc, errno);
			dm_destroy_session(sid);
			DM_EXIT();
		} else {
			dmMsg = (dm_eventmsg_t *)dmMsgBuf;
			token = dmMsg->ev_token;
			type = dmMsg->ev_type;

			DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
		}

		if (type == DM_EVENT_MOUNT) {
			/* SPECIAL CASE: need to set disposition, events and response */
			dm_mount_event_t *me = DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
			void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
			size_t lhlen = DM_GET_LEN(me, me_handle1);

			DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
			DMLOG_PRINT(DMLVL_DEBUG, "  Mode: %x\n", me->me_mode);
			DMLOG_PRINT(DMLVL_DEBUG, "  File system handle: %p\n", lhanp);
			DMLOG_PRINT(DMLVL_DEBUG, "  File system handle length: %d\n", lhlen);
			DMLOG_PRINT(DMLVL_DEBUG, "  Mountpoint handle: %p\n", DM_GET_VALUE(me, me_handle2, void *));
			DMLOG_PRINT(DMLVL_DEBUG, "  Mountpoint handle length: %d\n", DM_GET_LEN(me, me_handle2));
			DMLOG_PRINT(DMLVL_DEBUG, "  Mountpoint path: %s\n", DM_GET_VALUE(me, me_name1, char *));
			DMLOG_PRINT(DMLVL_DEBUG, "  Media designator: %s\n", DM_GET_VALUE(me, me_name2, char *));
			DMLOG_PRINT(DMLVL_DEBUG, "  Root handle: %p\n", DM_GET_VALUE(me, me_roothandle, void *));
			DMLOG_PRINT(DMLVL_DEBUG, "  Root handle length: %d\n", DM_GET_LEN(me, me_roothandle));
	   
    			bMounted = dm_handle_is_valid(lhanp, lhlen);

    			rc = dm_request_right(sid, lhanp, lhlen, token, DM_RR_WAIT, DM_RIGHT_EXCL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
				dm_destroy_session(sid);
				DM_EXIT();
			}

			DMEV_ZERO(events);
			DMEV_SET(DM_EVENT_PREUNMOUNT, events);
			DMEV_SET(DM_EVENT_UNMOUNT, events);
			DMEV_SET(DM_EVENT_READ, events);
			DMEV_SET(DM_EVENT_WRITE, events);
			rc = dm_set_disp(sid, lhanp, lhlen, token, &events, DM_EVENT_MAX);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "dm_set_disp failed! (rc = %d, errno = %d)\n", rc, errno);
				dm_destroy_session(sid);
				DM_EXIT();
			}

			DMEV_ZERO(events);
			DMEV_SET(DM_EVENT_PREUNMOUNT, events);
			DMEV_SET(DM_EVENT_UNMOUNT, events);
			rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events, DM_EVENT_MAX);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "dm_set_eventlist failed! (rc = %d, errno = %d)\n", rc, errno);
				dm_destroy_session(sid);
				DM_EXIT();
			}

    			rc = dm_release_right(sid, lhanp, lhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
				dm_destroy_session(sid);
				DM_EXIT();
			}

			response = DM_RESP_CONTINUE;
		} else if (type == DM_EVENT_UNMOUNT) {
			dm_namesp_event_t *nse = DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
			if (nse->ne_retcode == 0) {
				bMounted = DM_FALSE;
			}

			response = DM_RESP_CONTINUE;
		} else {
Exemplo n.º 2
0
int
main(
	int	argc,
	char	**argv)
{
	dm_sessid_t	sid, oldsid, targetsid, *newsidp, *sidbufp;
	dm_token_t	token, *tokenp, *rtokenp, *tokenbufp;
	dm_attrname_t	*attrnamep;
	dm_off_t	off, *offp, *roffp;
	dm_extent_t	*extentp;
	dm_inherit_t	*inheritbufp;
	dm_stat_t	*statp;
	dm_size_t	len, *dmrlenp, *retvalp;
	dm_attrloc_t	*locp;
	dm_eventset_t	*eventsetp;
	dm_config_t	flagname;
	dm_region_t	*regbufp;
	dm_response_t	response;
	dm_right_t	right, *rightp;
	dm_igen_t	igen, *igenp;
	dm_msgtype_t	msgtype;
	dm_fileattr_t	*attrp;
	dm_boolean_t	enable, *exactflagp;
	dm_timestruct_t	*delay;
	mode_t		mode;
	size_t		hlen, dirhlen, hlen1, hlen2, targhlen, *fshlenp, *hlenp;
	size_t		msglen, buflen, *rlenp;
	u_int		nelem, mask, maxmsgs, uflags, *nelemp, maxevent;
	void		*hanp, *dirhanp, *hanp1, *hanp2, *targhanp;
	void		*msgdatap, *bufp, **hanpp, *respbufp, **fshanpp;
	dm_fsid_t	fsid, *fsidp;
	dm_ino_t	ino, *inop;
	char		*cname, *sessinfop, *path, *pathbufp, **versionstrpp;
	int		flags, fd, setdtime, reterror;
	u_int	urc;
	int	rc;
	dm_ssize_t	ssrc;

/* Definitions per the prototypes in dmport.h, in the same order. */

	rc = dm_clear_inherit(sid, hanp, hlen, token, attrnamep);
	rc = dm_create_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname);
	rc = dm_create_session(oldsid, sessinfop, newsidp);
	rc = dm_create_userevent(sid, msglen, msgdatap, tokenp);
	rc = dm_destroy_session(sid);
	rc = dm_downgrade_right(sid, hanp, hlen, token);
	rc = dm_fd_to_handle(fd, hanpp, hlenp);
	rc = dm_find_eventmsg(sid, token, buflen, bufp, rlenp);
	rc = dm_get_allocinfo(sid, hanp, hlen,
		token, offp, nelem, extentp, nelemp);
	rc = dm_get_bulkall(sid, hanp, hlen, token, mask, attrnamep,
		locp, buflen, bufp, rlenp);
	rc = dm_get_bulkattr(sid, hanp, hlen, token, mask, locp, buflen, 
		bufp, rlenp);
	rc = dm_get_config(hanp, hlen, flagname, retvalp);
	rc = dm_get_config_events(hanp, hlen, nelem, eventsetp, nelemp);
	rc = dm_get_dirattrs(sid, hanp, hlen, token, mask, locp, buflen,
		bufp, rlenp);
	rc = dm_get_dmattr(sid, hanp, hlen, token, attrnamep, buflen,
		bufp, rlenp);
	rc = dm_get_eventlist(sid, hanp, hlen, token, nelem, eventsetp, nelemp);
	rc = dm_get_events(sid, maxmsgs, flags, buflen, bufp, rlenp);
	rc = dm_get_fileattr(sid, hanp, hlen, token, mask, statp);
	rc = dm_get_mountinfo(sid, hanp, hlen, token, buflen, bufp, rlenp);
	rc = dm_get_region(sid, hanp, hlen, token, nelem, regbufp, nelemp);
	rc = dm_getall_disp(sid, buflen, bufp, rlenp);
	rc = dm_getall_dmattr(sid, hanp, hlen, token, buflen, bufp, rlenp);
	rc = dm_getall_inherit(sid, hanp, hlen,
		token, nelem, inheritbufp, nelemp);
	rc = dm_getall_sessions(nelem, sidbufp, nelemp);
	rc = dm_getall_tokens(sid, nelem, tokenbufp, nelemp);
	rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
	dm_handle_free(hanp, hlen);
	urc = dm_handle_hash(hanp, hlen);
	rc = dm_handle_is_valid(hanp, hlen);
	rc = dm_handle_to_fshandle(hanp, hlen, fshanpp, fshlenp);
	rc = dm_handle_to_fsid(hanp, hlen, fsidp);
	rc = dm_handle_to_igen(hanp, hlen, igenp);
	rc = dm_handle_to_ino(hanp, hlen, inop);
	rc = dm_handle_to_path(dirhanp, dirhlen, targhanp, targhlen, 
		buflen, pathbufp, rlenp);
	rc = dm_init_attrloc(sid, hanp, hlen, token, locp);
	rc = dm_init_service(versionstrpp);
	rc = dm_make_handle(&fsid, &ino, &igen, hanpp, hlenp);
	rc = dm_make_fshandle(&fsid, hanpp, hlenp);
	rc = dm_mkdir_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname); 
	rc = dm_move_event(sid, token, targetsid, rtokenp);
	rc = dm_obj_ref_hold(sid, token, hanp, hlen);
	rc = dm_obj_ref_query(sid, token, hanp, hlen);
	rc = dm_obj_ref_rele(sid, token, hanp, hlen);
	rc = dm_path_to_fshandle(path, hanpp, hlenp);
	rc = dm_path_to_handle(path, hanpp, hlenp);
	rc = dm_pending(sid, token, delay);
	rc = dm_probe_hole(sid, hanp, hlen, token, off, len, roffp, dmrlenp);
	rc = dm_punch_hole(sid, hanp, hlen, token, off, len);
	rc = dm_query_right(sid, hanp, hlen, token, rightp);
	rc = dm_query_session(sid, buflen, bufp, rlenp);
	ssrc = dm_read_invis(sid, hanp, hlen, token, off, len, bufp);
	rc =  dm_release_right(sid, hanp, hlen, token);
	rc = dm_remove_dmattr(sid, hanp, hlen, token, setdtime, attrnamep);
	rc = dm_request_right(sid, hanp, hlen, token, uflags, right);
	rc = dm_respond_event(sid, token, response, reterror, buflen, respbufp);
	rc = dm_send_msg(sid, msgtype, buflen, bufp);
	rc = dm_set_disp(sid, hanp, hlen, token, eventsetp, maxevent);
	rc = dm_set_dmattr(sid, hanp, hlen,
		token, attrnamep, setdtime, buflen, bufp);
	rc = dm_set_eventlist(sid, hanp, hlen, token, eventsetp, maxevent);
	rc = dm_set_fileattr(sid, hanp, hlen, token, mask, attrp);
	rc = dm_set_inherit(sid, hanp, hlen, token, attrnamep, mode);
	rc = dm_set_region(sid, hanp, hlen, token, nelem, regbufp, exactflagp);
	rc = dm_set_return_on_destroy(sid, hanp, hlen,
		token,  attrnamep, enable);
	rc = dm_symlink_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname, path); 
	rc = dm_sync_by_handle(sid, hanp, hlen, token);
	rc = dm_upgrade_right(sid, hanp, hlen, token);
	ssrc = dm_write_invis(sid, hanp, hlen, flags, token, off, len, bufp);
	exit(0);
}
Exemplo n.º 3
0
static int
dmapi_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
	    unsigned long arg)
{
	sys_dmapi_args_t kargs;
	sys_dmapi_args_t *uap = &kargs;
	int error = 0;
	int rvp = -ENOSYS;
	int use_rvp = 0;

	if (!capable(CAP_MKNOD))
		return(-EPERM);

	if( copy_from_user( &kargs, (sys_dmapi_args_t*)arg,
			   sizeof(sys_dmapi_args_t) ) )
		return -EFAULT;

	switch (cmd) {
	case DM_CLEAR_INHERIT:
		error = dm_clear_inherit(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrname_t *) uap->arg5);	/* attrnamep */
		break;
	case DM_CREATE_BY_HANDLE:
		error = dm_create_by_handle(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* dirhanp */
				(size_t)	uap->arg3,	/* dirhlen */
				(dm_token_t)	uap->arg4,	/* token */
				(void *)	uap->arg5,	/* hanp */
				(size_t)	uap->arg6,	/* hlen */
				(char *)	uap->arg7);	/* cname */
		break;
	case DM_CREATE_SESSION:
		error = dm_create_session(
				(dm_sessid_t)	uap->arg1,	/* oldsid */
				(char *)	uap->arg2,	/* sessinfop */
				(dm_sessid_t *)	uap->arg3);	/* newsidp */
		break;
	case DM_CREATE_USEREVENT:
		error = dm_create_userevent(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(size_t)	uap->arg2,	/* msglen */
				(void *)	uap->arg3,	/* msgdatap */
				(dm_token_t *)	uap->arg4);	/* tokenp */
		break;
	case DM_DESTROY_SESSION:
		error = dm_destroy_session(
				(dm_sessid_t)	uap->arg1);	/* sid */
		break;
	case DM_DOWNGRADE_RIGHT:
		error = dm_downgrade_right(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4);	/* token */
		break;
	case DM_FD_TO_HANDLE:
		error = dm_fd_to_hdl(
				(int)		uap->arg1,	/* fd */
				(void *)	uap->arg2,	/* hanp */
				(size_t *)	uap->arg3);	/* hlenp */
		break;
	case DM_FIND_EVENTMSG:
		error = dm_find_eventmsg(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(size_t)	uap->arg3,	/* buflen */
				(void *)	uap->arg4,	/* bufp */
				(size_t *)	uap->arg5);	/* rlenp */
		break;
	case DM_GET_ALLOCINFO:
		use_rvp = 1;
		error = dm_get_allocinfo_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_off_t *)	uap->arg5,	/* offp */
				(u_int)		uap->arg6,	/* nelem */
				(dm_extent_t *)	uap->arg7,	/* extentp */
				(u_int *)	uap->arg8,	/* nelemp */
						&rvp);
		break;
	case DM_GET_BULKALL:
		use_rvp = 1;
		error = dm_get_bulkall_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* mask */
				(dm_attrname_t *) uap->arg6,	/* attrnamep */
				(dm_attrloc_t *) uap->arg7,	/* locp */
				(size_t)	uap->arg8,	/* buflen */
				(void *)	uap->arg9,	/* bufp */
				(size_t *)	uap->arg10,	/* rlenp */
						&rvp);
		break;
	case DM_GET_BULKATTR:
		use_rvp = 1;
		error = dm_get_bulkattr_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* mask */
				(dm_attrloc_t *)uap->arg6,	/* locp */
				(size_t)	uap->arg7,	/* buflen */
				(void *)	uap->arg8,	/* bufp */
				(size_t *)	uap->arg9,	/* rlenp */
						&rvp);
		break;
	case DM_GET_CONFIG:
		error = dm_get_config(
				(void *)	uap->arg1,	/* hanp */
				(size_t)	uap->arg2,	/* hlen */
				(dm_config_t)	uap->arg3,	/* flagname */
				(dm_size_t *)	uap->arg4);	/* retvalp */
		break;
	case DM_GET_CONFIG_EVENTS:
		error = dm_get_config_events(
				(void *)	uap->arg1,	/* hanp */
				(size_t)	uap->arg2,	/* hlen */
				(u_int)		uap->arg3,	/* nelem */
				(dm_eventset_t *) uap->arg4,	/* eventsetp */
				(u_int *)	uap->arg5);	/* nelemp */
		break;
	case DM_GET_DIOINFO:
		error = dm_get_dioinfo(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_dioinfo_t *)uap->arg5);	/* diop */
		break;
	case DM_GET_DIRATTRS:
		use_rvp = 1;
		error = dm_get_dirattrs_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* mask */
				(dm_attrloc_t *)uap->arg6,	/* locp */
				(size_t)	uap->arg7,	/* buflen */
				(void *)	uap->arg8,	/* bufp */
				(size_t *)	uap->arg9,	/* rlenp */
						&rvp);
		break;
	case DM_GET_DMATTR:
		error = dm_get_dmattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrname_t *) uap->arg5,	/* attrnamep */
				(size_t)	uap->arg6,	/* buflen */
				(void *)	uap->arg7,	/* bufp */
				(size_t *)	uap->arg8);	/* rlenp */

		break;
	case DM_GET_EVENTLIST:
		error = dm_get_eventlist(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* nelem */
				(dm_eventset_t *) uap->arg6,	/* eventsetp */
				(u_int *)	uap->arg7);	/* nelemp */
		break;
	case DM_GET_EVENTS:
		error = dm_get_events(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(u_int)		uap->arg2,	/* maxmsgs */
				(u_int)		uap->arg3,	/* flags */
				(size_t)	uap->arg4,	/* buflen */
				(void *)	uap->arg5,	/* bufp */
				(size_t *)	uap->arg6);	/* rlenp */
		break;
	case DM_GET_FILEATTR:
		error = dm_get_fileattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* mask */
				(dm_stat_t *)	uap->arg6);	/* statp */
		break;
	case DM_GET_MOUNTINFO:
		error = dm_get_mountinfo(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(size_t)	uap->arg5,	/* buflen */
				(void *)	uap->arg6,	/* bufp */
				(size_t *)	uap->arg7);	/* rlenp */
		break;
	case DM_GET_REGION:
		error = dm_get_region(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* nelem */
				(dm_region_t *)	uap->arg6,	/* regbufp */
				(u_int *)	uap->arg7);	/* nelemp */
		break;
	case DM_GETALL_DISP:
		error = dm_getall_disp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(size_t)	uap->arg2,	/* buflen */
				(void *)	uap->arg3,	/* bufp */
				(size_t *)	uap->arg4);	/* rlenp */
		break;
	case DM_GETALL_DMATTR:
		error = dm_getall_dmattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(size_t)	uap->arg5,	/* buflen */
				(void *)	uap->arg6,	/* bufp */
				(size_t *)	uap->arg7);	/* rlenp */
		break;
	case DM_GETALL_INHERIT:
		error = dm_getall_inherit(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* nelem */
				(dm_inherit_t *)uap->arg6,	/* inheritbufp*/
				(u_int *)	uap->arg7);	/* nelemp */
		break;
	case DM_GETALL_SESSIONS:
		error = dm_getall_sessions(
				(u_int)		uap->arg1,	/* nelem */
				(dm_sessid_t *)	uap->arg2,	/* sidbufp */
				(u_int *)	uap->arg3);	/* nelemp */
		break;
	case DM_GETALL_TOKENS:
		error = dm_getall_tokens(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(u_int)		uap->arg2,	/* nelem */
				(dm_token_t *)	uap->arg3,	/* tokenbufp */
				(u_int *)	uap->arg4);	/* nelemp */
		break;
	case DM_INIT_ATTRLOC:
		error = dm_init_attrloc(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrloc_t *) uap->arg5);	/* locp */
		break;
	case DM_MKDIR_BY_HANDLE:
		error = dm_mkdir_by_handle(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* dirhanp */
				(size_t)	uap->arg3,	/* dirhlen */
				(dm_token_t)	uap->arg4,	/* token */
				(void *)	uap->arg5,	/* hanp */
				(size_t)	uap->arg6,	/* hlen */
				(char *)	uap->arg7);	/* cname */
		break;
	case DM_MOVE_EVENT:
		error = dm_move_event(
				(dm_sessid_t)	uap->arg1,	/* srcsid */
				(dm_token_t)	uap->arg2,	/* token */
				(dm_sessid_t)	uap->arg3,	/* targetsid */
				(dm_token_t *)	uap->arg4);	/* rtokenp */
		break;
	case DM_OBJ_REF_HOLD:
		error = dm_obj_ref_hold(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(void *)	uap->arg3,	/* hanp */
				(size_t)	uap->arg4);	/* hlen */
		break;
	case DM_OBJ_REF_QUERY:
		use_rvp = 1;
		error = dm_obj_ref_query_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(void *)	uap->arg3,	/* hanp */
				(size_t)	uap->arg4,	/* hlen */
						&rvp);
		break;
	case DM_OBJ_REF_RELE:
		error = dm_obj_ref_rele(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(void *)	uap->arg3,	/* hanp */
				(size_t)	uap->arg4);	/* hlen */
		break;
	case DM_PATH_TO_FSHANDLE:
		error = dm_path_to_fshdl(
				(char *)	uap->arg1,	/* path */
				(void *)	uap->arg2,	/* hanp */
				(size_t *)	uap->arg3);	/* hlenp */
		break;
	case DM_PATH_TO_HANDLE:
		error = dm_path_to_hdl(
				(char *)	uap->arg1,	/* path */
				(void *)	uap->arg2,	/* hanp */
				(size_t *)	uap->arg3);	/* hlenp */
		break;
	case DM_PENDING:
		error = dm_pending(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(dm_timestruct_t *) uap->arg3);	/* delay */
		break;
	case DM_PROBE_HOLE:
		error = dm_probe_hole(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_off_t)	uap->arg5,	/* off */
				(dm_size_t)	uap->arg6,	/* len */
				(dm_off_t *)	uap->arg7,	/* roffp */
				(dm_size_t *)	uap->arg8);	/* rlenp */
		break;
	case DM_PUNCH_HOLE:
		error = dm_punch_hole(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_off_t)	uap->arg5,	/* off */
				(dm_size_t)	uap->arg6);	/* len */
		break;
	case DM_QUERY_RIGHT:
		error = dm_query_right(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_right_t *)	uap->arg5);	/* rightp */
		break;
	case DM_QUERY_SESSION:
		error = dm_query_session(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(size_t)	uap->arg2,	/* buflen */
				(void *)	uap->arg3,	/* bufp */
				(size_t *)	uap->arg4);	/* rlenp */
		break;
	case DM_READ_INVIS:
		use_rvp = 1;
		error = dm_read_invis_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_off_t)	uap->arg5,	/* off */
				(dm_size_t)	uap->arg6,	/* len */
				(void *)	uap->arg7,	/* bufp */
						&rvp);
		break;
	case DM_RELEASE_RIGHT:
		error = dm_release_right(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4);	/* token */
		break;
	case DM_REMOVE_DMATTR:
		error = dm_remove_dmattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(int)		uap->arg5,	/* setdtime */
				(dm_attrname_t *) uap->arg6);	/* attrnamep */
		break;
	case DM_REQUEST_RIGHT:
		error = dm_request_right(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* flags */
				(dm_right_t)	uap->arg6);	/* right */
		break;
	case DM_RESPOND_EVENT:
		error = dm_respond_event(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(dm_token_t)	uap->arg2,	/* token */
				(dm_response_t)	uap->arg3,	/* response */
				(int)		uap->arg4,	/* reterror */
				(size_t)	uap->arg5,	/* buflen */
				(void *)	uap->arg6);	/* respbufp */
		break;
	case DM_SEND_MSG:
		error = dm_send_msg(
				(dm_sessid_t)	uap->arg1,	/* targetsid */
				(dm_msgtype_t)	uap->arg2,	/* msgtype */
				(size_t)	uap->arg3,	/* buflen */
				(void *)	uap->arg4);	/* bufp */
		break;
	case DM_SET_DISP:
		error = dm_set_disp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_eventset_t *) uap->arg5,	/* eventsetp */
				(u_int)		uap->arg6);	/* maxevent */
		break;
	case DM_SET_DMATTR:
		error = dm_set_dmattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrname_t *) uap->arg5,	/* attrnamep */
				(int)		uap->arg6,	/* setdtime */
				(size_t)	uap->arg7,	/* buflen */
				(void *)	uap->arg8);	/* bufp */
		break;
	case DM_SET_EVENTLIST:
		error = dm_set_eventlist(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_eventset_t *) uap->arg5,	/* eventsetp */
				(u_int)		uap->arg6);	/* maxevent */
		break;
	case DM_SET_FILEATTR:
		error = dm_set_fileattr(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* mask */
				(dm_fileattr_t *)uap->arg6);	/* attrp */
		break;
	case DM_SET_INHERIT:
		error = dm_set_inherit(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrname_t *)uap->arg5,	/* attrnamep */
				(mode_t)	uap->arg6);	/* mode */
		break;
	case DM_SET_REGION:
		error = dm_set_region(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(u_int)		uap->arg5,	/* nelem */
				(dm_region_t *)	uap->arg6,	/* regbufp */
				(dm_boolean_t *) uap->arg7);	/* exactflagp */
		break;
	case DM_SET_RETURN_ON_DESTROY:
		error = dm_set_return_on_destroy(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(dm_attrname_t *) uap->arg5,	/* attrnamep */
				(dm_boolean_t)	uap->arg6);	/* enable */
		break;
	case DM_SYMLINK_BY_HANDLE:
		error = dm_symlink_by_handle(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* dirhanp */
				(size_t)	uap->arg3,	/* dirhlen */
				(dm_token_t)	uap->arg4,	/* token */
				(void *)	uap->arg5,	/* hanp */
				(size_t)	uap->arg6,	/* hlen */
				(char *)	uap->arg7,	/* cname */
				(char *)	uap->arg8);	/* path */
		break;
	case DM_SYNC_BY_HANDLE:
		error = dm_sync_by_handle(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4);	/* token */
		break;
	case DM_UPGRADE_RIGHT:
		error = dm_upgrade_right(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4);	/* token */
		break;
	case DM_WRITE_INVIS:
		use_rvp = 1;
		error = dm_write_invis_rvp(
				(dm_sessid_t)	uap->arg1,	/* sid */
				(void *)	uap->arg2,	/* hanp */
				(size_t)	uap->arg3,	/* hlen */
				(dm_token_t)	uap->arg4,	/* token */
				(int)		uap->arg5,	/* flags */
				(dm_off_t)	uap->arg6,	/* off */
				(dm_size_t)	uap->arg7,	/* len */
				(void *)	uap->arg8,	/* bufp */
						&rvp);
		break;
	default:
		error = ENOSYS;
		break;
	}
	/* If it was an *_rvp() function, then
		if error==0, return |rvp|
	*/
	if( use_rvp && (error == 0) )
		return rvp;
	else
		return -error;
}
Exemplo n.º 4
0
void DoTest(dm_token_t token, void *hanp, size_t hlen)
{

	char *szFuncName;
	int   rc;

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI rights tests\n") ;

	szFuncName = "dm_request_right";

	/*
	 * TEST    : dm_request_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_request_right(INVALID_ADDR, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_request_right(sid, (void *)INVALID_ADDR, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_request_right(sid, hanp, INVALID_ADDR, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, INVALID_ADDR, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid right
	 * EXPECTED: rc = -1, errno = EINVAL
	 *
	 * This variation uncovered XFS BUG #29 (0 returned instead of -1 and
	 * errno EINVAL)
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid right)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 6)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, DM_NO_TOKEN, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_NULL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 7)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL -> DM_RIGHT_SHARED)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_release_right(sid, hanp, hlen, token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_NULL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 8)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL -> DM_RIGHT_EXCL)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_release_right(sid, hanp, hlen, token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
	 *		DM_RR_WAIT clear
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 10)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT clear)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
	 *		DM_RR_WAIT set
	 * EXPECTED: rc = -1, errno = EACCES
	 *
	 * This variation uncovered XFS BUG #30 (0 returned instead of -1 and
	 * errno EACCES)
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 11)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT set)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, DM_RR_WAIT, DM_RIGHT_EXCL);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 12)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL -> DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 13)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL -> DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 14)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_request_right(DM_NO_SESSION, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 15)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_request_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 16)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_request_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 17)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_release_right";

	/*
	 * TEST    : dm_release_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_release_right(INVALID_ADDR, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_release_right(sid, (void *)INVALID_ADDR, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_release_right(sid, hanp, INVALID_ADDR, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, DM_NO_TOKEN);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EACCES
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 6)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_release_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_release_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_release_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 9)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_release_right(DM_NO_SESSION, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 10)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_release_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 11)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc == dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_release_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_release_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 12)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc == dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_release_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_query_right";

	/*
	 * TEST    : dm_query_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 1)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_query_right(INVALID_ADDR, hanp, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 2)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_query_right(sid, (void *)INVALID_ADDR, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 3)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_query_right(sid, hanp, INVALID_ADDR, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 4)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, INVALID_ADDR, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid rightp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rightp)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, token, (dm_right_t *)INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 6)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, DM_NO_TOKEN, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 7)) {
		dm_right_t right;

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_query_right(sid, hanp, hlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 8)) {
		dm_right_t right;

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_query_right(sid, hanp, hlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_EXCL) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_EXCL);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 9)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_query_right(DM_NO_SESSION, hanp, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 10)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_query_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 11)) {
		void *fhanp;
		size_t fhlen;
		dm_right_t right;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_query_right(sid, fhanp, fhlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_query_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 12)) {
		void *fshanp;
		size_t fshlen;
		dm_right_t right;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_query_right(sid, fshanp, fshlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_upgrade_right";

	/*
	 * TEST    : dm_upgrade_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 1)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_upgrade_right(INVALID_ADDR, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 2)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_upgrade_right(sid, (void *)INVALID_ADDR, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 3)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, INVALID_ADDR, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 4)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EPERM
	 *
	 * This variation uncovered XFS BUG #31 (EACCES returned instead of
	 * EPERM)
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_upgrade_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 6)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_upgrade_right(DM_NO_SESSION, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 10)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_upgrade_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 11)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_downgrade_right";

	/*
	 * TEST    : dm_downgrade_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 1)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_downgrade_right(INVALID_ADDR, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 2)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_downgrade_right(sid, (void *)INVALID_ADDR, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 3)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, INVALID_ADDR, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 4)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EPERM
	 *
	 * This variation uncovered XFS BUG #32 (EACCES returned instead of
	 * EPERM)
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_downgrade_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = -1, errno = EPERM
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 6)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_downgrade_right(DM_NO_SESSION, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_downgrade_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 10)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_EXCL)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_downgrade_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_downgrade_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 11)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_EXCL)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_downgrade_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

}