Skip to contentSkip to conversation

PATCH 2.4.0.10: Update hotplug

PATCH Jeff Garzik 2 participants 3 messages Nov 2, 2000 – Nov 4, 2000

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

Note - this is just an RFC patch, do not apply. It compiles, but is not tested.

Attached is a patch against 2.4.0-test10 which updates the kernel's hotplug capabilities per recent discussions (both public and private).

Major changes:
* pci: Execute /sbin/hotplug for each hotplug device insertion or removal
* net: Export network device hardware info to userspace as /proc/net/if/$IF/businfo
* net: Execute /sbin/network for each net device register/unregister

Minor changes:
* kbuild: CONFIG_HOTPLUG now requires CONFIG_KMOD
* epic100: demonstration of how a net device exports its bus info
* procfs: add standard method of exporting bus info to userspace. Currently ISA, PCI, and SBUS are supported.
* pci: support businfo
* sparc: support businfo
* usb: update /sbin/hotplug execution to pass event type (verb) as standardized cmd line arg

DaveM - netdevice.h seems like the best place to include businfo.h. Since it doesn't include anything but linux/types.h, that should eliminate any worry about a nightmare of nested includes...

Note - the patch to include/linux/pci.h will go away, that is a remnant of an earlier change. But it is included as you may need it to compile.

Signature · 4 lines
Jeff Garzik             | "Mind if I drive?"  -Sam
Building 1024           | "Not if you don't mind me clawing at the
MandrakeSoft            |  dash and shrieking like a cheerleader."
                        |                     -Max

Index: linux_2_4/Documentation/00-INDEX

Documentation/00-INDEX renamed from Documentation/00-INDEX:1.1.1.1 +2 -0
diff -u linux_2_4/Documentation/00-INDEX:1.1.1.1 linux_2_4/Documentation/00-INDEX:1.1.1.1.34.1
@@ -53,6 +53,8 @@
 	- notes about the floppy tape device driver
 hayes-esp.txt
 	- info on using the Hayes ESP serial driver.
+hotplug.txt
+	- kernel hotplug support
 i386/
 	- directory with info about Linux on the intel ix86 architecture.
 ide.txt

Index: linux_2_4/Documentation/hotplug.txt

Documentation/hotplug.txt new file +111 -0

111 lines not on this page · raw message

Index: linux_2_4/Documentation/networking/00-INDEX

Documentation/networking/00-INDEX renamed from Documentation/networking/00-INDEX:1.1.1.1 +2 -0
diff -u linux_2_4/Documentation/networking/00-INDEX:1.1.1.1 linux_2_4/Documentation/networking/00-INDEX:1.1.1.1.34.1
@@ -58,6 +58,8 @@
 	- info and "insmod" parameters for all network driver modules.
 policy-routing.txt
 	- IP policy-based routing
