--- read_write.c.orig	Sat Feb 23 03:01:27 2002
+++ read_write.c	Sun Feb 24 16:45:48 2002
@@ -20,6 +20,68 @@
 	mmap:		generic_file_mmap,
 };
 
+#define COMMAND_LEN 15
+void reportread_write(const char* func, struct file* file) {
+  struct task_struct *cur = current;
+  char *name=0, *np;
+  /* Make room for at least one NULL terminaltion */
+  char commandname[COMMAND_LEN+1];
+  int len;
+
+  if (file && file->f_dentry && ((file->f_dentry)->d_name).name) {
+    struct dentry* dp = file->f_dentry;
+    struct mm_struct *mm;
+
+    mm = cur->mm;
+
+    /* When does this happen?? Who knows */
+    if (! (mm))
+      return;
+
+    len = mm->arg_end - mm->arg_start;
+    len = len < COMMAND_LEN ? len : COMMAND_LEN;
+    if (access_process_vm(cur, mm->arg_start, commandname, len, 0) <= 0)
+      return;
+    /* Make sure there at least one NULL termination */
+    commandname[len]=0;
+
+    if ( (strncmp("/sbin/syslogd", commandname, 13) == 0) ||
+	 (strncmp("/sbin/klogd", commandname, 11) == 0) ) {
+      return;
+    }
+
+    /* This is in fact a char device, and no char */
+    /* devices are disks... or this is a nodev filesystem */
+    if (dp->d_inode->i_cdev ||
+	! (dp->d_inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV))
+      return;
+
+    if (!(name = (char*) kmalloc(20000, GFP_KERNEL)))
+      return;
+
+    np = name + 20000-2;
+    np[1] = '\0';
+    
+    do {
+      char* cp = (dp->d_name).name + 
+	(dp->d_name).len;
+      int len = (dp->d_name).len;
+      while(len--)
+	*np-- = *--cp;
+      if (*(((dp->d_parent)->d_name).name) != '/')
+	*np-- = '/';
+    } while (dp != dp->d_parent && (dp = dp->d_parent));
+    np++;
+
+    printk("%s(%i):%s %s\n",
+	   commandname,
+	   cur->pid,
+	   func,
+	   np);
+    kfree(name);
+  }
+}
+
 ssize_t generic_read_dir(struct file *filp, char *buf, size_t siz, loff_t *ppos)
 {
 	return -EISDIR;
@@ -103,6 +165,7 @@
 	if (origin <= 2) {
 		loff_t res = llseek(file, offset, origin);
 		retval = res;
+		reportread_write(__FUNCTION__, file);
 		if (res != (loff_t)retval)
 			retval = -EOVERFLOW;	/* LFS: should only happen on 32 bit platforms */
 	}
@@ -131,6 +194,7 @@
 	offset = llseek(file, ((loff_t) offset_high << 32) | offset_low,
 			origin);
 
+	reportread_write(__FUNCTION__, file);
 	retval = (int)offset;
 	if (offset >= 0) {
 		retval = -EFAULT;
@@ -153,6 +217,7 @@
 	file = fget(fd);
 	if (file) {
 		if (file->f_mode & FMODE_READ) {
+		  reportread_write(__FUNCTION__, file);
 			ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
 						file, file->f_pos, count);
 			if (!ret) {
@@ -180,6 +245,7 @@
 	if (file) {
 		if (file->f_mode & FMODE_WRITE) {
 			struct inode *inode = file->f_dentry->d_inode;
+			reportread_write(__FUNCTION__, file);
 			ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file,
 				file->f_pos, count);
 			if (!ret) {
@@ -235,7 +301,7 @@
 	if (copy_from_user(iov, vector, count*sizeof(*vector)))
 		goto out;
 
-	/* BSD readv/writev returns EINVAL if one of the iov_len
+	/* BSD readv/writev returns EINVAL if oe of the iov_len
 	   values < 0 or tot_len overflowed a 32-bit integer. -ink */
 	tot_len = 0;
 	ret = -EINVAL;
@@ -312,8 +378,10 @@
 	if (!file)
 		goto bad_file;
 	if (file->f_op && (file->f_mode & FMODE_READ) &&
-	    (file->f_op->readv || file->f_op->read))
+	    (file->f_op->readv || file->f_op->read)) {
 		ret = do_readv_writev(VERIFY_WRITE, file, vector, count);
+		reportread_write(__FUNCTION__, file);
+	}
 	fput(file);
 
 bad_file:
@@ -332,8 +400,10 @@
 	if (!file)
 		goto bad_file;
 	if (file->f_op && (file->f_mode & FMODE_WRITE) &&
-	    (file->f_op->writev || file->f_op->write))
+	    (file->f_op->writev || file->f_op->write)){
 		ret = do_readv_writev(VERIFY_READ, file, vector, count);
+		reportread_write(__FUNCTION__, file);
+	}
 	fput(file);
 
 bad_file:
@@ -359,6 +429,8 @@
 		goto out;
 	ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
 				file, pos, count);
+	reportread_write(__FUNCTION__, file);
+
 	if (ret)
 		goto out;
 	ret = -EINVAL;
@@ -366,6 +438,7 @@
 		goto out;
 	if (pos < 0)
 		goto out;
+	reportread_write(__FUNCTION__, file);
 	ret = read(file, buf, count, &pos);
 	if (ret > 0)
 		inode_dir_notify(file->f_dentry->d_parent->d_inode, DN_ACCESS);
@@ -398,6 +471,7 @@
 	if (pos < 0)
 		goto out;
 
+	reportread_write(__FUNCTION__, file);
 	ret = write(file, buf, count, &pos);
 	if (ret > 0)
 		inode_dir_notify(file->f_dentry->d_parent->d_inode, DN_MODIFY);
@@ -406,3 +480,4 @@
 bad_file:
 	return ret;
 }
+

