compat IOCTL

2021. 9. 27. 13:27Linux

    목차
반응형

 

1. About compat IOCTL

           64-bit kernel 상에서 동작하는 32-bit program,
           ioctl 호출 시, kernel ioctol .compat_ioctl divert
 
ex.
const struct file_operations snd_pcm_f_ops[2] = {
{

.unlocked_ioctl = snd_pcm_playback_ioctl,
.compat_ioctl = snd_pcm_ioctl_compat,

}, …
 

 

 

2. Ex. Of compat IOCTL

           snd_pcm_ioctl_compat (..., unsigned long arg) {
                     void __user *argp = compat_ptr(arg);
                     snd_pcm_playback_ioctl1(file, substream, cmd, argp);
        }
 
 
           snd_pcm_playback_ioctl1(..., void __user *arg) {
                     struct snd_xferi xferi;
                     struct snd_xferi __user *_xferi = arg;
 
                     copy_from_user(&xferi, _xferi, sizeof(xferi))
          
                     result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames);
                     __put_user(result, &_xferi->result);
        }

 

 

 

kernel config에서 아래 config를 enable 해 줘야 compat으로 동작함

CONFIG_COMPAT

 

 

 

반응형

'Linux' 카테고리의 다른 글

virtual address space  (0) 2021.12.13
process scheduling  (0) 2021.12.13
virtual address space  (0) 2021.09.27
input driver  (0) 2021.09.27
System call  (0) 2021.09.27