+proc-net-if.txt
+	- Description of /proc/net/if/* contents
 pt.txt
 	- the Gracilis Packetwin AX.25 device driver
 routing.txt

Index: linux_2_4/Documentation/networking/proc-net-if.txt

Documentation/networking/proc-net-if.txt new file +20 -0
diff -u /dev/null linux_2_4/Documentation/networking/proc-net-if.txt:1.1.2.1
@@ -0,0 +1,20 @@
+Contents of /proc/net/if/*:
+
+/proc/net/if is a container for per-interface procfs information.
+Each interface has its own directory, which contains the following
+pseudo-files:
+
+businfo
+	- Outputs a bus-specific string describing the hardware device
+	which owns this network interface.  Zero bytes are output if
+	no hardware info is associated with the network device.
+
+Examples:
+
+	$ cat /proc/net/if/eth0/businfo
+	PCI bus 0 devfn 0
+	$
+
+	$ cat /proc/net/if/lo/businfo
+	$
+

Index: linux_2_4/arch/alpha/config.in

arch/alpha/config.in renamed from arch/alpha/config.in:1.1.1.7 +3 -0
diff -u linux_2_4/arch/alpha/config.in:1.1.1.7 linux_2_4/arch/alpha/config.in:1.1.1.7.10.1
@@ -222,6 +222,9 @@
  
 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/arm/config.in

arch/arm/config.in renamed from arch/arm/config.in:1.1.1.8 +3 -0
diff -u linux_2_4/arch/arm/config.in:1.1.1.8 linux_2_4/arch/arm/config.in:1.1.1.8.16.1
@@ -242,6 +242,9 @@
 bool 'Support hot-pluggable devices' CONFIG_HOTPLUG
 if [ "$CONFIG_HOTPLUG" = "y" ]; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/i386/config.in

arch/i386/config.in renamed from arch/i386/config.in:1.1.1.7 +3 -0
diff -u linux_2_4/arch/i386/config.in:1.1.1.7 linux_2_4/arch/i386/config.in:1.1.1.7.10.2
@@ -202,6 +202,9 @@
 
 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/ia64/config.in

arch/ia64/config.in renamed from arch/ia64/config.in:1.1.1.8 +3 -0
diff -u linux_2_4/arch/ia64/config.in:1.1.1.8 linux_2_4/arch/ia64/config.in:1.1.1.8.14.1
@@ -98,6 +98,9 @@
 bool 'Support for hot-pluggable devices' CONFIG_HOTPLUG
 if [ "$CONFIG_HOTPLUG" = "y" ]; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/mips/config.in

arch/mips/config.in renamed from arch/mips/config.in:1.1.1.7 +3 -0
diff -u linux_2_4/arch/mips/config.in:1.1.1.7 linux_2_4/arch/mips/config.in:1.1.1.7.18.1
@@ -181,6 +181,9 @@
 
 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/mips64/config.in

arch/mips64/config.in renamed from arch/mips64/config.in:1.1.1.7 +3 -0
diff -u linux_2_4/arch/mips64/config.in:1.1.1.7 linux_2_4/arch/mips64/config.in:1.1.1.7.18.1
@@ -93,6 +93,9 @@
 
 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/ppc/config.in

arch/ppc/config.in renamed from arch/ppc/config.in:1.1.1.8 +3 -0
diff -u linux_2_4/arch/ppc/config.in:1.1.1.8 linux_2_4/arch/ppc/config.in:1.1.1.8.10.1
@@ -132,6 +132,9 @@
 
 if [ "$CONFIG_HOTPLUG" = "y" ]; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/arch/sh/config.in

arch/sh/config.in renamed from arch/sh/config.in:1.1.1.7 +3 -0
diff -u linux_2_4/arch/sh/config.in:1.1.1.7 linux_2_4/arch/sh/config.in:1.1.1.7.18.1
@@ -100,6 +100,9 @@
 
 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
    source drivers/pcmcia/Config.in
+   if [ "$CONFIG_KMOD" != "y" ] ; then
+      define_bool CONFIG_KMOD y
+   fi
 else
    define_bool CONFIG_PCMCIA n
 fi

Index: linux_2_4/drivers/net/epic100.c

drivers/net/epic100.c renamed from drivers/net/epic100.c:1.1.1.6 +4 -0
diff -u linux_2_4/drivers/net/epic100.c:1.1.1.6 linux_2_4/drivers/net/epic100.c:1.1.1.6.18.2
@@ -491,6 +491,10 @@
 	dev->watchdog_timeo = TX_TIMEOUT;
 	dev->tx_timeout = &epic_tx_timeout;
 
+	dev->bus_info.u.pci.pdev = pdev;
+	wmb();
+	dev->bus_info.bus_type = BUSINFO_PCI;
+
 	return 0;
 
 #ifndef USE_IO_OPS

Index: linux_2_4/drivers/pci/pci.c

drivers/pci/pci.c renamed from drivers/pci/pci.c:1.1.1.6 +62 -2

99 lines not on this page · raw message

Index: linux_2_4/drivers/sbus/sbus.c

drivers/sbus/sbus.c renamed from drivers/sbus/sbus.c:1.1.1.1 +20 -0
diff -u linux_2_4/drivers/sbus/sbus.c:1.1.1.1 linux_2_4/drivers/sbus/sbus.c:1.1.1.1.34.1
@@ -9,6 +9,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/businfo.h>
 
 #include <asm/system.h>
 #include <asm/sbus.h>
@@ -546,4 +547,23 @@
 		clock_probe();
 	}
 #endif
+}
+
+
+/*
+ * format for ASCII SBUS device identifiers:
+ *	SBUS bus A dev B slot C
+ * A - OBP node of SBUS
+ * B - OBP node of this device
+ * C - SBUS slot number
+ */
+void sprintf_sbus_businfo (char *buf, struct bus_info *bi)
+{
+	if (!bi->u.sbus.bus || !bi->u.sbus.dev)
+		buf[0] = 0;
+	else
+		sprintf (buf, "SBUS bus %d dev %d slot %d",
+			 bi->u.sbus.bus->prom_node,
+			 bi->u.sbus.dev->prom_node,
+			 bi->u.sbus.dev->slot);
 }

