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
c637d6b1
Commit
c637d6b1
authored
Oct 29, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sysfs: convert sysfs to use more functions from fs/libfs.c
parent
736c7efc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
99 deletions
+6
-99
fs/sysfs/inode.c
fs/sysfs/inode.c
+6
-99
No files found.
fs/sysfs/inode.c
View file @
c637d6b1
...
@@ -42,7 +42,6 @@
...
@@ -42,7 +42,6 @@
static
struct
super_operations
sysfs_ops
;
static
struct
super_operations
sysfs_ops
;
static
struct
file_operations
sysfs_file_operations
;
static
struct
file_operations
sysfs_file_operations
;
static
struct
inode_operations
sysfs_dir_inode_operations
;
static
struct
address_space_operations
sysfs_aops
;
static
struct
address_space_operations
sysfs_aops
;
static
struct
vfsmount
*
sysfs_mount
;
static
struct
vfsmount
*
sysfs_mount
;
...
@@ -52,45 +51,6 @@ static struct backing_dev_info sysfs_backing_dev_info = {
...
@@ -52,45 +51,6 @@ static struct backing_dev_info sysfs_backing_dev_info = {
.
memory_backed
=
1
,
/* Does not contribute to dirty memory */
.
memory_backed
=
1
,
/* Does not contribute to dirty memory */
};
};
static
int
sysfs_readpage
(
struct
file
*
file
,
struct
page
*
page
)
{
if
(
!
PageUptodate
(
page
))
{
void
*
kaddr
=
kmap_atomic
(
page
,
KM_USER0
);
memset
(
kaddr
,
0
,
PAGE_CACHE_SIZE
);
flush_dcache_page
(
page
);
kunmap_atomic
(
kaddr
,
KM_USER0
);
SetPageUptodate
(
page
);
}
unlock_page
(
page
);
return
0
;
}
static
int
sysfs_prepare_write
(
struct
file
*
file
,
struct
page
*
page
,
unsigned
offset
,
unsigned
to
)
{
if
(
!
PageUptodate
(
page
))
{
void
*
kaddr
=
kmap_atomic
(
page
,
KM_USER0
);
memset
(
kaddr
,
0
,
PAGE_CACHE_SIZE
);
flush_dcache_page
(
page
);
kunmap_atomic
(
kaddr
,
KM_USER0
);
SetPageUptodate
(
page
);
}
return
0
;
}
static
int
sysfs_commit_write
(
struct
file
*
file
,
struct
page
*
page
,
unsigned
offset
,
unsigned
to
)
{
struct
inode
*
inode
=
page
->
mapping
->
host
;
loff_t
pos
=
((
loff_t
)
page
->
index
<<
PAGE_CACHE_SHIFT
)
+
to
;
set_page_dirty
(
page
);
if
(
pos
>
inode
->
i_size
)
inode
->
i_size
=
pos
;
return
0
;
}
static
struct
inode
*
sysfs_get_inode
(
struct
super_block
*
sb
,
int
mode
,
int
dev
)
static
struct
inode
*
sysfs_get_inode
(
struct
super_block
*
sb
,
int
mode
,
int
dev
)
{
{
struct
inode
*
inode
=
new_inode
(
sb
);
struct
inode
*
inode
=
new_inode
(
sb
);
...
@@ -113,7 +73,7 @@ static struct inode *sysfs_get_inode(struct super_block *sb, int mode, int dev)
...
@@ -113,7 +73,7 @@ static struct inode *sysfs_get_inode(struct super_block *sb, int mode, int dev)
inode
->
i_fop
=
&
sysfs_file_operations
;
inode
->
i_fop
=
&
sysfs_file_operations
;
break
;
break
;
case
S_IFDIR
:
case
S_IFDIR
:
inode
->
i_op
=
&
s
ysfs
_dir_inode_operations
;
inode
->
i_op
=
&
s
imple
_dir_inode_operations
;
inode
->
i_fop
=
&
simple_dir_operations
;
inode
->
i_fop
=
&
simple_dir_operations
;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
/* directory inodes start off with i_nlink == 2 (for "." entry) */
...
@@ -182,29 +142,6 @@ static int sysfs_symlink(struct inode * dir, struct dentry *dentry, const char *
...
@@ -182,29 +142,6 @@ static int sysfs_symlink(struct inode * dir, struct dentry *dentry, const char *
return
error
;
return
error
;
}
}
static
inline
int
sysfs_positive
(
struct
dentry
*
dentry
)
{
return
(
dentry
->
d_inode
&&
!
d_unhashed
(
dentry
));
}
static
int
sysfs_empty
(
struct
dentry
*
dentry
)
{
struct
list_head
*
list
;
spin_lock
(
&
dcache_lock
);
list_for_each
(
list
,
&
dentry
->
d_subdirs
)
{
struct
dentry
*
de
=
list_entry
(
list
,
struct
dentry
,
d_child
);
if
(
sysfs_positive
(
de
))
{
spin_unlock
(
&
dcache_lock
);
return
0
;
}
}
spin_unlock
(
&
dcache_lock
);
return
1
;
}
static
int
sysfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
static
int
sysfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
{
struct
inode
*
inode
=
dentry
->
d_inode
;
struct
inode
*
inode
=
dentry
->
d_inode
;
...
@@ -329,32 +266,6 @@ sysfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos)
...
@@ -329,32 +266,6 @@ sysfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos)
return
retval
;
return
retval
;
}
}
static
loff_t
sysfs_file_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
retval
=
-
EINVAL
;
down
(
&
file
->
f_dentry
->
d_inode
->
i_sem
);
switch
(
orig
)
{
case
0
:
if
(
offset
>
0
)
{
file
->
f_pos
=
offset
;
retval
=
file
->
f_pos
;
}
break
;
case
1
:
if
((
offset
+
file
->
f_pos
)
>
0
)
{
file
->
f_pos
+=
offset
;
retval
=
file
->
f_pos
;
}
break
;
default:
break
;
}
up
(
&
file
->
f_dentry
->
d_inode
->
i_sem
);
return
retval
;
}
static
int
sysfs_open_file
(
struct
inode
*
inode
,
struct
file
*
filp
)
static
int
sysfs_open_file
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
{
struct
driver_dir_entry
*
dir
;
struct
driver_dir_entry
*
dir
;
...
@@ -386,20 +297,16 @@ static int sysfs_release(struct inode * inode, struct file * filp)
...
@@ -386,20 +297,16 @@ static int sysfs_release(struct inode * inode, struct file * filp)
static
struct
file_operations
sysfs_file_operations
=
{
static
struct
file_operations
sysfs_file_operations
=
{
.
read
=
sysfs_read_file
,
.
read
=
sysfs_read_file
,
.
write
=
sysfs_write_file
,
.
write
=
sysfs_write_file
,
.
llseek
=
sysfs_file_
lseek
,
.
llseek
=
generic_file_l
lseek
,
.
open
=
sysfs_open_file
,
.
open
=
sysfs_open_file
,
.
release
=
sysfs_release
,
.
release
=
sysfs_release
,
};
};
static
struct
inode_operations
sysfs_dir_inode_operations
=
{
.
lookup
=
simple_lookup
,
};
static
struct
address_space_operations
sysfs_aops
=
{
static
struct
address_space_operations
sysfs_aops
=
{
.
readpage
=
s
ysfs
_readpage
,
.
readpage
=
s
imple
_readpage
,
.
writepage
=
fail_writepage
,
.
writepage
=
fail_writepage
,
.
prepare_write
=
s
ysfs
_prepare_write
,
.
prepare_write
=
s
imple
_prepare_write
,
.
commit_write
=
s
ysfs
_commit_write
.
commit_write
=
s
imple
_commit_write
};
};
static
struct
super_operations
sysfs_ops
=
{
static
struct
super_operations
sysfs_ops
=
{
...
@@ -622,7 +529,7 @@ void sysfs_remove_dir(struct driver_dir_entry * dir)
...
@@ -622,7 +529,7 @@ void sysfs_remove_dir(struct driver_dir_entry * dir)
}
}
d_invalidate
(
dentry
);
d_invalidate
(
dentry
);
if
(
s
ysfs
_empty
(
dentry
))
{
if
(
s
imple
_empty
(
dentry
))
{
dentry
->
d_inode
->
i_nlink
-=
2
;
dentry
->
d_inode
->
i_nlink
-=
2
;
dentry
->
d_inode
->
i_flags
|=
S_DEAD
;
dentry
->
d_inode
->
i_flags
|=
S_DEAD
;
parent
->
d_inode
->
i_nlink
--
;
parent
->
d_inode
->
i_nlink
--
;
...
...
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