17 Jul, 2013
6 commits
-
With the last patches stat.h was included to the header, and thus those
permission defines should be used.Signed-off-by: Oliver Schinagl
Signed-off-by: Greg Kroah-Hartman -
With the recent changes to sysfs there's various helper macro's.
However there's no RW, RO BIN_ helper macro's. This patch adds them.Signed-off-by: Oliver Schinagl
Signed-off-by: Greg Kroah-Hartman -
groups should be able to support binary attributes, just like it
supports "normal" attributes. This lets us only handle one type of
structure, groups, throughout the driver core and subsystems, making
binary attributes a "full fledged" part of the driver model, and not
something just "tacked on".Reported-by: Oliver Schinagl
Reviewed-by: Guenter Roeck
Tested-by: Guenter Roeck
Signed-off-by: Greg Kroah-Hartman -
This makes it easier to create static binary attributes, which is needed
in a number of drivers, instead of "open coding" them.Reviewed-by: Guenter Roeck
Tested-by: Guenter Roeck
Signed-off-by: Greg Kroah-Hartman -
To make it easier for driver subsystems to work with attribute groups,
create the ATTRIBUTE_GROUPS macro to remove some of the repetitive
typing for the most common use for attribute groups.Reviewed-by: Guenter Roeck
Tested-by: Guenter Roeck
Signed-off-by: Greg Kroah-Hartman -
A number of parts of the kernel created their own version of this, might
as well have the sysfs core provide it instead.Reviewed-by: Guenter Roeck
Tested-by: Guenter Roeck
Signed-off-by: Greg Kroah-Hartman
26 Jan, 2013
1 commit
-
The most convenient way to expose ACPI power resources lists of a
device is to put symbolic links to sysfs directories representing
those resources into special attribute groups in the device's sysfs
directory. For this purpose, it is necessary to be able to add
symbolic links to attribute groups.For this reason, add sysfs helper functions for adding/removing
symbolic links to/from attribute groups, sysfs_add_link_to_group()
and sysfs_remove_link_from_group(), respectively.This change set includes a build fix from David Rientjes.
Signed-off-by: Rafael J. Wysocki
Acked-by: Greg Kroah-Hartman
15 May, 2012
1 commit
-
This patch (as1554) fixes a lockdep false-positive report. The
problem arises because lockdep is unable to deal with the
tree-structured locks created by the device core and sysfs.This particular problem involves a sysfs attribute method that
unregisters itself, not from the device it was called for, but from a
descendant device. Lockdep doesn't understand the distinction and
reports a possible deadlock, even though the operation is safe.This is the sort of thing that would normally be handled by using a
nested lock annotation; unfortunately it's not feasible to do that
here. There's no sensible way to tell sysfs when attribute removal
occurs in the context of a parent attribute method.As a workaround, the patch adds a new flag to struct attribute
telling sysfs not to inform lockdep when it acquires a readlock on a
sysfs_dirent instance for the attribute. The readlock is still
acquired, but lockdep doesn't know about it and hence does not
complain about impossible deadlock scenarios.Also added are macros for static initialization of attribute
structures with the ignore_lockdep flag set. The three offending
attributes in the USB subsystem are converted to use the new macros.Signed-off-by: Alan Stern
Acked-by: Tejun Heo
CC: Eric W. Biederman
CC: Peter Zijlstra
Signed-off-by: Greg Kroah-Hartman
04 Jan, 2012
3 commits
-
Signed-off-by: Al Viro
-
Signed-off-by: Al Viro
-
Signed-off-by: Al Viro
20 Oct, 2011
1 commit
-
Looking up files in sysfs is hard to understand and analyize because we
currently allow placing untagged files in tagged directories. In the
implementation of that we have two subtly different meanings of NULL.
NULL meaning there is no tag on a directory entry and NULL meaning
we don't care which namespace the lookup is performed for. This
multiple uses of NULL have resulted in subtle bugs (since fixed)
in the code.Currently it is only the bonding driver that needs to have an untagged
file in a tagged directory.To untagle this mess I am adding support for tagged files to sysfs.
Modifying the bonding driver to implement bonding_masters as a tagged
file. Registering bonding_masters once for each network namespace.
Then I am removing support for untagged entries in tagged sysfs
directories.Resulting in code that is much easier to reason about.
Signed-off-by: Eric W. Biederman
Acked-by: Greg Kroah-Hartman
Signed-off-by: David S. Miller
27 Jul, 2011
1 commit
-
This allows us to move duplicated code in
(atomic_inc_not_zero() for now) toSigned-off-by: Arun Sharma
Reviewed-by: Eric Dumazet
Cc: Ingo Molnar
Cc: David Miller
Cc: Eric Dumazet
Acked-by: Mike Frysinger
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
13 Jun, 2011
1 commit
-
* new refcount in struct net, controlling actual freeing of the memory
* new method in kobj_ns_type_operations (->drop_ns())
* ->current_ns() semantics change - it's supposed to be followed by
corresponding ->drop_ns(). For struct net in case of CONFIG_NET_NS it bumps
the new refcount; net_drop_ns() decrements it and calls net_free() if the
last reference has been dropped. Method renamed to ->grab_current_ns().
* old net_free() callers call net_drop_ns() instead.
* sysfs_exit_ns() is gone, along with a large part of callchain
leading to it; now that the references stored in ->ns[...] stay valid we
do not need to hunt them down and replace them with NULL. That fixes
problems in sysfs_lookup() and sysfs_readdir(), along with getting rid
of sb->s_instances abuse.Note that struct net *shutdown* logics has not changed - net_cleanup()
is called exactly when it used to be called. The only thing postponed by
having a sysfs instance refering to that struct net is actual freeing of
memory occupied by struct net.Signed-off-by: Al Viro
14 May, 2011
1 commit
-
On some arches (x86, sh, arm, unicore, powerpc) the oops message would
print out the last sysfs file accessed.This was very useful in finding a number of sysfs and driver core bugs
in the 2.5 and early 2.6 development days, but it has been a number of
years since this file has actually helped in debugging anything that
couldn't also be trivially determined from the stack traceback.So it's time to delete the line. This is good as we need all the space
we can get for oops messages at times on consoles.Acked-by: Phil Carmody
Acked-by: Ingo Molnar
Cc: Andrew Morton
Cc: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
17 Oct, 2010
1 commit
-
This patch (as1420) adds sysfs_merge_group() and sysfs_unmerge_group()
functions, allowing drivers easily to add and remove sets of
attributes to a pre-existing attribute group directory.Signed-off-by: Alan Stern
Acked-by: Greg Kroah-Hartman
Signed-off-by: Rafael J. Wysocki
24 Aug, 2010
1 commit
-
Break the kobject namespace defs into their own header to avoid a header file
inclusion ordering problem between linux/sysfs.h and linux/kobject.h.This fixes the build breakage on older versions of gcc.
Signed-off-by: David Howells
Cc: Eric Biederman
Signed-off-by: Greg Kroah-Hartman
06 Aug, 2010
2 commits
-
Signed-off-by: Guenter Roeck
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
sysfs_chmod_file doesn't change the attribute it operates on, so this
attribute can be marked const.Signed-off-by: Jean Delvare
Signed-off-by: Greg Kroah-Hartman
22 May, 2010
5 commits
-
This allows bin_attr->read,write,mmap callbacks to check file specific data
(such as inode owner) as part of any privilege validation.Signed-off-by: Chris Wright
Signed-off-by: Greg Kroah-Hartman -
It appears gcc can't cope with using an enum that is only declared in
an inline function declaration, that doesn't even use the variable
that is so declared.Avoid the silliness and replace the enum with an int, and make gcc
happy.Signed-off-by: Eric W. Biederman
Acked-by: Randy Dunlap
Signed-off-by: Greg Kroah-Hartman -
Add some in-line comments to explain the new infrastructure, which
was introduced to support sysfs directory tagging with namespaces.
I think an overall description someplace might be good too, but it
didn't really seem to fit into Documentation/filesystems/sysfs.txt,
which appears more geared toward users, rather than maintainers, of
sysfs.(Tejun, please let me know if I can make anything clearer or failed
altogether to comment something that should be commented.)Signed-off-by: Serge E. Hallyn
Cc: Eric W. Biederman
Cc: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
When removing a symlink sysfs_remove_link does not provide
enough information to figure out which tagged directory the symlink
falls in. So I need sysfs_delete_link which is passed the target
of the symlink to delete.sysfs_rename_link is updated to call sysfs_delete_link instead
of sysfs_remove_link as we have all of the information necessary
and the callers are interesting.Both of these functions now have enough information to find a symlink
in a tagged directory. The only restriction is that they must be called
before the target kobject is renamed or deleted. If they are called
later I loose track of which tag the target kobject was marked with
and can no longer find the old symlink to remove it.This patch was split from an earlier patch.
Signed-off-by: Eric W. Biederman
Signed-off-by: Benjamin Thery
Signed-off-by: Daniel Lezcano
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
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
Signed-off-by: Benjamin Thery
Signed-off-by: Greg Kroah-Hartman
08 Mar, 2010
5 commits
-
After merging the final tree, today's linux-next build (powerpc
allyesconfig) failed like this:drivers/pci/pci-sysfs.c: In function 'pci_create_legacy_files':
drivers/pci/pci-sysfs.c:645: error: lvalue required as unary '&' operand
drivers/pci/pci-sysfs.c:658: error: lvalue required as unary '&' operandCaused by commit "sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on
dynamic attributes" interacting with commit "sysfs: Use one lockdep
class per sysfs attribute") both from the driver-core tree.Signed-off-by: Stephen Rothwell
Cc: "Eric W. Biederman"
Signed-off-by: Greg Kroah-Hartman -
Because of rename ordering problems we occassionally give false
warnings about invalid sysfs operations. So using sysfs_rename
create a sysfs_rename_link function that doesn't need strange
workarounds.Cc: Benjamin Thery
Cc: Daniel Lezcano
Acked-by: Serge Hallyn
Acked-by: Tejun Heo
Signed-off-by: Eric W. Biederman
Signed-off-by: Greg Kroah-Hartman -
I have added a new requirement to the external sysfs interface
that dynamically allocated sysfs attributes must call sysfs_attr_init
if lockdep is enabled. For the time being callying sysfs_attr_init
is only mandatory if lockdep is enabled, so we can live with a few
unconverted instances until we find them all. As this is part of
the public interface of sysfs it is a good idea to document these
pseudo functions so someone inspeciting the code can find out
what has happened.Signed-off-by: Eric W. Biederman
Signed-off-by: Greg Kroah-Hartman -
Acknowledge that the logical sysfs rwsem has one instance per
sysfs attribute with different locking depencencies for different
attributes.There is a sysfs idiom where writing to one sysfs file causes the
addition or removal of other sysfs files. Lumping all of the
sysfs attributes together in one lock class causes lockdep to
generate lots of false positives.This introduces the requirement that non-static sysfs attributes
need to be initialized with sysfs_attr_init or sysfs_bin_attr_init.
Strictly speaking this requirement only exists when lockdep is
enabled, and when lockdep is enabled we get a bit fat warning
if this requirement is not met.Signed-off-by: Eric W. Biederman
Acked-by: WANG Cong
Cc: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Adding/Removing a whole array of attributes is very common. Add a standard
utility function to do this with a simple function call, instead of
requiring drivers to open code this.Signed-off-by: Andi Kleen
Signed-off-by: Greg Kroah-Hartman
24 Dec, 2009
1 commit
-
Many struct bin_attribute descriptors are purely read-only
structures, and there's no need to change them. Therefore
make the promise not to, which will let those descriptors
be put in a ro section.Signed-off-by: Phil Carmody
Signed-off-by: Greg Kroah-Hartman
20 Oct, 2008
1 commit
-
Tejun's commit 7b595756ec1f49e0049a9e01a1298d53a7faaa15 made sysfs
attribute->owner unnecessary. But the field was left in the structure to
ease the merge. It's been over a year since that change and it is now
time to start killing attribute->owner along with its users - one arch at
a time!This patch is attempt #1 to get rid of attribute->owner only for
CONFIG_X86_64 or CONFIG_X86_32 . We will deal with other arches later on
as and when possible - avr32 will be the next since that is something I
can test. Compile (make allyesconfig / make allmodconfig / custom config)
and boot tested.akpm: the idea is that we put the declaration of sttribute.owner inside
`#ifndef CONFIG_X86'. But that proved to be too ambitious for now because
new usages kept on turning up in subsystem trees.[akpm: remove the ifdef for now]
Signed-off-by: Parag Warudkar
Cc: Greg KH
Cc: Ingo Molnar
Cc: Tejun Heo
Cc: Len Brown
Cc: Jens Axboe
Cc: Jean Delvare
Cc: Roland Dreier
Cc: David Brownell
Cc: Alessandro Zummo
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
17 Oct, 2008
5 commits
-
It finally dawned on me what the clean fix to sysfs_rename_dir
calling kobject_set_name is. Move the work into kobject_rename
where it belongs. The callers serialize us anyway so this is
safe.Signed-off-by: Eric W. Biederman
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
When looking at kobject_rename I found two bugs with
that exist when sysfs support is disabled in the kernel.kobject_rename does not change the name on the kobject when
sysfs support is not compiled in.kobject_rename without locking attempts to check the
validity of a rename operation, which the kobject layer
simply does not have the infrastructure to do.This patch documents the previously unstated requirement of
kobject_rename that is the responsibility of the caller to
provide mutual exclusion and to be certain that the new_name
for the kobject is valid.This patch modifies sysfs_rename_dir in !CONFIG_SYSFS case
to call kobject_set_name to actually change the kobject_name.This patch removes the bogus and misleading check in kobject_rename
that attempts to see if a rename is valid. The check is bogus
because we do not have the proper locking. The check is misleading
because it looks like we can and do perform checking at the kobject
level that we don't.Signed-off-by: Eric W. Biederman
Signed-off-by: Greg Kroah-Hartman -
Because they can be, and because code like this produces a warning if
they're not:struct device_attribute dev_attr;
sysfs_notify(&kobj, NULL, dev_attr.attr.name);
Signed-off-by: Trent Piepho
CC: Neil Brown
Signed-off-by: Greg Kroah-Hartman -
Support sysfs_notify from atomic context with new sysfs_notify_dirent
sysfs_notify currently takes sysfs_mutex.
This means that it cannot be called in atomic context.
sysfs_mutex is sometimes held over a malloc (sysfs_rename_dir)
so it can block on low memory.In md I want to be able to notify on a sysfs attribute from
atomic context, and I don't want to block on low memory because I
could be in the writeout path for freeing memory.So:
- export the "sysfs_dirent" structure along with sysfs_get, sysfs_put
and sysfs_get_dirent so I can get the sysfs_dirent that I want to
notify on and hold it in an md structure.
- split sysfs_notify_dirent out of sysfs_notify so the sysfs_dirent
can be notified on with no blocking (just a spinlock).Signed-off-by: Neil Brown
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Print the name of the last-accessed sysfs file when we oops, to help track
down oopses which occur in sysfs store/read handlers. Because these oopses
tend to not leave any trace of the offending code in the stack traces.Cc: Kay Sievers
Cc: Mathieu Desnoyers
Signed-off-by: Andrew Morton
Signed-off-by: Greg Kroah-Hartman
22 Jul, 2008
1 commit
-
driver core: Suppress sysfs warnings for device_rename().
Renaming network devices to an already existing name is not
something we want sysfs to print a scary warning for, since the
callers can deal with this correctly. So let's introduce
sysfs_create_link_nowarn() which gets rid of the common warning.Signed-off-by: Cornelia Huck
Signed-off-by: Greg Kroah-Hartman
05 May, 2008
1 commit
-
x86.git testing found the following build failure on v2.6.26-rc1:
In file included from include/linux/kobject.h:22,
from include/linux/module.h:17,
from include/linux/crypto.h:22,
from arch/x86/kernel/asm-offsets_32.c:8,
from arch/x86/kernel/asm-offsets.c:3:
include/linux/sysfs.h:201: error: redefinition of 'sysfs_update_group'
include/linux/sysfs.h:195: error: previous definition of 'sysfs_update_group' was here
make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2with the following config:
http://redhat.com/~mingo/misc/config-Sun_May__4_07_09_30_CEST_2008.bad
the reason for the build failure is the duplicate definition of the
sysfs_update_group() inline function in include/linux/sysfs.h.The duplication was a merge error: it was added via -mm by commit
v2.6.25-7262-g2850699, "sysfs: sysfs_update_group stub for
CONFIG_SYSFS=n" a day before v2.6.26-rc1, but a day before that the same
commit was already merged upstream via the sysfs tree, with commit
v2.6.25-7211-g1cbfb7a.Signed-off-by: Ingo Molnar
Signed-off-by: Linus Torvalds
01 May, 2008
2 commits
-
scsi_transport_spi uses sysfs_update_group() when CONFIG_SYSFS=n, so provide a
stub for it.next-20080423/drivers/scsi/scsi_transport_spi.c:1467: error: implicit declaration of function 'sysfs_update_group'
make[3]: *** [drivers/scsi/scsi_transport_spi.o] Error 1Signed-off-by: Randy Dunlap
Cc: Greg KH
Cc: James Bottomley
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
scsi_transport_spi uses sysfs_update_group() when CONFIG_SYSFS=n,
so provide a stub for it.next-20080423/drivers/scsi/scsi_transport_spi.c:1467: error: implicit declaration of function 'sysfs_update_group'
make[3]: *** [drivers/scsi/scsi_transport_spi.o] Error 1Signed-off-by: Randy Dunlap
Cc: James Bottomley
Signed-off-by: Greg Kroah-Hartman