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

Re: [bluetooth-dev] destroyed proc filesystem



Hi Peter,

Peter Kjellerstedt wrote:
> 
> First of all, please use the -u option to diff when creating
> a patch as that provides a context and makes it sooo much
> easier to read.
Yes, of course. The diff in my last posting was not meant to be a patch.
It should only point to the problem
because I didn't know where the really problem was :-) It was only for
discussion.
 
> Second, the code needs to support creating the /proc files
> for 2.0, 2.2 as well as 2.4, and most of your patch seems to
> be about removing support for Linux < 2.4. This also makes
> it very hard to see what you actually changed in the 2.4 case.
You're right. I could only test it on 2.4.x kernels. Please excuse my
ignorance.

Attached is a really patch against sdp.c that fixes the problem. The
patch mainly does three things:

1) filling out the file_operations struct is now done in the
2.4.x-kernel's manner. It uses the colon syntax.

2) The inode_operations struct is not needed. I removed it for 2.4.x
kernels. Perhaps this can also be done for	2.2.x and 2.0.x kernels.

3) This is the really bug fix I had to do for my PowerPC system (2.4.2
or 2.4.10). I had to replace the "sdp_srv" string from the
proc_dir_entry struct by a pointer to a constant string (see patch). I
am not sure why this helps. Perhaps anybody else knows. If anybody has a
better idea on how to solve my problem, if will test it and send a
further patch.

If my changes are ok, I will apply them on the other proc files, too. 
 
> Could you please provide a cleaner patch?
attached !

> And btw, the /proc files look perfectly fine on my 2.4.10
> system (little endian).
Yes, I have no problem on my PC, too.

Peter, can you apply the patch to the cvs ?

Matthias
--- axis_cvs/linux/drivers/char/bluetooth/sdp.c	Fri Sep 21 14:51:06 2001
+++ local/linux/drivers/char/bluetooth/sdp.c	Mon Oct 15 13:34:50 2001
@@ -158,8 +158,10 @@
 			      const char * buf, s32 count);
 
 #endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 static s32 sdp_proc_dir_entry_read(char *buf, char **start, off_t offset,
 				   s32 len, s32 unused);
+#endif
 
 #else /* USERMODE STACK */
 static s32 open_socket(char *name);
@@ -191,22 +193,13 @@
 	NULL,                   /* no special release code */
 	NULL                    /* can't fsync */
 };
-#else 
-static struct file_operations sdp_procfile_operation = {
-	NULL,                   /* module owner */
-	NULL,                   /* lseek - default */
-	sdp_database_read,      /* read - bad */
-	sdp_database_write,     /* write - bad */
-	NULL,                   /* readdir */
-	NULL,                   /* select - default */
-	NULL,                   /* ioctl - default */
-	NULL,                   /* mmap */
-	NULL,                   /* no special open code */
-	NULL,                   /* no special release code */
-	NULL                    /* can't fsync */
+#else
+struct file_operations sdp_procfile_operation = {
+	read:  sdp_database_read,
+	write: sdp_database_write,
 };
 #endif
- 
+
  /*
   * proc directories can do almost nothing..
   */
@@ -230,31 +223,14 @@
 	NULL,                   /* truncate */
 	NULL                    /* permission */
 };
-#else
-static struct inode_operations sdp_proc_inode_operations = {
-	NULL,                   /* create */
-	NULL,                   /* lookup */
-	NULL,                   /* link */
-	NULL,                   /* unlink */
-	NULL,                   /* symlink */
-	NULL,                   /* mkdir */
-	NULL,                   /* rmdir */
-	NULL,                   /* mknod */
-	NULL,                   /* rename */
-	NULL,                   /* readlink */
-	NULL,                   /* follow_link */
-	NULL,                   /* readpage */
-	NULL,                   /* writepage */
-	NULL,                   /* bmap */
-	NULL,                   /* truncate */
-	NULL                    /* permission */
-};
 #endif
 
+static const char sdp_proc_entry_name[] = "sdp_srv"; 
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 static struct proc_dir_entry sdp_proc_entry = {
 	0,
-	7, "sdp_srv",
+	7, sdp_proc_entry_name,
 	S_IFREG | S_IRUGO | S_IWUSR,
 	1, 0, 0,
 	0,
@@ -264,11 +240,11 @@
 #else
 static struct proc_dir_entry sdp_proc_entry = {
 	0,
-	7, "sdp_srv",
+	7, sdp_proc_entry_name,
 	S_IFREG | S_IRUGO | S_IWUSR,
 	1, 0, 0,
 	0,
-	&sdp_proc_inode_operations,
+	NULL,
 	&sdp_procfile_operation,
 };
 #endif /* LINUX_VERSION_CODE */
@@ -429,7 +405,6 @@
 			/* If the proc entry was registered successfully,    */
 			/* then set all the necessary structure information. */
 			/*---------------------------------------------------*/
-			entry->proc_iops = sdp_proc_entry.proc_iops;
 			entry->proc_fops = sdp_proc_entry.proc_fops;
 			procfs_status = 0;
 		}
@@ -879,6 +854,7 @@
 #endif
 
 #ifdef __KERNEL__
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 s32 sdp_proc_dir_entry_read(char *buf, char **start, off_t offset,
 			    s32 len, s32 unused)
 {
@@ -888,6 +864,7 @@
 	return sdp_database_read(NULL, NULL, buf, len);
 #endif
 }
+#endif /* LINUX_VERSION_CODE */
 
 #ifdef USE_NEW_PROC
 ssize_t sdp_database_read(struct file *f, char *buf,