1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 /* Main entry point for an NFSv3 server which will proxy requests to a cloud
34 #include "mount_prot.h"
35 #include "nfs3_prot.h"
38 #include <rpc/pmap_clnt.h>
41 #include <sys/socket.h>
42 #include <netinet/in.h>
52 /* A cookie value returned for uncommitted writes and verified by commits; this
53 * should be a unique value each time the server is started. */
54 char nfsd_instance_verf_cookie[NFS3_WRITEVERFSIZE];
56 static void shutdown_handler(int num)
58 g_print("SIGINT caught, shutting down...\n");
59 g_print("Proxy statistics:\n");
60 bluesky_stats_dump_all();
64 int main(int argc, char *argv[])
68 signal(SIGPIPE, SIG_IGN);
69 signal(SIGINT, shutdown_handler);
72 g_set_prgname("nfsd");
74 const char *target = getenv("BLUESKY_TARGET");
78 const char *key = getenv("BLUESKY_KEY");
82 const char *profile_output = getenv("BLUESKY_PROFILE_OUT");
83 if (profile_output != NULL)
84 bluesky_profile_set_output(fopen(profile_output, "a"));
86 store = bluesky_store_new(target);
87 fs = bluesky_init_fs("export", store, key);
89 const char *stats_output = getenv("BLUESKY_STATS_OUT");
90 if (stats_output != NULL)
91 bluesky_stats_run_periodic_dump(fopen(stats_output, "a"));
93 bluesky_crypt_random_bytes(nfsd_instance_verf_cookie,
94 sizeof(nfsd_instance_verf_cookie));
99 fprintf(stderr, "%s", "svc_run returned");