作成したprocエントリにある量のデータをエクスポートするカーネルモジュールを作成しました。データの量が少ない場合は、簡単にprocエントリを作成してデータをエクスポートできます。しかし、データ量が大きいと、バッファオーバーフローエラーが発生します。大量のデータをprocに書き込む方法
私はデータをエクスポートするために関数int read_proc(char *buf,char **start,off_t offset,int count, int *eof, void *data)
を使用しました。そして、私は次のようにデータを書いた:
length =sprintf(buf,"The RESTART_SYSCALL address is %x\n",syscall_table[__NR_restart_syscall]);
length +=sprintf(buf+length,"The EXIT address is %x\n",syscall_table[__NR_exit]);
length +=sprintf(buf+length,"The FORK address is %x\n",syscall_table[__NR_fork]);
length +=sprintf(buf+length,"The READ address is %x\n",syscall_table[__NR_read]);
length +=sprintf(buf+length,"The WRITE address is %x\n",syscall_table[__NR_write]);
length +=sprintf(buf+length,"The OPEN address is %x\n",syscall_table[__NR_open]);
length +=sprintf(buf+length,"The CLOSE address is %x\n",syscall_table[__NR_close]);
length +=sprintf(buf+length,"The WAITPID address is %x\n",syscall_table[__NR_waitpid]);
length +=sprintf(buf+length,"The CREAT address is %x\n",syscall_table[__NR_creat]);
length +=sprintf(buf+length,"The LINK address is %x\n",syscall_table[__NR_link]);
length +=sprintf(buf+length,"The UNLINK address is %x\n",syscall_table[__NR_unlink]);
length +=sprintf(buf+length,"The EXECVE address is %x\n",syscall_table[__NR_execve]);
length +=sprintf(buf+length,"The TIME address is %x\n",syscall_table[__NR_time]);
length +=sprintf(buf+length,"The MKNOD address is %x\n",syscall_table[__NR_mknod]);
length +=sprintf(buf+length,"The LCHOWN address is %x\n",syscall_table[__NR_lchown]);
length +=sprintf(buf+length,"The BREAK address is %x\n",syscall_table[__NR_break]);
length +=sprintf(buf+length,"The OLDSTAT address is %x\n",syscall_table[__NR_oldstat]);
length +=sprintf(buf+length,"The LSEEK address is %x\n",syscall_table[__NR_lseek]);
length +=sprintf(buf+length,"The GETPID address is %x\n",syscall_table[__NR_getpid]);
-----------------------------------
---------------------------------
---------------------------------
私は、デフォルトでは4キロバイトである唯一のPAGE_SIZEが、エクスポートされていることを読みました。大量のデータをエクスポートする方法を見つけるためにLDDを参照しました。しかし、私はそこに書かれたものを理解できませんでした。誰もがこれで私を助けることができますか?
私は、 '/ proc/self/maps'または'/proc/vmallocinfo'を実行します。おそらく、各行を一度に1つずつ書き、何らかの状態を維持するでしょう。 –