Encrypt data blocks being stored to S3.
[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 "libs3.h"
23 #include "bluesky.h"
24
25 void register_rpc();
26
27 BlueSkyFS *fs;
28 static uint8_t filesystem_key[16];
29
30 int main(int argc, char *argv[])
31 {
32     int i;
33     g_thread_init(NULL);
34     bluesky_crypt_init();
35     register_rpc();
36
37     bluesky_crypt_random_bytes(filesystem_key, sizeof(filesystem_key));
38     printf("Filesystem key: ");
39     for (i = 0; i < sizeof(filesystem_key); i++) {
40         printf("%02x", filesystem_key[i]);
41     }
42     printf("\n");
43
44     S3_initialize(NULL, S3_INIT_ALL);
45
46     fs = bluesky_new_fs("export");
47     fs->encryption_key = filesystem_key;
48
49     BlueSkyInode *root;
50     root = bluesky_new_inode(BLUESKY_ROOT_INUM, fs, BLUESKY_DIRECTORY);
51     root->nlink = 1;
52     root->mode = 0755;
53     bluesky_insert_inode(fs, root);
54
55     BlueSkyInode *file;
56     file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), fs, BLUESKY_REGULAR);
57     file->nlink = 1;
58     file->mode = 0755;
59     bluesky_insert_inode(fs, file);
60     bluesky_directory_insert(root, "demo", file->inum);
61
62     svc_run();
63     fprintf(stderr, "%s", "svc_run returned");
64     exit(1);
65 }