You are not logged in.
How does /dev/null works on hardware level? or kernel level?
If you send something to /dev/null, what happens to those output bits? Are they still written somewhere? or a buffer or anywhere on the drive?
Offline
It's all implemented via file_operations (drivers/char/mem.c if you're curious to look yourself):
static const struct file_operations null_fops = {
.llseek = null_lseek,
.read = read_null,
.write = write_null,
.splice_write = splice_write_null,
};
write_null is what's called when you write to /dev/null. It always returns the same number of bytes that you write to it:
static ssize_t write_null(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
return count;
}
That's it. The buffer is just ignored.
Last edited by falconindy (2012-03-18 03:56:38)
Offline