r326: Don't require read-write access to base file when doing copy on write
authoryoe <yoe>
Mon, 17 Mar 2008 10:20:01 +0000 (10:20 +0000)
committeryoe <yoe>
Mon, 17 Mar 2008 10:20:01 +0000 (10:20 +0000)
nbd-server.c

index 1606d5d..315d44e 100644 (file)
@@ -1220,8 +1220,12 @@ void setupexport(CLIENT* client) {
                        /* Try again because maybe media was read-only */
                        fi.fhandle = open(tmpname, O_RDONLY);
                        if(fi.fhandle != -1) {
-                               client->server->flags |= F_AUTOREADONLY;
-                               client->server->flags |= F_READONLY;
+                               /* Opening the base file in copyonwrite mode is
+                                * okay */
+                               if(!(client->server->flags & F_COPYONWRITE)) {
+                                       client->server->flags |= F_AUTOREADONLY;
+                                       client->server->flags |= F_READONLY;
+                               }
                        }
                }
                if(fi.fhandle == -1) {