Index: linux_2_4/drivers/usb/usb.c

drivers/usb/usb.c renamed from drivers/usb/usb.c:1.1.1.12 +12 -20
diff -u linux_2_4/drivers/usb/usb.c:1.1.1.12 linux_2_4/drivers/usb/usb.c:1.1.1.12.2.2
@@ -574,7 +574,7 @@
 }
 
 
-#if	defined(CONFIG_KMOD) && defined(CONFIG_HOTPLUG)
+#ifdef CONFIG_HOTPLUG
 
 /*
  * USB hotplugging invokes what /proc/sys/kernel/hotplug says
@@ -639,9 +639,9 @@
  * cases, we know no other thread can recycle our address, since we must
  * already have been serialized enough to prevent that.
  */
-static void call_policy (char *verb, struct usb_device *dev)
+static void call_policy (struct usb_device *dev, int insert)
 {
-	char *argv [3], **envp, *buf, *scratch;
+	char *argv [4], *envp[8], *buf, *scratch;
 	int i = 0, value;
 
 	if (!hotplug_path [0])
@@ -652,27 +652,24 @@
 	}
 	if (!current->fs->root) {
 		/* statically linked USB is initted rather early */
-		dbg ("call_policy %s, num %d -- no FS yet", verb, dev->devnum);
+		dbg ("call_policy %s, num %d -- no FS yet",
+		     insert ? "add" : "del", dev->devnum);
 		return;
 	}
 	if (dev->devnum < 0) {
 		dbg ("device already deleted ??");
 		return;
 	}
-	if (!(envp = (char **) kmalloc (20 * sizeof (char *), GFP_KERNEL))) {
-		dbg ("enomem");
-		return;
-	}
 	if (!(buf = kmalloc (256, GFP_KERNEL))) {
-		kfree (envp);
 		dbg ("enomem2");
 		return;
 	}
 
-	/* only one standardized param to hotplug command: type */
+	/* args: /sbin/hotplug [bus type] [add/del] */
 	argv [0] = hotplug_path;
 	argv [1] = "usb";
-	argv [2] = 0;
+	argv [2] = insert ? "add" : "del";
+	argv [3] = 0;
 
 	/* minimal command environment */
 	envp [i++] = "HOME=/";
@@ -687,10 +684,6 @@
 	 */
 	scratch = buf;
 
-	/* action:  add, remove */
-	envp [i++] = scratch;
-	scratch += sprintf (scratch, "ACTION=%s", verb) + 1;
-
 #ifdef	CONFIG_USB_DEVICEFS
 	/* If this is available, userspace programs can directly read
 	 * all the device descriptors we don't tell them about.  Or
@@ -742,7 +735,6 @@
 	dbg ("kusbd: %s %s %d", argv [0], verb, dev->devnum);
 	value = call_usermodehelper (argv [0], argv, envp);
 	kfree (buf);
-	kfree (envp);
 	if (value != 0)
 		dbg ("kusbd policy returned 0x%x", value);
 }
@@ -750,10 +742,10 @@
 #else
 
 static inline void
-call_policy (char *verb, struct usb_device *dev)
+call_policy (struct usb_device *dev, int insert)
 { } 
 
-#endif	/* KMOD && HOTPLUG */
+#endif /* CONFIG_HOTPLUG */
 
 
 /*
@@ -1520,7 +1512,7 @@
 	}
 
 	/* Let policy agent unload modules etc */
-	call_policy ("remove", dev);
+	call_policy (dev, 0);
 
 	/* Free the device number and remove the /proc/bus/usb entry */
 	if (dev->devnum > 0) {
@@ -2037,7 +2029,7 @@
 	usb_find_drivers(dev);
 
 	/* userspace may load modules and/or configure further */
-	call_policy ("add", dev);
+	call_policy (dev, 1);
 
 	return 0;
 }

