kobject_uevent CONFIG_SYSFS=n build fix
Subsystems (3)
PATCH 1/1 kobject_uevent CONFIG_SYSFS=n build fix
Hello,
In 2.6.16-rc6 (probably in earlier rc as well),
following build error occurs with CONFIG_SYSFS=n.
kernel/built-in.o(.data+0x1d40): undefined reference to uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x5c1): In function kobject_uevent':
/build/rc6/source/lib/kobject_uevent.c:152: undefined reference to uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x5d0):/build/rc6/source/lib/kobject_uevent.c:152: undefined reference to uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x901):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x910):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to uevent_helper'
This seems to be caused by mismatch of build condition. uevent_seqnum and uevent_helper are conditional to CONFIG_SYSFS. While they are referenced if CONFIG_HOTPLUG (and CONFIG_NET) is enabled.
Attached patch consolidates them to CONFIG_HOTPLUG && CONFIG_NET.
I tried with (!CONFIG_NET && CONFIG_SYSFS) and
(CONFIG_NET && !CONFIG_SYSFS).
Both built ok.
So I think it doesn't conflict with "[PATCH] kobject_uevent CONFIG_NET=n fix" which is in 2.6.16-rc6.
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Solutions (America), Inc.
CONFIG_SYSFS=n fails to build due to mismatch of conditions for uevent_seqnum and uevent_helper.
kernel/built-in.o(.data+0x1d40): undefined reference to uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x5c1): In function kobject_uevent':
/build/rc6/source/lib/kobject_uevent.c:152: undefined reference to uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x5d0):/build/rc6/source/lib/kobject_uevent.c:152: undefined reference to uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x901):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x910):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to uevent_helper'
lib/kobject_uevent.c +3 -0
@@ -26,6 +26,9 @@#define NUM_ENVP 32/* number of env pointers */ #if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET ) +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; +static DEFINE_SPINLOCK (sequence_lock);static struct sock *uevent_sock;
kernel/sysctl.c +1 -1
@@ -399,7 +399,7 @@ static ctl_table kern_table[] = { .strategy = &sysctl_string, },#endif -#ifdef CONFIG_HOTPLUG +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET ) { .ctl_name = KERN_HOTPLUG, .procname = "hotplug",
kernel/ksysfs.c +2 -5
@@ -15,9 +15,6 @@#include <linux/module.h> #include <linux/init.h> -u64 uevent_seqnum; -char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; -#define KERNEL_ATTR_RO (_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
@@ -25,7 +22,7 @@ static struct subsys_attribute _name##_a static struct subsys_attribute _name##_attr = \ __ATTR(_name, 0644, _name##_show, _name##_store) -#ifdef CONFIG_HOTPLUG +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )/* current uevent sequence number */ static ssize_t uevent_seqnum_show (struct subsystem *subsys,char *page) {
@@ -55,7 +52,7 @@ decl_subsys(kernel, NULL, NULL);EXPORT_SYMBOL_GPL (kernel_subsys); static struct attribute * kernel_attrs[] = { -#ifdef CONFIG_HOTPLUG +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET ) &uevent_seqnum_attr.attr, &uevent_helper_attr.attr,#endif
include/linux/kobject.h +3 -0
@@ -27,6 +27,8 @@#include <asm/atomic.h> #define KOBJ_NAME_LEN 20 + +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )#define UEVENT_HELPER_PATH_LEN 256/* path to the userspace helper executed on an event */
@@ -34,6 +36,7 @@ extern char uevent_helper[];/* counter to tag the uevent, read only except for the kobject core */ extern u64 uevent_seqnum; +#endif /* the actions here must match the proper string in lib/kobject_uevent.c */ typedef int __bitwise kobject_action_t ;
Quoted 44 lines · Jun'ichi Nomura
Hello,
In 2.6.16-rc6 (probably in earlier rc as well),
following build error occurs withCONFIG_SYSFS=n.kernel/built-in.o(.data+0x1d40): undefined reference to
uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x5c1): In functionkobject_uevent':
/build/rc6/source/lib/kobject_uevent.c:152: undefined reference touevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x5d0):/build/rc6/source/lib/kobject_uevent.c:152: undefined reference touevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x901):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference touevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x910):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference touevent_helper'This seems to be caused by mismatch of build condition.
uevent_seqnumanduevent_helperare conditional toCONFIG_SYSFS. While they are referenced ifCONFIG_HOTPLUG(andCONFIG_NET) is enabled.Attached patch consolidates them to
CONFIG_HOTPLUG&&CONFIG_NET.I tried with (!CONFIG_NET &&
CONFIG_SYSFS) and
(CONFIG_NET&& !CONFIG_SYSFS).
Both built ok.
So I think it doesn't conflict with "[PATCH]kobject_ueventCONFIG_NET=nfix" which is in 2.6.16-rc6.Thanks,
Signature · 13 lines
Jun'ichi Nomura, NEC Solutions (America), Inc. CONFIG_SYSFS=n fails to build due to mismatch of conditions for uevent_seqnum and uevent_helper. kernel/built-in.o(.data+0x1d40): undefined reference to `uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x5c1): In function `kobject_uevent': /build/rc6/source/lib/kobject_uevent.c:152: undefined reference to `uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x5d0):/build/rc6/source/lib/kobject_uevent.c:152: undefined reference to `uevent_seqnum' lib/lib.a(kobject_uevent.o)(.text+0x901):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to `uevent_helper' lib/lib.a(kobject_uevent.o)(.text+0x910):/build/rc6/source/lib/kobject_uevent.c:182: undefined reference to `uevent_helper' Signed-off-by: Jun'ichi Nomura <[email protected]>
lib/kobject_uevent.c line 30
Quoted 5 lines
lib/kobject_uevent.c +2
-0@@ -26,6 +26,9 @@#define NUM_ENVP 32/* number of env pointers */ #if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET ) +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ;
No, the seqnum and helper can be called even if we have not defined CONFIG_NET. Please redo the patch based on this.
thanks,
greg k-h
Hi Greg,
Quoted 6 lines · Greg KH
Review
Quoted 3 lines
#if
defined(CONFIG_HOTPLUG)&&defined(CONFIG_NET)(quoted diff) +2
-0+u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";No, the seqnum and helper can be called even if we have not defined
CONFIG_NET. Please redo the patch based on this.
OK, thanks for the comment.
I thought it could be conditional on CONFIG_NET because it's used only from kobject_uevent() except for kernel/ksysfs.c which just exports them to sysfs. Are there other users? Or do you mean we have to keep sysfs files for user space?
Attached patch makes them conditional on CONFIG_HOTPLUG only. Build tested with both (!CONFIG_NET && CONFIG_SYSFS) and (CONFIG_NET && !CONFIG_SYSFS).
Does this look correct?
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Solutions (America), Inc.
lib/kobject_uevent.c +5 -0
@@ -25,6 +25,11 @@#define BUFFER_SIZE 2048/* buffer for the variables */ #define NUM_ENVP 32/* number of env pointers */ +#ifdef CONFIG_HOTPLUG +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; +#endif +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )static DEFINE_SPINLOCK (sequence_lock);static struct sock *uevent_sock;
kernel/ksysfs.c +0 -3
@@ -15,9 +15,6 @@#include <linux/module.h> #include <linux/init.h> -u64 uevent_seqnum; -char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; -#define KERNEL_ATTR_RO (_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
include/linux/kobject.h +3 -0
@@ -27,6 +27,8 @@#include <asm/atomic.h> #define KOBJ_NAME_LEN 20 + +#ifdef CONFIG_HOTPLUG #define UEVENT_HELPER_PATH_LEN 256/* path to the userspace helper executed on an event */
@@ -34,6 +36,7 @@ extern char uevent_helper[];/* counter to tag the uevent, read only except for the kobject core */ extern u64 uevent_seqnum; +#endif /* the actions here must match the proper string in lib/kobject_uevent.c */ typedef int __bitwise kobject_action_t ;
Quoted 17 lines · Jun'ichi Nomura
lib/kobject_uevent.c +5
-0@@ -25,6 +25,11 @@#define BUFFER_SIZE 2048/* buffer for the variables */ #define NUM_ENVP 32/* number of env pointers */ +#ifdef CONFIG_HOTPLUG +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; +#endif +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )static DEFINE_SPINLOCK (sequence_lock);static struct sock *uevent_sock;
kernel/ksysfs.c line 20
Quoted 9 lines
kernel/ksysfs.c +0
-3@@ -15,9 +15,6 @@#include <linux/module.h> #include <linux/init.h> -u64 uevent_seqnum; -char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; -#define KERNEL_ATTR_RO (_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
Those two changes look correct. But why did you modify kobject.h below?
Quoted 12 lines
include/linux/kobject.h +2
-0@@ -27,6 +27,8 @@#include <asm/atomic.h> #define KOBJ_NAME_LEN 20 + +#ifdef CONFIG_HOTPLUG #define UEVENT_HELPER_PATH_LEN 256/* path to the userspace helper executed on an event */
include/linux/kobject.h extern char uevent_helper[]; · line 42
Quoted 7 lines
include/linux/kobject.h +1
-0@@ -34,6 +36,7 @@ extern char uevent_helper[];/* counter to tag the uevent, read only except for the kobject core */ extern u64 uevent_seqnum; +#endif /* the actions here must match the proper string in lib/kobject_uevent.c */ typedef int __bitwise kobject_action_t ;
That shouldn't be needed, right?
thanks,
greg k-h
Hi,
Quoted 9 lines · Greg KH
Review line 32
Quoted 7 lines
(quoted diff) +2
-0@@ -27,6 +27,8 @@ #include <asm/atomic.h> #define KOBJ_NAME_LEN 20 + +#ifdef CONFIG_HOTPLUG #define UEVENT_HELPER_PATH_LEN 256That shouldn't be needed, right?
You're right. They are not needed.
Please disregard that part.
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Solutions (America), Inc.
lib/kobject_uevent.c +5 -0
@@ -25,6 +25,11 @@#define BUFFER_SIZE 2048/* buffer for the variables */ #define NUM_ENVP 32/* number of env pointers */ +#ifdef CONFIG_HOTPLUG +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; +#endif +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )static DEFINE_SPINLOCK (sequence_lock);static struct sock *uevent_sock;
kernel/ksysfs.c +0 -3
@@ -15,9 +15,6 @@#include <linux/module.h> #include <linux/init.h> -u64 uevent_seqnum; -char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; -#define KERNEL_ATTR_RO (_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
Quoted 13 lines · Jun'ichi Nomura
Hi,
Quoted 9 lines · Greg KH
Review line 32
Quoted 7 lines
(quoted diff) +2
-0@@ -27,6 +27,8 @@ #include <asm/atomic.h> #define KOBJ_NAME_LEN 20 + +#ifdef CONFIG_HOTPLUG #define UEVENT_HELPER_PATH_LEN 256That shouldn't be needed, right?
Quoted 2 lines
You're right. They are not needed.
Please disregard that part.
Looks good. Care to resend it one more time, this time with a good changelog description and a Signed-off-by: line?
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
+#ifdef
CONFIG_HOTPLUG
#defineUEVENT_HELPER_PATH_LEN256That shouldn't be needed, right?
You're right. They are not needed.
Please disregard that part.Looks good. Care to resend it one more time, this time with a good changelog description and a Signed-off-by: line?
OK, here you are.
The patch is applicable to either 2.6.16-rc6 or 2.6.16-rc6-mm1.
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Solutions (America), Inc.
Moving uevent_seqnum and uevent_helper to kobject_uevent.c because they are used even if CONFIG_SYSFS=n while kernel/ksysfs.c is built only if CONFIG_SYSFS=y,
lib/kobject_uevent.c +5 -0
@@ -25,6 +25,11 @@#define BUFFER_SIZE 2048/* buffer for the variables */ #define NUM_ENVP 32/* number of env pointers */ +#ifdef CONFIG_HOTPLUG +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; +#endif +#if defined(CONFIG_HOTPLUG ) && defined(CONFIG_NET )static DEFINE_SPINLOCK (sequence_lock);static struct sock *uevent_sock;
kernel/ksysfs.c +0 -3
@@ -15,9 +15,6 @@#include <linux/module.h> #include <linux/init.h> -u64 uevent_seqnum; -char uevent_helper[UEVENT_HELPER_PATH_LEN ] ="/sbin/hotplug" ; -#define KERNEL_ATTR_RO (_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)