回文章列表
作者supermin.bbs@ptt.cc ( ) 看板: linux
標題[問題] 請問有關撰寫/proc時所用的proc_read函式
時間批踢踢實業 (2008/06/19 Thu 21:48:01)
我使用kernel-2.6.17,撰寫kernel modules來記錄一些系統資訊,

使用與user space溝通的機制是/proc,在開完檔案之後指定read function大致如下:

int procfile_read(char *buffer, char **buffer_location,
                  off_t offset, int buffer_length, int *eof, void *data)
{
    if (offset > 0) {
        ret = 0;
    } else {
        *buffer_location = my_buffer;
    }

    bufferLength = 0;

    return bufferLength;
}

其中my_buffer以及bufferLength為全域變數,

我想在記錄完一堆東西之後使用cat /proc/myfile來看我記錄的東西

不過由於bufferLength頗大,超過10000bytes,而cat的結果被切掉了,

只能顯示部分內容,這時候該怎麼解決才能看到全部內容呢?



--
※ 發信站: 批踢踢實業坊(ptt.cc) 
◆ From: 140.113.215.191
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