Index: linux_2_4/fs/proc/Makefile

fs/proc/Makefile renamed from fs/proc/Makefile:1.1.1.1 +2 -1
diff -u linux_2_4/fs/proc/Makefile:1.1.1.1 linux_2_4/fs/proc/Makefile:1.1.1.1.34.1
@@ -9,7 +9,8 @@
 
 O_TARGET := proc.o
 O_OBJS   := inode.o root.o base.o generic.o array.o \
-		kmsg.o proc_tty.o proc_misc.o kcore.o
+		kmsg.o proc_tty.o proc_misc.o kcore.o \
+		businfo.o
 OX_OBJS  := procfs_syms.o
 M_OBJS   := 
 

Index: linux_2_4/fs/proc/businfo.c

fs/proc/businfo.c new file +116 -0

116 lines not on this page · raw message

Index: linux_2_4/include/linux/businfo.h

include/linux/businfo.h new file +64 -0

64 lines not on this page · raw message

Index: linux_2_4/include/linux/netdevice.h

include/linux/netdevice.h renamed from include/linux/netdevice.h:1.1.1.8 +4 -0
diff -u linux_2_4/include/linux/netdevice.h:1.1.1.8 linux_2_4/include/linux/netdevice.h:1.1.1.8.2.2
@@ -28,6 +28,7 @@
 #include <linux/if.h>
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
+#include <linux/businfo.h>
 
 #include <asm/atomic.h>
 #include <asm/cache.h>
@@ -261,6 +262,9 @@
 	int			(*init)(struct net_device *dev);
 
 	/* ------- Fields preinitialized in Space.c finish here ------- */
+
+	/* Hardware bus identity, exported to userspace */
+	struct bus_info		bus_info;
 
 	struct net_device	*next_sched;
 

Index: linux_2_4/include/linux/pci.h

include/linux/pci.h renamed from include/linux/pci.h:1.1.1.2 +1 -0
diff -u linux_2_4/include/linux/pci.h:1.1.1.2 linux_2_4/include/linux/pci.h:1.1.1.2.18.2
@@ -286,6 +286,7 @@
 #include <linux/ioport.h>
 #include <linux/list.h>
 #include <linux/errno.h>
+#include <linux/businfo.h>
 
 /* This defines the direction arg to the DMA mapping routines. */
 #define PCI_DMA_BIDIRECTIONAL	0

int (*)(struct pci_dev *, u8, u8));
+

/* New-style probing supporting hot-pluggable devices */ int pci_register_driver(struct pci_driver *);
Index: linux_2_4/init/main.c

init/main.c renamed from init/main.c:1.1.1.10 +8 -0
diff -u linux_2_4/init/main.c:1.1.1.10 linux_2_4/init/main.c:1.1.1.10.6.1
@@ -95,6 +95,7 @@
 extern void signals_init(void);
 extern void bdev_init(void);
 extern int init_pcmcia_ds(void);
+extern void net_notifier_init(void);
 
 extern void free_initmem(void);
 extern void filesystem_setup(void);
@@ -710,6 +711,13 @@
 #ifdef CONFIG_PCMCIA
 	init_pcmcia_ds();		/* Do this last */
 #endif
+
+	/* do this after other 'do this last' stuff, because we want
+	 * to minimize spurious executions of /sbin/network
+	 * during boot-up
+	 */
+	net_notifier_init();
+
 	/* Mount the root filesystem.. */
 	mount_root();
 

Index: linux_2_4/net/core/dev.c

net/core/dev.c renamed from net/core/dev.c:1.1.1.8 +99 -6

159 lines not on this page · raw message

#1 lore raw

Date: Thu, 02 Nov 2000 03:05:45 -0500
From: Jeff Garzik <[email protected]>

DaveM - netdevice.h seems like the best place to include businfo.h. Since it doesn't include anything but linux/types.h, that should eliminate any worry about a nightmare of nested includes...

Ok.

Later,
David S. Miller
[email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw

PATCH 2.4.0.10 v2: Update hotplug

In reply to Jeff Garzik

Attached is a revised "hotplug update" patch, against 2.4.0-test10. It's looking close to submit-able now.

General change description is the same as the first patch, which can be found at
http://boudicca.tux.org/hypermail/linux-kernel/this-week/0785.html

Changes since the first patch:
* CONFIG_HOTPLUG and CONFIG_KMOD are now totally independent. It was an incestuous relationship anyway.
* exec_usermodehelper and call_usermodehelper are now unconditionally present
* new file Documentation/networking/netdevices.txt describes /sbin/network usage, and netdevice locking
* usb supports ACTION=$verb again, for compatibility with existing implementation
* don't use magic numbers for 'insert' value in code, use TRUE/FALSE
* ditch the sbus slot number
* use '/' separate in PCI environment variables, for consistency with USB
* eliminate EXPORT_SYMBOL(hotplug_path), modules don't need it
* constify netdev_event_name[] array

Now, time to track down that elusive thing called sleep... :)

Signature · 3 lines
Jeff Garzik             | Dinner is ready when
Building 1024           | the smoke alarm goes off.
MandrakeSoft            |	-/usr/games/fortune

Index: linux_2_4/Documentation/00-INDEX

Documentation/00-INDEX renamed from Documentation/00-INDEX:1.1.1.1 +2 -0
diff -u linux_2_4/Documentation/00-INDEX:1.1.1.1 linux_2_4/Documentation/00-INDEX:1.1.1.1.34.1
@@ -53,6 +53,8 @@
 	- notes about the floppy tape device driver
 hayes-esp.txt
 	- info on using the Hayes ESP serial driver.
+hotplug.txt
+	- kernel hotplug support
 i386/
 	- directory with info about Linux on the intel ix86 architecture.
 ide.txt

Index: linux_2_4/Documentation/hotplug.txt

Documentation/hotplug.txt new file +92 -0

92 lines not on this page · raw message

Index: linux_2_4/Documentation/networking/00-INDEX

Documentation/networking/00-INDEX renamed from Documentation/networking/00-INDEX:1.1.1.1 +4 -0
diff -u linux_2_4/Documentation/networking/00-INDEX:1.1.1.1 linux_2_4/Documentation/networking/00-INDEX:1.1.1.1.34.2
@@ -54,10 +54,14 @@
 	- Behaviour of cards under Multicast
 ncsa-telnet
 	- notes on how NCSA telnet (DOS) breaks with MTU discovery enabled.
+netdevices.txt
+	- notes on developing and using network devices
 net-modules.txt
 	- info and "insmod" parameters for all network driver modules.
 policy-routing.txt
 	- IP policy-based routing
+proc-net-if.txt
+	- Description of /proc/net/if/* contents
 pt.txt
 	- the Gracilis Packetwin AX.25 device driver
 routing.txt

Index: linux_2_4/Documentation/networking/netdevices.txt

Documentation/networking/netdevices.txt new file +69 -0

69 lines not on this page · raw message

Index: linux_2_4/Documentation/networking/proc-net-if.txt

Documentation/networking/proc-net-if.txt new file +20 -0
diff -u /dev/null linux_2_4/Documentation/networking/proc-net-if.txt:1.1.2.1
@@ -0,0 +1,20 @@
+Contents of /proc/net/if/*:
+
+/proc/net/if is a container for per-interface procfs information.
+Each interface has its own directory, which contains the following
+pseudo-files:
+
+businfo
+	- Outputs a bus-specific string describing the hardware device
+	which owns this network interface.  Zero bytes are output if
+	no hardware info is associated with the network device.
+
+Examples:
+
+	$ cat /proc/net/if/eth0/businfo
+	PCI bus 0 devfn 0
+	$
+
+	$ cat /proc/net/if/lo/businfo
+	$
+

Index: linux_2_4/drivers/net/epic100.c

drivers/net/epic100.c renamed from drivers/net/epic100.c:1.1.1.6 +4 -0
diff -u linux_2_4/drivers/net/epic100.c:1.1.1.6 linux_2_4/drivers/net/epic100.c:1.1.1.6.18.2
@@ -491,6 +491,10 @@
 	dev->watchdog_timeo = TX_TIMEOUT;
 	dev->tx_timeout = &epic_tx_timeout;
 
+	dev->bus_info.u.pci.pdev = pdev;
+	wmb();
+	dev->bus_info.bus_type = BUSINFO_PCI;
+
 	return 0;
 
 #ifndef USE_IO_OPS

Index: linux_2_4/drivers/pci/pci.c

drivers/pci/pci.c renamed from drivers/pci/pci.c:1.1.1.6 +69 -1

102 lines not on this page · raw message

Index: linux_2_4/drivers/sbus/sbus.c

drivers/sbus/sbus.c renamed from drivers/sbus/sbus.c:1.1.1.1 +18 -0
diff -u linux_2_4/drivers/sbus/sbus.c:1.1.1.1 linux_2_4/drivers/sbus/sbus.c:1.1.1.1.34.2
@@ -9,6 +9,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/businfo.h>
 
 #include <asm/system.h>
 #include <asm/sbus.h>
@@ -546,4 +547,21 @@
 		clock_probe();
 	}
 #endif
+}
+
+
+/*
+ * format for ASCII SBUS device identifiers:
+ *	SBUS bus A dev B
+ * A - OBP node of SBUS
+ * B - OBP node of this device
+ */
+void sprintf_sbus_businfo (char *buf, struct bus_info *bi)
+{
+	if (!bi->u.sbus.bus || !bi->u.sbus.dev)
+		buf[0] = 0;
+	else
+		sprintf (buf, "SBUS bus %d dev %d",
+			 bi->u.sbus.bus->prom_node,
+			 bi->u.sbus.dev->prom_node);
 }

Index: linux_2_4/drivers/usb/usb.c

drivers/usb/usb.c renamed from drivers/usb/usb.c:1.1.1.12 +20 -17
diff -u linux_2_4/drivers/usb/usb.c:1.1.1.12 linux_2_4/drivers/usb/usb.c:1.1.1.12.2.3
@@ -574,7 +574,7 @@
 }
 
 
-#if	defined(CONFIG_KMOD) && defined(CONFIG_HOTPLUG)
+#ifdef CONFIG_HOTPLUG
 
 /*
  * USB hotplugging invokes what /proc/sys/kernel/hotplug says
@@ -623,6 +623,13 @@
 	return retval;
 }
 
+
+/* defined for users of call_policy() */
+#ifndef FALSE
+#define FALSE 0
+#define TRUE (!FALSE)
+#endif
+
 /*
  * This invokes a user mode policy agent, typically helping to load driver
  * or other modules, configure the device, or both.
@@ -639,9 +646,9 @@
  * cases, we know no other thread can recycle our address, since we must
  * already have been serialized enough to prevent that.
  */
-static void call_policy (char *verb, struct usb_device *dev)
+static void call_policy (struct usb_device *dev, int insert)
 {
-	char *argv [3], **envp, *buf, *scratch;
+	char *argv [4], *envp[8], *buf, *scratch;
 	int i = 0, value;
 
 	if (!hotplug_path [0])
@@ -652,27 +659,24 @@
 	}
 	if (!current->fs->root) {
 		/* statically linked USB is initted rather early */
-		dbg ("call_policy %s, num %d -- no FS yet", verb, dev->devnum);
+		dbg ("call_policy %s, num %d -- no FS yet",
+		     insert ? "add" : "del", dev->devnum);
 		return;
 	}
 	if (dev->devnum < 0) {
 		dbg ("device already deleted ??");
 		return;
 	}
-	if (!(envp = (char **) kmalloc (20 * sizeof (char *), GFP_KERNEL))) {
-		dbg ("enomem");
-		return;
-	}
 	if (!(buf = kmalloc (256, GFP_KERNEL))) {
-		kfree (envp);
 		dbg ("enomem2");
 		return;
 	}
 
-	/* only one standardized param to hotplug command: type */
+	/* args: /sbin/hotplug [bus type] [add/del] */
 	argv [0] = hotplug_path;
 	argv [1] = "usb";
-	argv [2] = 0;
+	argv [2] = insert ? "add" : "del";
+	argv [3] = 0;
 
 	/* minimal command environment */
 	envp [i++] = "HOME=/";
@@ -689,7 +693,7 @@
 
 	/* action:  add, remove */
 	envp [i++] = scratch;
