From c446c128e9be75fa8617a11403d867a8885ee80b Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Fri, 8 Feb 2002 19:50:00 +0000 Subject: [PATCH] Allow AFS to shutdown on Solaris (and subsequently be reloaded and restarted). Still leaks memory, unlike the Linux module. --- src/afs/SOLARIS/osi_vfsops.c | 25 ++++++++++++++++++++++--- src/rx/SOLARIS/rx_knet.c | 17 +++++++++++++++++ src/rx/rx_kcommon.c | 5 +++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index 2a7d4350e..009b34a6b 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -246,6 +246,9 @@ void (*ufs_iupdatp)(); int (*ufs_igetp)(); void (*ufs_itimes_nolockp)(); +int (*afs_orig_ioctl)(), (*afs_orig_ioctl32)(); +int (*afs_orig_setgroups)(), (*afs_orig_setgroups32)(); + struct streamtab *udp_infop = 0; struct ill_s *ill_g_headp = 0; @@ -264,15 +267,19 @@ extern Afs_syscall(); afsinit(struct vfssw *vfsswp, int fstype) { - extern int afs_xioctl(), afs_xflock(); + extern int afs_xioctl(); extern int afs_xsetgroups(); AFS_STATCNT(afsinit); + afs_orig_setgroups = sysent[SYS_setgroups].sy_callc; + afs_orig_ioctl = sysent[SYS_ioctl].sy_call; sysent[SYS_setgroups].sy_callc = afs_xsetgroups; sysent[SYS_ioctl].sy_call = afs_xioctl; #if defined(AFS_SUN57_64BIT_ENV) + afs_orig_setgroups32 = sysent32[SYS_setgroups].sy_callc; + afs_orig_ioctl32 = sysent32[SYS_ioctl].sy_call; sysent32[SYS_setgroups].sy_callc = afs_xsetgroups; sysent32[SYS_ioctl].sy_call = afs_xioctl; #endif @@ -405,6 +412,9 @@ _init() extern struct bind *sb_hashtab[]; struct modctl *mp = 0; + if (afs_sinited) + return EBUSY; + if ((!(mp = mod_find_by_filename("fs", "ufs")) && !(mp = mod_find_by_filename(NULL, "/kernel/fs/ufs")) && !(mp = mod_find_by_filename(NULL, "sys/ufs"))) || @@ -486,8 +496,17 @@ _fini() { int code; - if (afs_sinited) - return (EBUSY); + if (afs_globalVFS) + return EBUSY; + + if (afs_sinited) { + sysent[SYS_setgroups].sy_callc = afs_orig_setgroups; + sysent[SYS_ioctl].sy_call = afs_orig_ioctl; +#if defined(AFS_SUN57_64BIT_ENV) + sysent32[SYS_setgroups].sy_callc = afs_orig_setgroups32; + sysent32[SYS_ioctl].sy_call = afs_orig_ioctl32; +#endif + } code = mod_remove(&afs_modlinkage); return code; } diff --git a/src/rx/SOLARIS/rx_knet.c b/src/rx/SOLARIS/rx_knet.c index 04f8d5132..a2a75ca0c 100644 --- a/src/rx/SOLARIS/rx_knet.c +++ b/src/rx/SOLARIS/rx_knet.c @@ -51,6 +51,10 @@ int (*sockfs_sosendmsg) (struct sonode *, struct nmsghdr *, struct uio *) = NULL; int (*sockfs_sosetsockopt) (struct sonode *, int, int, void *, int) = NULL; +int (*sockfs_sounbind) + (struct sonode *, int); +void (*sockfs_sockfree) + (struct sonode *); static afs_uint32 myNetAddrs[ADDRSPERSITE]; static int myNetMTUs[ADDRSPERSITE]; @@ -238,6 +242,16 @@ struct osi_socket *rxk_NewSocket(short aport) return NULL; } } + if (sockfs_sounbind == NULL) { + sockfs_sounbind = (int (*)())modlookup("sockfs", "sounbind"); + if (sockfs_sounbind == NULL) + return NULL; + } + if (sockfs_sockfree == NULL) { + sockfs_sockfree = (void (*)())modlookup("sockfs", "sockfree"); + if (sockfs_sockfree == NULL) + return NULL; + } accessvp = sockfs_solookup(AF_INET, SOCK_DGRAM, 0, "/dev/udp", &error); if (accessvp == NULL) { @@ -285,6 +299,9 @@ int osi_FreeSocket(asocket) kill(rxk_ListenerPid, SIGUSR1); afs_osi_Sleep(&rxk_ListenerPid); } + + sockfs_sounbind(so, 0); + sockfs_sockfree(so); return 0; } diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index 8a2756f44..44438e6fe 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -1061,6 +1061,11 @@ void rxk_Listener(void) #endif #ifdef AFS_SUN5_ENV AFS_GUNLOCK(); +#ifdef AFS_SUN57_ENV + if (!curproc->p_corefile) /* newproc doesn't set it, but exit frees it */ + curproc->p_corefile = refstr_alloc("core"); +#endif + exit(CLD_EXITED, 0); #endif /* AFS_SUN5_ENV */ } -- 2.39.5