instead of to HEAD. Reversed it.
else
AC_MSG_RESULT(no)
fi
else
AC_MSG_RESULT(no)
fi
-AC_CHECK_HEADERS([linux/nbd.h arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/mount.h sys/socket.h syslog.h],,,[[typedef unsigned short u32;
-typedef unsigned int u64;
-]])
+AC_CHECK_HEADERS([linux/nbd.h arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/mount.h sys/socket.h syslog.h])
AC_HEADER_SYS_WAIT
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_HEADER_SYS_WAIT
AC_TYPE_OFF_T
AC_TYPE_PID_T
#include <linux/ioctl.h>
#include "cliserv.h"
#include <linux/ioctl.h>
#include "cliserv.h"
-/**
- * Open a connection to a given host on a given port.
- * @param name The host to connect to
- * @param port The port to connect to
- * @return A connected socket to the given host on the given port
- **/
int opennet(char *name, int port)
{
int sock;
int opennet(char *name, int port)
{
int sock;
-/**
- * Do everything
- * @todo cut this thing into little tiny manageable pieces, preferably with a
- * chainsaw.
- **/
int main(int argc, char *argv[])
{
int port, sock, nbd, one = 1;
int main(int argc, char *argv[])
{
int port, sock, nbd, one = 1;
#define DEBUG2( a,b )
#define DEBUG3( a,b,c )
#endif
#define DEBUG2( a,b )
#define DEBUG3( a,b,c )
#endif
-/** sending macro... not really required */
-#define SEND writeit( net, &reply, sizeof( reply ));
-/** error macro... not sure whether we really need this */
-#define ERROR { reply.error = htonl(-1); SEND; reply.error = 0; lastpoint = -1; }
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION ""
#endif
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION ""
#endif
/**
* Variables associated with a copyonwrite server. Not yet used.
**/
/**
* Variables associated with a copyonwrite server. Not yet used.
**/
-typedef struct __cow_opts {
char* difffilename; /**< filename of the copy-on-write file */
int difffile; /**< filedescriptor of copyonwrite file. @todo
shouldn't this be an array too? (cfr
char* difffilename; /**< filename of the copy-on-write file */
int difffile; /**< filedescriptor of copyonwrite file. @todo
shouldn't this be an array too? (cfr
- * Variables associated with a server. Not yet used.
+ * Variables associated with a server. Not yet used. @todo modify the code to
+ * use an instance of this struct instead of the heap of global variables.
-typedef struct __nbd_server_opts {
char* exportname; /**< filename of the file we're exporting */
unsigned int port; /**< port we're exporting this file at */
char* authname; /**< filename of the authorization file */
char* exportname; /**< filename of the file we're exporting */
unsigned int port; /**< port we're exporting this file at */
char* authname; /**< filename of the authorization file */
int export[1024]; /**< array of filedescriptors of exported files;
only the first is actually used unless we're
doing the multiple file option */
int export[1024]; /**< array of filedescriptors of exported files;
only the first is actually used unless we're
doing the multiple file option */
- cow_opts* cow; /**< only used if (flags | F_COPYONWRITE) */
+ cow_opts* cow; /**< only used if (flags | F_COPYONWRITE) (NULL
+ otherwise) */
- * Check whether a client is allowed to connect. Works with an
- * authorization file which contains one line per machine, no
- * wildcards.
+ * Check whether a client is allowed to connect. Works with an authorization
+ * file which contains one line per machine, no wildcards.
+ *
* @param name IP address of client trying to connect (in human-readable form)
* @return 0 - authorization refused, 1 - OK
**/
* @param name IP address of client trying to connect (in human-readable form)
* @return 0 - authorization refused, 1 - OK
**/
* Parse the command line.
*
* @todo getopt() is a great thing, and easy to use. Also, we want to
* Parse the command line.
*
* @todo getopt() is a great thing, and easy to use. Also, we want to
- * create a configuration file which nbd-server will read.
+ * create a configuration file which nbd-server will read. Maybe do (as in,
+ * parse) that here.
*
* @param argc the argc argument to main()
* @param argv the argv argument to main()
*
* @param argc the argc argument to main()
* @param argv the argv argument to main()
if(parent) {
unlink(pidfname);
}
if(parent) {
unlink(pidfname);
}
u32 es32;
struct stat stat_buf;
int error;
u32 es32;
struct stat stat_buf;
int error;
DEBUG("looking for export size with lseek SEEK_END\n");
es = lseek(export, (off_t)0, SEEK_END);
if (es > ((off_t)0)) {
DEBUG("looking for export size with lseek SEEK_END\n");
es = lseek(export, (off_t)0, SEEK_END);
if (es > ((off_t)0)) {
} else {
DEBUG2("lseek failed: %d", errno==EBADF?1:(errno==ESPIPE?2:(errno==EINVAL?3:4)));
}
} else {
DEBUG2("lseek failed: %d", errno==EBADF?1:(errno==ESPIPE?2:(errno==EINVAL?3:4)));
}
DEBUG("looking for export size with fstat\n");
stat_buf.st_size = 0;
error = fstat(export, &stat_buf);
DEBUG("looking for export size with fstat\n");
stat_buf.st_size = 0;
error = fstat(export, &stat_buf);
/**
* seek to a position in a file, no matter what. Used when using maybeseek is a
* bad idea (for instance, because we're reading the copyonwrite file instead
/**
* seek to a position in a file, no matter what. Used when using maybeseek is a
* bad idea (for instance, because we're reading the copyonwrite file instead
- * of the exported file)
+ * of the exported file).
* @param handle a filedescriptor
* @param a position to seek to
* @param handle a filedescriptor
* @param a position to seek to
+ * @todo get rid of this; lastpoint is a global variable right now, but it
+ * shouldn't be. If we pass it on as a parameter, that makes things a *lot*
+ * easier.
**/
void myseek(int handle,off_t a) {
if (lseek(handle, a, SEEK_SET) < 0) {
**/
void myseek(int handle,off_t a) {
if (lseek(handle, a, SEEK_SET) < 0) {
err("Negotiation failed: %m");
}
err("Negotiation failed: %m");
}
+/** sending macro; not really required. Uses variables in the local
+ * scope of mainloop(). Get rid of it. */
+#define SEND writeit( net, &reply, sizeof( reply ));
+/** error macro; not sure whether we really need this. Uses variables
+ * in the local scope of mainloop(). Get rid of this beast. */
+#define ERROR { reply.error = htonl(-1); SEND; reply.error = 0; lastpoint = -1; }
/**
* Serve a file to a single client.
*
/**
* Serve a file to a single client.
*