Hi :)
Quoting manolis...@gmail.com (2016-05-25 17:05:57)
> From: Manolis Ragkousis
>
> * libhurdutil/hurdutil.h: New file.
> * libhurdutil/settrans.c: New file.
> * libhurdutil/Makefile: New file.
> * utils/Makefile (HURDLIBS, settrans): Use the new library.
> * utils/settrans.c: Update to use the new library.
> * Makefile: (lib-subdirs): Add library.
> ---
> Makefile | 2 +-
> libhurdutil/Makefile | 28 +++
> libhurdutil/hurdutil.h | 78
> libhurdutil/settrans.c | 377 +++
> utils/Makefile | 4 +-
> utils/settrans.c | 475
> +++--
> 6 files changed, 594 insertions(+), 370 deletions(-)
> create mode 100644 libhurdutil/Makefile
> create mode 100644 libhurdutil/hurdutil.h
> create mode 100644 libhurdutil/settrans.c
>
> diff --git a/Makefile b/Makefile
> index d48baaa..e712767 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -29,7 +29,7 @@ include ./Makeconf
> lib-subdirs = libshouldbeinlibc libihash libiohelp libports libthreads \
> libpager libfshelp libdiskfs libtrivfs libps \
> libnetfs libpipe libstore libhurdbugaddr libftpconn libcons \
> - libhurd-slab
> + libhurd-slab libhurdutil
>
> # Hurd programs
> prog-subdirs = auth proc exec term \
> diff --git a/libhurdutil/Makefile b/libhurdutil/Makefile
> new file mode 100644
> index 000..2e0e642
> --- /dev/null
> +++ b/libhurdutil/Makefile
> @@ -0,0 +1,28 @@
> +# Copyright (C) 2016 Free Software Foundation, Inc.
> +#
> +# This file is part of the GNU Hurd.
> +#
> +# The GNU Hurd is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation; either version 2, or (at
> +# your option) any later version.
> +#
> +# The GNU Hurd is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +# General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This is an old license template, the current one doesn't list a
snailmail address, but some URL.
> +
> +dir := libhurdutil
> +makemode := library
> +
> +libname := libhurdutil
> +SRCS = settrans.c
> +installhdrs = hurdutil.h
> +
> +OBJS = $(SRCS:.c=.o)
> +
> +include ../Makeconf
> diff --git a/libhurdutil/hurdutil.h b/libhurdutil/hurdutil.h
> new file mode 100644
> index 000..5786cff
> --- /dev/null
> +++ b/libhurdutil/hurdutil.h
> @@ -0,0 +1,78 @@
> +/* hurdutil.h - Hurd utils interface.
> + Copyright (C) 2016 Free Software Foundation, Inc.
> + Written by Manolis Fragkiskos Ragkousis .
> +
> + This file is part of the GNU Hurd.
> +
> + The GNU Hurd is free software; you can redistribute it and/or
> + modify it under the terms of the GNU General Public License as
> + published by the Free Software Foundation; either version 2, or (at
> + your option) any later version.
> +
> + The GNU Hurd is distributed in the hope that it will be useful, but
> + WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with the GNU Hurd; if not, write to the Free Software
> + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
> +
> +#ifndef _HURD_UTIL_H
> +#define _HURD_UTIL_H
> +
> +#include
> +#include
> +#include
> +#include
> +#include
> +
> +#include
> +
As Guillem noted, we might want to change the way options are passed
into the library. Let's see...
> +struct settrans_flags
> +{
> + /* The name of the node we're putting the translator on. */
> + char *node_name;
> +
> + /* Flags to pass to file_set_translator. */
> + int lookup_flags;
> + int goaway_flags;
These two contain ORed flags.
> + /* Various option flags. */
> + int passive;
> + int active;
> + int keep_active;
> + int pause;
> + int kill_active;
> + int orphan;
> + int start;
> + int stack;
> + int excl;
> + int timeout;
These are boolean, and the idiomatic way would be to OR some constants
containing powers of two together. Or use a bitfield, that might be
more modern, I don't know.
> + char *pid_file;
> + char *underlying_node_name;
> + int underlying_lookup_flags;
> + char **chroot_command;
> + char *chroot_chdir;
> +
> + /* The translator's arg vector, in '\0' separated format. */
> + char *argz;
> + size_t argz_len;
> +};
So only using bitflags is not enough, we have plenty of other kind of
options. Maybe we shouldn't call it 'settrans_flags' then, mayb