X-Git-Url: https://git.distorted.org.uk/~mdw/rsync-backup/blobdiff_plain/f6b4ffdc7265b79b945e2350efbd9d2a94df4450..HEAD:/rfreezefs.c diff --git a/rfreezefs.c b/rfreezefs.c index c390c36..fa1f053 100644 --- a/rfreezefs.c +++ b/rfreezefs.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -228,7 +229,7 @@ static size_t nfs; /* Number of descriptors */ /*----- Cleanup -----------------------------------------------------------*/ #define EOM ((char *)0) -static void emerg(const char *msg,...) +static void EXECL_LIKE(0) emerg(const char *msg, ...) { va_list ap; @@ -251,7 +252,7 @@ static void partial_cleanup(size_t n) int i; int bad = 0; - for (i = 0; i < nfs; i++) { + for (i = 0; i < n; i++) { if (fs[i] == -1) emerg("not really thawing ", fsname[i], EOM); else if (fs[i] != -2) { @@ -274,12 +275,12 @@ static int sigcatch[] = { SIGILL, SIGSEGV, SIGBUS, SIGFPE, SIGABRT }; -static void sigmumble(int sig) +static void NORETURN sigmumble(int sig) { sigset_t ss; cleanup(); - emerg(strsignal(sig), 0); + emerg(strsignal(sig), EOM); signal(sig, SIG_DFL); sigemptyset(&ss); sigaddset(&ss, sig); @@ -302,17 +303,31 @@ static void help(FILE *fp) fputs("\n\ Freezes a filesystem temporarily, with some measure of safety.\n\ \n\ -The program listens for connections on a TCP port, and prints a line\n\ +The program listens for connections on a TCP port, and prints a number of\n\ +lines:\n\ +\n\ + PORT \n\ + TOKEN FREEZE \n\ + TOKEN FROZEN \n\ + TOKEN KEEPALIVE \n\ + TOKEN THAW \n\ + TOKEN THAWED \n\ + READY\n\ \n\ - PORT COOKIE\n\ +to standard output. You must connect to the , using TCP, and send\n\ +the FREEZE token followed by a newline within a short period of time. The\n\ +filesystems will then be frozen, and the FROZEN token written to the\n\ +connection. In order to keep the file system frozen, you must keep the\n\ +connection open, and periodically echo the KEEPALIVE token to it. To\n\ +release the filesystems, write the THAW token to the connection, followed\n\ +by a newline; the filesystem will be thawed, and the THAWED token echoed\n\ +back. If the connection closes, or no valid message is received within a\n\ +set period of time, or the program receives one of a variety of signals or\n\ +otherwise becomes unhappy, the filesystems are thawed again.\n\ \n\ -to standard output. You must connect to this PORT and send the COOKIE\n\ -followed by a newline within a short period of time. The filesystems\n\ -will then be frozen, and `OK' written to the connection. In order to\n\ -keep the file system frozen, you must keep the connection open, and\n\ -feed data into it. If the connection closes, or no data is received\n\ -within a set period of time, or the program receives one of a variety\n\ -of signals or otherwise becomes unhappy, the filesystems are thawed again.\n\ +The program exits with status zero if everything worked as planned, while\n\ +nonzero codes indicate failures of various kinds (see the manual); an exit\n\ +status of 112 means that thawing a filesystem failed.\n\ \n\ Options:\n\ \n\ @@ -542,7 +557,7 @@ connected: * Hopefully this will prevent bad things happening if we have an accident. */ - for (i = 0; i < sizeof(sigcatch)/sizeof(sigcatch[0]); i++) { + for (i = 0; i < N(sigcatch); i++) { if (signal(sigcatch[i], sigmumble) == SIG_ERR) die(2, "signal (%d): %s", i, strerror(errno)); }