From a79655c1eb2e68ecb08e6bc650be848f6f158db6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 21 Jun 2020 16:28:01 +0000 Subject: [PATCH] scst/include/backport.h: Improve kobj_ns_grab_current() backport git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9032 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index d5e119abc..8093f3c90 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -40,6 +40,9 @@ #include #include #include /* sync_page_range() */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) +#include /* init_net */ +#endif #include #include /* struct scsi_cmnd */ struct scsi_target; @@ -802,13 +805,26 @@ enum umh_wait { /* */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) /* - * See also commit a685e08987d1 ("Delay struct net freeing while there's a - * sysfs instance refering to it") # v3.0. + * See also commit 8488a38f4d2f ("kobject: Break the kobject namespace defs + * into their own header") # v2.6.36. + */ +enum kobj_ns_type { + KOBJ_NS_TYPE_NET = 1, +}; +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +/* + * See also commit 5f256becd868 ("[NET]: Basic network namespace + * infrastructure.") # v2.6.24. a685e08987d1 ("Delay struct net freeing while + * there's a sysfs instance refering to it") # v3.0. */ static inline void *kobj_ns_grab_current(enum kobj_ns_type type) { + WARN_ON_ONCE(type != KOBJ_NS_TYPE_NET); return &init_net; }