Do not start the RPC services until the filesystem is ready.
[bluesky.git] / nfs3 / nfsd.c
index 727011d..d323fdb 100644 (file)
@@ -25,34 +25,23 @@ void register_rpc();
 
 BlueSkyFS *fs;
 BlueSkyStore *store;
-static uint8_t filesystem_key[16];
 
 int main(int argc, char *argv[])
 {
     int i;
     bluesky_init();
-    register_rpc();
+    g_set_prgname("nfsd");
 
-    bluesky_crypt_random_bytes(filesystem_key, sizeof(filesystem_key));
-    printf("Filesystem key: ");
-    for (i = 0; i < sizeof(filesystem_key); i++) {
-        printf("%02x", filesystem_key[i]);
-    }
-    printf("\n");
+    const char *target = getenv("BLUESKY_TARGET");
+    if (target == NULL)
+        target = "s3";
 
-    store = bluesky_store_new("file");
+    store = bluesky_store_new(target);
     fs = bluesky_init_fs("export", store);
-    fs->encryption_key = filesystem_key;
-
-    BlueSkyInode *root;
-    root = bluesky_get_inode(fs, BLUESKY_ROOT_INUM);
-    if (root == NULL) {
-        printf("Initializing fresh root inode...\n");
-        root = bluesky_new_inode(BLUESKY_ROOT_INUM, fs, BLUESKY_DIRECTORY);
-        root->nlink = 1;
-        root->mode = 0755;
-        bluesky_insert_inode(fs, root);
-    }
+
+    register_rpc();
+
+    bluesky_debug_dump(fs);
 
     svc_run();
     fprintf(stderr, "%s", "svc_run returned");