Commit Graph

97 Commits

Author SHA1 Message Date
Alex Richardson
63889bbde0 No longer install sys/nv.h and sys/cnv.h in lib/libnv/Makefile
Use tools/build/Makefile to install the headers into ${WORLDTMP}/legacy
instead. Compared to r336026 this has the minor advantage that it avoids
unncessary header installation when building the non-bootstrap libnv.

Reviewed By:	bdrewery, kevans
Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D16187
2018-07-16 10:57:26 +00:00
Kyle Evans
3cafc9a654 config(8): Fix broken ABI
r336019 introduced ${SRCTOP}/sys to the include paths in order to pull in a
new sys/{c,}nv.h. This is wrong, because the build tree's ABI isn't
guaranteed to match what's running on the host system.

Fix instead by removing -I${SRCTOP}/sys and installing the libnv headers
with `make -C lib/libnv includes`... this may or may not get re-worked in
the future so that a userland lib isn't installing includes from sys/.

Reported by:	bdrewery
2018-07-06 11:23:14 +00:00
Mariusz Zaborski
24881c060c libnv: Add nvlist_append_*_array() family of functions.
The nvlist_append_{bool,number,string,nvlist,descriptor}_array() functions
allows to dynamically extend array stored in the nvlist.

Submitted by:	Mindaugas Rasiukevicius <rmind@netbsd.org>
2018-06-18 22:57:32 +00:00
Mariusz Zaborski
8f2285b26d libnv: add regression test for r335344. 2018-06-18 22:22:06 +00:00
Mariusz Zaborski
d82e41b6b8 libnv: Remove nvlist argument from cnvlist_{take,free}_* functions.
All information which are need for those operations is already stored in
the cookie.

We decided not to bump libnv version because this API is not used yet in the
base system.

Reviewed by:	pjd
2018-06-18 21:26:58 +00:00
Pedro F. Giffuni
5e53a4f90f lib: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-26 02:00:33 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Mariusz Zaborski
08016b3185 Remove redundant initialization. Don't use variable - just return the value.
Make scan-build happy by casting to 'void *' instead of 'void **'.

Submitted by:	pjd@
MFC after:	1 month
Found by:	scan-build and cppcheck
Sponsored by:	Wheel Systems
2017-09-21 10:00:16 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Enji Cooper
f31a4fc86c :dnvlist_get_string__default_value: fix a bogus string comparison test
Check actual_value vs "5", not "5" vs itself.

MFC after:	3 days
Reported by:	Coverity
CID:		1362021
Sponsored by:	Dell EMC Isilon
2017-05-29 19:02:52 +00:00
Enji Cooper
6399b5e03a :nvlist_unpack__duplicate_key : check the result of nvlist_pack(3)
This fixes a potential NULL pointer dereference.

MFC after:	3 days
Reported by:	Coverity
CID:		1362051
Sponsored by:	Dell EMC Isilon
2017-05-29 18:39:28 +00:00
Enji Cooper
2c6778ed5b lib/libnv/tests/dnv_test: fix memory leaks for memory allocated via
either strdup or one of the dnvlist* libcalls.

Reported by:	Coverity
CID:		1362056-1362060
Sponsored by:	Dell EMC Isilon
2017-05-29 18:34:45 +00:00
Enji Cooper
a9468a4e63 Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones
This implifies pathing in make/displayed output

MFC after:    3 weeks
Sponsored by: Dell EMC Isilon
2017-01-20 04:40:55 +00:00
Mariusz Zaborski
736bc73796 Fix style issue in the cnv API.
Remove unused arguments in a macro.
Remove unused typedef.
2016-08-27 13:40:27 +00:00
Mariusz Zaborski
5ef231f6f7 Add cnv API.
cnv API is a set of functions for managing name/value pairs by cookie.
The cookie can be obtained by nvlist_next(), nvlist_get_parent() or
nvlist_get_pararr() function. This patch also includes unit tests.

