/dev/portと/dev/full
先の項目タイトルの流れで、ここでの2つの関連性まったくありましぇん。で、/dev/portは、カーネルコンパイルオプションCONFIG_DEVPORTで作成され、IOを参照するデバイスです。
write_port()は同じ処理で、inp()がoutp()に変わっただけって感しです。
/dev/fullは以下のとうりです。説明によると、DISKフルの検証を行うためらしいです。読み込みについては、常識的に/dev/zeroと言うことです。
#ifdef CONFIG_DEVPORT
static const struct file_operations port_fops = {
.llseek = memory_lseek,
.read = read_port,
.write = write_port,
.open = open_port,
};
#endif
read_port()で読み込み処理。access_ok()で指定されたバッファエンドがユーザ空間かまずチェック。OKなら、count分inp()でIOを読み込んで、__put_user()で、順次引数のユーザバッファーに設定するだけです。なお、読み込みサイズの最大をi < 65536としているのは、IOアドレスが16ビットという事でしょう。(たぶん)write_port()は同じ処理で、inp()がoutp()に変わっただけって感しです。
static ssize_t read_port(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long i = *ppos;
char __user *tmp = buf;
if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT;
while (count-- > 0 && i < 65536) {
if (__put_user(inb(i), tmp) < 0)
return -EFAULT;
i++;
tmp++;
}
*ppos = i;
return tmp-buf;
}
/dev/fullは以下のとうりです。説明によると、DISKフルの検証を行うためらしいです。読み込みについては、常識的に/dev/zeroと言うことです。
static const struct file_operations full_fops = {
.llseek = full_lseek,
.read = read_full,
.write = write_full,
};
#define read_full read_zero
static ssize_t write_full(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
return -ENOSPC;
}






