Use at_exit() to invoke procfs_exit() instead of calling it directly.

Note that an unload facility should be used to call rm_at_exit() (if
procfs is being loaded as an LKM and is subsequently removed), but it
was non-obvious how to do this in the VFS framework.

Reviewed by:	Julian Elischer
This commit is contained in:
sef 1997-12-08 01:06:36 +00:00
parent 2484645f8d
commit 287c0e3604
5 changed files with 27 additions and 18 deletions

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95
*
* $Id: procfs_subr.c,v 1.17 1997/08/02 14:32:18 bde Exp $
* $Id: procfs_subr.c,v 1.18 1997/12/06 04:11:12 sef Exp $
*/
#include <sys/param.h>
@ -353,9 +353,10 @@ vfs_findname(nm, buf, buflen)
}
void
procfs_exit(pid_t pid)
procfs_exit(struct proc *p)
{
struct pfsnode *pfs;
pid_t pid = p->p_pid;
for (pfs = pfshead; pfs ; pfs = pfs->pfs_next) {
if (pfs->pfs_pid == pid)

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
*
* $Id: procfs_vfsops.c,v 1.16 1997/08/02 14:32:19 bde Exp $
* $Id: procfs_vfsops.c,v 1.17 1997/08/16 19:15:19 wollman Exp $
*/
/*
@ -61,6 +61,8 @@ static int procfs_statfs __P((struct mount *mp, struct statfs *sbp,
static int procfs_unmount __P((struct mount *mp, int mntflags,
struct proc *p));
extern void procfs_exit __P((struct proc *));
/*
* VFS Operations.
*
@ -96,6 +98,7 @@ procfs_mount(mp, path, data, ndp, p)
bcopy("procfs", mp->mnt_stat.f_mntfromname, size);
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
(void)procfs_statfs(mp, &mp->mnt_stat, p);
return (0);
}
@ -172,6 +175,12 @@ static int
procfs_init(vfsp)
struct vfsconf *vfsp;
{
int error;
/*
* XXX - this should be rm_at_exit'd in an LKM unload function,
*/
if (error = at_exit(procfs_exit))
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return (0);
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
* $Id: kern_exit.c,v 1.61 1997/12/06 04:11:10 sef Exp $
* $Id: kern_exit.c,v 1.62 1997/12/07 18:16:43 sef Exp $
*/
#include "opt_ktrace.h"
@ -114,9 +114,6 @@ exit1(p, rv)
register struct proc *q, *nq;
register struct vmspace *vm;
ele_p ep = exit_list;
#ifdef PROCFS
extern void procfs_exit(pid_t);
#endif
if (p->p_pid == 1) {
printf("init died (signal %d, exit %d)\n",
@ -161,14 +158,6 @@ exit1(p, rv)
#endif
STOPEVENT(p, S_EXIT, rv);
#ifdef PROCFS
/*
* Now that we're back from stopevent(), force a close
* of all open procfs files for this process.
*/
procfs_exit(p->p_pid);
#endif
/*
* Check if any LKMs need anything done at process exit.
* e.g. SYSV IPC stuff

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95
*
* $Id: procfs_subr.c,v 1.17 1997/08/02 14:32:18 bde Exp $
* $Id: procfs_subr.c,v 1.18 1997/12/06 04:11:12 sef Exp $
*/
#include <sys/param.h>
@ -353,9 +353,10 @@ vfs_findname(nm, buf, buflen)
}
void
procfs_exit(pid_t pid)
procfs_exit(struct proc *p)
{
struct pfsnode *pfs;
pid_t pid = p->p_pid;
for (pfs = pfshead; pfs ; pfs = pfs->pfs_next) {
if (pfs->pfs_pid == pid)

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
*
* $Id: procfs_vfsops.c,v 1.16 1997/08/02 14:32:19 bde Exp $
* $Id: procfs_vfsops.c,v 1.17 1997/08/16 19:15:19 wollman Exp $
*/
/*
@ -61,6 +61,8 @@ static int procfs_statfs __P((struct mount *mp, struct statfs *sbp,
static int procfs_unmount __P((struct mount *mp, int mntflags,
struct proc *p));
extern void procfs_exit __P((struct proc *));
/*
* VFS Operations.
*
@ -96,6 +98,7 @@ procfs_mount(mp, path, data, ndp, p)
bcopy("procfs", mp->mnt_stat.f_mntfromname, size);
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
(void)procfs_statfs(mp, &mp->mnt_stat, p);
return (0);
}
@ -172,6 +175,12 @@ static int
procfs_init(vfsp)
struct vfsconf *vfsp;
{
int error;
/*
* XXX - this should be rm_at_exit'd in an LKM unload function,
*/
if (error = at_exit(procfs_exit))
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return (0);
}