r74: * Added checks for GLib (not used yet, but will be in this release)
[nbd.git] / nbd-server.c
index e22223a..58050bc 100644 (file)
@@ -81,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"
@@ -741,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) {