mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
new helper: __alloc_fd()
Essentially, alloc_fd() in a files_struct we own a reference to. Most of the time wanting to use it is a sign of lousy API design (such as android/binder). It's *not* a general-purpose interface; better that than open-coding its guts, but again, playing with other process' descriptor table is a sign of bad design. Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
f33ff9927f
commit
dcfadfa4ec
3 changed files with 16 additions and 58 deletions
12
fs/file.c
12
fs/file.c
|
|
@ -420,11 +420,10 @@ struct files_struct init_files = {
|
|||
/*
|
||||
* allocate a file descriptor, mark it busy.
|
||||
*/
|
||||
int alloc_fd(unsigned start, unsigned flags)
|
||||
int __alloc_fd(struct files_struct *files,
|
||||
unsigned start, unsigned end, unsigned flags)
|
||||
{
|
||||
struct files_struct *files = current->files;
|
||||
unsigned int fd;
|
||||
unsigned end = rlimit(RLIMIT_NOFILE);
|
||||
int error;
|
||||
struct fdtable *fdt;
|
||||
|
||||
|
|
@ -479,8 +478,13 @@ out:
|
|||
return error;
|
||||
}
|
||||
|
||||
int alloc_fd(unsigned start, unsigned flags)
|
||||
{
|
||||
return __alloc_fd(current->files, start, rlimit(RLIMIT_NOFILE), flags);
|
||||
}
|
||||
|
||||
int get_unused_fd_flags(unsigned flags)
|
||||
{
|
||||
return alloc_fd(0, flags);
|
||||
return __alloc_fd(current->files, 0, rlimit(RLIMIT_NOFILE), flags);
|
||||
}
|
||||
EXPORT_SYMBOL(get_unused_fd_flags);
|
||||
|
|
|
|||
Loading…
Reference in a new issue