From 967c65a99059fd459b956c1588ce0ba227912c4e Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 16 Dec 1997 05:34:03 +0000 Subject: Merge with Linux 2.1.72, part 1. --- net/unix/af_unix.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'net/unix/af_unix.c') diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 936d61220..1a9baa549 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -26,6 +26,7 @@ * Alan Cox : Started POSIXisms * Andreas Schwab : Replace inode by dentry for proper * reference counting + * Kirk Petersen : Made this a module * * Known differences from reference BSD that was tested: * @@ -57,6 +58,7 @@ * with BSD names. */ +#include #include #include #include @@ -310,6 +312,9 @@ static void unix_destroy_socket(unix_socket *sk) sk->dead=1; unix_delayed_delete(sk); /* Try every so often until buffers are all freed */ } + + /* socket destroyed, decrement count */ + MOD_DEC_USE_COUNT; } static int unix_listen(struct socket *sock, int backlog) @@ -373,6 +378,10 @@ static int unix_create(struct socket *sock, int protocol) sk->mtu=4096; sk->protinfo.af_unix.list=&unix_sockets_unbound; unix_insert_socket(sk); + + /* socket created, increment count */ + MOD_INC_USE_COUNT; + return 0; } @@ -1465,7 +1474,16 @@ struct net_proto_family unix_family_ops = { unix_create }; +#ifdef MODULE +#ifdef CONFIG_SYSCTL +extern void unix_sysctl_register(void); +extern void unix_sysctl_unregister(void); +#endif + +int init_module(void) +#else __initfunc(void unix_proto_init(struct net_proto *pro)) +#endif { struct sk_buff *dummy_skb; struct proc_dir_entry *ent; @@ -1474,14 +1492,37 @@ __initfunc(void unix_proto_init(struct net_proto *pro)) if (sizeof(struct unix_skb_parms) > sizeof(dummy_skb->cb)) { printk(KERN_CRIT "unix_proto_init: panic\n"); +#ifdef MODULE + return -1; +#else return; +#endif } sock_register(&unix_family_ops); #ifdef CONFIG_PROC_FS ent = create_proc_entry("net/unix", 0, 0); ent->read_proc = unix_read_proc; #endif + +#ifdef MODULE +#ifdef CONFIG_SYSCTL + unix_sysctl_register(); +#endif + + return 0; +#endif } + +#ifdef MODULE +void cleanup_module(void) +{ + sock_unregister(AF_UNIX); +#ifdef CONFIG_SYSCTL + unix_sysctl_unregister(); +#endif +} +#endif + /* * Local variables: * compile-command: "gcc -g -D__KERNEL__ -Wall -O6 -I/usr/src/linux/include -c af_unix.c" -- cgit v1.2.3