All pastes #800949 Raw Edit

Stuff

public text v1 · immutable
#800949 ·published 2007-11-28 21:29 UTC
rendered paste body
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>


#define DEVICE_NAME "/dev/toto"

int device_g = 0;



int main()
{

/* verifie que l'initialisation n'a pas deja ete faite */
if (device_g) {
	return 0;
}

/* ouvre le device */
device_g = open(DEVICE_NAME, O_RDWR);
if (device_g == -1) {
	printf("ERROR => %s\n", strerror(errno));
	// printf("ERROR => %m\n");
	return -1;
}

	return 0;
}