2017-08-28 5 views
0

質問は素朴に思えるかもしれませんが、私はカーネル/ドライバのプログラミングには新しいです。ブロックデバイス上にデバイスマッパーを作成しましたが、これは問題なく動作しています。それはコンストラクタ/デストラクタであり、mapメソッドが呼び出されます。デバイスマッパーのための 'ioctl'署名

今、私はこのマッパーのためにioctlを書こうとしています。 IOCTLをデバイスのために書かれている場合は、次のシグネチャを有する:

int ioctl(int d, /* other args */); 

ファイル構造/記述子はIOCTLに期待されています。これは、ファイルへのアクセス権があるため、アプリケーションプロセスで簡単に使用できます。

しかし、デバイスマッパーのためのioctlは(構造体TARGET_TYPEで)次のシグネチャがあります。

​​

どのようにユーザアプリケーションが構造体dm_targetの知識がなくioctlを持つデバイスマッパーへのアクセスを得ることができますか?

答えて

0
-Ioctl which stand for Input Output control is a system call used in linux to implement system calls which are not be available in the 
kernel by default. 

-The major use of this is in case of handling some specific operations of a device for which the kernel does not have a system call by default. For eg: Ejecting the media from a "CD" drive. An ioctl command is implemented to give the eject system call to the cd drive. 

-ioctl(fd, cmd , INPARAM or OUTPARAM); 
      | 
     3rd arguement is INPARAM or OUTPARAM i.e we don't have to read a device, then how how to interact with device ? use ioctl. 

-open ioctl.h and check you will get more information 
    #define "ioctl name" __IOX("magic number","command number","argument type") 


static long char_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 
{ 
    /* verify arguemenst using access_ok() */ 
    /* impliment support of ioctl commands */ 
} 
関連する問題