-	scratch += sprintf (scratch, "ACTION=%s", verb) + 1;
+	scratch += sprintf (scratch, "ACTION=%s", insert ? "add" : "remove") + 1;
 
 #ifdef	CONFIG_USB_DEVICEFS
 	/* If this is available, userspace programs can directly read
@@ -742,7 +746,6 @@
 	dbg ("kusbd: %s %s %d", argv [0], verb, dev->devnum);
 	value = call_usermodehelper (argv [0], argv, envp);
 	kfree (buf);
-	kfree (envp);
 	if (value != 0)
 		dbg ("kusbd policy returned 0x%x", value);
 }
@@ -750,10 +753,10 @@
 #else
 
 static inline void
-call_policy (char *verb, struct usb_device *dev)
+call_policy (struct usb_device *dev, int insert)
 { } 
 
-#endif	/* KMOD && HOTPLUG */
+#endif /* CONFIG_HOTPLUG */
 
 
 /*
@@ -1520,7 +1523,7 @@
 	}
 
 	/* Let policy agent unload modules etc */
-	call_policy ("remove", dev);
+	call_policy (dev, FALSE);
 
 	/* Free the device number and remove the /proc/bus/usb entry */
 	if (dev->devnum > 0) {
@@ -2037,7 +2040,7 @@
 	usb_find_drivers(dev);
 
 	/* userspace may load modules and/or configure further */
-	call_policy ("add", dev);
+	call_policy (dev, TRUE);
 
 	return 0;
 }

Index: linux_2_4/fs/proc/Makefile

fs/proc/Makefile renamed from fs/proc/Makefile:1.1.1.1 +2 -1
diff -u linux_2_4/fs/proc/Makefile:1.1.1.1 linux_2_4/fs/proc/Makefile:1.1.1.1.34.1
@@ -9,7 +9,8 @@
 
 O_TARGET := proc.o
 O_OBJS   := inode.o root.o base.o generic.o array.o \
-		kmsg.o proc_tty.o proc_misc.o kcore.o
+		kmsg.o proc_tty.o proc_misc.o kcore.o \
+		businfo.o
 OX_OBJS  := procfs_syms.o
 M_OBJS   := 
 

Index: linux_2_4/fs/proc/businfo.c

fs/proc/businfo.c new file +116 -0

116 lines not on this page · raw message

Index: linux_2_4/include/linux/businfo.h

include/linux/businfo.h new file +64 -0

64 lines not on this page · raw message

Index: linux_2_4/include/linux/netdevice.h

include/linux/netdevice.h renamed from include/linux/netdevice.h:1.1.1.8 +4 -0
diff -u linux_2_4/include/linux/netdevice.h:1.1.1.8 linux_2_4/include/linux/netdevice.h:1.1.1.8.2.2
@@ -28,6 +28,7 @@
 #include <linux/if.h>
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
+#include <linux/businfo.h>
 
 #include <asm/atomic.h>
 #include <asm/cache.h>
@@ -261,6 +262,9 @@
 	int			(*init)(struct net_device *dev);
 
 	/* ------- Fields preinitialized in Space.c finish here ------- */
+
+	/* Hardware bus identity, exported to userspace */
+	struct bus_info		bus_info;
 
 	struct net_device	*next_sched;
 

Index: linux_2_4/init/main.c

init/main.c renamed from init/main.c:1.1.1.10 +8 -0
diff -u linux_2_4/init/main.c:1.1.1.10 linux_2_4/init/main.c:1.1.1.10.6.1
@@ -95,6 +95,7 @@
 extern void signals_init(void);
 extern void bdev_init(void);
 extern int init_pcmcia_ds(void);
+extern void net_notifier_init(void);
 
 extern void free_initmem(void);
 extern void filesystem_setup(void);
@@ -710,6 +711,13 @@
 #ifdef CONFIG_PCMCIA
 	init_pcmcia_ds();		/* Do this last */
 #endif
+
+	/* do this after other 'do this last' stuff, because we want
+	 * to minimize spurious executions of /sbin/network
+	 * during boot-up
+	 */
+	net_notifier_init();
+
 	/* Mount the root filesystem.. */
 	mount_root();
 

Index: linux_2_4/kernel/Makefile

kernel/Makefile renamed from kernel/Makefile:1.1.1.3 +1 -5
diff -u linux_2_4/kernel/Makefile:1.1.1.3 linux_2_4/kernel/Makefile:1.1.1.3.24.2
@@ -12,14 +12,10 @@
 	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
 	    sysctl.o acct.o capability.o ptrace.o timer.o user.o
 
