Skip to contentSkip to conversation

2.6.18-mm3 pktcdvd: make procfs interface optional

PATCH In review Thomas Maier 3 participants 7 messages Oct 3, 2006 – Oct 14, 2006 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 7/11 2.6.18-mm3 pktcdvd: make procfs interface optional

Hello,

this patch makes the procfs interface optional and groups the procfs functions together.
New kernel config parameter: CDROM_PKTCDVD_PROCINTF

http://people.freenet.de/BalaGi/download/pktcdvd-7-procfs-optional_2.6.18.patch

-Thomas Maier

drivers/block/Kconfig +25 -5
diff -urpN 6-sysfs/drivers/block/Kconfig 7-procfs-optional/drivers/block/Kconfig
@@ -428,17 +428,22 @@ config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
 	help
-	  If you have a CDROM drive that supports packet writing, say Y to
-	  include preliminary support. It should work with any MMC/Mt Fuji
-	  compliant ATAPI or SCSI drive, which is just about any newer CD
-	  writer.
+	  If you have a CDROM/DVD drive that supports packet writing, say
+	  Y to include preliminary support. It should work with any
+	  MMC/Mt Fuji compliant ATAPI or SCSI drive, which is just about
+	  any newer DVD/CD writer.
 
-	  Currently only writing to CD-RW, DVD-RW and DVD+RW discs is possible.
+	  Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs
+	  is possible.
 	  DVD-RW disks must be in restricted overwrite mode.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called pktcdvd.
 
+	  For further information see the file
+
+	    Documentation/cdrom/packet-writing.txt
+	  
 config CDROM_PKTCDVD_BUFFERS
 	int "Free buffers for data gathering"
 	depends on CDROM_PKTCDVD
@@ -458,6 +463,21 @@ config CDROM_PKTCDVD_WCACHE
 	  this option is dangerous unless the CD-RW media is known good, as we
 	  don't do deferred write error handling yet.
 
+config CDROM_PKTCDVD_PROCINTF
+	bool "Enable procfs interface"
+	depends on CDROM_PKTCDVD
+	default y
+	help
+	  Enable the proc filesystem interface for pktcdvd.
+	  The files can be found as:
+	  
+	  /proc/driver/pktcdvd/pktcdvd<idx>
+	  
+	  Also a misc device is added with a dynamic minor device id.
+	  See the entry in  /proc/misc  for the minor number.
+	  The misc pktcdvd driver supports ioctl calls, needed
+	  by the pktsetup tool found in udftools package.
+
 source "drivers/s390/block/Kconfig"
 
 config ATA_OVER_ETH
drivers/block/pktcdvd.c +124 -100

305 lines not on this page · raw message

include/linux/pktcdvd.h +9 -0
diff -urpN 6-sysfs/include/linux/pktcdvd.h 7-procfs-optional/include/linux/pktcdvd.h
@@ -108,12 +108,21 @@ struct pkt_ctrl_command {
 #define PACKET_CTRL_CMD		_IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command)
 
 #ifdef __KERNEL__
+#include <linux/config.h>
 #include <linux/blkdev.h>
 #include <linux/completion.h>
 #include <linux/cdrom.h>
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
 
+/* use (old) procfs interface? */
+#ifdef CONFIG_CDROM_PKTCDVD_PROCINTF
+#define PKT_USE_PROCFS  1
+#else
+#define PKT_USE_PROCFS  0
+#endif
+
+
 struct packet_settings
 {
 	__u32			size;		/* packet size in (512 byte) sectors */
#1 lore raw
Quoted 3 lines · Thomas Maier

this patch makes the procfs interface optional and groups the procfs functions together.
New kernel config parameter: CDROM_PKTCDVD_PROCINTF

The Kconfig help text update looks good (slightly modified). Andrew, please apply:

From: Thomas Maier <[email protected]>

pktcdvd: Update Kconfig help text.

---

 drivers/block/Kconfig |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/block/Kconfig +9 -5
index 17dc222..f7eb08b 100644
@@ -429,14 +429,18 @@ config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
 	help
-	  If you have a CDROM drive that supports packet writing, say Y to
-	  include preliminary support. It should work with any MMC/Mt Fuji
-	  compliant ATAPI or SCSI drive, which is just about any newer CD
-	  writer.
+	  If you have a CDROM/DVD drive that supports packet writing, say
+	  Y to include support. It should work with any MMC/Mt Fuji
+	  compliant ATAPI or SCSI drive, which is just about any newer
+	  DVD/CD writer.
 
-	  Currently only writing to CD-RW, DVD-RW and DVD+RW discs is possible.
+	  Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs
+	  is possible.
 	  DVD-RW disks must be in restricted overwrite mode.
 
+	  See the file <file:Documentation/cdrom/packet-writing.txt>
+	  for further information on the use of this driver.
+
 	  To compile this driver as a module, choose M here: the
 	  module will be called pktcdvd.
 
Signature · 2 lines
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
#2 lore raw

PATCH 1/2 2.6.19-rc1-mm1 pktcdvd: init pktdev_major

Hello,

this is a bugfix for pktcdvd.c:

pktdev_major must be initialized to 0.

drivers/block/pktcdvd.c +1 -1
diff -urpN linux-2.6.19-rc1-mm1/drivers/block/pktcdvd.c 1-init-pktdev_major/drivers/block/pktcdvd.c
@@ -83,7 +83,7 @@
 
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
-static int pktdev_major;
+static int pktdev_major = 0;
 static struct mutex ctl_mutex;	/* Serialize open/close/setup/teardown */
 static mempool_t *psd_pool;
 
#3 lore raw

Re: [PATCH 1/2] 2.6.19-rc1-mm1 pktcdvd: init pktdev_major

Quoted 1 line · Thomas Maier

pktdev_major must be initialized to 0.

No it doesn't. The BSS section is automatically initialized to 0. In fact, in the past there have been several patches for various parts of the kernel to remove explicit 0 initialization of global variables.

Signature · 2 lines
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
#4 lore raw
In reply to Thomas Maier
Quoted 3 lines · Thomas Maier

this patch makes the procfs interface optional and groups the procfs functions together.
New kernel config parameter: CDROM_PKTCDVD_PROCINTF

Given the fact that Linus doesn't allow breaking user space tools unless absolutely necessary, I don't think it makes sense to be able to disable the character device control code.

The /proc/driver/pktcdvd/pktcdvd? file only contains debugging stuff though, and the main reason it's not already in debugfs is that debugfs didn't exist when Jens wrote this driver.

Therefore a patch that unconditionally moves /proc/driver/pktcdvd/pktcdvd? to debugfs would make a lot of sense.

Also, the current change has another problem:

static int pkt_seq_show(struct seq_file *m, void *p) +{
+ struct pktcdvd_device *pd = m->private;
+ char buf[1024];
+

+       pkt_print_info(pd, buf, sizeof(buf));
+       seq_printf(m, "%s", buf);
+       return 0;

+}

This wastes 1K stack space, and it can corrupt the stack if the pkt_print_info() function wants to write more than 1K data.

Unconditionally moving to debugfs would remove the need for the pkt_print_info() function so the buf array wouldn't be needed any more.

Signature · 2 lines
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
#5 lore raw

Hello,

Am 05.10.2006, 21:59 Uhr, schrieb Peter Osterlund <[email protected]>:

Quoted 3 lines

Given the fact that Linus doesn't allow breaking user space tools unless absolutely necessary, I don't think it makes sense to be able to disable the character device control code.

Hmm, since it will be optional to leave the procfs interface in the kernel, it is on the admin / distribution builder to decide this. I know only one tool that uses this interface (pktsetup), maybe there are others, but if the sysfs interface will be available in future (?), there is another (simple) option to control the driver, using simple shell commands e.g.
And i read anywhere, that procfs should only contain process information in a far away (?) future ;)

Quoted 2 lines

Therefore a patch that unconditionally moves /proc/driver/pktcdvd/pktcdvd? to debugfs would make a lot of sense.

Then move it to debugfs and drop it from procfs.

Quoted 12 lines

Also, the current change has another problem:

static int pkt_seq_show(struct seq_file *m, void *p)

drivers/block/pktcdvd.c +8 -0
+{
+       struct pktcdvd_device *pd = m->private;
+       char buf[1024];
+
+       pkt_print_info(pd, buf, sizeof(buf));
+       seq_printf(m, "%s", buf);
+       return 0;
+}
Quoted 2 lines

This wastes 1K stack space, and it can corrupt the stack if the pkt_print_info() function wants to write more than 1K data.

Ok, 1k is a little bit high, since only about 300 chars are written into the buffer currently.
But also, pkt_print_info() would only write sizeof(buf) chars into the buffer.

-Thomas

#6 lore raw

Hi,

Quoted 4 lines · Thomas Maier

Ok, 1k is a little bit high, since only about 300 chars are written into the buffer currently.
But also, pkt_print_info() would only write sizeof(buf) chars into the buffer.

What about making pkt_print_info() accept a "struct seq_file *" instead and print directly into the seq_file buffer?

Regards

Ingo Oeser