4
Ioctl
명령어를 사용하여 char 디바이스 모듈을 쓰는 동안 오류가 발생했습니다.리눅스 커널에서 IOCTL 함수의 호환되지 않는 포인터로부터 에러 초기화 4.8.0-53- 일반 리눅스 민트 64 비트
static struct file_operations my_fops =
{
.unlocked_ioctl = my_ioctl, error is here. I can not fix this.
};
참고 : 내 모든 print_k
을 무시하십시오.
제발 도와주세요. 여러분 모두에게 감사드립니다.
static long my_ioctl(struct file *f,unsigned int cm,unsigned long arg[b])
{
int re;
unsigned long arg[3];
switch (cm)
{
case H_ADD:
arg[2] = arg[0] + arg[1];
print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);
break;
case H_SUB:
print_k ("Driver: Start ...\n");
arg[2] = arg[0] - arg[1];
print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);
break;
case H_MULL:
print_k ("Driver: Start ...\n");
arg[2] = arg[0] * arg[1];
print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);
break;
case H_DIV:
print_k ("Driver: Start ...\n");
arg[2] = arg[0]/arg[1];
print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);
break;
default:
print_k ("Driver: I don't have this operation!\n");
re = -Er;
break;
}
return re;
}
static struct file_operations my_fops =
{
.unlocked_ioctl = my_ioctl,
};
'static long my_ioctl (struct file * f, 부호없는 int cm, 부호없는 long arg [b])'가 잘못되었습니다. 마지막 인자는'arg [b]'가 아닌'unsigned long arg'이어야합니다. 마지막 인자가 일종의 배열에 대한 포인터가되도록 고안된 것이라면 그에 따라 함수 내에서 * 그것을 캐스팅해야합니다. –
(코드를 읽을 수 있도록) 서식을 고정했습니다. –
안녕하세요. @ BronislavElizavetin 답장을 보내 주셔서 감사합니다. 마지막 인수에 대해 유감입니다. 그건 실수 야. 그것은 서명되지 않은 long arg []입니다. 나는 약간의 테스트를했고 커널 버전 4.8보다 낮게 작동합니다. 불행히도, 그것은 내 자신의 리눅스 커널 버전 4.8 -64 비트에서 작동하지 않습니다. –