From: Tracey Emery Subject: Re: struct for priv_fds To: gameoftrees@openbsd.org Date: Mon, 30 May 2022 07:55:39 -0600 On Sun, May 29, 2022 at 05:35:02PM +0200, Stefan Sperling wrote: > On Wed, May 25, 2022 at 04:44:04PM -0600, Tracey Emery wrote: > > Howdy, > > > > I'd like to add the following to got_repository.h to prepare for adding > > multiple privileged fds to gotwebd, instead of the single one it has > > now. > > > > ok? > > Can you show how this will be used? > > Each fd that is being passed around should serve a dedicated purpose. > It could be a temporary file that is used e.g. during delta application > or some other process that needs to store temporary state that may not > fit into memory. It could be a file output is written to. It could be > a file that contains input the other process will use. And so on. > > With a list like this, how can we tell the purpose of each fd on the list? > Is that what the 'id' member is for? > Wouldn't it make more sense to pass required fds as function arguments? > And if multiple fds are required for a shared purpose, could we not pass > an fd array and a length instead of a list? No, that makes total sense. I had not thought about an array. Then, what about something like below as a starting point? An array can be loaded up and this would give us an association for each fd. -- Tracey Emery diff d6a28ffe187127e3247254d7e242bb52d66eb26b /home/tracey/src/got blob - b6e44e8b40b8476a471c53fd10cffd4a7ff3b32d file + include/got_repository.h --- include/got_repository.h +++ include/got_repository.h @@ -177,3 +177,12 @@ const struct got_error *got_repo_get_loose_object_info /* Obtain the number and size of packed objects in the repository. */ const struct got_error *got_repo_get_packfile_info(int *npackfiles, int *nobjects, off_t *total_packsize, struct got_repository *); + +/* Privileged file descriptors */ +enum got_priv_fds { + DIFF_FD, + BLAME_FD, + PACK_BASE_FD, + PACK_ACCUM_FD, + PRIV_FDS__MAX, +};