X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=nfs3%2Fnfsd.c;h=e3862aa74abbb81983ab7ccd5b22303e45974197;hb=45a4f324927f8fe3b7e689dd0c9a28716d0d1e93;hp=03b39fbce902bd56bc25233a186db34e1784b35b;hpb=8819789ef2264b26aebfae489932a447f6e0f65f;p=bluesky.git diff --git a/nfs3/nfsd.c b/nfs3/nfsd.c index 03b39fb..e3862aa 100644 --- a/nfs3/nfsd.c +++ b/nfs3/nfsd.c @@ -19,25 +19,41 @@ #include #include +#include "libs3.h" #include "bluesky.h" void register_rpc(); BlueSkyFS *fs; +static uint8_t filesystem_key[16]; int main(int argc, char *argv[]) { - g_thread_init(NULL); + int i; + bluesky_init(); register_rpc(); + 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"); + + fs = bluesky_new_fs("export"); + fs->encryption_key = filesystem_key; + BlueSkyInode *root; - root = bluesky_new_inode(BLUESKY_ROOT_INUM, BLUESKY_DIRECTORY); - root->nlink = 1; - root->mode = 0755; - bluesky_insert_inode(fs, root); - - svc_run (); - fprintf (stderr, "%s", "svc_run returned"); - exit (1); - /* NOTREACHED */ + 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); + } + + svc_run(); + fprintf(stderr, "%s", "svc_run returned"); + exit(1); }