Casper service for handle files passed over argv/argc.
Unit Tests Skipped
I think this looks good. (Note that I haven't yet reviewed in detail.)
I wonder how hard it would be to extend / provide an alternate API allowing per-file flags/modes? Allowing us to support something like pdftk with a commandline such as pdftk in1.pdf in2.pdf cat output out1.pdf. It would require application-specific code to parse all arguments in advance, but would be quite convenient to create a fileargs context with a readable in1.pdf and in2.pdf and writable out1.pdf.
I noticed that we're missing manpages for the casper services and submitted PR 226102 to track that; we should add a manpage for cap_fileargs too. I can try to help create it.
So for know the idea is to just create two or three whatever fileargs instance as you need with difference rights.
If we want that in one service the question is do we need it in fileargs or in filesystem one?
Perhaps the stubs deserve a comment?
Other than a couple of small comments I think this is good to go.
Consider using 1 as with other casper services? (I think users may see a lone .so.0 and assume it is outdated.)
Ought to add a SPDX-License-Identifier: BSD-2-Clause-FreeBSD (and to the .c)
In file included from /scratch/tmp/emaste/freebsd/usr.bin/head/head.c:60: /scratch/tmp/emaste/obj/scratch/tmp/emaste/freebsd/amd64.amd64/tmp/usr/include/casper/cap_fileargs.h:82:6: error: implicit declaration of function 'dnvlist_get_number' is invalid in C99 [-Werror,-Wimplicit-function-declaration] dnvlist_get_number(limits, "mode", 0)); ^
I don't see a tests directory in the review... am I just missing it?
Rather than providing two separate functions, might it make sense to have one fileargs_init function that takes an optionally-NULL argument?
It feels a bit odd to me that the user of this interface is required to know the details of the implementation, e.g., whether fileargs or an nvlist are used to store the descriptors. Couldn't this be hidden behind an opaque type with the nv-or-plain-structure choice as an implementation detail?
This is a service Makefile:
I open for such change.
But I don't have strong opinion about that.
This is optional function only for optimization purpose. Normally you would use fileargs_init, fileargs_initnv I found usefully when I need to pares somehow argc/argv and I don't want to create extra buffer and copy memory etc... I left all that operation to be handled by nvlist.