Repository navigation
Tags: briandowns/jail
Tags
Add jail.{AllByID,AllByName} (#11)
This change introduces two new functions.
The first of the two functions, jail.AllByID, returns all known
jail IDs. It does this through the special parameter 'lastjid',
which is mentioned in the man page for jail_get(2) for this purpose
in particular:
> The special parameter lastjid can be used to retrieve a list of all
> jails. It will fetch the jail with the jid above and closest to the
> passed value. The first jail (usually but not always jid 1) can be found
> by passing a lastjid of zero.
We find the "first" jid to begin with, and from there we iterate until
we encounter ENOENT. We assume that there are no gaps between jids, and
if there happens to be gaps, our approach will fall short.
The second of the two methods, AllByName, returns all known jail names. It
is implemented on top of AllByID.