1
0
Fork 0
alistair23-linux/drivers
Eric W. Biederman 3ff195b011 sysfs: Implement sysfs tagged directory support.
The problem.  When implementing a network namespace I need to be able
to have multiple network devices with the same name.  Currently this
is a problem for /sys/class/net/*, /sys/devices/virtual/net/*, and
potentially a few other directories of the form /sys/ ... /net/*.

What this patch does is to add an additional tag field to the
sysfs dirent structure.  For directories that should show different
contents depending on the context such as /sys/class/net/, and
/sys/devices/virtual/net/ this tag field is used to specify the
context in which those directories should be visible.  Effectively
this is the same as creating multiple distinct directories with
the same name but internally to sysfs the result is nicer.

I am calling the concept of a single directory that looks like multiple
directories all at the same path in the filesystem tagged directories.

For the networking namespace the set of directories whose contents I need
to filter with tags can depend on the presence or absence of hotplug
hardware or which modules are currently loaded.  Which means I need
a simple race free way to setup those directories as tagged.

To achieve a reace free design all tagged directories are created
and managed by sysfs itself.

Users of this interface:
- define a type in the sysfs_tag_type enumeration.
- call sysfs_register_ns_types with the type and it's operations
- sysfs_exit_ns when an individual tag is no longer valid

- Implement mount_ns() which returns the ns of the calling process
  so we can attach it to a sysfs superblock.
- Implement ktype.namespace() which returns the ns of a syfs kobject.

Everything else is left up to sysfs and the driver layer.

For the network namespace mount_ns and namespace() are essentially
one line functions, and look to remain that.

Tags are currently represented a const void * pointers as that is
both generic, prevides enough information for equality comparisons,
and is trivial to create for current users, as it is just the
existing namespace pointer.

The work needed in sysfs is more extensive.  At each directory
or symlink creating I need to check if the directory it is being
created in is a tagged directory and if so generate the appropriate
tag to place on the sysfs_dirent.  Likewise at each symlink or
directory removal I need to check if the sysfs directory it is
being removed from is a tagged directory and if so figure out
which tag goes along with the name I am deleting.

Currently only directories which hold kobjects, and
symlinks are supported.  There is not enough information
in the current file attribute interfaces to give us anything
to discriminate on which makes it useless, and there are
no potential users which makes it an uninteresting problem
to solve.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-21 09:37:31 -07:00
..
accessibility
acpi Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2010-05-20 09:45:38 -07:00
amba
ata Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev 2010-05-20 09:27:37 -07:00
atm atm: select FW_LOADER in Kconfig for solos-pci 2010-05-17 17:44:36 -07:00
auxdisplay
base kobj: Add basic infrastructure for dealing with namespaces. 2010-05-21 09:37:31 -07:00
block generate "change" uevent for loop device 2010-05-21 09:37:30 -07:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-05-20 21:04:44 -07:00
cdrom
char Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-05-20 10:33:06 -07:00
clocksource Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-19 17:10:57 -07:00
connector
cpufreq Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-18 08:49:13 -07:00
cpuidle PM QOS update 2010-05-10 23:08:19 +02:00
crypto
dca
dio
dma Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2010-05-19 11:36:03 -07:00
edac edac, mce: Fix wrong mask and macro usage 2010-04-30 10:15:39 -07:00
eisa
firewire Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
firmware
gpio sysfs: Implement sysfs tagged directory support. 2010-05-21 09:37:31 -07:00
gpu Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
hid USB: rename usb_buffer_alloc() and usb_buffer_free() users 2010-05-20 13:21:38 -07:00
hwmon Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging 2010-05-11 17:38:04 -07:00
i2c Merge branch 'for-linus/i2c-2635' of git://git.fluff.org/bjdooks/linux 2010-05-20 09:41:17 -07:00
ide pcmcia: dev_node removal (drivers with updated printk call) 2010-05-10 10:23:15 +02:00
idle
ieee1394
ieee802154
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-05-20 21:04:44 -07:00
input Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6 2010-05-20 21:26:12 -07:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-05-20 21:04:44 -07:00
leds
lguest
macintosh Merge branch 'master' into for-next 2010-04-23 02:08:44 +02:00
mca
md sysfs: Implement sysfs tagged directory support. 2010-05-21 09:37:31 -07:00
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6 2010-05-20 21:26:12 -07:00
memstick
message Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-05-21 07:19:18 -07:00
mfd Merge branch 'topic/asoc' into for-linus 2010-05-20 12:00:43 +02:00
misc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
mmc Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm 2010-05-19 11:37:22 -07:00
mtd Merge git://git.infradead.org/mtd-2.6 2010-05-21 07:25:43 -07:00
net drivers/base: Convert dev->sem to mutex 2010-05-21 09:37:30 -07:00
nubus
of of: check for IS_ERR() 2010-04-28 01:07:29 -06:00
oprofile oprofile: protect from not being in an IRQ context 2010-05-03 23:02:39 +02:00
parisc
parport pcmcia: dev_node removal (write-only drivers) 2010-05-10 10:23:14 +02:00
pci Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
pcmcia Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2010-05-20 09:09:46 -07:00
platform eeepc-laptop: add missing sparse_keymap_free 2010-04-23 15:23:21 -04:00
pnp Merge branches 'bugzilla-14337', 'bugzilla-14998', 'bugzilla-15407', 'bugzilla-15903' and 'misc-2.6.34' into release 2010-05-06 22:04:31 -04:00
power
pps
ps3 Merge branch 'master' into for-next 2010-04-23 02:08:44 +02:00
rapidio
regulator Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
rtc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-05-21 07:19:18 -07:00
sbus drivers/sbus/char/flash.c: flash_read should update ppos instead of file->f_pos 2010-04-27 18:48:52 -07:00
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-05-21 07:19:18 -07:00
serial Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2010-05-20 09:09:46 -07:00
sfi
sh sh: simplify WARN usage in SH clock driver 2010-05-13 17:43:11 +09:00
sn
spi Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-05-20 09:20:59 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-05-20 21:04:44 -07:00
staging drivers/base: Convert dev->sem to mutex 2010-05-21 09:37:30 -07:00
tc
telephony pcmcia: dev_node removal (write-only drivers) 2010-05-10 10:23:14 +02:00
thermal
uio
usb drivers/base: Convert dev->sem to mutex 2010-05-21 09:37:30 -07:00
uwb
vhost Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2010-05-16 22:26:58 -07:00
video Merge branch 'viafb-next' of git://git.lwn.net/linux-2.6 2010-05-20 13:34:17 -07:00
virtio Merge branch 'master' into for-next 2010-04-23 02:08:44 +02:00
vlynq vlynq: make whole Kconfig-menu dependant on architecture 2010-05-14 16:59:54 +02:00
w1 w1: fix omap 1-wire driver compilation 2010-04-24 11:31:25 -07:00
watchdog USB: rename usb_buffer_alloc() and usb_buffer_free() users 2010-05-20 13:21:38 -07:00
xen stop_machine: reimplement using cpu_stop 2010-05-06 18:49:20 +02:00
zorro m68k: amiga - Zorro host bridge platform device conversion 2010-05-17 21:37:42 +02:00
Kconfig
Makefile virtio: initialize earlier 2010-05-07 14:01:17 -07:00