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
6e0b96ce
Commit
6e0b96ce
authored
Jul 30, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
driverfs: consolidate all the hashed lookups into a static helper: get_dentry()
parent
99db4061
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
21 deletions
+14
-21
fs/driverfs/inode.c
fs/driverfs/inode.c
+14
-21
No files found.
fs/driverfs/inode.c
View file @
6e0b96ce
...
...
@@ -558,6 +558,16 @@ int __init init_driverfs_fs(void)
return
register_filesystem
(
&
driverfs_fs_type
);
}
static
struct
dentry
*
get_dentry
(
struct
dentry
*
parent
,
const
char
*
name
)
{
struct
qstr
qstr
;
qstr
.
name
=
name
;
qstr
.
len
=
strlen
(
name
);
qstr
.
hash
=
full_name_hash
(
name
,
qstr
.
len
);
return
lookup_hash
(
&
qstr
,
parent
);
}
/**
* driverfs_create_dir - create a directory in the filesystem
* @entry: directory entry
...
...
@@ -569,7 +579,6 @@ driverfs_create_dir(struct driver_dir_entry * entry,
{
struct
dentry
*
dentry
=
NULL
;
struct
dentry
*
parent_dentry
;
struct
qstr
qstr
;
int
error
=
0
;
if
(
!
entry
)
...
...
@@ -589,10 +598,7 @@ driverfs_create_dir(struct driver_dir_entry * entry,
}
down
(
&
parent_dentry
->
d_inode
->
i_sem
);
qstr
.
name
=
entry
->
name
;
qstr
.
len
=
strlen
(
entry
->
name
);
qstr
.
hash
=
full_name_hash
(
entry
->
name
,
qstr
.
len
);
dentry
=
lookup_hash
(
&
qstr
,
parent_dentry
);
dentry
=
get_dentry
(
parent_dentry
,
entry
->
name
);
if
(
!
IS_ERR
(
dentry
))
{
dentry
->
d_fsdata
=
(
void
*
)
entry
;
entry
->
dentry
=
dentry
;
...
...
@@ -616,7 +622,6 @@ driverfs_create_file(struct driver_file_entry * entry,
struct
driver_dir_entry
*
parent
)
{
struct
dentry
*
dentry
;
struct
qstr
qstr
;
int
error
=
0
;
if
(
!
entry
||
!
parent
)
...
...
@@ -631,10 +636,7 @@ driverfs_create_file(struct driver_file_entry * entry,
}
down
(
&
parent
->
dentry
->
d_inode
->
i_sem
);
qstr
.
name
=
entry
->
name
;
qstr
.
len
=
strlen
(
entry
->
name
);
qstr
.
hash
=
full_name_hash
(
entry
->
name
,
qstr
.
len
);
dentry
=
lookup_hash
(
&
qstr
,
parent
->
dentry
);
dentry
=
get_dentry
(
parent
->
dentry
,
entry
->
name
);
if
(
!
IS_ERR
(
dentry
))
{
dentry
->
d_fsdata
=
(
void
*
)
entry
;
error
=
driverfs_create
(
parent
->
dentry
->
d_inode
,
dentry
,
entry
->
mode
);
...
...
@@ -658,7 +660,6 @@ int driverfs_create_symlink(struct driver_dir_entry * parent,
char
*
target
)
{
struct
dentry
*
dentry
;
struct
qstr
qstr
;
int
error
=
0
;
if
(
!
entry
||
!
parent
)
...
...
@@ -671,10 +672,7 @@ int driverfs_create_symlink(struct driver_dir_entry * parent,
return
-
EINVAL
;
}
down
(
&
parent
->
dentry
->
d_inode
->
i_sem
);
qstr
.
name
=
entry
->
name
;
qstr
.
len
=
strlen
(
entry
->
name
);
qstr
.
hash
=
full_name_hash
(
entry
->
name
,
qstr
.
len
);
dentry
=
lookup_hash
(
&
qstr
,
parent
->
dentry
);
dentry
=
get_dentry
(
parent
->
dentry
,
entry
->
name
);
if
(
!
IS_ERR
(
dentry
))
{
dentry
->
d_fsdata
=
(
void
*
)
entry
;
error
=
driverfs_symlink
(
parent
->
dentry
->
d_inode
,
dentry
,
target
);
...
...
@@ -697,17 +695,12 @@ int driverfs_create_symlink(struct driver_dir_entry * parent,
void
driverfs_remove_file
(
struct
driver_dir_entry
*
dir
,
const
char
*
name
)
{
struct
dentry
*
dentry
;
struct
qstr
qstr
;
if
(
!
dir
->
dentry
)
return
;
down
(
&
dir
->
dentry
->
d_inode
->
i_sem
);
qstr
.
name
=
name
;
qstr
.
len
=
strlen
(
name
);
qstr
.
hash
=
full_name_hash
(
name
,
qstr
.
len
);
dentry
=
lookup_hash
(
&
qstr
,
dir
->
dentry
);
dentry
=
get_dentry
(
dir
->
dentry
,
name
);
if
(
!
IS_ERR
(
dentry
))
{
/* make sure dentry is really there */
if
(
dentry
->
d_inode
&&
...
...
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