[ENBD] Bring enbd back in Debian?
Peter T. Breuer
ptb at inv.it.uc3m.es
Mon Mar 13 04:37:13 MST 2006
"Also sprach Bas van Schaik:"
> Currently, I'm having problems with the configfile /etc/enbd.conf and
> it's manpage. Both packages are related to this configfile and the
> manpage, but the files can't be in two packages at the same time. The
> most ideal solution would be two different configfiles:
> /etc/enbd/clients.conf and
> /etc/enbd/servers.conf
>=20
> or
>=20
> /etc/enbd-clients.conf and
> /etc/enbd-servers.conf
>=20
> with two different manpages. I think this is a rather good idea, since
> the syntax for client and server directives differs on many points.
I have no problem with that, but the file is referenced by both
enbd-cstatd and enbd-sstatd, the helper daemons. They might not like
it :-).
nbd/enbd_conf.h defines
# define NBD_CONFIG_FILE "/etc/enbd.conf"
and one wants to change that to
# define NBD_SERVER_CONFIG_FILE "/etc/enbd-servers.conf"
# define NBD_CLIENT_CONFIG_FILE "/etc/enbd-clients.conf"
I'm not too keen on the plural in the name - I think it's understood
that one file can support several configurations. M=E6ybe
# define NBD_SERVER_CONFIG_FILE "/etc/enbd-server.conf"
# define NBD_CLIENT_CONFIG_FILE "/etc/enbd-client.conf"
Isn't debian supposed to work with /etc/enbd/*, though?
The enbd_conf.h file is included in=20
nbd/enbd-cstatd.c:#include "enbd_conf.h"
nbd/enbd-sstatd.c:#include "enbd_conf.h"
but I only see a reference to NBD_CONFIG_FILE in nbd/config.c
(and that file should change its name since it causes horrible
problems with make config at times). That file defines an object
with three methods, set, get, end, apparently intended to start reading
the configuration file, get the next entry, and close the file. The
initialisation routine needs to be changed to take the name of the file
as an argument, or possibly take the type of the daemon as an argument.
I notice that enbd_conf.h defines three constants
# define NBD_CONFIG_MODULE 1
# define NBD_CONFIG_CLIENT 2
# define NBD_CONFIG_SERVER 3
so one could pass a value like that as an argument to init_nbd_conf ..
but that would require exporting the header file more widely.
I suspect the answer is to make two init routines, init_nbd_client_conf
and init_nbd_server_conf, which set a different conf file name.=20
void init_enbd_conf(struct nbd_confent * self, char *filename) {
self->fp =3D NULL;
self->fn =3D filename;
self->set =3D setconfent;
self->end =3D endconfent;
self->get =3D getconfent;
}=20
=20
void init_enbd_client_conf(struct nbd_confent * self) {
init_enbd_conf(NBD_CLIENT_CONFIG_FILE);
}
void init_enbd_server_conf(struct nbd_confent * self) {
init_enbd_conf(NBD_SERVER_CONFIG_FILE);
}
and change the exlicit reference to NBD_CONFIG_FILE in config.c to
self->fp =3D fopen(self->fn, "r");
(maybe check it's not null too)
and add a field to nbd_confent in enbd_conf.h
char *fn; // file name
The question in my mind now is how much info server and client need
respectively.
Also the init.d/enbd script references that conf file.
CONFIG=3D${NBD_CONFIG-/etc/enbd.conf}
one now needs two definitions
SERVER_CONFIG=3D${NBD_SERVER_CONFIG-/etc/enbd-server.conf}
CLIENT_CONFIG=3D${NBD_CLIENT_CONFIG-/etc/enbd-client.conf}
[ ! -r $SERVER_CONFIG ] && [ ! -r $CLIENT_CONFIG ] && exit 0
in init.d/enbd. This should be set up by ./configure, really.=20
Now one has to go through the file searching for CONFIG and seeing what
to replace it with .. in stop_all_clients(), it should be CLIENT_CONFIG,
clearly, but in main(), the simplest approach is to replace
cat $CONFIG
with a cat of both. The code figures out for what each config line is
intended.
(
[ -r $SERVER_CONFIG ] && cat $SERVER_CONFIG;
[ -r $CLIENT_CONFIG ] && cat $CLIENT_CONFIG;
)
I guess some quotes could be added all round!
> Also the init.d script /etc/init.d/enbd can't be in two packages at the
> same time. To be honest, I don't think may people will run client &
> server on the same machine, because it doesn't make any sense to use a
> networked block device when you can easily use a local one. So two
> scripts /etc/init.d/enbd-clients and /etc/init.d/enbd-servers seems to
> be the best solution.
That can be done too.
> Please let me hear your thoughts on this, because it affects not only
> the Debian-package, but also the source package.
Well, I have no real objections at all. Thank you for your efforts.
Peter
More information about the ENBD
mailing list