extern struct tdb_context *migrate_db;
extern const char *cache;
extern const char *remote;
+extern const char *export;
extern int this_log_level;
enum deb_lev {
/* this is the directory where we present the cached image and which
we re-export through our local nfs server to the clients */
-static const char *export = NULL;
+const char *export = NULL;
enum deb_lev debug_level = DEBUG_ERR;
printf("Using BIG_WRITES\n");
}
+ ret = fork();
+ if (ret == -1) {
+ DEBUG(DEBUG_ERR, ("Failed to fork\n"));
+ exit(10);
+ }
+ if (ret != 0) {
+ return 0;
+ }
+
migpid = start_migration_daemon();
if (migpid == -1) {
DEBUG(DEBUG_CRIT,("Failed to spawn migration daemon. Aborting\n"));
printf("here we go ...\n");
return fuse_main(num_args, discard_const(fuse_argv), &remote_cache_ops, NULL);
}
+
+
DEBUG(DEBUG_DEBUG,("No more files to migrate, for now\n"));
}
+static void migd_sigusr2_handler(struct event_context *ev, struct signal_event *se, int signum, int count, void *dont_care, void *private_data)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ char *cmd;
+ int ret;
+
+ cmd = talloc_asprintf(mem_ctx, "fusermount -u %s\n", export);
+ DEBUG(DEBUG_ERR,("Got SIGUSR2, unmounting fuse filesystem %s\n", export));
+ ret = system(cmd);
+
+ talloc_free(mem_ctx);
+ _exit(10);
+}
+
int start_migration_daemon(void)
{
TALLOC_CTX *migd;
return -1;
}
+ /* make sure we unmount the filesystem when the migration dameon exits */
+ /* set up a handler to pick up sigusr2 */
+ se = event_add_signal(ev, migd, SIGUSR2, 0, migd_sigusr2_handler, migd);
+
event_loop_wait(ev);
DEBUG(DEBUG_CRIT,("Returned from event loop. This can not happen\n"));