Exemple #1
0
static void
child(int sock)
{
	nvlist_t *nvl;

	nvl = nvlist_create(0);

	nvlist_add_bool(nvl, "nvlist/bool/true", true);
	nvlist_add_bool(nvl, "nvlist/bool/false", false);
	nvlist_add_number(nvl, "nvlist/number/0", 0);
	nvlist_add_number(nvl, "nvlist/number/1", 1);
	nvlist_add_number(nvl, "nvlist/number/-1", -1);
	nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX);
	nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN);
	nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX);
	nvlist_add_string(nvl, "nvlist/string/", "");
	nvlist_add_string(nvl, "nvlist/string/x", "x");
	nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz");
	nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO);
	nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1);
	nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz"));
	nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl);

	nvlist_send(sock, nvl);

	nvlist_destroy(nvl);
}
Exemple #2
0
int
cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen,
    char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
	nvlist_t *nvl;
	int error;

	nvl = nvlist_create(0);
	nvlist_add_string(nvl, "cmd", "getnameinfo");
	nvlist_add_number(nvl, "hostlen", (uint64_t)hostlen);
	nvlist_add_number(nvl, "servlen", (uint64_t)servlen);
	nvlist_add_binary(nvl, "sa", sa, (size_t)salen);
	nvlist_add_number(nvl, "flags", (uint64_t)flags);
	nvl = cap_xfer_nvlist(chan, nvl, 0);
	if (nvl == NULL)
		return (EAI_MEMORY);
	if (nvlist_get_number(nvl, "error") != 0) {
		error = (int)nvlist_get_number(nvl, "error");
		nvlist_destroy(nvl);
		return (error);
	}

	if (host != NULL)
		strlcpy(host, nvlist_get_string(nvl, "host"), hostlen + 1);
	if (serv != NULL)
		strlcpy(serv, nvlist_get_string(nvl, "serv"), servlen + 1);
	nvlist_destroy(nvl);
	return (0);
}
Exemple #3
0
struct hostent *
cap_gethostbyaddr(cap_channel_t *chan, const void *addr, socklen_t len,
    int type)
{
	struct hostent *hp;
	nvlist_t *nvl;

	nvl = nvlist_create(0);
	nvlist_add_string(nvl, "cmd", "gethostbyaddr");
	nvlist_add_binary(nvl, "addr", addr, (size_t)len);
	nvlist_add_number(nvl, "family", (uint64_t)type);
	nvl = cap_xfer_nvlist(chan, nvl, 0);
	if (nvl == NULL) {
		h_errno = NO_RECOVERY;
		return (NULL);
	}
	if (nvlist_get_number(nvl, "error") != 0) {
		h_errno = (int)nvlist_get_number(nvl, "error");
		nvlist_destroy(nvl);
		return (NULL);
	}
	hp = hostent_unpack(nvl, &hent);
	nvlist_destroy(nvl);
	return (hp);
}
Exemple #4
0
int
cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,
    size_t *oldlenp, const void *newp, size_t newlen)
{
	nvlist_t *nvl;
	const uint8_t *retoldp;
	uint8_t operation;
	size_t oldlen;

	operation = 0;
	if (oldp != NULL)
		operation |= CAP_SYSCTL_READ;
	if (newp != NULL)
		operation |= CAP_SYSCTL_WRITE;

	nvl = nvlist_create(0);
	nvlist_add_string(nvl, "cmd", "sysctl");
	nvlist_add_string(nvl, "name", name);
	nvlist_add_number(nvl, "operation", (uint64_t)operation);
	if (oldp == NULL && oldlenp != NULL)
		nvlist_add_null(nvl, "justsize");
	else if (oldlenp != NULL)
		nvlist_add_number(nvl, "oldlen", (uint64_t)*oldlenp);
	if (newp != NULL)
		nvlist_add_binary(nvl, "newp", newp, newlen);
	nvl = cap_xfer_nvlist(chan, nvl, 0);
	if (nvl == NULL)
		return (-1);
	if (nvlist_get_number(nvl, "error") != 0) {
		errno = (int)nvlist_get_number(nvl, "error");
		nvlist_destroy(nvl);
		return (-1);
	}

	if (oldp == NULL && oldlenp != NULL) {
		*oldlenp = (size_t)nvlist_get_number(nvl, "oldlen");
	} else if (oldp != NULL) {
		retoldp = nvlist_get_binary(nvl, "oldp", &oldlen);
		memcpy(oldp, retoldp, oldlen);
		if (oldlenp != NULL)
			*oldlenp = oldlen;
	}
	nvlist_destroy(nvl);

	return (0);
}
Exemple #5
0
int
u_sysctl(int ns,
    int *oid,
    u_int namelen,
    void *oldp,
    size_t *oldlenp,
    const void *newp,
    size_t newlen)
{
	nvlist_t *nvl = NULL, *nvl_resp = NULL;
	int retval = 0;
	const char *rbuf;
	size_t r_len;
	int r_errno;

#if 0
	printf("sysctl: nl=%d, oldp=%p, oldlen=%d, newp=%p, newlen=%d\n",
	    namelen,
	    oldp,
	    (int) *oldlenp,
	    newp,
	    (int) newlen);
#endif

	/* Create nvlist to populate the request into */
	nvl = nvlist_create(0);
	if (nvl == NULL) {
		warn("nvlist_create");
		retval = -1;
		goto done;
	}

	/* Create nvlist for a sysctl_oid request */
	nvlist_add_string(nvl, "type", "sysctl_oid");
	nvlist_add_binary(nvl, "sysctl_oid", oid, namelen * sizeof(int));

	/* XXX this sets errno as appropriate */
	retval = u_sysctl_do_sysctl(nvl, ns, oldp, oldlenp, newp, newlen);

done:
	if (nvl)
		nvlist_destroy(nvl);
	return (retval);
}
int
main(void)
{
	nvlist_t *nvl;

	printf("1..232\n");

	nvl = nvlist_create(0);

	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/null"));
	nvlist_add_null(nvl, "nvlist/null");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/null"));
	CHECK(nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/null"));

	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/bool"));
	nvlist_add_bool(nvl, "nvlist/bool", true);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/bool"));
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/bool"));

	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/number"));
	nvlist_add_number(nvl, "nvlist/number", 0);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/number"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/number"));

	CHECK(!nvlist_exists(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/string"));
	nvlist_add_string(nvl, "nvlist/string", "test");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/string"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/string"));

	CHECK(!nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist"));
	nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/nvlist"));

	CHECK(!nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor"));
	nvlist_add_descriptor(nvl, "nvlist/descriptor", STDERR_FILENO);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/descriptor"));

	CHECK(!nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary"));
	nvlist_add_binary(nvl, "nvlist/binary", "test", 4);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/binary"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	CHECK(nvlist_exists(nvl, "nvlist/null"));
	CHECK(nvlist_exists(nvl, "nvlist/bool"));
	CHECK(nvlist_exists(nvl, "nvlist/number"));
	CHECK(nvlist_exists(nvl, "nvlist/string"));
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_null(nvl, "nvlist/null");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(nvlist_exists(nvl, "nvlist/bool"));
	CHECK(nvlist_exists(nvl, "nvlist/number"));
	CHECK(nvlist_exists(nvl, "nvlist/string"));
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_bool(nvl, "nvlist/bool");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(nvlist_exists(nvl, "nvlist/number"));
	CHECK(nvlist_exists(nvl, "nvlist/string"));
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_number(nvl, "nvlist/number");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(nvlist_exists(nvl, "nvlist/string"));
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_string(nvl, "nvlist/string");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists(nvl, "nvlist/string"));
	CHECK(nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_nvlist(nvl, "nvlist/nvlist");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists(nvl, "nvlist/string"));
	CHECK(!nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_descriptor(nvl, "nvlist/descriptor");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists(nvl, "nvlist/string"));
	CHECK(!nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary"));

	nvlist_free_binary(nvl, "nvlist/binary");
	CHECK(!nvlist_exists(nvl, "nvlist/null"));
	CHECK(!nvlist_exists(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists(nvl, "nvlist/number"));
	CHECK(!nvlist_exists(nvl, "nvlist/string"));
	CHECK(!nvlist_exists(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists(nvl, "nvlist/binary"));
	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool"));
	CHECK(!nvlist_exists_number(nvl, "nvlist/number"));
	CHECK(!nvlist_exists_string(nvl, "nvlist/string"));
	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor"));
	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary"));

	CHECK(nvlist_empty(nvl));

	nvlist_destroy(nvl);

	return (0);
}
int
main(void)
{
	const nvlist_t *cnvl;
	nvlist_t *nvl;

	printf("1..94\n");

	nvl = nvlist_create(0);

	CHECK(!nvlist_exists_null(nvl, "nvlist/null"));
	nvlist_add_null(nvl, "nvlist/null");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_null(nvl, "nvlist/null"));

	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true"));
	nvlist_add_bool(nvl, "nvlist/bool/true", true);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true"));

	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false"));
	nvlist_add_bool(nvl, "nvlist/bool/false", false);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/0"));
	nvlist_add_number(nvl, "nvlist/number/0", 0);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/0"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/1"));
	nvlist_add_number(nvl, "nvlist/number/1", 1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/1"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1"));
	nvlist_add_number(nvl, "nvlist/number/-1", -1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/-1"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX"));
	nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN"));
	nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN"));

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX"));
	nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/"));
	nvlist_add_string(nvl, "nvlist/string/", "");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/string/"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/x"));
	nvlist_add_string(nvl, "nvlist/string/x", "x");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/string/x"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"));
	nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/"));
	nvlist_add_stringf(nvl, "nvlist/stringf/", "%s", "");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/x"));
	nvlist_add_stringf(nvl, "nvlist/stringf/x", "%s", "x");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x"));

	CHECK(!nvlist_exists_string(nvl, "nvlist/stringf/666Xabc"));
	nvlist_add_stringf(nvl, "nvlist/stringf/666Xabc", "%d%c%s", 666, 'X', "abc");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc"));

	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"));
	nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"));

	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x"));
	nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x"));

	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz"));
	nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz"));
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz"));

	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));

	CHECK(nvlist_exists_null(nvl, "nvlist/null"));
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool/true"));
	CHECK(nvlist_exists_bool(nvl, "nvlist/bool/false"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/0"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/1"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/-1"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MIN"));
	CHECK(nvlist_exists_number(nvl, "nvlist/number/INT64_MAX"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string/"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string/x"));
	CHECK(nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"));
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/"));
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/x"));
	CHECK(nvlist_exists_string(nvl, "nvlist/stringf/666Xabc"));
	CHECK(nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary/x"));
	CHECK(nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz"));
	CHECK(nvlist_exists_nvlist(nvl, "nvlist/nvlist"));

	cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist");
	CHECK(nvlist_exists_null(cnvl, "nvlist/null"));
	CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/true"));
	CHECK(nvlist_exists_bool(cnvl, "nvlist/bool/false"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/0"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/1"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/-1"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/UINT64_MAX"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MIN"));
	CHECK(nvlist_exists_number(cnvl, "nvlist/number/INT64_MAX"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/string/"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/string/x"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/x"));
	CHECK(nvlist_exists_string(cnvl, "nvlist/stringf/666Xabc"));
	CHECK(nvlist_exists_descriptor(cnvl, "nvlist/descriptor/STDERR_FILENO"));
	CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/x"));
	CHECK(nvlist_exists_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz"));

	nvlist_destroy(nvl);

	return (0);
}
Exemple #8
0
static int
u_sysctl_do_sysctl(struct nvlist *nvl, int ns,
    void *oldp,
    size_t *oldlenp,
    const void *newp,
    size_t newlen)
{
	nvlist_t *nvl_resp = NULL;
	int retval = 0;
	int r_errno;
	const char *rbuf;
	size_t r_len;

	/* XXX Eventually this should be in a sysctl transaction struct */
	int shm_fd = -1;
	char *shm_mem = NULL;
	size_t shm_len = 0;
	char shm_path[128];

	/* Setup request and response buffer information */

	/*
	 * If the requested size is provided and it's greater than the
	 * maximum size allowed, we'll flip to using shm
	 */
	if (oldlenp != NULL && *oldlenp >= U_SYSCTL_MAX_REQ_BUF_LEN) {
		/* Construct a shm path */
		/* XXX should make this less guessable */
		snprintf(shm_path, 128, "/sysctl.%ld", (long) arc4random());

		/* Open it */
		shm_fd = shm_open(shm_path, O_CREAT | O_RDWR, 0640);
		if (shm_fd < 0) {
			warn("shm_open (%s)", shm_path);
			retval = -1;
			goto done;
		}

		/*
		 * Calculate a mmap size that's a multiple of
		 * the system page length.
		 */
		shm_len = round_page(*oldlenp);

		/* make it that big! */
		if (ftruncate(shm_fd, shm_len) < 0) {
			warn("ftruncate");
			goto done;
		}

		/* mmap it */
		shm_mem = mmap(NULL, shm_len, PROT_READ | PROT_WRITE,
		    0, shm_fd, 0);
		if (shm_mem == NULL) {
			warn("mmap");
			goto done;
		}

		/* add the shm path to the outbound request */
		nvlist_add_string(nvl, "sysctl_respbuf_shm_path", shm_path);
		nvlist_add_number(nvl, "sysctl_respbuf_shm_len", shm_len);
	}

	/*
	 * Writing a value may pass in a NULL oldlenp, so only conditionally
	 * send it.
	 */
	if (oldlenp != NULL)
		nvlist_add_number(nvl, "sysctl_respbuf_len", *oldlenp);

	if (newlen > 0) {
		nvlist_add_binary(nvl, "sysctl_reqbuf", newp, newlen);
	}

	/* Send command */
	if (nvlist_send(ns, nvl) < 0) {
		warn("nvlist_send");
		retval = -1;
		goto done;
	}

	/* Read response */
	nvl_resp = nvlist_recv(ns);
	if (nvl_resp == NULL) {
		warn("nvlist_recv");
		retval = -1;
		goto done;
	}

	if (! nvlist_exists_number(nvl_resp, "sysctl_errno")) {
		fprintf(stderr, "response: no errno?\n");
		goto done;
	}
	r_errno = (int) nvlist_get_number(nvl_resp, "sysctl_errno");

	/* XXX validate r_len versus oldlenp */
	if (nvlist_exists_binary(nvl_resp, "sysctl_respbuf")) {
		rbuf = nvlist_get_binary(nvl_resp, "sysctl_respbuf", &r_len);
		memcpy(oldp, rbuf, r_len);
	} else if (shm_mem != NULL) {
		memcpy(oldp, shm_mem, r_len);
		r_len = nvlist_get_number(nvl_resp, "sysctl_respbuf_shm_len");
	} else if (nvlist_exists_number(nvl_resp, "sysctl_respbuf_len")) {
		r_len = nvlist_get_number(nvl_resp, "sysctl_respbuf_len");
	} else {
		r_len = 0;
	}

	if (oldlenp != NULL)
		*oldlenp = r_len;

	if (r_errno == 0) {
		retval = 0;
	} else {
		retval = -1;
		errno = r_errno;
	}

done:
	if (shm_mem != NULL)
		munmap(shm_mem, shm_len);
	if (shm_fd != -1) {
		close(shm_fd);
		shm_unlink(shm_path);
	}
	if (nvl_resp)
		nvlist_destroy(nvl_resp);
	return (retval);
}
Exemple #9
0
int
main(void)
{
	const nvlist_t *cnvl;
	nvlist_t *nvl;
	size_t size;

	printf("1..83\n");

	nvl = nvlist_create(0);

	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/true"));
	nvlist_add_bool(nvl, "nvlist/bool/true", true);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true);

	CHECK(!nvlist_exists_bool(nvl, "nvlist/bool/false"));
	nvlist_add_bool(nvl, "nvlist/bool/false", false);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/0"));
	nvlist_add_number(nvl, "nvlist/number/0", 0);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/1"));
	nvlist_add_number(nvl, "nvlist/number/1", 1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/-1"));
	nvlist_add_number(nvl, "nvlist/number/-1", -1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/UINT64_MAX"));
	nvlist_add_number(nvl, "nvlist/number/UINT64_MAX", UINT64_MAX);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MIN"));
	nvlist_add_number(nvl, "nvlist/number/INT64_MIN", INT64_MIN);
	CHECK(nvlist_error(nvl) == 0);
	CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN);

	CHECK(!nvlist_exists_number(nvl, "nvlist/number/INT64_MAX"));
	nvlist_add_number(nvl, "nvlist/number/INT64_MAX", INT64_MAX);
	CHECK(nvlist_error(nvl) == 0);
	CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX);

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/"));
	nvlist_add_string(nvl, "nvlist/string/", "");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0);

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/x"));
	nvlist_add_string(nvl, "nvlist/string/x", "x");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0);

	CHECK(!nvlist_exists_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"));
	nvlist_add_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz");
	CHECK(nvlist_error(nvl) == 0);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0);

	CHECK(!nvlist_exists_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO"));
	nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", STDERR_FILENO);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")));

	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/x"));
	nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1);
	CHECK(nvlist_error(nvl) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0);
	CHECK(size == 1);

	CHECK(!nvlist_exists_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz"));
	nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz"));
	CHECK(nvlist_error(nvl) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz"));

	CHECK(!nvlist_exists_nvlist(nvl, "nvlist/nvlist"));
	nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl);
	CHECK(nvlist_error(nvl) == 0);
	cnvl = nvlist_get_nvlist(nvl, "nvlist/nvlist");
	CHECK(nvlist_get_bool(cnvl, "nvlist/bool/true") == true);
	CHECK(nvlist_get_bool(cnvl, "nvlist/bool/false") == false);
	CHECK(nvlist_get_number(cnvl, "nvlist/number/0") == 0);
	CHECK(nvlist_get_number(cnvl, "nvlist/number/1") == 1);
	CHECK((int)nvlist_get_number(cnvl, "nvlist/number/-1") == -1);
	CHECK(nvlist_get_number(cnvl, "nvlist/number/UINT64_MAX") == UINT64_MAX);
	CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MIN") == INT64_MIN);
	CHECK((int64_t)nvlist_get_number(cnvl, "nvlist/number/INT64_MAX") == INT64_MAX);
	CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/"), "") == 0);
	CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/x"), "x") == 0);
	CHECK(strcmp(nvlist_get_string(cnvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0);
	/* TODO */
	CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", NULL), "x", 1) == 0);
	CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/x", &size), "x", 1) == 0);
	CHECK(size == 1);
	CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(memcmp(nvlist_get_binary(cnvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz"));

	CHECK(nvlist_get_bool(nvl, "nvlist/bool/true") == true);
	CHECK(nvlist_get_bool(nvl, "nvlist/bool/false") == false);
	CHECK(nvlist_get_number(nvl, "nvlist/number/0") == 0);
	CHECK(nvlist_get_number(nvl, "nvlist/number/1") == 1);
	CHECK((int)nvlist_get_number(nvl, "nvlist/number/-1") == -1);
	CHECK(nvlist_get_number(nvl, "nvlist/number/UINT64_MAX") == UINT64_MAX);
	CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MIN") == INT64_MIN);
	CHECK((int64_t)nvlist_get_number(nvl, "nvlist/number/INT64_MAX") == INT64_MAX);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/"), "") == 0);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/x"), "x") == 0);
	CHECK(strcmp(nvlist_get_string(nvl, "nvlist/string/abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz") == 0);
	CHECK(fd_is_valid(nvlist_get_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO")));
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", NULL), "x", 1) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/x", &size), "x", 1) == 0);
	CHECK(size == 1);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", NULL), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(memcmp(nvlist_get_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", &size), "abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz")) == 0);
	CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz"));

	nvlist_destroy(nvl);

	return (0);
}