From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>,
axboe@kernel.dk, Kay Sievers <kay.sievers@vrfy.org>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 13/31] SYSFS: Allow boot time switching between deprecated and modern sysfs layout
Date: Fri, 22 Oct 2010 11:24:58 -0700 [thread overview]
Message-ID: <1287771916-15016-13-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20101022175107.GB13489@kroah.com>
From: Andi Kleen <ak@linux.intel.com>
I have some systems which need legacy sysfs due to old tools that are
making assumptions that a directory can never be a symlink to another
directory, and it's a big hazzle to compile separate kernels for them.
This patch turns CONFIG_SYSFS_DEPRECATED into a run time option
that can be switched on/off the kernel command line. This way
the same binary can be used in both cases with just a option
on the command line.
The old CONFIG_SYSFS_DEPRECATED_V2 option is still there to set
the default. I kept the weird name to not break existing
config files.
Also the compat code can be still completely disabled by undefining
CONFIG_SYSFS_DEPRECATED_SWITCH -- just the optimizer takes
care of this now instead of lots of ifdefs. This makes the code
look nicer.
v2: This is an updated version on top of Kay's patch to only
handle the block devices. I tested it on my old systems
and that seems to work.
Cc: axboe@kernel.dk
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
Documentation/kernel-parameters.txt | 9 +++++++++
block/genhd.c | 7 ++-----
drivers/base/class.c | 4 ++--
drivers/base/core.c | 26 +++++++++++++++++---------
fs/partitions/check.c | 19 +++++++++----------
include/linux/device.h | 7 +++++++
init/Kconfig | 26 ++++++++++++++++++++++----
7 files changed, 68 insertions(+), 30 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 3d854c9..67fa3fd 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2365,6 +2365,15 @@ and is between 256 and 4096 characters. It is defined in the file
switches= [HW,M68k]
+ sysfs.deprecated=0|1 [KNL]
+ Enable/disable old style sysfs layout for old udev
+ on older distributions. When this option is enabled
+ very new udev will not work anymore. When this option
+ is disabled (or CONFIG_SYSFS_DEPRECATED not compiled)
+ in older udev will not work anymore.
+ Default depends on CONFIG_SYSFS_DEPRECATED_V2 set in
+ the kernel configuration.
+
sysrq_always_enabled
[KNL]
Ignore sysrq setting - this boot parameter will
diff --git a/block/genhd.c b/block/genhd.c
index 59a2db6..4e28a84 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -22,9 +22,7 @@
#include "blk.h"
static DEFINE_MUTEX(block_class_lock);
-#ifndef CONFIG_SYSFS_DEPRECATED
struct kobject *block_depr;
-#endif
/* for extended dynamic devt allocation, currently only one major is used */
#define MAX_EXT_DEVT (1 << MINORBITS)
@@ -803,10 +801,9 @@ static int __init genhd_device_init(void)
register_blkdev(BLOCK_EXT_MAJOR, "blkext");
-#ifndef CONFIG_SYSFS_DEPRECATED
/* create top-level block dir */
- block_depr = kobject_create_and_add("block", NULL);
-#endif
+ if (!sysfs_deprecated)
+ block_depr = kobject_create_and_add("block", NULL);
return 0;
}
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 1078969..9c63a56 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -184,9 +184,9 @@ int __class_register(struct class *cls, struct lock_class_key *key)
if (!cls->dev_kobj)
cls->dev_kobj = sysfs_dev_char_kobj;
-#if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
+#if defined(CONFIG_BLOCK)
/* let the block class directory show up in the root of sysfs */
- if (cls != &block_class)
+ if (!sysfs_deprecated || cls != &block_class)
cp->class_subsys.kobj.kset = class_kset;
#else
cp->class_subsys.kobj.kset = class_kset;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6cf9069..f7f906f 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -26,6 +26,19 @@
#include "base.h"
#include "power/power.h"
+#ifdef CONFIG_SYSFS_DEPRECATED
+#ifdef CONFIG_SYSFS_DEPRECATED_V2
+long sysfs_deprecated = 1;
+#else
+long sysfs_deprecated = 0;
+#endif
+static __init int sysfs_deprecated_setup(char *arg)
+{
+ return strict_strtol(arg, 10, &sysfs_deprecated);
+}
+early_param("sysfs.deprecated", sysfs_deprecated_setup);
+#endif
+
int (*platform_notify)(struct device *dev) = NULL;
int (*platform_notify_remove)(struct device *dev) = NULL;
static struct kobject *dev_kobj;
@@ -617,14 +630,13 @@ static struct kobject *get_device_parent(struct device *dev,
struct kobject *parent_kobj;
struct kobject *k;
-#ifdef CONFIG_SYSFS_DEPRECATED
/* block disks show up in /sys/block */
- if (dev->class == &block_class) {
+ if (sysfs_deprecated && dev->class == &block_class) {
if (parent && parent->class == &block_class)
return &parent->kobj;
return &block_class.p->class_subsys.kobj;
}
-#endif
+
/*
* If we have no parent, we live in "virtual".
* Class-devices with a non class-device as parent, live
@@ -707,11 +719,9 @@ static int device_add_class_symlinks(struct device *dev)
goto out_subsys;
}
-#ifdef CONFIG_SYSFS_DEPRECATED
/* /sys/block has directories and does not need symlinks */
- if (dev->class == &block_class)
+ if (sysfs_deprecated && dev->class == &block_class)
return 0;
-#endif
/* link in the class directory pointing to the device */
error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
@@ -738,10 +748,8 @@ static void device_remove_class_symlinks(struct device *dev)
if (dev->parent && device_is_not_partition(dev))
sysfs_remove_link(&dev->kobj, "device");
sysfs_remove_link(&dev->kobj, "subsystem");
-#ifdef CONFIG_SYSFS_DEPRECATED
- if (dev->class == &block_class)
+ if (sysfs_deprecated && dev->class == &block_class)
return;
-#endif
sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
}
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 79fbf3f..137bf97 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -513,14 +513,14 @@ void register_disk(struct gendisk *disk)
if (device_add(ddev))
return;
-#ifndef CONFIG_SYSFS_DEPRECATED
- err = sysfs_create_link(block_depr, &ddev->kobj,
- kobject_name(&ddev->kobj));
- if (err) {
- device_del(ddev);
- return;
+ if (!sysfs_deprecated) {
+ err = sysfs_create_link(block_depr, &ddev->kobj,
+ kobject_name(&ddev->kobj));
+ if (err) {
+ device_del(ddev);
+ return;
+ }
}
-#endif
disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
@@ -737,8 +737,7 @@ void del_gendisk(struct gendisk *disk)
kobject_put(disk->part0.holder_dir);
kobject_put(disk->slave_dir);
disk->driverfs_dev = NULL;
-#ifndef CONFIG_SYSFS_DEPRECATED
- sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
-#endif
+ if (!sysfs_deprecated)
+ sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
device_del(disk_to_dev(disk));
}
diff --git a/include/linux/device.h b/include/linux/device.h
index 516feca..dd48953 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -751,4 +751,11 @@ do { \
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
MODULE_ALIAS("char-major-" __stringify(major) "-*")
+
+#ifdef CONFIG_SYSFS_DEPRECATED
+extern long sysfs_deprecated;
+#else
+#define sysfs_deprecated 0
+#endif
+
#endif /* _DEVICE_H_ */
diff --git a/init/Kconfig b/init/Kconfig
index 137609f..d742b6f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -660,8 +660,12 @@ config SYSFS_DEPRECATED
depends on SYSFS
default n
help
- This option switches the layout of the "block" class devices, to not
- show up in /sys/class/block/, but only in /sys/block/.
+ This option adds code that switches the layout of the "block" class
+ devices, to not show up in /sys/class/block/, but only in
+ /sys/block/.
+
+ This switch is only active when the sysfs.deprecated=1 boot option is
+ passed or the SYSFS_DEPRECATED_V2 option is set.
This option allows new kernels to run on old distributions and tools,
which might get confused by /sys/class/block/. Since 2007/2008 all
@@ -672,8 +676,22 @@ config SYSFS_DEPRECATED
option enabled.
Only if you are using a new kernel on an old distribution, you might
- need to say Y here. Never say Y, if the original kernel, that came
- with your distribution, has not set this option.
+ need to say Y here.
+
+config SYSFS_DEPRECATED_V2
+ bool "enabled deprecated sysfs features by default"
+ default n
+ depends on SYSFS
+ depends on SYSFS_DEPRECATED
+ help
+ Enable deprecated sysfs by default.
+
+ See the CONFIG_SYSFS_DEPRECATED option for more details about this
+ option.
+
+ Only if you are using a new kernel on an old distribution, you might
+ need to say Y here. Even then, odds are you would not need it
+ enabled, you can always pass the boot option if absolutely necessary.
config RELAY
bool "Kernel->user space relay support (formerly relayfs)"
--
1.7.2
next prev parent reply other threads:[~2010-10-22 18:29 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 17:51 [GIT PATCH] driver core merge for .37-rc1 Greg KH
2010-10-22 18:24 ` [PATCH 01/31] Dynamic Debug: Split out query string parsing/setup from proc_write Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 02/31] Dynamic Debug: Introduce ddebug_query= boot parameter Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 03/31] Dynamic Debug: Initialize dynamic debug earlier via arch_initcall Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 04/31] driver core: platform: Use drv->driver.bus instead of assuming platform_bus_type Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 05/31] uio: do not use PCI resources before pci_enable_device() Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 06/31] driver core: platform_bus: allow runtime override of dev_pm_ops Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 07/31] add Packet hub driver for Topcliff Platform controller hub Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 08/31] pch_phub: fix build warnings Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 09/31] debugfs: mark me as the maintainer Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 10/31] base/platform: Safe handling for NULL platform data and resources Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 11/31] base/platform: Simplifications for NULL platform data/resources handling Greg Kroah-Hartman
2010-10-22 18:24 ` [PATCH 12/31] driver core: remove CONFIG_SYSFS_DEPRECATED_V2 but keep it for block devices Greg Kroah-Hartman
2010-10-22 18:24 ` Greg Kroah-Hartman [this message]
2010-10-22 18:24 ` [PATCH 14/31] uio: Fix lack of locking in init_uio_class Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 15/31] uio: Don't clear driver data Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 16/31] uio: Cleanup irq handling Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 17/31] uio: Support 2^MINOR_BITS minors Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 18/31] uio: Statically allocate uio_class and use class .dev_attrs Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 19/31] FW_LOADER: fix kconfig dependency warning on HOTPLUG Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 20/31] sysfs: Fail bin file mmap if vma close is implemented Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 21/31] sysfs: only access bin file vm_ops with the active lock Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 22/31] driver-core: base: change to new flag variable Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 23/31] driver core: fix build for CONFIG_BLOCK not enabled Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 24/31] kobject: Introduce kset_find_obj_hinted Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 25/31] driver core: Introduce find_memory_block_hinted which utilizes kset_find_obj_hinted Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 26/31] driver core: Convert link_mem_sections to use find_memory_block_hinted Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 27/31] hpilo: Despecificate driver from iLO generation Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 28/31] Driver core: Move find_memory_block routine Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 29/31] Driver core: Add mutex for adding/removing memory blocks Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 30/31] Driver core: Add section count to memory_block struct Greg Kroah-Hartman
2010-10-22 18:25 ` [PATCH 31/31] driver core: Display error codes when class suspend fails Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287771916-15016-13-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=ak@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome