#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/file.h>
-
-#include <asm/bitops.h>
+#include <linux/bitops.h>
/*
* spinlock held for write.
*/
-int expand_fd_array(struct files_struct *files, int nr)
+static int expand_fd_array(struct files_struct *files, int nr)
+ __releases(files->file_lock)
+ __acquires(files->file_lock)
{
struct file **new_fds;
int error, nfds;
* Expand the fdset in the files_struct. Called with the files spinlock
* held for write.
*/
-int expand_fdset(struct files_struct *files, int nr)
+static int expand_fdset(struct files_struct *files, int nr)
+ __releases(file->file_lock)
+ __acquires(file->file_lock)
{
- fd_set *new_openset = 0, *new_execset = 0;
+ fd_set *new_openset = NULL, *new_execset = NULL;
int error, nfds = 0;
error = -EMFILE;
return error;
}
+/*
+ * Expand files.
+ * Return <0 on error; 0 nothing done; 1 files expanded, we may have blocked.
+ * Should be called with the files->file_lock spinlock held for write.
+ */
+int expand_files(struct files_struct *files, int nr)
+{
+ int err, expand = 0;
+
+ if (nr >= files->max_fdset) {
+ expand = 1;
+ if ((err = expand_fdset(files, nr)))
+ goto out;
+ }
+ if (nr >= files->max_fds) {
+ expand = 1;
+ if ((err = expand_fd_array(files, nr)))
+ goto out;
+ }
+ err = expand;
+out:
+ return err;
+}