2014-10-03 02:26:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#define HELLOCTL "/dev/helloctl"
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
int fd = -1;
|
2017-11-06 03:19:48 +00:00
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2014-10-03 02:26:28 +00:00
|
|
|
fd = open(HELLOCTL, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
fprintf(stderr, "Could not open %s\n", HELLOCTL);
|
|
|
|
_exit(1);
|
|
|
|
}
|
|
|
|
|
2017-11-06 03:19:48 +00:00
|
|
|
|
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
if (ret = ioctl(fd, 1, argv[i]) < 0) {
|
|
|
|
fprintf(stderr, "ioctl failed with: %s\n", strerror(ret));
|
|
|
|
goto done;
|
|
|
|
}
|
2014-10-03 02:26:28 +00:00
|
|
|
}
|
|
|
|
done:
|
|
|
|
close(fd);
|
|
|
|
}
|