歡迎您光臨本站 註冊首頁

編譯linux內核 Documentation 為man手冊

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

對每一個linux內核以及驅動開發者來說,內核自帶的 Documentation目錄無疑是一個非常非常有用的參考資料和學習資料。建議多讀~

當我們在寫驅動或者修改內核的時候,可能需要用到某些kernel api,我們也想能夠像libc api那樣可以通過man手冊查看其使用方法,毫無疑問,直接到內核 source code 裡面去查找到相關的函數定義是一種方法,但是顯得比較麻煩。你可以將內核api安裝為man手冊,然後你就可以很方便的 man xxx-kernel-api 了。具體步驟如下(based on FC6 ):

(1)在kernel source的頂層目錄,執行make installmandocs就可以將man 手冊安裝到 /usr/local/man/man9下面了。

NOTES: 注意,如果在執行make installmandocs的時候需要其他的一些工具程序,可以使用yum工具來進行在線安裝,比如,我的系統在make installmandocs時報缺少xmlto,所以執行yum install xmlto安裝好需要的工具之後再執行make installmandocs就可以了。

自此,已經安裝好了。下面show一段: man copy_from_user
QUOTE:
COPY_FROM_USER(9) User Space Memory Access COPY_FROM_USER(9)

NAME
copy_from_user - Copy a block of data from user space.

SYNOPSIS
unsigned long copy_from_user (void * to, const void __user * from,
unsigned long n);

ARGUMENTS
to Destination address, in kernel space.

from Source address, in user space.

n Number of bytes to copy.

CONTEXT
User context only. This function may sleep.

DESCRIPTION
Copy data from user space to kernel space.

Returns number of bytes that could not be copied. On success, this will
be zero.

If some data could not be copied, this function will pad the copied
data to the requested size using zero bytes.

Kernel Hackers Manual January 2008 COPY_FROM_USER(9)

呵呵,還湊合吧!

PS: 不過缺點就是說明相對來說簡單了些,如果需要更詳細的說明,看內核代碼吧。

[火星人 ] 編譯linux內核 Documentation 為man手冊已經有628次圍觀

http://coctec.com/docs/linux/show-post-187460.html