1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

A better solution to the rm_at_exit problem: Register the exit function

during first mount.  Unregister the exit function at last unmount.

Concept by:	sef
Reviewed by:	sef
Implemented by:	alex
This commit is contained in:
Alexander Langer 1998-07-27 01:07:01 +00:00
parent d352b6c59e
commit 3f47ee5c4d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37877
4 changed files with 24 additions and 50 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.10 1998/07/01 17:02:57 bde Exp $
# $Id: Makefile,v 1.11 1998/07/25 15:52:43 alex Exp $
.PATH: ${.CURDIR}/../../sys/miscfs/procfs
KMOD= procfs_mod
@ -6,7 +6,7 @@ SRCS= opt_vmpage.h procfs_ctl.c procfs_map.c procfs_note.c procfs_status.c \
procfs_subr.c procfs_type.c procfs_vfsops.c procfs_vnops.c
NOMAN=
VFS_LKM=
CFLAGS+= -DPROCFS -DVFS_LKM_NO_DEFAULT_DISPATCH
CFLAGS+= -DPROCFS
CLEANFILES+= opt_vmpage.h
opt_vmpage.h:

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
*
* $Id: procfs_vfsops.c,v 1.22 1998/06/07 17:11:58 dfr Exp $
* $Id: procfs_vfsops.c,v 1.23 1998/07/25 15:52:44 alex Exp $
*/
/*
@ -76,6 +76,7 @@ procfs_mount(mp, path, data, ndp, p)
struct proc *p;
{
size_t size;
int error;
if (UIO_MX & (UIO_MX-1)) {
log(LOG_ERR, "procfs: invalid directory entry size\n");
@ -85,6 +86,11 @@ procfs_mount(mp, path, data, ndp, p)
if (mp->mnt_flag & MNT_UPDATE)
return (EOPNOTSUPP);
if (mp->mnt_vfc->vfc_refcount == 1 && (error = at_exit(procfs_exit))) {
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return(error);
}
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_data = 0;
vfs_getnewfsid(mp);
@ -112,6 +118,9 @@ procfs_unmount(mp, mntflags, p)
int error;
int flags = 0;
if (mp->mnt_vfc->vfc_refcount == 1)
rm_at_exit(procfs_exit);
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
@ -173,11 +182,6 @@ static int
procfs_init(vfsp)
struct vfsconf *vfsp;
{
int error;
if (error = at_exit(procfs_exit))
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return (0);
}
@ -208,20 +212,3 @@ static struct vfsops procfs_vfsops = {
};
VFS_SET(procfs_vfsops, procfs, MOUNT_PROCFS, VFCF_SYNTHETIC);
#ifdef VFS_LKM
static int
procfs_unload ()
{
rm_at_exit(procfs_exit);
return(0);
}
int
procfs_mod(struct lkm_table *lkmtp, int cmd, int ver)
{
MOD_DISPATCH(procfs, lkmtp, cmd, ver, lkm_nullcmd,
procfs_unload, lkm_nullcmd);
}
#endif

View File

@ -36,7 +36,7 @@
*
* @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
*
* $Id: procfs_vfsops.c,v 1.22 1998/06/07 17:11:58 dfr Exp $
* $Id: procfs_vfsops.c,v 1.23 1998/07/25 15:52:44 alex Exp $
*/
/*
@ -76,6 +76,7 @@ procfs_mount(mp, path, data, ndp, p)
struct proc *p;
{
size_t size;
int error;
if (UIO_MX & (UIO_MX-1)) {
log(LOG_ERR, "procfs: invalid directory entry size\n");
@ -85,6 +86,11 @@ procfs_mount(mp, path, data, ndp, p)
if (mp->mnt_flag & MNT_UPDATE)
return (EOPNOTSUPP);
if (mp->mnt_vfc->vfc_refcount == 1 && (error = at_exit(procfs_exit))) {
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return(error);
}
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_data = 0;
vfs_getnewfsid(mp);
@ -112,6 +118,9 @@ procfs_unmount(mp, mntflags, p)
int error;
int flags = 0;
if (mp->mnt_vfc->vfc_refcount == 1)
rm_at_exit(procfs_exit);
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
@ -173,11 +182,6 @@ static int
procfs_init(vfsp)
struct vfsconf *vfsp;
{
int error;
if (error = at_exit(procfs_exit))
printf("procfs: cannot register procfs_exit with at_exit -- error %d\n", error);
return (0);
}
@ -208,20 +212,3 @@ static struct vfsops procfs_vfsops = {
};
VFS_SET(procfs_vfsops, procfs, MOUNT_PROCFS, VFCF_SYNTHETIC);
#ifdef VFS_LKM
static int
procfs_unload ()
{
rm_at_exit(procfs_exit);
return(0);
}
int
procfs_mod(struct lkm_table *lkmtp, int cmd, int ver)
{
MOD_DISPATCH(procfs, lkmtp, cmd, ver, lkm_nullcmd,
procfs_unload, lkm_nullcmd);
}
#endif

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.10 1998/07/01 17:02:57 bde Exp $
# $Id: Makefile,v 1.11 1998/07/25 15:52:43 alex Exp $
.PATH: ${.CURDIR}/../../sys/miscfs/procfs
KMOD= procfs_mod
@ -6,7 +6,7 @@ SRCS= opt_vmpage.h procfs_ctl.c procfs_map.c procfs_note.c procfs_status.c \
procfs_subr.c procfs_type.c procfs_vfsops.c procfs_vnops.c
NOMAN=
VFS_LKM=
CFLAGS+= -DPROCFS -DVFS_LKM_NO_DEFAULT_DISPATCH
CFLAGS+= -DPROCFS
CLEANFILES+= opt_vmpage.h
opt_vmpage.h: