2017-05-27 55 views
-1

繼教程:Ubuntu的內核(Vmware的)沒有在/usr/include/linux/fs.h來文件的結構file_operations結構

http://derekmolloy.ie/writing-a-linux-kernel-module-part-2-a-character-device/

執行在Ubuntu後:

sudo apt-get update 
apt-cache search linux-headers-$(uname -r) 
sudo apt-get install linux-headers-4.8.0-36-generic 
cd /usr/src/linux-headers-4.8.0-36 

爲什麼ubuntu內核(Vmware)在/usr/include/linux/fs.h文件中沒有file_operations結構?

struct file_operations { 
     struct module *owner; 
     loff_t (*llseek) (struct file *, loff_t, int); 
     ssize_t (*read) (struct file *, char *, size_t, loff_t *); 
     ssize_t (*write) (struct file *, const char *, size_t, loff_t *); 
    . 
    . 
    . 
    }; 

回答

0

這些標頭用於用戶空間程序。你爲什麼期望in-kernel fs.h文件在那裏?你在做什麼呢?

如果您檢查內核源代碼樹,您會看到它在usr/include/linux中包含一組單獨的頭文件。

您正在查找的可能軟件包名爲-devel(或-dev)。 apt-file search應該能夠告訴你,或者最好是手動的,無論你在這裏應該做什麼。

編輯:

教程手段的作者包括在內核源代碼樹/ LINUX/fs.h文件中的文件。

本教程的質量極差,不能遵循。此外,看起來你自己是一般的初學者程序員,在這種情況下,我強烈不鼓勵在這個階段玩內核。

+0

謝謝員工我編輯的問題與我試圖遵循的教程的鏈接。 – Ruben