-OX_OBJS  += signal.o sys.o
+OX_OBJS  += signal.o sys.o kmod.o
 
 ifeq ($(CONFIG_UID16),y)
 O_OBJS += uid16.o
-endif
-
-ifeq ($(CONFIG_KMOD),y)
-O_OBJS += kmod.o
 endif
 
 ifeq ($(CONFIG_MODULES),y)

Index: linux_2_4/kernel/kmod.c

kernel/kmod.c renamed from kernel/kmod.c:1.1.1.6 +16 -5
diff -u linux_2_4/kernel/kmod.c:1.1.1.6 linux_2_4/kernel/kmod.c:1.1.1.6.18.1
@@ -16,17 +16,13 @@
 #define __KERNEL_SYSCALLS__
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/unistd.h>
 #include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
-/*
-	modprobe_path is set via /proc/sys.
-*/
-char modprobe_path[256] = "/sbin/modprobe";
-
 extern int max_threads;
 
 static inline void
@@ -130,6 +126,13 @@
 	return 0;
 }
 
+#ifdef CONFIG_KMOD
+
+/*
+	modprobe_path is set via /proc/sys.
+*/
+char modprobe_path[256] = "/sbin/modprobe";
+
 static int exec_modprobe(void * module_name)
 {
 	static char * envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
@@ -226,6 +229,7 @@
 	}
 	return 0;
 }
+#endif /* CONFIG_KMOD */
 
 
 #ifdef CONFIG_HOTPLUG
@@ -247,6 +251,8 @@
 */
 char hotplug_path[256] = "/sbin/hotplug";
 
+#endif /* CONFIG_HOTPLUG */
+
 
 static int exec_helper (void *arg)
 {
@@ -286,5 +292,10 @@
 	return retval;
 }
 
+EXPORT_SYMBOL(exec_usermodehelper);
+EXPORT_SYMBOL(call_usermodehelper);
+
+#ifdef CONFIG_KMOD
+EXPORT_SYMBOL(request_module);
 #endif
 

Index: linux_2_4/kernel/ksyms.c

kernel/ksyms.c renamed from kernel/ksyms.c:1.1.1.10 +0 -9
diff -u linux_2_4/kernel/ksyms.c:1.1.1.10 linux_2_4/kernel/ksyms.c:1.1.1.10.4.1
@@ -71,15 +71,6 @@
 #endif
 
 
-#ifdef CONFIG_KMOD
-EXPORT_SYMBOL(request_module);
-EXPORT_SYMBOL(exec_usermodehelper);
-#ifdef CONFIG_HOTPLUG
-EXPORT_SYMBOL(hotplug_path);
-EXPORT_SYMBOL(call_usermodehelper);
-#endif
-#endif
-
 #ifdef CONFIG_MODULES
 EXPORT_SYMBOL(get_module_symbol);
 EXPORT_SYMBOL(put_module_symbol);

Index: linux_2_4/kernel/sysctl.c

kernel/sysctl.c renamed from kernel/sysctl.c:1.1.1.7 +2 -2
diff -u linux_2_4/kernel/sysctl.c:1.1.1.7 linux_2_4/kernel/sysctl.c:1.1.1.7.2.1
@@ -54,10 +54,10 @@
 
 #ifdef CONFIG_KMOD
 extern char modprobe_path[];
+#endif
 #ifdef CONFIG_HOTPLUG
 extern char hotplug_path[];
 #endif
-#endif
 #ifdef CONFIG_CHR_DEV_SG
 extern int sg_big_buff;
 #endif
@@ -188,10 +188,10 @@
 #ifdef CONFIG_KMOD
 	{KERN_MODPROBE, "modprobe", &modprobe_path, 256,
 	 0644, NULL, &proc_dostring, &sysctl_string },
+#endif
 #ifdef CONFIG_HOTPLUG
 	{KERN_HOTPLUG, "hotplug", &hotplug_path, 256,
 	 0644, NULL, &proc_dostring, &sysctl_string },
-#endif
 #endif
 #ifdef CONFIG_CHR_DEV_SG
 	{KERN_SG_BIG_BUFF, "sg-big-buff", &sg_big_buff, sizeof (int),

Index: linux_2_4/net/core/dev.c

net/core/dev.c renamed from net/core/dev.c:1.1.1.8 +99 -6

159 lines not on this page · raw message