[PATCH 2/2] Added "/dev/full" and "/dev/null" devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alexander Shiyan <shc_work@xxxxxxx>
---
 commands/stddev.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/commands/stddev.c b/commands/stddev.c
index 18fea94..8995fad 100644
--- a/commands/stddev.c
+++ b/commands/stddev.c
@@ -49,3 +49,58 @@ static int zero_init(void)
 }
 
 device_initcall(zero_init);
+
+static ssize_t full_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
+{
+	memset(buf, 0xff, count);
+	return count;
+}
+
+static struct file_operations fullops = {
+	.read  = full_read,
+	.lseek = dev_lseek_default,
+};
+
+static int full_init(void)
+{
+	struct cdev *cdev;
+
+	cdev = xzalloc(sizeof (*cdev));
+
+	cdev->name = "full";
+	cdev->size = ~0;
+	cdev->ops = &fullops;
+
+	devfs_create(cdev);
+
+	return 0;
+}
+
+device_initcall(full_init);
+
+static ssize_t null_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
+{
+	return count;
+}
+
+static struct file_operations nullops = {
+	.write = null_write,
+	.lseek = dev_lseek_default,
+};
+
+static int null_init(void)
+{
+	struct cdev *cdev;
+
+	cdev = xzalloc(sizeof (*cdev));
+
+	cdev->name = "null";
+	cdev->size = 0;
+	cdev->ops = &nullops;
+
+	devfs_create(cdev);
+
+	return 0;
+}
+
+device_initcall(null_init);
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux