diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-02-08 17:59:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-02-08 17:59:57 -0500 |
commit | 23bb80d2158cf4421fe239d788fd53cafb151050 (patch) | |
tree | 63b3033a3d6ee10baf7ecdda350b2cc0cd03baa9 /net | |
parent | dbca9b2750e3b1ee6f56a616160ccfc12e8b161f (diff) |
[NET]: cleanup sock_from_file()
I believe dead code from sock_from_file() can be cleaned up.
All sockets are now built using sock_attach_fd(), that puts the 'sock' pointer
into file->private_data and &socket_file_ops into file->f_op
I could not find a place where file->private_data could be set to NULL,
keeping opened the file.
So to get 'sock' from a 'file' pointer, either :
- This is a socket file (f_op == &socket_file_ops), and we can directly get
'sock' from private_data.
- This is not a socket, we return -ENOTSOCK and dont even try to find a socket
via dentry/inode :)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/socket.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/net/socket.c b/net/socket.c index 4e396312f8d5..fc74930f1443 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -407,24 +407,11 @@ int sock_map_fd(struct socket *sock) | |||
407 | 407 | ||
408 | static struct socket *sock_from_file(struct file *file, int *err) | 408 | static struct socket *sock_from_file(struct file *file, int *err) |
409 | { | 409 | { |
410 | struct inode *inode; | ||
411 | struct socket *sock; | ||
412 | |||
413 | if (file->f_op == &socket_file_ops) | 410 | if (file->f_op == &socket_file_ops) |
414 | return file->private_data; /* set in sock_map_fd */ | 411 | return file->private_data; /* set in sock_map_fd */ |
415 | 412 | ||
416 | inode = file->f_path.dentry->d_inode; | 413 | *err = -ENOTSOCK; |
417 | if (!S_ISSOCK(inode->i_mode)) { | 414 | return NULL; |
418 | *err = -ENOTSOCK; | ||
419 | return NULL; | ||
420 | } | ||
421 | |||
422 | sock = SOCKET_I(inode); | ||
423 | if (sock->file != file) { | ||
424 | printk(KERN_ERR "socki_lookup: socket file changed!\n"); | ||
425 | sock->file = file; | ||
426 | } | ||
427 | return sock; | ||
428 | } | 415 | } |
429 | 416 | ||
430 | /** | 417 | /** |