Miscellaneous fixes.
[bluesky.git] / nfs3 / nfsd.c
1 /* Blue Sky: File Systems in the Cloud
2  *
3  * Copyright (C) 2009  The Regents of the University of California
4  * Written by Michael Vrable <mvrable@cs.ucsd.edu>
5  *
6  * TODO: Licensing
7  */
8
9 /* Main entry point for an NFSv3 server which will proxy requests to a cloud
10  * filesystem. */
11
12 #include "mount_prot.h"
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <rpc/pmap_clnt.h>
16 #include <string.h>
17 #include <memory.h>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <glib.h>
21
22 #include "bluesky.h"
23
24 void register_rpc();
25
26 BlueSkyFS *fs;
27 static uint8_t filesystem_key[16];
28
29 int main(int argc, char *argv[])
30 {
31     int i;
32     bluesky_init();
33     register_rpc();
34
35     bluesky_crypt_random_bytes(filesystem_key, sizeof(filesystem_key));
36     printf("Filesystem key: ");
37     for (i = 0; i < sizeof(filesystem_key); i++) {
38         printf("%02x", filesystem_key[i]);
39     }
40     printf("\n");
41
42     fs = bluesky_new_fs("export");
43     fs->encryption_key = filesystem_key;
44
45     BlueSkyInode *root;
46     root = bluesky_get_inode(fs, BLUESKY_ROOT_INUM);
47     if (root == NULL) {
48         printf("Initializing fresh root inode...\n");
49         root = bluesky_new_inode(BLUESKY_ROOT_INUM, fs, BLUESKY_DIRECTORY);
50         root->nlink = 1;
51         root->mode = 0755;
52         bluesky_insert_inode(fs, root);
53     }
54
55     svc_run();
56     fprintf(stderr, "%s", "svc_run returned");
57     exit(1);
58 }