diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
commit | 905ec87e93bc9e01b15c60035cd6a50c636cbaef (patch) | |
tree | 46fd7618d6511611ffc19eb0dd4d7bc6b90a41c2 /fs/proc/base.c | |
parent | 1d6ae775d7a948c9575658eb41184fd2e506c0df (diff) | |
parent | 2f4ba45a75d6383b4a1201169a808ffea416ffa0 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 84751f3f52d5..23db452ab428 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/namespace.h> | 62 | #include <linux/namespace.h> |
63 | #include <linux/mm.h> | 63 | #include <linux/mm.h> |
64 | #include <linux/smp_lock.h> | 64 | #include <linux/smp_lock.h> |
65 | #include <linux/rcupdate.h> | ||
65 | #include <linux/kallsyms.h> | 66 | #include <linux/kallsyms.h> |
66 | #include <linux/mount.h> | 67 | #include <linux/mount.h> |
67 | #include <linux/security.h> | 68 | #include <linux/security.h> |
@@ -283,16 +284,16 @@ static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsm | |||
283 | 284 | ||
284 | files = get_files_struct(task); | 285 | files = get_files_struct(task); |
285 | if (files) { | 286 | if (files) { |
286 | spin_lock(&files->file_lock); | 287 | rcu_read_lock(); |
287 | file = fcheck_files(files, fd); | 288 | file = fcheck_files(files, fd); |
288 | if (file) { | 289 | if (file) { |
289 | *mnt = mntget(file->f_vfsmnt); | 290 | *mnt = mntget(file->f_vfsmnt); |
290 | *dentry = dget(file->f_dentry); | 291 | *dentry = dget(file->f_dentry); |
291 | spin_unlock(&files->file_lock); | 292 | rcu_read_unlock(); |
292 | put_files_struct(files); | 293 | put_files_struct(files); |
293 | return 0; | 294 | return 0; |
294 | } | 295 | } |
295 | spin_unlock(&files->file_lock); | 296 | rcu_read_unlock(); |
296 | put_files_struct(files); | 297 | put_files_struct(files); |
297 | } | 298 | } |
298 | return -ENOENT; | 299 | return -ENOENT; |
@@ -1039,6 +1040,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) | |||
1039 | int retval; | 1040 | int retval; |
1040 | char buf[NUMBUF]; | 1041 | char buf[NUMBUF]; |
1041 | struct files_struct * files; | 1042 | struct files_struct * files; |
1043 | struct fdtable *fdt; | ||
1042 | 1044 | ||
1043 | retval = -ENOENT; | 1045 | retval = -ENOENT; |
1044 | if (!pid_alive(p)) | 1046 | if (!pid_alive(p)) |
@@ -1061,15 +1063,16 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) | |||
1061 | files = get_files_struct(p); | 1063 | files = get_files_struct(p); |
1062 | if (!files) | 1064 | if (!files) |
1063 | goto out; | 1065 | goto out; |
1064 | spin_lock(&files->file_lock); | 1066 | rcu_read_lock(); |
1067 | fdt = files_fdtable(files); | ||
1065 | for (fd = filp->f_pos-2; | 1068 | for (fd = filp->f_pos-2; |
1066 | fd < files->max_fds; | 1069 | fd < fdt->max_fds; |
1067 | fd++, filp->f_pos++) { | 1070 | fd++, filp->f_pos++) { |
1068 | unsigned int i,j; | 1071 | unsigned int i,j; |
1069 | 1072 | ||
1070 | if (!fcheck_files(files, fd)) | 1073 | if (!fcheck_files(files, fd)) |
1071 | continue; | 1074 | continue; |
1072 | spin_unlock(&files->file_lock); | 1075 | rcu_read_unlock(); |
1073 | 1076 | ||
1074 | j = NUMBUF; | 1077 | j = NUMBUF; |
1075 | i = fd; | 1078 | i = fd; |
@@ -1081,12 +1084,12 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) | |||
1081 | 1084 | ||
1082 | ino = fake_ino(tid, PROC_TID_FD_DIR + fd); | 1085 | ino = fake_ino(tid, PROC_TID_FD_DIR + fd); |
1083 | if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) { | 1086 | if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) { |
1084 | spin_lock(&files->file_lock); | 1087 | rcu_read_lock(); |
1085 | break; | 1088 | break; |
1086 | } | 1089 | } |
1087 | spin_lock(&files->file_lock); | 1090 | rcu_read_lock(); |
1088 | } | 1091 | } |
1089 | spin_unlock(&files->file_lock); | 1092 | rcu_read_unlock(); |
1090 | put_files_struct(files); | 1093 | put_files_struct(files); |
1091 | } | 1094 | } |
1092 | out: | 1095 | out: |
@@ -1261,9 +1264,9 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1261 | 1264 | ||
1262 | files = get_files_struct(task); | 1265 | files = get_files_struct(task); |
1263 | if (files) { | 1266 | if (files) { |
1264 | spin_lock(&files->file_lock); | 1267 | rcu_read_lock(); |
1265 | if (fcheck_files(files, fd)) { | 1268 | if (fcheck_files(files, fd)) { |
1266 | spin_unlock(&files->file_lock); | 1269 | rcu_read_unlock(); |
1267 | put_files_struct(files); | 1270 | put_files_struct(files); |
1268 | if (task_dumpable(task)) { | 1271 | if (task_dumpable(task)) { |
1269 | inode->i_uid = task->euid; | 1272 | inode->i_uid = task->euid; |
@@ -1275,7 +1278,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1275 | security_task_to_inode(task, inode); | 1278 | security_task_to_inode(task, inode); |
1276 | return 1; | 1279 | return 1; |
1277 | } | 1280 | } |
1278 | spin_unlock(&files->file_lock); | 1281 | rcu_read_unlock(); |
1279 | put_files_struct(files); | 1282 | put_files_struct(files); |
1280 | } | 1283 | } |
1281 | d_drop(dentry); | 1284 | d_drop(dentry); |
@@ -1367,7 +1370,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, | |||
1367 | if (!files) | 1370 | if (!files) |
1368 | goto out_unlock; | 1371 | goto out_unlock; |
1369 | inode->i_mode = S_IFLNK; | 1372 | inode->i_mode = S_IFLNK; |
1370 | spin_lock(&files->file_lock); | 1373 | rcu_read_lock(); |
1371 | file = fcheck_files(files, fd); | 1374 | file = fcheck_files(files, fd); |
1372 | if (!file) | 1375 | if (!file) |
1373 | goto out_unlock2; | 1376 | goto out_unlock2; |
@@ -1375,7 +1378,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, | |||
1375 | inode->i_mode |= S_IRUSR | S_IXUSR; | 1378 | inode->i_mode |= S_IRUSR | S_IXUSR; |
1376 | if (file->f_mode & 2) | 1379 | if (file->f_mode & 2) |
1377 | inode->i_mode |= S_IWUSR | S_IXUSR; | 1380 | inode->i_mode |= S_IWUSR | S_IXUSR; |
1378 | spin_unlock(&files->file_lock); | 1381 | rcu_read_unlock(); |
1379 | put_files_struct(files); | 1382 | put_files_struct(files); |
1380 | inode->i_op = &proc_pid_link_inode_operations; | 1383 | inode->i_op = &proc_pid_link_inode_operations; |
1381 | inode->i_size = 64; | 1384 | inode->i_size = 64; |
@@ -1385,7 +1388,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, | |||
1385 | return NULL; | 1388 | return NULL; |
1386 | 1389 | ||
1387 | out_unlock2: | 1390 | out_unlock2: |
1388 | spin_unlock(&files->file_lock); | 1391 | rcu_read_unlock(); |
1389 | put_files_struct(files); | 1392 | put_files_struct(files); |
1390 | out_unlock: | 1393 | out_unlock: |
1391 | iput(inode); | 1394 | iput(inode); |