33 lines
520 B
C++
33 lines
520 B
C++
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <sys/ioctl.h>
|
|
#include <unistd.h>
|
|
|
|
#include "ucli.h"
|
|
|
|
/**
|
|
* @brief 调用ioctl
|
|
*/
|
|
long diag_call_ioctl(unsigned long request, unsigned long arg) {
|
|
long ret = 0;
|
|
int fd;
|
|
|
|
fd = open(DEVICE, O_RDWR, 0);
|
|
if (fd < 0) {
|
|
printf("open %s error!\n", DEVICE);
|
|
return -EEXIST;
|
|
}
|
|
|
|
ret = ioctl(fd, request, arg);
|
|
if (ret < 0) {
|
|
printf("call cmd %lx fail, ret is %ld\n", request, ret);
|
|
goto err;
|
|
}
|
|
|
|
err:
|
|
close(fd);
|
|
return ret;
|
|
}
|
|
|