Skip to contentSkip to conversation

example for userspace scanner

RFC PATCH In review Izik Eidus 1 participant 1 message Jan 21, 2008

Subsystems (2)
lore
Share & tools
lore

Izik Eidus

author
#0 lore raw

RFC PATCH 4/5 example for userspace scanner

Signature · 2 lines
-- 
woof.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include "linux/ksm.h"

int main()

{
	int fd;
	int fd_scan;
	int r;

	fd = open("/dev/ksm", O_RDWR | O_TRUNC, (mode_t)0600);
	if (fd == -1) {
		fprintf(stderr, "couldnt even open it\n");
		exit(1);
	}

	fd_scan = ioctl(fd, KSM_CREATE_SCAN);
	if (fd_scan == -1) {
		printf("KSM_CREATE_SCAN failed\n");
		exit(1);
	}
	printf("created scanner!\n");

	while(1) {
		r = ioctl(fd_scan, KSM_SCAN, 100);
		usleep(1000);
	}
	return 0;
}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel