Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
1cf6d20f
Commit
1cf6d20f
authored
Jul 03, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] SYSFS: add module referencing to sysfs attribute files.
parent
687c7f9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
fs/sysfs/file.c
fs/sysfs/file.c
+9
-0
include/linux/device.h
include/linux/device.h
+6
-5
include/linux/sysfs.h
include/linux/sysfs.h
+2
-0
No files found.
fs/sysfs/file.c
View file @
1cf6d20f
...
...
@@ -247,6 +247,12 @@ static int check_perm(struct inode * inode, struct file * file)
if
(
!
kobj
||
!
attr
)
goto
Einval
;
/* Grab the module reference for this attribute if we have one */
if
(
!
try_module_get
(
attr
->
owner
))
{
error
=
-
ENODEV
;
goto
Done
;
}
/* if the kobject has no ktype, then we assume that it is a subsystem
* itself, and use ops for it.
*/
...
...
@@ -300,6 +306,7 @@ static int check_perm(struct inode * inode, struct file * file)
goto
Done
;
Eaccess:
error
=
-
EACCES
;
module_put
(
attr
->
owner
);
Done:
if
(
error
&&
kobj
)
kobject_put
(
kobj
);
...
...
@@ -314,10 +321,12 @@ static int sysfs_open_file(struct inode * inode, struct file * filp)
static
int
sysfs_release
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
struct
kobject
*
kobj
=
filp
->
f_dentry
->
d_parent
->
d_fsdata
;
struct
attribute
*
attr
=
filp
->
f_dentry
->
d_fsdata
;
struct
sysfs_buffer
*
buffer
=
filp
->
private_data
;
if
(
kobj
)
kobject_put
(
kobj
);
module_put
(
attr
->
owner
);
if
(
buffer
)
{
if
(
buffer
->
page
)
...
...
include/linux/device.h
View file @
1cf6d20f
...
...
@@ -18,6 +18,7 @@
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <asm/semaphore.h>
#include <asm/atomic.h>
...
...
@@ -95,7 +96,7 @@ struct bus_attribute {
#define BUS_ATTR(_name,_mode,_show,_store) \
struct bus_attribute bus_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.attr = {.name = __stringify(_name), .mode = _mode
, .owner = THIS_MODULE
}, \
.show = _show, \
.store = _store, \
};
...
...
@@ -136,7 +137,7 @@ struct driver_attribute {
#define DRIVER_ATTR(_name,_mode,_show,_store) \
struct driver_attribute driver_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.attr = {.name = __stringify(_name), .mode = _mode
, .owner = THIS_MODULE
}, \
.show = _show, \
.store = _store, \
};
...
...
@@ -176,7 +177,7 @@ struct class_attribute {
#define CLASS_ATTR(_name,_mode,_show,_store) \
struct class_attribute class_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.attr = {.name = __stringify(_name), .mode = _mode
, .owner = THIS_MODULE
}, \
.show = _show, \
.store = _store, \
};
...
...
@@ -226,7 +227,7 @@ struct class_device_attribute {
#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.attr = {.name = __stringify(_name), .mode = _mode
, .owner = THIS_MODULE
}, \
.show = _show, \
.store = _store, \
};
...
...
@@ -324,7 +325,7 @@ struct device_attribute {
#define DEVICE_ATTR(_name,_mode,_show,_store) \
struct device_attribute dev_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.attr = {.name = __stringify(_name), .mode = _mode
, .owner = THIS_MODULE
}, \
.show = _show, \
.store = _store, \
};
...
...
include/linux/sysfs.h
View file @
1cf6d20f
...
...
@@ -10,9 +10,11 @@
#define _SYSFS_H_
struct
kobject
;
struct
module
;
struct
attribute
{
char
*
name
;
struct
module
*
owner
;
mode_t
mode
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment