r74: * Added checks for GLib (not used yet, but will be in this release)
[nbd.git] / nbd-server.c
index 0eab68c..58050bc 100644 (file)
@@ -54,6 +54,7 @@
 /* Includes LFS defines, which defines behaviours of some of the following
  * headers, so must come before those */
 #include "config.h"
+#include "lfs.h"
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -80,6 +81,8 @@
 #include <strings.h>
 #include <dirent.h>
 
+#include <glib.h>
+
 /* used in cliserv.h, so must come first */
 #define MY_NAME "nbd_server"
 #include "cliserv.h"
@@ -740,11 +743,15 @@ int mainloop(int net)
  **/
 int splitexport(void) {
        off_t i ;
-       
+
        for (i=0; i<exportsize; i+=hunksize) {
                char exportname3[1024];
-               
-               snprintf(exportname3, 1024, "%s.%d", exportname2, (int)(i/hunksize));
+
+               if(flags & F_MULTIFILE) {
+                       snprintf(exportname3, 1024, "%s.%d", exportname2, (int)(i/hunksize));
+               } else {
+                       strncpy(exportname3, exportname2, 1024);
+               }
                exportname3[1023]='\0';
                printf( "Opening %s\n", exportname3 );
                if ((export[i/hunksize] = open(exportname3, (flags & F_READONLY) ? O_RDONLY : O_RDWR)) == -1) {