Skip to content

Commit

Permalink
file: Merge __alloc_fd into alloc_fd
Browse files Browse the repository at this point in the history
The function __alloc_fd was added to support binder[1].  With binder
fixed[2] there are no more users.

As alloc_fd just calls __alloc_fd with "files=current->files",
merge them together by transforming the files parameter into a
local variable initialized to current->files.

[1] dcfadfa ("new helper: __alloc_fd()")
[2] 44d8047 ("binder: use standard functions to allocate fds")
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
v1: https://lkml.kernel.org/r/20200817220425.9389-16-ebiederm@xmission.com
Link: https://lkml.kernel.org/r/20201120231441.29911-20-ebiederm@xmission.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
  • Loading branch information
Eric W. Biederman committed Dec 10, 2020
1 parent e06b53c commit aa384d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 3 additions & 8 deletions fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)
/*
* allocate a file descriptor, mark it busy.
*/
int __alloc_fd(struct files_struct *files,
unsigned start, unsigned end, unsigned flags)
static int alloc_fd(unsigned start, unsigned end, unsigned flags)
{
struct files_struct *files = current->files;
unsigned int fd;
int error;
struct fdtable *fdt;
Expand Down Expand Up @@ -538,14 +538,9 @@ int __alloc_fd(struct files_struct *files,
return error;
}

static int alloc_fd(unsigned start, unsigned end, unsigned flags)
{
return __alloc_fd(current->files, start, end, flags);
}

int __get_unused_fd_flags(unsigned flags, unsigned long nofile)
{
return __alloc_fd(current->files, 0, nofile, flags);
return alloc_fd(0, nofile, flags);
}

int get_unused_fd_flags(unsigned flags)
Expand Down
2 changes: 0 additions & 2 deletions include/linux/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ int iterate_fd(struct files_struct *, unsigned,
int (*)(const void *, struct file *, unsigned),
const void *);

extern int __alloc_fd(struct files_struct *files,
unsigned start, unsigned end, unsigned flags);
extern int __close_fd(struct files_struct *files,
unsigned int fd);
extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags);
Expand Down

0 comments on commit aa384d1

Please sign in to comment.