|
|
|
@ -23,12 +23,12 @@ |
|
|
|
|
#include <linux/rcupdate.h> |
|
|
|
|
#include <linux/workqueue.h> |
|
|
|
|
|
|
|
|
|
int sysctl_nr_open __read_mostly = 1024*1024; |
|
|
|
|
int sysctl_nr_open_min = BITS_PER_LONG; |
|
|
|
|
unsigned int sysctl_nr_open __read_mostly = 1024*1024; |
|
|
|
|
unsigned int sysctl_nr_open_min = BITS_PER_LONG; |
|
|
|
|
/* our min() is unusable in constant expressions ;-/ */ |
|
|
|
|
#define __const_min(x, y) ((x) < (y) ? (x) : (y)) |
|
|
|
|
int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & |
|
|
|
|
-BITS_PER_LONG; |
|
|
|
|
unsigned int sysctl_nr_open_max = |
|
|
|
|
__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG; |
|
|
|
|
|
|
|
|
|
static void *alloc_fdmem(size_t size) |
|
|
|
|
{ |
|
|
|
@ -163,7 +163,7 @@ out: |
|
|
|
|
* Return <0 error code on error; 1 on successful completion. |
|
|
|
|
* The files->file_lock should be held on entry, and will be held on exit. |
|
|
|
|
*/ |
|
|
|
|
static int expand_fdtable(struct files_struct *files, int nr) |
|
|
|
|
static int expand_fdtable(struct files_struct *files, unsigned int nr) |
|
|
|
|
__releases(files->file_lock) |
|
|
|
|
__acquires(files->file_lock) |
|
|
|
|
{ |
|
|
|
@ -208,7 +208,7 @@ static int expand_fdtable(struct files_struct *files, int nr) |
|
|
|
|
* expanded and execution may have blocked. |
|
|
|
|
* The files->file_lock should be held on entry, and will be held on exit. |
|
|
|
|
*/ |
|
|
|
|
static int expand_files(struct files_struct *files, int nr) |
|
|
|
|
static int expand_files(struct files_struct *files, unsigned int nr) |
|
|
|
|
__releases(files->file_lock) |
|
|
|
|
__acquires(files->file_lock) |
|
|
|
|
{ |
|
|
|
@ -243,12 +243,12 @@ repeat: |
|
|
|
|
return expanded; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline void __set_close_on_exec(int fd, struct fdtable *fdt) |
|
|
|
|
static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) |
|
|
|
|
{ |
|
|
|
|
__set_bit(fd, fdt->close_on_exec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline void __clear_close_on_exec(int fd, struct fdtable *fdt) |
|
|
|
|
static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) |
|
|
|
|
{ |
|
|
|
|
if (test_bit(fd, fdt->close_on_exec)) |
|
|
|
|
__clear_bit(fd, fdt->close_on_exec); |
|
|
|
@ -268,10 +268,10 @@ static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) |
|
|
|
|
__clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int count_open_files(struct fdtable *fdt) |
|
|
|
|
static unsigned int count_open_files(struct fdtable *fdt) |
|
|
|
|
{ |
|
|
|
|
int size = fdt->max_fds; |
|
|
|
|
int i; |
|
|
|
|
unsigned int size = fdt->max_fds; |
|
|
|
|
unsigned int i; |
|
|
|
|
|
|
|
|
|
/* Find the last open fd */ |
|
|
|
|
for (i = size / BITS_PER_LONG; i > 0; ) { |
|
|
|
@ -291,7 +291,7 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) |
|
|
|
|
{ |
|
|
|
|
struct files_struct *newf; |
|
|
|
|
struct file **old_fds, **new_fds; |
|
|
|
|
int open_files, i; |
|
|
|
|
unsigned int open_files, i; |
|
|
|
|
struct fdtable *old_fdt, *new_fdt; |
|
|
|
|
|
|
|
|
|
*errorp = -ENOMEM; |
|
|
|
@ -391,7 +391,7 @@ static struct fdtable *close_files(struct files_struct * files) |
|
|
|
|
* files structure. |
|
|
|
|
*/ |
|
|
|
|
struct fdtable *fdt = rcu_dereference_raw(files->fdt); |
|
|
|
|
int i, j = 0; |
|
|
|
|
unsigned int i, j = 0; |
|
|
|
|
|
|
|
|
|
for (;;) { |
|
|
|
|
unsigned long set; |
|
|
|
@ -477,11 +477,11 @@ struct files_struct init_files = { |
|
|
|
|
.file_lock = __SPIN_LOCK_UNLOCKED(init_files.file_lock), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static unsigned long find_next_fd(struct fdtable *fdt, unsigned long start) |
|
|
|
|
static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) |
|
|
|
|
{ |
|
|
|
|
unsigned long maxfd = fdt->max_fds; |
|
|
|
|
unsigned long maxbit = maxfd / BITS_PER_LONG; |
|
|
|
|
unsigned long bitbit = start / BITS_PER_LONG; |
|
|
|
|
unsigned int maxfd = fdt->max_fds; |
|
|
|
|
unsigned int maxbit = maxfd / BITS_PER_LONG; |
|
|
|
|
unsigned int bitbit = start / BITS_PER_LONG; |
|
|
|
|
|
|
|
|
|
bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; |
|
|
|
|
if (bitbit > maxfd) |
|
|
|
|