Skip to contentSkip to conversation

fix /proc/scsi/sg/devices when no SCSI devices

PATCH In review Tony Battersby 2 participants 2 messages Jan 22, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix /proc/scsi/sg/devices when no SCSI devices

The patch "[SCSI] sg: use idr to replace static arrays" in 2.6.24-rc1 causes a bogus line to appear in /proc/scsi/sg/devices containing "-1 -1 -1 -1 -1 -1 -1 -1 -1" when there are no SCSI devices in the system. In 2.6.23, /proc/scsi/sg/devices is empty when there are no SCSI devices in the system. A similar problem exists with /proc/scsi/sg/device_strs. The following patch restores the behavior of 2.6.23.

---

drivers/scsi/sg.c renamed from drivers/scsi/sg.c.orig +1 -1
@@ -2521,7 +2521,7 @@ sg_idr_max_id(int id, void *p, void *dat
 static int
 sg_last_dev(void)
 {
-	int k = 0;
+	int k = -1;
 	unsigned long iflags;
 
 	read_lock_irqsave(&sg_index_lock, iflags);
#1 lore raw
Quoted 14 lines · Tony Battersby

The patch "[SCSI] sg: use idr to replace static arrays" in 2.6.24-rc1 causes a bogus line to appear in /proc/scsi/sg/devices containing "-1 -1 -1 -1 -1 -1 -1 -1 -1" when there are no SCSI devices in the system. In 2.6.23, /proc/scsi/sg/devices is empty when there are no SCSI devices in the system. A similar problem exists with /proc/scsi/sg/device_strs. The following patch restores the behavior of 2.6.23.

---

drivers/scsi/sg.c renamed from drivers/scsi/sg.c.orig +0 -0
@@ -2521,7 +2521,7 @@ sg_idr_max_id(int id, void *p, void *dat
 static int

drivers/scsi/sg.c sg_idr_max_id(int id, void *p, void *dat

Quoted 10 lines
drivers/scsi/sg.c renamed from drivers/scsi/sg.c.orig +1 -2
 sg_last_dev(void)
 {
-	int k = 0;
+	int k = -1;
 	unsigned long iflags;
 
 	read_lock_irqsave(&sg_index_lock, iflags);
 
 
-

Tony,
Thanks.