-/* Cumulus: Smart Filesystem Backup to Dumb Servers
- *
- * Copyright (C) 2007 The Regents of the University of California
- * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+/* Cumulus: Efficient Filesystem Backup to the Cloud
+ * Copyright (C) 2007-2008 The Cumulus Developers
+ * See the AUTHORS file for a list of contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <uuid/uuid.h>
#include <iostream>
{
return strtoll(s.c_str(), NULL, 0);
}
+
+/* Mark a file descriptor as close-on-exec. */
+void cloexec(int fd)
+{
+ long flags = fcntl(fd, F_GETFD);
+
+ if (flags < 0)
+ return;
+
+ fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+}
+
+/* Report a fatal error and exit. */
+void fatal(string msg)
+{
+ fprintf(stderr, "FATAL: %s\n", msg.c_str());
+ exit(1);
+}