o af_unix: remove typedef unix_socket, use plain struct sock

parent 0b13af99
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define __LINUX_NET_AFUNIX_H #define __LINUX_NET_AFUNIX_H
extern void unix_inflight(struct file *fp); extern void unix_inflight(struct file *fp);
extern void unix_notinflight(struct file *fp); extern void unix_notinflight(struct file *fp);
typedef struct sock unix_socket;
extern void unix_gc(void); extern void unix_gc(void);
#define UNIX_HASH_SIZE 256 #define UNIX_HASH_SIZE 256
...@@ -12,7 +11,7 @@ extern rwlock_t unix_table_lock; ...@@ -12,7 +11,7 @@ extern rwlock_t unix_table_lock;
extern atomic_t unix_tot_inflight; extern atomic_t unix_tot_inflight;
static inline unix_socket *first_unix_socket(int *i) static inline struct sock *first_unix_socket(int *i)
{ {
for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) { for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
if (!hlist_empty(&unix_socket_table[*i])) if (!hlist_empty(&unix_socket_table[*i]))
...@@ -21,7 +20,7 @@ static inline unix_socket *first_unix_socket(int *i) ...@@ -21,7 +20,7 @@ static inline unix_socket *first_unix_socket(int *i)
return NULL; return NULL;
} }
static inline unix_socket *next_unix_socket(int *i, unix_socket *s) static inline struct sock *next_unix_socket(int *i, struct sock *s)
{ {
struct sock *next = sk_next(s); struct sock *next = sk_next(s);
/* More in this chain? */ /* More in this chain? */
......
...@@ -147,19 +147,19 @@ static inline unsigned unix_hash_fold(unsigned hash) ...@@ -147,19 +147,19 @@ static inline unsigned unix_hash_fold(unsigned hash)
#define unix_peer(sk) ((sk)->sk_pair) #define unix_peer(sk) ((sk)->sk_pair)
static inline int unix_our_peer(unix_socket *sk, unix_socket *osk) static inline int unix_our_peer(struct sock *sk, struct sock *osk)
{ {
return unix_peer(osk) == sk; return unix_peer(osk) == sk;
} }
static inline int unix_may_send(unix_socket *sk, unix_socket *osk) static inline int unix_may_send(struct sock *sk, struct sock *osk)
{ {
return (unix_peer(osk) == NULL || unix_our_peer(sk, osk)); return (unix_peer(osk) == NULL || unix_our_peer(sk, osk));
} }
static unix_socket *unix_peer_get(unix_socket *s) static struct sock *unix_peer_get(struct sock *s)
{ {
unix_socket *peer; struct sock *peer;
unix_state_rlock(s); unix_state_rlock(s);
peer = unix_peer(s); peer = unix_peer(s);
...@@ -209,37 +209,37 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp) ...@@ -209,37 +209,37 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
return len; return len;
} }
static void __unix_remove_socket(unix_socket *sk) static void __unix_remove_socket(struct sock *sk)
{ {
if (sk_del_node_init(sk)) if (sk_del_node_init(sk))
__sock_put(sk); __sock_put(sk);
} }
static void __unix_insert_socket(struct hlist_head *list, unix_socket *sk) static void __unix_insert_socket(struct hlist_head *list, struct sock *sk)
{ {
BUG_TRAP(sk_unhashed(sk)); BUG_TRAP(sk_unhashed(sk));
sk_add_node(sk, list); sk_add_node(sk, list);
sock_hold(sk); sock_hold(sk);
} }
static inline void unix_remove_socket(unix_socket *sk) static inline void unix_remove_socket(struct sock *sk)
{ {
write_lock(&unix_table_lock); write_lock(&unix_table_lock);
__unix_remove_socket(sk); __unix_remove_socket(sk);
write_unlock(&unix_table_lock); write_unlock(&unix_table_lock);
} }
static inline void unix_insert_socket(struct hlist_head *list, unix_socket *sk) static inline void unix_insert_socket(struct hlist_head *list, struct sock *sk)
{ {
write_lock(&unix_table_lock); write_lock(&unix_table_lock);
__unix_insert_socket(list, sk); __unix_insert_socket(list, sk);
write_unlock(&unix_table_lock); write_unlock(&unix_table_lock);
} }
static unix_socket *__unix_find_socket_byname(struct sockaddr_un *sunname, static struct sock *__unix_find_socket_byname(struct sockaddr_un *sunname,
int len, int type, unsigned hash) int len, int type, unsigned hash)
{ {
unix_socket *s; struct sock *s;
struct hlist_node *node; struct hlist_node *node;
sk_for_each(s, node, &unix_socket_table[hash ^ type]) { sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
...@@ -254,11 +254,11 @@ static unix_socket *__unix_find_socket_byname(struct sockaddr_un *sunname, ...@@ -254,11 +254,11 @@ static unix_socket *__unix_find_socket_byname(struct sockaddr_un *sunname,
return s; return s;
} }
static inline unix_socket * static inline struct sock *unix_find_socket_byname(struct sockaddr_un *sunname,
unix_find_socket_byname(struct sockaddr_un *sunname, int len, int type,
int len, int type, unsigned hash) unsigned hash)
{ {
unix_socket *s; struct sock *s;
read_lock(&unix_table_lock); read_lock(&unix_table_lock);
s = __unix_find_socket_byname(sunname, len, type, hash); s = __unix_find_socket_byname(sunname, len, type, hash);
...@@ -268,9 +268,9 @@ unix_find_socket_byname(struct sockaddr_un *sunname, ...@@ -268,9 +268,9 @@ unix_find_socket_byname(struct sockaddr_un *sunname,
return s; return s;
} }
static unix_socket *unix_find_socket_byinode(struct inode *i) static struct sock *unix_find_socket_byinode(struct inode *i)
{ {
unix_socket *s; struct sock *s;
struct hlist_node *node; struct hlist_node *node;
read_lock(&unix_table_lock); read_lock(&unix_table_lock);
...@@ -350,12 +350,12 @@ static void unix_sock_destructor(struct sock *sk) ...@@ -350,12 +350,12 @@ static void unix_sock_destructor(struct sock *sk)
#endif #endif
} }
static int unix_release_sock (unix_socket *sk, int embrion) static int unix_release_sock (struct sock *sk, int embrion)
{ {
struct unix_sock *u = unix_sk(sk); struct unix_sock *u = unix_sk(sk);
struct dentry *dentry; struct dentry *dentry;
struct vfsmount *mnt; struct vfsmount *mnt;
unix_socket *skpair; struct sock *skpair;
struct sk_buff *skb; struct sk_buff *skb;
int state; int state;
...@@ -525,7 +525,7 @@ static int unix_create(struct socket *sock, int protocol) ...@@ -525,7 +525,7 @@ static int unix_create(struct socket *sock, int protocol)
static int unix_release(struct socket *sock) static int unix_release(struct socket *sock)
{ {
unix_socket *sk = sock->sk; struct sock *sk = sock->sk;
if (!sk) if (!sk)
return 0; return 0;
...@@ -585,10 +585,10 @@ out: up(&u->readsem); ...@@ -585,10 +585,10 @@ out: up(&u->readsem);
return err; return err;
} }
static unix_socket *unix_find_other(struct sockaddr_un *sunname, int len, static struct sock *unix_find_other(struct sockaddr_un *sunname, int len,
int type, unsigned hash, int *error) int type, unsigned hash, int *error)
{ {
unix_socket *u; struct sock *u;
struct nameidata nd; struct nameidata nd;
int err = 0; int err = 0;
...@@ -839,7 +839,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, ...@@ -839,7 +839,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
return err; return err;
} }
static long unix_wait_for_peer(unix_socket *other, long timeo) static long unix_wait_for_peer(struct sock *other, long timeo)
{ {
struct unix_sock *u = unix_sk(other); struct unix_sock *u = unix_sk(other);
int sched; int sched;
...@@ -868,7 +868,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -868,7 +868,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct unix_sock *u = unix_sk(sk), *newu, *otheru; struct unix_sock *u = unix_sk(sk), *newu, *otheru;
struct sock *newsk = NULL; struct sock *newsk = NULL;
unix_socket *other = NULL; struct sock *other = NULL;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
unsigned hash; unsigned hash;
int st; int st;
...@@ -1061,8 +1061,8 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb) ...@@ -1061,8 +1061,8 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb)
static int unix_accept(struct socket *sock, struct socket *newsock, int flags) static int unix_accept(struct socket *sock, struct socket *newsock, int flags)
{ {
unix_socket *sk = sock->sk; struct sock *sk = sock->sk;
unix_socket *tsk; struct sock *tsk;
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
...@@ -1183,7 +1183,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1183,7 +1183,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct unix_sock *u = unix_sk(sk); struct unix_sock *u = unix_sk(sk);
struct sockaddr_un *sunaddr=msg->msg_name; struct sockaddr_un *sunaddr=msg->msg_name;
unix_socket *other = NULL; struct sock *other = NULL;
int namelen = 0; /* fake GCC */ int namelen = 0; /* fake GCC */
int err; int err;
unsigned hash; unsigned hash;
...@@ -1329,7 +1329,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1329,7 +1329,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
{ {
struct sock_iocb *siocb = kiocb_to_siocb(kiocb); struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
unix_socket *other = NULL; struct sock *other = NULL;
struct sockaddr_un *sunaddr=msg->msg_name; struct sockaddr_un *sunaddr=msg->msg_name;
int err,size; int err,size;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -1525,7 +1525,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1525,7 +1525,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
* Sleep until data has arrive. But check for races.. * Sleep until data has arrive. But check for races..
*/ */
static long unix_stream_data_wait(unix_socket * sk, long timeo) static long unix_stream_data_wait(struct sock * sk, long timeo)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
...@@ -1699,7 +1699,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1699,7 +1699,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
static int unix_shutdown(struct socket *sock, int mode) static int unix_shutdown(struct socket *sock, int mode)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
unix_socket *other; struct sock *other;
mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN); mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN);
...@@ -1814,7 +1814,7 @@ static int unix_read_proc(char *buffer, char **start, off_t offset, ...@@ -1814,7 +1814,7 @@ static int unix_read_proc(char *buffer, char **start, off_t offset,
off_t begin=0; off_t begin=0;
int len=0; int len=0;
int i; int i;
unix_socket *s; struct sock *s;
len+= sprintf(buffer,"Num RefCount Protocol Flags Type St " len+= sprintf(buffer,"Num RefCount Protocol Flags Type St "
"Inode Path\n"); "Inode Path\n");
......
...@@ -84,17 +84,17 @@ ...@@ -84,17 +84,17 @@
/* Internal data structures and random procedures: */ /* Internal data structures and random procedures: */
#define GC_HEAD ((unix_socket *)(-1)) #define GC_HEAD ((struct sock *)(-1))
#define GC_ORPHAN ((unix_socket *)(-3)) #define GC_ORPHAN ((struct sock *)(-3))
static unix_socket *gc_current=GC_HEAD; /* stack of objects to mark */ static struct sock *gc_current = GC_HEAD; /* stack of objects to mark */
atomic_t unix_tot_inflight = ATOMIC_INIT(0); atomic_t unix_tot_inflight = ATOMIC_INIT(0);
static unix_socket *unix_get_socket(struct file *filp) static struct sock *unix_get_socket(struct file *filp)
{ {
unix_socket * u_sock = NULL; struct sock *u_sock = NULL;
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
/* /*
...@@ -120,7 +120,7 @@ static unix_socket *unix_get_socket(struct file *filp) ...@@ -120,7 +120,7 @@ static unix_socket *unix_get_socket(struct file *filp)
void unix_inflight(struct file *fp) void unix_inflight(struct file *fp)
{ {
unix_socket *s=unix_get_socket(fp); struct sock *s = unix_get_socket(fp);
if(s) { if(s) {
atomic_inc(&unix_sk(s)->inflight); atomic_inc(&unix_sk(s)->inflight);
atomic_inc(&unix_tot_inflight); atomic_inc(&unix_tot_inflight);
...@@ -129,7 +129,7 @@ void unix_inflight(struct file *fp) ...@@ -129,7 +129,7 @@ void unix_inflight(struct file *fp)
void unix_notinflight(struct file *fp) void unix_notinflight(struct file *fp)
{ {
unix_socket *s=unix_get_socket(fp); struct sock *s = unix_get_socket(fp);
if(s) { if(s) {
atomic_dec(&unix_sk(s)->inflight); atomic_dec(&unix_sk(s)->inflight);
atomic_dec(&unix_tot_inflight); atomic_dec(&unix_tot_inflight);
...@@ -141,9 +141,9 @@ void unix_notinflight(struct file *fp) ...@@ -141,9 +141,9 @@ void unix_notinflight(struct file *fp)
* Garbage Collector Support Functions * Garbage Collector Support Functions
*/ */
static inline unix_socket *pop_stack(void) static inline struct sock *pop_stack(void)
{ {
unix_socket *p=gc_current; struct sock *p = gc_current;
gc_current = unix_sk(p)->gc_tree; gc_current = unix_sk(p)->gc_tree;
return p; return p;
} }
...@@ -153,7 +153,7 @@ static inline int empty_stack(void) ...@@ -153,7 +153,7 @@ static inline int empty_stack(void)
return gc_current == GC_HEAD; return gc_current == GC_HEAD;
} }
static void maybe_unmark_and_push(unix_socket *x) static void maybe_unmark_and_push(struct sock *x)
{ {
struct unix_sock *u = unix_sk(x); struct unix_sock *u = unix_sk(x);
...@@ -171,7 +171,7 @@ void unix_gc(void) ...@@ -171,7 +171,7 @@ void unix_gc(void)
{ {
static DECLARE_MUTEX(unix_gc_sem); static DECLARE_MUTEX(unix_gc_sem);
int i; int i;
unix_socket *s; struct sock *s;
struct sk_buff_head hitlist; struct sk_buff_head hitlist;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -231,8 +231,8 @@ void unix_gc(void) ...@@ -231,8 +231,8 @@ void unix_gc(void)
while (!empty_stack()) while (!empty_stack())
{ {
unix_socket *x = pop_stack(); struct sock *x = pop_stack();
unix_socket *sk; struct sock *sk;
spin_lock(&x->sk_receive_queue.lock); spin_lock(&x->sk_receive_queue.lock);
skb = skb_peek(&x->sk_receive_queue); skb = skb_peek(&x->sk_receive_queue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment