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
nexedi
linux
Commits
56007cae
Commit
56007cae
authored
Aug 15, 2012
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move put_unused_fd() and fd_install() to fs/file.c
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
1983e781
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
44 deletions
+44
-44
fs/file.c
fs/file.c
+44
-0
fs/open.c
fs/open.c
+0
-44
No files found.
fs/file.c
View file @
56007cae
...
...
@@ -569,3 +569,47 @@ int get_unused_fd_flags(unsigned flags)
return
__alloc_fd
(
current
->
files
,
0
,
rlimit
(
RLIMIT_NOFILE
),
flags
);
}
EXPORT_SYMBOL
(
get_unused_fd_flags
);
static
void
__put_unused_fd
(
struct
files_struct
*
files
,
unsigned
int
fd
)
{
struct
fdtable
*
fdt
=
files_fdtable
(
files
);
__clear_open_fd
(
fd
,
fdt
);
if
(
fd
<
files
->
next_fd
)
files
->
next_fd
=
fd
;
}
void
put_unused_fd
(
unsigned
int
fd
)
{
struct
files_struct
*
files
=
current
->
files
;
spin_lock
(
&
files
->
file_lock
);
__put_unused_fd
(
files
,
fd
);
spin_unlock
(
&
files
->
file_lock
);
}
EXPORT_SYMBOL
(
put_unused_fd
);
/*
* Install a file pointer in the fd array.
*
* The VFS is full of places where we drop the files lock between
* setting the open_fds bitmap and installing the file in the file
* array. At any such point, we are vulnerable to a dup2() race
* installing a file in the array before us. We need to detect this and
* fput() the struct file we are about to overwrite in this case.
*
* It should never happen - if we allow dup2() do it, _really_ bad things
* will follow.
*/
void
fd_install
(
unsigned
int
fd
,
struct
file
*
file
)
{
struct
files_struct
*
files
=
current
->
files
;
struct
fdtable
*
fdt
;
spin_lock
(
&
files
->
file_lock
);
fdt
=
files_fdtable
(
files
);
BUG_ON
(
fdt
->
fd
[
fd
]
!=
NULL
);
rcu_assign_pointer
(
fdt
->
fd
[
fd
],
file
);
spin_unlock
(
&
files
->
file_lock
);
}
EXPORT_SYMBOL
(
fd_install
);
fs/open.c
View file @
56007cae
...
...
@@ -803,50 +803,6 @@ struct file *dentry_open(const struct path *path, int flags,
}
EXPORT_SYMBOL
(
dentry_open
);
static
void
__put_unused_fd
(
struct
files_struct
*
files
,
unsigned
int
fd
)
{
struct
fdtable
*
fdt
=
files_fdtable
(
files
);
__clear_open_fd
(
fd
,
fdt
);
if
(
fd
<
files
->
next_fd
)
files
->
next_fd
=
fd
;
}
void
put_unused_fd
(
unsigned
int
fd
)
{
struct
files_struct
*
files
=
current
->
files
;
spin_lock
(
&
files
->
file_lock
);
__put_unused_fd
(
files
,
fd
);
spin_unlock
(
&
files
->
file_lock
);
}
EXPORT_SYMBOL
(
put_unused_fd
);
/*
* Install a file pointer in the fd array.
*
* The VFS is full of places where we drop the files lock between
* setting the open_fds bitmap and installing the file in the file
* array. At any such point, we are vulnerable to a dup2() race
* installing a file in the array before us. We need to detect this and
* fput() the struct file we are about to overwrite in this case.
*
* It should never happen - if we allow dup2() do it, _really_ bad things
* will follow.
*/
void
fd_install
(
unsigned
int
fd
,
struct
file
*
file
)
{
struct
files_struct
*
files
=
current
->
files
;
struct
fdtable
*
fdt
;
spin_lock
(
&
files
->
file_lock
);
fdt
=
files_fdtable
(
files
);
BUG_ON
(
fdt
->
fd
[
fd
]
!=
NULL
);
rcu_assign_pointer
(
fdt
->
fd
[
fd
],
file
);
spin_unlock
(
&
files
->
file_lock
);
}
EXPORT_SYMBOL
(
fd_install
);
static
inline
int
build_open_flags
(
int
flags
,
umode_t
mode
,
struct
open_flags
*
op
)
{
int
lookup_flags
=
0
;
...
...
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