Change meaning of -swap option: rather than trying to use a kernel patch
which has been effectively dead since sometime around 2.1.something, do
an mlockall() so that the kernel won't throw us out.
The MCL_CURRENT | MCL_FUTURE bit might prove to be problematic, but if
so, we'll deal with it when we get there.
#include <syslog.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <syslog.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <errno.h>
#ifndef __GNUC__
#include <errno.h>
#ifndef __GNUC__
if (ioctl(nbd, NBD_SET_SOCK, sock) < 0)
err("Ioctl NBD_SET_SOCK failed: %m\n");
if (ioctl(nbd, NBD_SET_SOCK, sock) < 0)
err("Ioctl NBD_SET_SOCK failed: %m\n");
+/*
+ * If anyone ever forward-patches this patch, I'll happily re-enable
+ * this code. Until then...
#ifndef SO_SWAPPING
if (swap)
err("You have to compile me on machine with swapping patch enabled in order to use it later.");
#ifndef SO_SWAPPING
if (swap)
err("You have to compile me on machine with swapping patch enabled in order to use it later.");
if (setsockopt(sock, SOL_SOCKET, SO_SWAPPING, &one, sizeof(int)) < 0)
err("Could not enable swapping: %m");
#endif
if (setsockopt(sock, SOL_SOCKET, SO_SWAPPING, &one, sizeof(int)) < 0)
err("Could not enable swapping: %m");
#endif
+*/
+ mlockall(MCL_CURRENT | MCL_FUTURE);
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
}
++argv; --argc; /* skip programname */
}
++argv; --argc; /* skip programname */
if (strcmp(argv[0], "-d")==0) {
nbd = open(argv[1], O_RDWR);
if (nbd < 0)
if (strcmp(argv[0], "-d")==0) {
nbd = open(argv[1], O_RDWR);
if (nbd < 0)