FreeBSoD |
03-03-2008 07:07 AM |
If you're still interested, I wrote a kernel patch for /dev/one support. Apply to drivers/char/mem.c.
Code:
--- mem.c.orig 2008-02-13 21:01:54.000000000 +0100
+++ mem.c 2008-02-14 00:11:53.000000000 +0100
@@ -8,6 +8,11 @@
* Shared /dev/zero mmaping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
*/
+/*
+ * Added support for the /dev/one device. Intended for poly-p-ux.
+ * Feb-09-2008, Marcin Koziuk <marcin.koziuk@planet.nl>
+ */
+
#include <linux/mm.h>
#include <linux/miscdevice.h>
#include <linux/slab.h>
@@ -654,6 +659,23 @@
return written ? written : -EFAULT;
}
+static ssize_t read_one(struct file * file, char __user * buf,
+ size_t count, loff_t *ppos)
+{
+ size_t written;
+ unsigned long unwritten;
+ static int one = ~0;
+
+ for (written = 0; written < count; written++) {
+ unwritten = copy_to_user(&buf[written], &one, 1);
+ if (unwritten)
+ break;
+ cond_resched();
+ }
+
+ return written ? written : -EFAULT;
+}
+
static int mmap_zero(struct file * file, struct vm_area_struct * vma)
{
#ifndef CONFIG_MMU
@@ -724,6 +746,9 @@
#define open_mem open_port
#define open_kmem open_mem
#define open_oldmem open_mem
+#define one_lseek null_lseek
+#define write_one write_null
+#define mmap_one mmap_zero
static const struct file_operations mem_fops = {
.llseek = memory_lseek,
@@ -766,6 +791,12 @@
.mmap = mmap_zero,
};
+static const struct file_operations one_fops = {
+ .llseek = one_lseek,
+ .read = read_one,
+ .write = write_one,
+ .mmap = mmap_one,
+};
/*
* capabilities for /dev/zero
* - permits private mappings, "copies" are taken of the source of zeros
@@ -854,6 +885,10 @@
filp->f_op = &oldmem_fops;
break;
#endif
+ case 13:
+ filp->f_mapping->backing_dev_info = &zero_bdi;
+ filp->f_op = &one_fops;
+ break;
default:
return -ENXIO;
}
@@ -886,6 +921,7 @@
#ifdef CONFIG_CRASH_DUMP
{12,"oldmem", S_IRUSR | S_IWUSR | S_IRGRP, &oldmem_fops},
#endif
+ {13,"one", S_IRUGO | S_IWUGO, &one_fops},
};
static struct class *mem_class;
|