|
Lines 167-172
static int proc_fd_link(struct dentry *d
Link Here
|
| 167 |
return ret; |
167 |
return ret; |
| 168 |
} |
168 |
} |
| 169 |
|
169 |
|
|
|
170 |
void *proc_pid_fd_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 171 |
{ |
| 172 |
void *v; |
| 173 |
|
| 174 |
v = proc_pid_follow_link(dentry, nd); |
| 175 |
if (v) |
| 176 |
return v; |
| 177 |
|
| 178 |
/* |
| 179 |
* Sockets can't be opened directly, which breaks |
| 180 |
* /dev/stderr and friends. We stuff the fd in the nameidata |
| 181 |
* here so that the open path can dup the fd after the open |
| 182 |
* fails. |
| 183 |
*/ |
| 184 |
if (S_ISSOCK(nd->inode->i_mode)) { |
| 185 |
struct task_struct *task = get_proc_task(dentry->d_inode); |
| 186 |
if (task == current) { |
| 187 |
nd->flags |= LOOKUP_DUP_FD; |
| 188 |
nd->dup_fd = proc_fd(dentry->d_inode); |
| 189 |
} |
| 190 |
put_task_struct(task); |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
return NULL; |
| 195 |
} |
| 196 |
|
| 197 |
static const struct inode_operations proc_pid_fd_link_inode_operations = { |
| 198 |
.readlink = proc_pid_readlink, |
| 199 |
.follow_link = proc_pid_fd_follow_link, |
| 200 |
.setattr = proc_setattr, |
| 201 |
}; |
| 202 |
|
| 170 |
static int |
203 |
static int |
| 171 |
proc_fd_instantiate(struct inode *dir, struct dentry *dentry, |
204 |
proc_fd_instantiate(struct inode *dir, struct dentry *dentry, |
| 172 |
struct task_struct *task, const void *ptr) |
205 |
struct task_struct *task, const void *ptr) |
|
Lines 183-189
proc_fd_instantiate(struct inode *dir, s
Link Here
|
| 183 |
ei->fd = fd; |
216 |
ei->fd = fd; |
| 184 |
|
217 |
|
| 185 |
inode->i_mode = S_IFLNK; |
218 |
inode->i_mode = S_IFLNK; |
| 186 |
inode->i_op = &proc_pid_link_inode_operations; |
219 |
inode->i_op = &proc_pid_fd_link_inode_operations; |
| 187 |
inode->i_size = 64; |
220 |
inode->i_size = 64; |
| 188 |
|
221 |
|
| 189 |
ei->op.proc_get_link = proc_fd_link; |
222 |
ei->op.proc_get_link = proc_fd_link; |