Skip to Content.
Sympa Menu

poly-p-ux - [Poly-p-ux] /dev/one patch

poly-p-ux AT lists.ibiblio.org

Subject: The *official* poly-p-ux mailing list

List archive

Chronological Thread  
  • From: Poly-p man <polypolyman AT ibiblio.org>
  • To: poly-p-ux AT lists.ibiblio.org
  • Subject: [Poly-p-ux] /dev/one patch
  • Date: Mon, 31 Mar 2008 16:46:05 -0400

Hi, all. Attached is the /dev/one patch, untested by me at least, correctly
formatted for kernel patching. I will be including this in the 586 version of
poly-p-ux coming up, and will include it in all releases beyond this.

However, I was thinking that this could be sent to the kernel devs for
possible inclusion. So, FreeBSoD (the actual author of this, who is among us
right now), if you would like to send it to them (after I test it real
quick), that would be great, if you would like me to send it to them, that
would be great too, I'd be sure to add your name in the "from:" line (see
http://www.zipworld.com.au/%7Eakpm/linux/patches/stuff/tpp.txt ).

To the rest of you, have fun with it (patches correctly against 2.6.24.4, I'm
testing to make sure it works), and feedback would be nice.

poly-p man

--- a/drivers/char/mem.c	2008-01-24 17:58:37.000000000 -0500
+++ b/drivers/char/mem.c	2008-03-31 16:30:51.000000000 -0400
@@ -6,6 +6,9 @@
  *  Added devfs support. 
  *    Jan-11-1998, C. Scott Ananian <cananian AT alumni.princeton.edu>
  *  Shared /dev/zero mmaping support, Feb 2000, Kanoj Sarcar <kanoj AT sgi.com>
+ *
+ *  Added support for the /dev/one device. Originally intended for poly-p-ux
+ *    Feb-09-2008, Marcin Koziuk <marcin.koziuk AT gmail.com>
  */
 
 #include <linux/mm.h>
@@ -654,6 +657,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 +744,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,
@@ -765,6 +788,12 @@
 	.write		= write_zero,
 	.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
@@ -854,6 +883,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 +919,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;



Archive powered by MHonArc 2.6.24.

Top of Page