Example #1
0
int
check_set_lock(
	int		amode,	/* R_OK | W_OK */
	md_setkey_t	*cl_sk,	/* clients idea of set locked */
	md_error_t	*ep	/* returned status */
)
{
	md_setkey_t	*svc_sk;

	if (cl_sk == NULL)
		return (0);

	svc_sk = svc_get_setkey(cl_sk->sk_setno);

	/* The set is not locked */
	if (svc_sk == NULL) {
		if ((amode & W_OK) == W_OK) {
			(void) mddserror(ep, MDE_DS_WRITEWITHSULK,
			    cl_sk->sk_setno, mynode(), NULL, cl_sk->sk_setname);
			return (1);
		}
		return (0);
	}

	/* The set is locked, do we have the key? */
	if (cl_sk->sk_key.tv_sec == svc_sk->sk_key.tv_sec &&
	    cl_sk->sk_key.tv_usec == svc_sk->sk_key.tv_usec)
		return (0);

	(void) mddserror(ep, MDE_DS_SETLOCKED, MD_SET_BAD, mynode(),
	    svc_sk->sk_host, svc_sk->sk_setname);

	return (1);
}
Example #2
0
int
meta_check_driveinset(mdsetname_t *sp, mddrivename_t *dn, md_error_t *ep)
{
	set_t		setno;
	set_t		max_sets;

	if ((max_sets = get_max_sets(ep)) == 0)
		return (-1);

	for (setno = 1; setno < max_sets; setno++) {
		mdsetname_t	*sp1;
		int		is_it;

		if (setno == sp->setno)
			continue;

		if ((sp1 = metasetnosetname(setno, ep)) == NULL) {
			if (mdismddberror(ep, MDE_DB_NODB)) {
				mdclrerror(ep);
				return (0);
			}
			if (mdiserror(ep, MDE_NO_SET)) {
				mdclrerror(ep);
				continue;
			}
			return (-1);
		}

		metaflushsetname(sp1);

		if ((is_it = meta_is_drive_in_thisset(sp1, dn, FALSE, ep))
		    == -1)
			return (-1);

		if (is_it)
			return (mddserror(ep, MDE_DS_DRIVEINSET, sp->setno,
			    sp1->setname, dn->cname, sp->setname));
	}

	return (0);
}