Introduce the NV_FLAG_NO_UNIQUE flag. When set, it allows to store
multiple values using the same key in a nvlist. Approved by: pjd (mentor) Obtained from: WHEEL Systems (http://www.wheelsystems.com) Update man page. Reviewed by: AllanJude Approved by: pjd (mentor)
This commit is contained in:
parent
cf66982b37
commit
d3c00f4352
@ -232,6 +232,8 @@ The following flag can be provided:
|
||||
.Bl -tag -width "NV_FLAG_IGNORE_CASE" -compact -offset indent
|
||||
.It Dv NV_FLAG_IGNORE_CASE
|
||||
Perform case-insensitive lookups of provided names.
|
||||
.It Dv NV_FLAG_NO_UNIQUE
|
||||
Names in the nvlist do not have to be unique.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
|
@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#define NV_FLAG_PRIVATE_MASK (NV_FLAG_BIG_ENDIAN)
|
||||
#define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE)
|
||||
#define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE | NV_FLAG_NO_UNIQUE)
|
||||
#define NV_FLAG_ALL_MASK (NV_FLAG_PRIVATE_MASK | NV_FLAG_PUBLIC_MASK)
|
||||
|
||||
#define NVLIST_MAGIC 0x6e766c /* "nvl" */
|
||||
@ -1074,10 +1074,12 @@ nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
if (nvlist_exists(nvl, nvpair_name(nvp))) {
|
||||
nvl->nvl_error = EEXIST;
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
|
||||
if (nvlist_exists(nvl, nvpair_name(nvp))) {
|
||||
nvl->nvl_error = EEXIST;
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
newnvp = nvpair_clone(nvp);
|
||||
@ -1266,11 +1268,13 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
if (nvlist_exists(nvl, nvpair_name(nvp))) {
|
||||
nvpair_free(nvp);
|
||||
nvl->nvl_error = EEXIST;
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
return;
|
||||
if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
|
||||
if (nvlist_exists(nvl, nvpair_name(nvp))) {
|
||||
nvpair_free(nvp);
|
||||
nvl->nvl_error = EEXIST;
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nvpair_insert(&nvl->nvl_head, nvp, nvl);
|
||||
|
@ -143,7 +143,8 @@ nvpair_insert(struct nvl_head *head, nvpair_t *nvp, nvlist_t *nvl)
|
||||
|
||||
NVPAIR_ASSERT(nvp);
|
||||
PJDLOG_ASSERT(nvp->nvp_list == NULL);
|
||||
PJDLOG_ASSERT(!nvlist_exists(nvl, nvpair_name(nvp)));
|
||||
PJDLOG_ASSERT((nvlist_flags(nvl) & NV_FLAG_NO_UNIQUE) != 0 ||
|
||||
!nvlist_exists(nvl, nvpair_name(nvp)));
|
||||
|
||||
TAILQ_INSERT_TAIL(head, nvp, nvp_next);
|
||||
nvp->nvp_list = nvl;
|
||||
|
@ -64,6 +64,10 @@ typedef struct nvlist nvlist_t;
|
||||
* Perform case-insensitive lookups of provided names.
|
||||
*/
|
||||
#define NV_FLAG_IGNORE_CASE 0x01
|
||||
/*
|
||||
* Names don't have to be unique.
|
||||
*/
|
||||
#define NV_FLAG_NO_UNIQUE 0x02
|
||||
|
||||
#if defined(_KERNEL) && defined(MALLOC_DECLARE)
|
||||
MALLOC_DECLARE(M_NVLIST);
|
||||
|
Loading…
x
Reference in New Issue
Block a user