Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Implement fdremove() which is used in place of all the c...
details: https://anonhg.NetBSD.org/src/rev/e3f34cefdfdb
branches: trunk
changeset: 484011:e3f34cefdfdb
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Mar 23 05:16:12 2000 +0000
description:
Implement fdremove() which is used in place of all the code that
did the "fdp->fd_ofiles[fd] = 0" assignment; fdremove() make sure
the fd_freefiles hints stay in sync.
>From OpenBSD.
diffstat:
sys/compat/svr4/svr4_net.c | 4 ++--
sys/kern/kern_descrip.c | 12 +++++++++++-
sys/kern/uipc_syscalls.c | 14 +++++++-------
sys/kern/vfs_syscalls.c | 10 +++++-----
sys/sys/filedesc.h | 3 ++-
5 files changed, 27 insertions(+), 16 deletions(-)
diffs (161 lines):
diff -r 6e5082b8a56e -r e3f34cefdfdb sys/compat/svr4/svr4_net.c
--- a/sys/compat/svr4/svr4_net.c Thu Mar 23 04:58:59 2000 +0000
+++ b/sys/compat/svr4/svr4_net.c Thu Mar 23 05:16:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_net.c,v 1.21 1999/09/07 18:20:19 christos Exp $ */
+/* $NetBSD: svr4_net.c,v 1.22 2000/03/23 05:16:16 thorpej Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -193,7 +193,7 @@
if ((error = socreate(family, &so, type, protocol)) != 0) {
DPRINTF(("socreate error %d\n", error));
- p->p_fd->fd_ofiles[fd] = 0;
+ fdremove(p->p_fd, fd);
FILE_UNUSE(fp, NULL);
ffree(fp);
return error;
diff -r 6e5082b8a56e -r e3f34cefdfdb sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c Thu Mar 23 04:58:59 2000 +0000
+++ b/sys/kern/kern_descrip.c Thu Mar 23 05:16:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.64 2000/03/22 17:42:57 thorpej Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.65 2000/03/23 05:16:14 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -418,6 +418,16 @@
return (0);
}
+void
+fdremove(fdp, fd)
+ struct filedesc *fdp;
+ int fd;
+{
+
+ fdp->fd_ofiles[fd] = NULL;
+ fd_unused(fdp, fd);
+}
+
int
fdrelease(p, fd)
struct proc *p;
diff -r 6e5082b8a56e -r e3f34cefdfdb sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c Thu Mar 23 04:58:59 2000 +0000
+++ b/sys/kern/uipc_syscalls.c Thu Mar 23 05:16:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.49 1999/11/05 11:48:57 mycroft Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.50 2000/03/23 05:16:14 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -103,7 +103,7 @@
SCARG(uap, protocol));
if (error) {
FILE_UNUSE(fp, p);
- fdp->fd_ofiles[fd] = 0;
+ fdremove(fdp, fd);
ffree(fp);
} else {
fp->f_data = (caddr_t)so;
@@ -257,7 +257,7 @@
}
/* if an error occured, free the file descriptor */
if (error) {
- fdp->fd_ofiles[fd] = 0;
+ fdremove(fdp, fd);
ffree(fp);
}
m_freem(nam);
@@ -377,11 +377,11 @@
free4:
FILE_UNUSE(fp2, p);
ffree(fp2);
- fdp->fd_ofiles[sv[1]] = 0;
+ fdremove(fdp, sv[1]);
free3:
FILE_UNUSE(fp1, p);
ffree(fp1);
- fdp->fd_ofiles[sv[0]] = 0;
+ fdremove(fdp, sv[0]);
free2:
(void)soclose(so2);
free1:
@@ -990,11 +990,11 @@
free4:
FILE_UNUSE(wf, p);
ffree(wf);
- fdp->fd_ofiles[retval[1]] = 0;
+ fdremove(fdp, retval[1]);
free3:
FILE_UNUSE(rf, p);
ffree(rf);
- fdp->fd_ofiles[retval[0]] = 0;
+ fdremove(fdp, retval[0]);
free2:
(void)soclose(wso);
free1:
diff -r 6e5082b8a56e -r e3f34cefdfdb sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Thu Mar 23 04:58:59 2000 +0000
+++ b/sys/kern/vfs_syscalls.c Thu Mar 23 05:16:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.152 2000/03/15 16:30:39 fvdl Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.153 2000/03/23 05:16:15 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -1014,7 +1014,7 @@
}
if (error == ERESTART)
error = EINTR;
- fdp->fd_ofiles[indx] = NULL;
+ fdremove(fdp, indx);
return (error);
}
p->p_dupfd = 0;
@@ -1040,7 +1040,7 @@
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
FILE_UNUSE(fp, p);
ffree(fp);
- fdp->fd_ofiles[indx] = NULL;
+ fdremove(fdp, indx);
return (error);
}
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -1204,7 +1204,7 @@
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
FILE_UNUSE(fp, p);
ffree(fp);
- fdp->fd_ofiles[indx] = NULL;
+ fdremove(fdp, indx);
return (error);
}
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -1218,7 +1218,7 @@
bad:
FILE_UNUSE(fp, p);
ffree(fp);
- fdp->fd_ofiles[indx] = NULL;
+ fdremove(fdp, indx);
if (vp != NULL)
vput(vp);
return (error);
diff -r 6e5082b8a56e -r e3f34cefdfdb sys/sys/filedesc.h
--- a/sys/sys/filedesc.h Thu Mar 23 04:58:59 2000 +0000
+++ b/sys/sys/filedesc.h Thu Mar 23 05:16:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: filedesc.h,v 1.18 1999/05/05 19:52:20 thorpej Exp $ */
+/* $NetBSD: filedesc.h,v 1.19 2000/03/23 05:16:12 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -114,6 +114,7 @@
void fdinit1 __P((struct filedesc0 *newfdp));
void fdclear __P((struct proc *p));
void fdfree __P((struct proc *p));
+void fdremove __P((struct filedesc *, int));
int fdrelease __P((struct proc *p, int));
void fdcloseexec __P((struct proc *));
Home |
Main Index |
Thread Index |
Old Index