pass through an arg
This commit is contained in:
parent
7e5df725d8
commit
424d185294
2 changed files with 12 additions and 6 deletions
|
@ -11,17 +11,22 @@
|
|||
|
||||
int main(int argc, char ** argv) {
|
||||
int fd = -1;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
fd = open(HELLOCTL, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Could not open %s\n", HELLOCTL);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int ret;
|
||||
if (ret = ioctl(fd, 1, 1) < 0) {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
done:
|
||||
close(fd);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ MODULE_VERSION("1.0");
|
|||
static long
|
||||
hello_control_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
printk(KERN_INFO "[%s] received command: %d\n", __this_module.name, cmd);
|
||||
char * temp = arg;
|
||||
printk(KERN_INFO "[%s] received command: %d (arg %s)\n", __this_module.name, cmd, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -43,11 +44,11 @@ static const struct file_operations hello_ctl_fops = {
|
|||
.read = hello_control_read,
|
||||
};
|
||||
|
||||
|
||||
static struct miscdevice hello_misc = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = "helloctl",
|
||||
.fops = &hello_ctl_fops,
|
||||
.mode = 0666,
|
||||
};
|
||||
|
||||
MODULE_ALIAS_MISCDEV(MISC_DYNAMIC_MINOR);
|
||||
|
|
Loading…
Reference in a new issue