X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Ffile.c;h=92b5f25985d2f75d09022ebbe1e4a6008cd2132d;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=d40c4028fab2e437e543510dfde5e43665588ce1;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/fs/file.c b/fs/file.c index d40c4028f..92b5f2598 100644 --- a/fs/file.c +++ b/fs/file.c @@ -12,8 +12,7 @@ #include #include #include - -#include +#include /* @@ -54,7 +53,9 @@ void free_fd_array(struct file **array, int num) * 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; @@ -157,7 +158,9 @@ void free_fdset(fd_set *array, int num) * 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 = NULL, *new_execset = NULL; int error, nfds = 0; @@ -226,3 +229,26 @@ out: 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; +}