From: Wouter Verhelst Date: Thu, 1 Jan 2009 12:44:46 +0000 (+0100) Subject: Build system fixes and documentation X-Git-Url: http://git.alex.org.uk Build system fixes and documentation Should make compiling on non-Linux operating systems not quite as painful --- diff --git a/README b/README index 3ca8a49..f805105 100644 --- a/README +++ b/README @@ -109,13 +109,6 @@ uClibc's "buildroot" script also seems to have support for NBD. If you're packaging NBD for a different operating system that isn't in the above list, I'd like to know about it. -Thanks, and have fun, - -Wouter Verhelst - - - - [1] When you write something to a block device, the kernel will not immediately write that to the physical block device; instead, your changes are written to a cache, which is periodically flushed by a @@ -127,6 +120,26 @@ If, while your kblockd is emptying the NBD buffer cache, the kernel decides that the cache of the block device your nbd-server is writing to needs to be emptied, then you've got a deadlock. -A kernel patch exists[2] to create a separate kernel thread for NBD -writes which woul fix this problem; however, it has not made it into -mainline yet. +A kernel patch exists to create a separate kernel thread for NBD writes +which woul fix this problem; however, it has not made it into mainline +yet. + +BUILDING THE SERVER FOR NON-LINUX OPERATING SYSTEMS +=================================================== + +Since the client requires kernel-side support, you can't just compile +nbd-client on a non-Linux kernel and hope it'll work; you'd have to +write a kernel-space driver before that would be possible. + +However, nbd-server assumes nothing more than POSIX and one headerfile +from the Linux kernel. Compiling it can be done as follows: +- Fetch the nbd userland sources, and unpack them. Since you're reading + this README file, you have already done this step. +- Fetch the "nbd.h" file from /usr/include/linux on a Linux system, or + from include/linux in the Linux source tree, and store it in the + toplevel directory of the nbd userland sources +- Edit the headerfile, and remove the line that says '#include + ' (on non-Linux systems, the userland source is smart + enough to figure out how this works by itself) +- now it's just a regular './configure && make && sudo make install' + diff --git a/cliserv.h b/cliserv.h index 5685528..cefdad2 100644 --- a/cliserv.h +++ b/cliserv.h @@ -42,8 +42,13 @@ typedef unsigned long long u64; #include "nbd.h" #endif #ifdef NBD_H_LINUX -#include -#include +# ifdef HAVE_LINUX_TYPES_H +# include +# else +# define __be32 u32 +# define __be64 u64 +# endif +# include #endif #if NBD_LFS==1 diff --git a/config.h.in b/config.h.in index 2a51644..7c6bfdb 100644 --- a/config.h.in +++ b/config.h.in @@ -25,6 +25,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_TYPES_H + /* Define to 1 if you have the `llseek' function. */ #undef HAVE_LLSEEK diff --git a/configure b/configure index 252b252..0d03fa4 100755 --- a/configure +++ b/configure @@ -7660,7 +7660,8 @@ done -for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h + +for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h linux/types.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then diff --git a/configure.ac b/configure.ac index 3e5663a..51787db 100644 --- a/configure.ac +++ b/configure.ac @@ -160,7 +160,7 @@ AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation o AC_CHECK_HEADERS([sys/mount.h],,, [[#include ]]) -AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h]) +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h linux/types.h]) AM_PATH_GLIB_2_0(2.6.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib])) AC_HEADER_SYS_WAIT AC_TYPE_OFF_T