This commit is contained in:
parent
2a82effd5b
commit
c27c81802d
@ -31,12 +31,16 @@ test -x $NBD_BIN || { echo "$NBD_BIN not installed";
|
||||
NBD_CONFIG=/etc/nbd-server.conf
|
||||
NBD29_CONFIG=/etc/nbd-server/config
|
||||
test -r $NBD_CONFIG && {
|
||||
echo "$NBD_CONFIG: Using old style config file deprecated";
|
||||
echo "$NBD_CONFIG: Using old style config file unsupported";
|
||||
}
|
||||
test -r $NBD_CONFIG || test -r $NBD29_CONFIG || {
|
||||
test -r $NBD29_CONFIG || {
|
||||
echo "No config file $NBD29_CONFIG existing";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
if [ "$1" = "stop" ]; then
|
||||
exit 0;
|
||||
else
|
||||
exit 6;
|
||||
fi;
|
||||
}
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
. /etc/rc.status
|
||||
@ -49,44 +53,21 @@ case "$1" in
|
||||
echo -n "Starting nbd-server "
|
||||
## Start daemon with startproc(8). If this fails
|
||||
## the return value is set appropriately by startproc.
|
||||
if test -r $NBD29_CONFIG; then
|
||||
$NBD_BIN
|
||||
rc_check
|
||||
else
|
||||
declare -i started
|
||||
started=0
|
||||
while read port file options; do
|
||||
if test -z "$port"; then continue; fi
|
||||
if test "${port:0:1}" = "#"; then continue; fi
|
||||
echo -n " $port"
|
||||
#/sbin/startproc -p /var/run/nbd-server.$port.pid $NBD_BIN $port $file $options
|
||||
$NBD_BIN $port $file $options
|
||||
rc_check
|
||||
let started+=1
|
||||
done < $NBD_CONFIG
|
||||
fi
|
||||
# Remember status and be verbose
|
||||
if test $_rc_status = 0 -a $started = 0; then
|
||||
rc_status -s
|
||||
else
|
||||
true
|
||||
rc_status -v
|
||||
fi
|
||||
startproc $NBD_BIN
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down nbd-server "
|
||||
## Stop daemon with killproc(8) and if this fails
|
||||
## killproc sets the return value according to LSB.
|
||||
if test -r $NBD29_CONFIG; then
|
||||
killall ${NBD_BIN##*/}
|
||||
else
|
||||
while read port file options; do
|
||||
if test -z "$port"; then continue; fi
|
||||
if test "${port:0:1}" = "#"; then continue; fi
|
||||
echo -n " $port"
|
||||
/sbin/killproc -p /var/run/nbd-server.$port.pid $NBD_BIN $port $file $options
|
||||
done < $NBD_CONFIG
|
||||
fi
|
||||
#killall ${NBD_BIN##*/}
|
||||
$0 status >/dev/null 2>&1
|
||||
stat=$?
|
||||
if test $stat = 3; then echo -n " (not running) ";
|
||||
elif test $stat != 0; then echo -n " (dead) "; fi
|
||||
killproc $NBD_BIN
|
||||
# TODO: Only kill nbd-server processes started by config file.
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
@ -97,7 +78,7 @@ case "$1" in
|
||||
if test "$1" = "condrestart"; then
|
||||
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||
fi
|
||||
$0 status
|
||||
$0 status >/dev/null 2>&1
|
||||
if test $? = 0; then
|
||||
$0 restart
|
||||
else
|
||||
@ -123,45 +104,31 @@ case "$1" in
|
||||
|
||||
echo -n "Reload service nbd-server "
|
||||
## if it supports it:
|
||||
/sbin/killproc -HUP $NBD_BIN
|
||||
#/sbin/killproc -HUP $NBD_BIN
|
||||
#touch /var/run/nbd-server.pid
|
||||
rc_status -v
|
||||
#rc_status -v
|
||||
|
||||
## Otherwise:
|
||||
#$0 try-restart
|
||||
#rc_status
|
||||
$0 try-restart
|
||||
rc_status
|
||||
;;
|
||||
reload)
|
||||
## Like force-reload, but if daemon does not support
|
||||
## signaling, do nothing (!)
|
||||
|
||||
# If it supports signaling:
|
||||
echo -n "Reload service nbd-server "
|
||||
/sbin/killproc -HUP $NBD_BIN
|
||||
#touch /var/run/nbd-server.pid
|
||||
rc_status -v
|
||||
#$0 force-reload
|
||||
#rc_status
|
||||
|
||||
## Otherwise if it does not support reload:
|
||||
#rc_failed 3
|
||||
#rc_status -v
|
||||
echo -n "Reload service nbd-server "
|
||||
rc_failed 3
|
||||
rc_status -v
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service nbd-server "
|
||||
## Check status with checkproc(8), if process is running
|
||||
## checkproc will return with exit status 0.
|
||||
checkproc $NBD_BIN
|
||||
|
||||
# NOTE: checkproc returns LSB compliant status values.
|
||||
while read port file options; do
|
||||
if test -z "$port"; then continue; fi
|
||||
if test "${port:0:1}" = "#"; then continue; fi
|
||||
echo -n " $port"
|
||||
if ! test -r /var/run/nbd-server.$port.pid; then rc_failed 3; echo -n ":DIS"; continue; fi
|
||||
read PID </var/run/nbd-server.$port.pid
|
||||
if ! test -e /proc/$PID/exe; then rc_failed 1; echo -n ":DEAD"; continue; fi
|
||||
if ! cmp /proc/$PID/exe $NBD_BIN; then rc_failed 1; echo -n ":DEAD"; continue; fi
|
||||
echo -n ":OK"
|
||||
#rc_status
|
||||
done < $NBD_CONFIG
|
||||
# NOTE: rc_status knows that we called this init script with
|
||||
# "status" option and adapts its messages accordingly.
|
||||
rc_status -v
|
||||
@ -171,8 +138,8 @@ case "$1" in
|
||||
## argument to this init script which is required for a reload.
|
||||
## Note: probe is not (yet) part of LSB (as of 1.9)
|
||||
|
||||
#test $NBD_CONFIG -nt /var/run/nbd-server.pid && echo restart
|
||||
rc_failed 3
|
||||
test $NBD29_CONFIG -nt /var/run/nbd-server.pid && echo restart
|
||||
#rc_failed 3
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a2d8c70da201ad4934d6f104e13dd49c4901e84a94b6d9858d1df992f082855
|
||||
size 178100
|
34
nbd-2.9.5-doc.diff
Normal file
34
nbd-2.9.5-doc.diff
Normal file
@ -0,0 +1,34 @@
|
||||
diff -uNrp nbd-2.9.5.nowarn/README nbd-2.9.5.doc/README
|
||||
--- nbd-2.9.5.nowarn/README 2007-01-30 14:00:59.000000000 +0100
|
||||
+++ nbd-2.9.5.doc/README 2007-07-30 17:08:31.328692000 +0200
|
||||
@@ -12,14 +12,16 @@ deadlock issues if you do that[1].
|
||||
To install the package, please see the INSTALL file. You'll need to
|
||||
install it on both the client and the server.
|
||||
|
||||
-Using NBD is quite easy. First, on the client, you need to create the
|
||||
-device nodes:
|
||||
+Using NBD is quite easy. First, on the client, you need to load the nbd
|
||||
+kernel module; on modern systems, udev will create the needed device
|
||||
+nodes /dev/nbdX.
|
||||
+Otherwise, you can create them manually:
|
||||
|
||||
# cd /dev
|
||||
-# ./MAKEDEV nb0
|
||||
+# ./MAKEDEV nbd0
|
||||
|
||||
-(if you need more than one NBD device, repeat the above command for nb1,
|
||||
-nb2, ...)
|
||||
+(if you need more than one NBD device, repeat the above command for nbd1,
|
||||
+nbd2, ...)
|
||||
|
||||
Next, start the server. You can use a file or a block device for that:
|
||||
|
||||
@@ -39,7 +41,7 @@ nbd-client <hostname> <port> <nbd device
|
||||
|
||||
e.g.,
|
||||
|
||||
-nbd-client 10.0.0.1 1234 /dev/nb0
|
||||
+nbd-client 10.0.0.1 1234 /dev/nbd0
|
||||
|
||||
nbd-client must be ran as root; the same is not true for nbd-server (but
|
||||
do make sure that /var/run is writeable by the server that nbd-server
|
48
nbd-2.9.5-warn.diff
Normal file
48
nbd-2.9.5-warn.diff
Normal file
@ -0,0 +1,48 @@
|
||||
diff -uNrp nbd-2.9.5/nbd-server.c nbd-2.9.5.nowarn/nbd-server.c
|
||||
--- nbd-2.9.5/nbd-server.c 2007-07-30 16:48:09.400856000 +0200
|
||||
+++ nbd-2.9.5.nowarn/nbd-server.c 2007-07-30 17:00:30.179327000 +0200
|
||||
@@ -395,7 +395,7 @@ SERVER* cmdline(int argc, char *argv[])
|
||||
size_t last;
|
||||
char suffix;
|
||||
gboolean do_output=FALSE;
|
||||
- gchar* section_header;
|
||||
+ gchar* section_header=NULL;
|
||||
|
||||
if(argc==1) {
|
||||
return NULL;
|
||||
@@ -865,7 +865,7 @@ ssize_t rawexpwrite(off_t a, char *buf,
|
||||
* @return 0 on success, nonzero on failure
|
||||
**/
|
||||
int rawexpwrite_fully(off_t a, char *buf, size_t len, CLIENT *client) {
|
||||
- ssize_t ret;
|
||||
+ ssize_t ret = 0;
|
||||
|
||||
while(len > 0 && (ret=rawexpwrite(a, buf, len, client)) > 0 ) {
|
||||
a += ret;
|
||||
@@ -907,7 +907,7 @@ ssize_t rawexpread(off_t a, char *buf, s
|
||||
* @return 0 on success, nonzero on failure
|
||||
**/
|
||||
int rawexpread_fully(off_t a, char *buf, size_t len, CLIENT *client) {
|
||||
- ssize_t ret;
|
||||
+ ssize_t ret = 0;
|
||||
|
||||
while(len > 0 && (ret=rawexpread(a, buf, len, client)) > 0 ) {
|
||||
a += ret;
|
||||
@@ -1266,7 +1266,7 @@ void serveconnection(CLIENT *client) {
|
||||
void set_peername(int net, CLIENT *client) {
|
||||
struct sockaddr_in addrin;
|
||||
struct sockaddr_in netaddr;
|
||||
- size_t addrinlen = sizeof( addrin );
|
||||
+ socklen_t addrinlen = sizeof( addrin );
|
||||
char *peername;
|
||||
char *netname;
|
||||
char *tmp;
|
||||
@@ -1486,7 +1486,7 @@ int serveloop(GArray* servers) {
|
||||
}
|
||||
/* child */
|
||||
g_hash_table_destroy(children);
|
||||
- for(i=0;i<servers->len,serve=(g_array_index(servers, SERVER*, i));i++) {
|
||||
+ for(i=0; (i<servers->len && (serve=(g_array_index(servers, SERVER*, i)))); i++) {
|
||||
close(serve->socket);
|
||||
}
|
||||
/* FALSE does not free the
|
3
nbd-2.9.5.tar.bz2
Normal file
3
nbd-2.9.5.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:60a951191f5d3a74d974d681bd75a701a16056e2206e7d53546be5b5e89241ff
|
||||
size 179919
|
27
nbd-server-daemonize-0.diff
Normal file
27
nbd-server-daemonize-0.diff
Normal file
@ -0,0 +1,27 @@
|
||||
diff -uNrp nbd-2.9.5.orig/nbd-server.c nbd-2.9.5/nbd-server.c
|
||||
--- nbd-2.9.5.orig/nbd-server.c 2007-07-08 11:58:44.000000000 +0200
|
||||
+++ nbd-2.9.5/nbd-server.c 2007-07-30 16:48:09.400856000 +0200
|
||||
@@ -1323,17 +1323,17 @@ void destroy_pid_t(gpointer data) {
|
||||
void daemonize(SERVER* serve) {
|
||||
FILE*pidf;
|
||||
|
||||
- if(!(serve->port)) {
|
||||
- return;
|
||||
- }
|
||||
- if(daemon(0,0)<0) {
|
||||
+ //if (!serve) {
|
||||
+ // return;
|
||||
+ //}
|
||||
+ if(daemon(0,0) < 0) {
|
||||
err("daemon");
|
||||
}
|
||||
if(!*pidftemplate) {
|
||||
if(serve) {
|
||||
- strncpy(pidftemplate, "/var/run/server.%d.pid", 255);
|
||||
+ strncpy(pidftemplate, "/var/run/nbd-server.%d.pid", 255);
|
||||
} else {
|
||||
- strncpy(pidftemplate, "/var/run/server.pid", 255);
|
||||
+ strncpy(pidftemplate, "/var/run/nbd-server.pid", 255);
|
||||
}
|
||||
}
|
||||
snprintf(pidfname, 255, pidftemplate, serve ? serve->port : 0);
|
19
nbd.changes
19
nbd.changes
@ -1,3 +1,22 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Jul 30 15:51:16 CEST 2007 - garloff@suse.de
|
||||
|
||||
- Convert options from old nbd-server.conf to new nbd-server/config
|
||||
on update and drop support for old config file syntax.
|
||||
- Fix daemonize(0) segfault and pid filename.
|
||||
- Fix compiler warnings.
|
||||
- Fix /dev filename docu.
|
||||
- Use startproc, killproc, checkproc in init script
|
||||
- nbd-server does not support SIGHUP, fix init script accordingly.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 17 00:54:45 CEST 2007 - garloff@suse.de
|
||||
|
||||
- Update to nbd-2.9.5:
|
||||
* Support for more platforms, pkgconfig, debug build.
|
||||
* -o option to convert cmdline options to config file.
|
||||
* Fix duplication in handling nonblocking server socket.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 12 23:45:45 CET 2007 - garloff@suse.de
|
||||
|
||||
|
57
nbd.spec
57
nbd.spec
@ -1,5 +1,5 @@
|
||||
#
|
||||
# spec file for package nbd (Version 2.9.2)
|
||||
# spec file for package nbd (Version 2.9.5)
|
||||
#
|
||||
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
@ -13,13 +13,16 @@
|
||||
Name: nbd
|
||||
BuildRequires: doxygen glib2-devel
|
||||
PreReq: %insserv_prereq
|
||||
Version: 2.9.2
|
||||
Version: 2.9.5
|
||||
Release: 1
|
||||
License: GNU General Public License (GPL)
|
||||
License: GPL v2 or later
|
||||
Group: Productivity/Networking/Other
|
||||
Autoreqprov: on
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
Source2: init.nbd-server
|
||||
Patch1: nbd-server-daemonize-0.diff
|
||||
Patch2: nbd-2.9.5-warn.diff
|
||||
Patch3: nbd-2.9.5-doc.diff
|
||||
Summary: Network Block Device Server and Client Utilities
|
||||
URL: http://nbd.sourceforge.net/
|
||||
Prefix: /usr
|
||||
@ -54,6 +57,9 @@ Authors:
|
||||
|
||||
%prep
|
||||
%setup
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
touch nbd-client.8
|
||||
|
||||
%build
|
||||
@ -62,7 +68,7 @@ export CFLAGS="$RPM_OPT_FLAGS -fstack-protector"
|
||||
#export CFLAGS="$RPM_OPT_FLAGS"
|
||||
./configure --with-gnu-ld --prefix=/usr --mandir=%{_mandir} \
|
||||
--infodir=%{_infodir} --libdir=%{_libdir} --libexecdir=%{_libdir} \
|
||||
--program-prefix="" --build=%{_target_cpu}-suse-linux
|
||||
--program-prefix="" --sysconfdir=/etc --build=%{_target_cpu}-suse-linux
|
||||
make
|
||||
doxygen
|
||||
|
||||
@ -72,7 +78,11 @@ mkdir -p $RPM_BUILD_ROOT/etc/init.d
|
||||
install %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/nbd-server
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/bin
|
||||
ln -s ../../etc/init.d/nbd-server $RPM_BUILD_ROOT/usr/bin/rcnbd-server
|
||||
echo "#Port file options" > $RPM_BUILD_ROOT/etc/nbd-server.conf
|
||||
#echo "#Port file options" > $RPM_BUILD_ROOT/etc/nbd-server.conf
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/nbd-server
|
||||
touch $RPM_BUILD_ROOT/etc/nbd-server/config
|
||||
touch $RPM_BUILD_ROOT/etc/nbd-server/allow
|
||||
grep -A16 -B1 '^\[generic\]' README > $RPM_BUILD_ROOT/etc/nbd-server/config.example
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
@ -84,15 +94,50 @@ echo "#Port file options" > $RPM_BUILD_ROOT/etc/nbd-server.conf
|
||||
%{_mandir}/man8/nbd-client.8.gz
|
||||
%doc README
|
||||
%doc doc/html
|
||||
%config(noreplace) /etc/nbd-server.conf
|
||||
#%config(noreplace) /etc/nbd-server.conf
|
||||
%dir /etc/nbd-server
|
||||
%ghost %config(noreplace) /etc/nbd-server/config
|
||||
%ghost %config(noreplace) /etc/nbd-server/allow
|
||||
/etc/nbd-server/config.example
|
||||
|
||||
%post
|
||||
%{fillup_and_insserv -f nbd-server}
|
||||
if test -e /etc/nbd-server.conf; then
|
||||
# Do we have to create a generic section?
|
||||
unset generic
|
||||
if test -e /etc/nbd-server/config; then generic=1; fi
|
||||
while read port file opts; do
|
||||
if test -z "$port"; then continue; fi
|
||||
if test "${port:0:1}" = "#"; then continue; fi
|
||||
if test -z "$generic"; then
|
||||
echo -e "[generic]\n\t# No generic options yet\n" > /etc/nbd-server/config
|
||||
generic=1
|
||||
fi
|
||||
FN=${file%/*}
|
||||
nm="cvt.$port.${FN##*/}.${file##*/}"
|
||||
echo " ... convert $port $file $opts -> $nm"
|
||||
/usr/bin/nbd-server $port $file $opts -o "$nm" >> /etc/nbd-server/config
|
||||
done < /etc/nbd-server.conf
|
||||
mv /etc/nbd-server.conf /etc/nbd-server.conf.converted
|
||||
fi
|
||||
|
||||
%postun
|
||||
%{insserv_cleanup}
|
||||
|
||||
%changelog
|
||||
* Mon Jul 30 2007 - garloff@suse.de
|
||||
- Convert options from old nbd-server.conf to new nbd-server/config
|
||||
on update and drop support for old config file syntax.
|
||||
- Fix daemonize(0) segfault and pid filename.
|
||||
- Fix compiler warnings.
|
||||
- Fix /dev filename docu.
|
||||
- Use startproc, killproc, checkproc in init script
|
||||
- nbd-server does not support SIGHUP, fix init script accordingly.
|
||||
* Tue Jul 17 2007 - garloff@suse.de
|
||||
- Update to nbd-2.9.5:
|
||||
* Support for more platforms, pkgconfig, debug build.
|
||||
* -o option to convert cmdline options to config file.
|
||||
* Fix duplication in handling nonblocking server socket.
|
||||
* Mon Mar 12 2007 - garloff@suse.de
|
||||
- Update to 2.9.2:
|
||||
* make child socket nonblocking
|
||||
|
Loading…
x
Reference in New Issue
Block a user