回覆列表
  • 1 # 使用者2458114238191884

    嵌教影片部驅程式碼及應用程式程式碼:

    ********************************************************************

    //memdev.c

    static const struct file_operations mem_fops =

    {

    .owner = THIS_MODULE,

    .llseek = mem_llseek,

    .read = mem_read,

    .write = mem_write,

    .open = mem_open,

    .release = mem_release,

    };

    **********************************************************************

    //app-mem.c

    /*打裝置檔案*/

    fp0 = fopen("/dev/memdev0","r+");

    /*寫入裝置*/

    fwrite(Buf, sizeof(Buf), 1, fp0);

    /*重新定位檔案位置(思考沒該指令何)*/

    fseek(fp0,0,SEEK_SET);//呼叫mem_llseek()定位

    /*讀裝置*/

    fread(Buf, sizeof(Buf), 1, fp0);

    呼叫函式名與fopen,fwrite,fread,fseek與file_operation指標名open,write.read,llseek核心何知道應該呼叫哪函式

  • 中秋節和大豐收的關聯?
  • 狙擊手的射擊水準和射擊運動員相比,誰厲害?狙擊手退役能當運動員嗎?