Submitted by:	Adam Starak <starak.adam@gmail.com>
2016-08-27 13:37:30 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Glen Barber
7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber
52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Bryan Drewery
d48a2d2303 Remove WARNS inherited fine by ../Makefile.inc.
Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:23 +00:00
Glen Barber
a70cba9582 First pass through library packaging.
Sponsored by:	The FreeBSD Foundation
2016-02-04 21:16:35 +00:00
Glen Barber
43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Enji Cooper
db61e6ef45 Remove free'ing of an uninitialized variable
Just remove it completely from the test as it's initialized but unused apart
from the free(3) call

Differential Revision: https://reviews.freebsd.org/D4769 (part of larger diff)
MFC after: 5 days
Reported by: cppcheck
Reviewed by: oshogbo
Sponsored by: EMC / Isilon Storage Division
2016-01-04 03:34:22 +00:00
Enji Cooper
e02f530ebb Use nitems(x) macro instead of using hardcoded numbers for indices into
the nvlists

Convert some of the variables from int to unsigned int to squelch -Wsign-compare
warnings when converting hardcoded values to nitems(..)

Differential Revision: https://reviews.freebsd.org/D4769 (part of larger diff)
MFC after: 5 days
Reviewed by: oshogbo
Sponsored by: EMC / Isilon Storage Division
2016-01-04 03:26:36 +00:00
Enji Cooper
bd7f70daa5 Convert another string variable to string_arr missed in r293130
Differential Revision: https://reviews.freebsd.org/D4769 (part of larger diff)
MFC after: 5 days
Reviewed by: oshogbo
Sponsored by: EMC / Isilon Storage Division
2016-01-04 03:12:18 +00:00
Enji Cooper
8d86e318ea Rename nitems and string variables to avoid collisions
Rename the `nitems` variable to `num_items` to avoid collisions with the
macro in sys/param.h for counting elements in an array

Similarly, rename `string` to `string_arr` to avoid future collisions with
potential keywords, as well as make it clear that `string_arr` isn't a char*
value, but instead a char** value.

Differential Revision: https://reviews.freebsd.org/D4769 (part of larger diff)
MFC after: 5 days
Reviewed by: oshogbo
Sponsored by: EMC / Isilon Storage Division
2016-01-04 03:02:44 +00:00
Enji Cooper
93ef13b5e0 Add sys/types.h for for size_t, etc
stable/10 requires it due to header pollution

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-01-03 11:22:15 +00:00
Bryan Drewery
7b3ea376a2 META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host.
This both avoids some dependencies on xinstall.host and allows
bootstrapping on older releases to work due to lack of at least 'install -l'
support.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:10:28 +00:00
Enji Cooper
b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Mariusz Zaborski
347a39b4a6 Add support for the arrays in nvlist library.
- Add
  nvlist_{add,get,take,move,exists,free}_{number,bool,string,nvlist,
  descriptor} functions.
- Add support for (un)packing arrays.
- Add the nvl_array_next field to the nvlist structure.
  If an array is added by the nvlist_{move,add}_nvlist_array function
  this field will contains next element in the array.
- Add the nitems field to the nvpair and nvpair_header structure.
  This field contains number of elements in the array.
- Add special flag (NV_FLAG_IN_ARRAY) which is set if nvlist is a part of
  an array.
- Add special type (NV_TYPE_NVLIST_ARRAY_NEXT).This type is used only
  on packing/unpacking.
- Add new API for traversing arrays (nvlist_get_array_next).
- Add the nvlist_get_pararr function which combines the
  nvlist_get_array_next and nvlist_get_parent functions. If nvlist is in
  the array it will return next element from array. If nvlist is last
  element in array or it isn't in array it will return his
  container (parent). This function should simplify traveling over nvlist.
- Add tests for new features.
- Add documentation for new functions.
- Add my copyright.
- Regenerate the sys/cddl/compat/opensolaris/sys/nvpair.h file.

PR:		191083
Reviewed by:	allanjude (doc)
Approved by:	pjd (mentor)
2015-08-15 06:34:49 +00:00
Mariusz Zaborski
54f98da930 Move the nvlist source and private includes from sys/kern to seperate
directory sys/contrib/libnv.

The goal of this operation is to NOT install header files which shouldn't
be used outside the nvlist library.

