}
task_lock(p);
if (p->files) {
- read_lock(&p->files->file_lock);
+ spin_lock(&p->files->file_lock);
for (i=0; i < p->files->max_fds; i++) {
filp = fcheck_files(p->files, i);
if (filp && (filp->f_op == &tty_fops) &&
break;
}
}
- read_unlock(&p->files->file_lock);
+ spin_unlock(&p->files->file_lock);
}
task_unlock(p);
}
{
long j = -1;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
for (;;) {
unsigned long set, i;
if (!set)
continue;
files->close_on_exec->fds_bits[j] = 0;
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
for ( ; set ; i++,set >>= 1) {
if (set & 1) {
sys_close(i);
}
}
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
}
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
}
int flush_old_exec(struct linux_binprm * bprm)
void set_close_on_exec(unsigned int fd, int flag)
{
struct files_struct *files = current->files;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (flag)
FD_SET(fd, files->close_on_exec);
else
FD_CLR(fd, files->close_on_exec);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
}
static inline int get_close_on_exec(unsigned int fd)
{
struct files_struct *files = current->files;
int res;
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
res = FD_ISSET(fd, files->close_on_exec);
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
return res;
}
struct files_struct * files = current->files;
int fd;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
fd = locate_fd(files, file, start);
if (fd >= 0) {
FD_SET(fd, files->open_fds);
FD_CLR(fd, files->close_on_exec);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
fd_install(fd, file);
} else {
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
fput(file);
}
struct file * file, *tofree;
struct files_struct * files = current->files;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (!(file = fcheck(oldfd)))
goto out_unlock;
err = newfd;
files->fd[newfd] = file;
FD_SET(newfd, files->open_fds);
FD_CLR(newfd, files->close_on_exec);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
if (tofree)
filp_close(tofree, files);
out:
return err;
out_unlock:
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
goto out;
out_fput:
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
fput(file);
goto out;
}
goto out;
nfds = files->max_fds;
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
/*
* Expand to the max in easy steps, and keep expanding it until
error = -ENOMEM;
new_fds = alloc_fd_array(nfds);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (!new_fds)
goto out;
memset(&new_fds[i], 0,
(nfds-i) * sizeof(struct file *));
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
free_fd_array(old_fds, i);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
}
} else {
/* Somebody expanded the array while we slept ... */
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
free_fd_array(new_fds, nfds);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
}
error = 0;
out:
goto out;
nfds = files->max_fdset;
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
/* Expand to the max in easy steps */
do {
error = -ENOMEM;
new_openset = alloc_fdset(nfds);
new_execset = alloc_fdset(nfds);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (!new_openset || !new_execset)
goto out;
nfds = xchg(&files->max_fdset, nfds);
new_openset = xchg(&files->open_fds, new_openset);
new_execset = xchg(&files->close_on_exec, new_execset);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
free_fdset (new_openset, nfds);
free_fdset (new_execset, nfds);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
return 0;
}
/* Somebody expanded the array while we slept ... */
out:
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
if (new_openset)
free_fdset(new_openset, nfds);
if (new_execset)
free_fdset(new_execset, nfds);
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
return error;
}
struct file *file;
struct files_struct *files = current->files;
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
file = fcheck(fd);
if (file)
get_file(file);
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
return file;
}
int fd, error;
error = -EMFILE;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
repeat:
fd = find_next_zero_bit(files->open_fds->fds_bits,
error = fd;
out:
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
return error;
}
void put_unused_fd(unsigned int fd)
{
struct files_struct *files = current->files;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
__put_unused_fd(files, fd);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
}
/*
void fd_install(unsigned int fd, struct file * file)
{
struct files_struct *files = current->files;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (unlikely(files->fd[fd] != NULL))
BUG();
files->fd[fd] = file;
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
}
asmlinkage long sys_open(const char __user * filename, int flags, int mode)
struct file * filp;
struct files_struct *files = current->files;
- write_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (fd >= files->max_fds)
goto out_unlock;
filp = files->fd[fd];
files->fd[fd] = NULL;
FD_CLR(fd, files->close_on_exec);
__put_unused_fd(files, fd);
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
return filp_close(filp, files);
out_unlock:
- write_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
return -EBADF;
}
atomic_inc(&files->count);
task_unlock(task);
if (files) {
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
file = fcheck_files(files, fd);
if (file) {
*mnt = mntget(file->f_vfsmnt);
*dentry = dget(file->f_dentry);
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
return 0;
}
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
}
return -ENOENT;
task_unlock(p);
if (!files)
goto out;
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
for (fd = filp->f_pos-2;
fd < files->max_fds;
fd++, filp->f_pos++) {
if (!fcheck_files(files, fd))
continue;
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
j = NUMBUF;
i = fd;
ino = fake_ino(pid, PROC_PID_FD_DIR + fd);
if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) {
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
break;
}
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
}
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
}
out:
atomic_inc(&files->count);
task_unlock(task);
if (files) {
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
if (fcheck_files(files, fd)) {
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
return 1;
}
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
}
d_drop(dentry);
if (!files)
goto out_unlock;
inode->i_mode = S_IFLNK;
- read_lock(&files->file_lock);
+ spin_lock(&files->file_lock);
file = fcheck_files(files, fd);
if (!file)
goto out_unlock2;
inode->i_mode |= S_IRUSR | S_IXUSR;
if (file->f_mode & 2)
inode->i_mode |= S_IWUSR | S_IXUSR;
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
inode->i_op = &proc_pid_link_inode_operations;
inode->i_size = 64;
return NULL;
out_unlock2:
- read_unlock(&files->file_lock);
+ spin_unlock(&files->file_lock);
put_files_struct(files);
out_unlock:
iput(inode);
int retval, i, off;
long __timeout = *timeout;
- read_lock(¤t->files->file_lock);
+ spin_lock(¤t->files->file_lock);
retval = max_select_fd(n, fds);
- read_unlock(¤t->files->file_lock);
+ spin_unlock(¤t->files->file_lock);
if (retval < 0)
return retval;
*/
struct files_struct {
atomic_t count;
- rwlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
+ spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
int max_fds;
int max_fdset;
int next_fd;
#define INIT_FILES \
{ \
.count = ATOMIC_INIT(1), \
- .file_lock = RW_LOCK_UNLOCKED, \
+ .file_lock = SPIN_LOCK_UNLOCKED, \
.max_fds = NR_OPEN_DEFAULT, \
.max_fdset = __FD_SETSIZE, \
.next_fd = 0, \
atomic_set(&newf->count, 1);
- newf->file_lock = RW_LOCK_UNLOCKED;
+ newf->file_lock = SPIN_LOCK_UNLOCKED;
newf->next_fd = 0;
newf->max_fds = NR_OPEN_DEFAULT;
newf->max_fdset = __FD_SETSIZE;
size = oldf->max_fdset;
if (size > __FD_SETSIZE) {
newf->max_fdset = 0;
- write_lock(&newf->file_lock);
+ spin_lock(&newf->file_lock);
error = expand_fdset(newf, size-1);
- write_unlock(&newf->file_lock);
+ spin_unlock(&newf->file_lock);
if (error)
goto out_release;
}
- read_lock(&oldf->file_lock);
+ spin_lock(&oldf->file_lock);
open_files = count_open_files(oldf, size);
*/
nfds = NR_OPEN_DEFAULT;
if (open_files > nfds) {
- read_unlock(&oldf->file_lock);
+ spin_unlock(&oldf->file_lock);
newf->max_fds = 0;
- write_lock(&newf->file_lock);
+ spin_lock(&newf->file_lock);
error = expand_fd_array(newf, open_files-1);
- write_unlock(&newf->file_lock);
+ spin_unlock(&newf->file_lock);
if (error)
goto out_release;
nfds = newf->max_fds;
- read_lock(&oldf->file_lock);
+ spin_lock(&oldf->file_lock);
}
old_fds = oldf->fd;
get_file(f);
*new_fds++ = f;
}
- read_unlock(&oldf->file_lock);
+ spin_unlock(&oldf->file_lock);
/* compute the remainder to be cleared */
size = (newf->max_fds - open_files) * sizeof(struct file *);