Approved by:	pjd (mentor)
2015-07-04 16:33:37 +00:00
Mariusz Zaborski
58c86148dd Move nvlist documentation to the FreeBSD Kernel Developer's sections.
Approved by:	pjd (mentor)
2015-07-04 10:27:30 +00:00
Mariusz Zaborski
c36e54bb32 Let the nv.h and dnv.h includes be only in sys directory.
Change consumers to include those files from sys.
Add duplicated files to ObsoleteFiles.

Approved by:	pjd (mentor)
2015-07-02 21:58:10 +00:00
Baptiste Daroussin
18b2ee82db Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Baptiste Daroussin
4232f82668 Enforce overwritting SHLIBDIR
Since METAMODE has been added, sys.mk loads bsd.mkopt.mk which ends load loading
bsd.own.mk which then defines SHLIBDIR before all the Makefile.inc everywhere.

This makes /lib being populated again.

Reported by:	many
2015-06-15 15:34:20 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Mariusz Zaborski
00173c094e Add test case for unpack with diffrent flags.
Approved by:	pjd (mentor)
2015-05-02 18:07:47 +00:00
Mariusz Zaborski
169c153b59 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)
2015-05-02 18:03:47 +00:00
Mariusz Zaborski
bd1da0a002 Approved, oprócz użycie RESTORE_ERRNO() do ustawiania errno.
Change the nvlist_recv() function to take additional argument that
specifies flags expected on the received nvlist. Receiving a nvlist with
different set of flags than the ones we expect might lead to undefined
behaviour, which might be potentially dangerous.

Update consumers of this and related functions and update the tests.

Approved by:	pjd (mentor)

Update man page for nvlist_unpack, nvlist_recv, nvlist_xfer, cap_recv_nvlist
and cap_xfer_nvlist.

Reviewed by:	AllanJude
Approved by:	pjd (mentor)
2015-05-02 17:45:52 +00:00
Mariusz Zaborski
24f93ee714 Add nvlist_flags() function, which returns nvlist's public flags.
Approved by:	pjd (mentor)
2015-05-01 17:50:24 +00:00
Mariusz Zaborski
041392bc29 Sort MLINKS alphabetically.
Approved by:	pjd (mentor)
2015-05-01 16:41:46 +00:00
Mariusz Zaborski
0bb5e6ef80 Remove the nvlist_.*[fv] functions.
Those functions are problematic, because there is no way to report
memory allocation problems without complicating the API, so we can
either abort or potentially return invalid results. None of which is
acceptable.

In most cases the caller knows the size of the name, so he can allocate
buffer on the stack and use snprintf(3) to prepare the name.

After some discussion the conclusion is to removed those functions,
which also simplifies the API.

Discussed with: pjd, rstone
Approved by:	pjd (mentor)
2015-04-29 22:57:04 +00:00
Mariusz Zaborski
37c6848ce6 Remove the use of nvlist_.*[fv] functions from tests.
Approved by:	pjd (mentor)
2015-04-29 22:46:18 +00:00
Dimitry Andric
bf5d6cf0a9 Fix lib/libnv tests compilation with -std=c++11, by adding appropriate
casts for NULL to invocations of the ATF_REQUIER_EQ() macro.

Reviewed by:	rstone, jmmv
Differential Revision: https://reviews.freebsd.org/D2027
2015-03-08 00:30:52 +00:00
Ryan Stone
081abde45c Fix build of nv_tests.cc
nv_tests.cc managed to get two copies of several functions due to me
applying a patch in an unclean working tree.  My kingdom for an
"svn clean" command.

MFC after:	1 month
X-MFC-With:	r279424
2015-03-01 00:37:23 +00:00
Ryan Stone
4d6a976e37 Move libnv into the kernel and hook it into the kernel build
Differential Revision:		https://reviews.freebsd.org/D1883
Reviewed by:			jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:34:27 +00:00
Ryan Stone
814f9a1824 Add macros to make code compile in kernel
Make it possible to compile libnv in the kernel.  Mostly this
involves wrapping functions that have a different signature in
the kernel and in userland (e.g. malloc()) in a macro that will
conditionally expand to the right API depending on whether the
code is being compiled for the kernel or not.

I have also #ifdef'ed out all of file descriptor-handling code,
as well as the unsafe varargs functions.

Differential Revision:		https://reviews.freebsd.org/D1882
Reviewed by:			jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc
2015-03-01 00:22:53 +00:00