From 07f70f97f11672b09936564f9d5517b45d1294e5 Mon Sep 17 00:00:00 2001 From: pk Date: Wed, 6 Sep 1995 19:53:27 +0000 Subject: [PATCH] Avoid calling device-close routine when open() not completed. Otherwise you lose if this sequence occurs: open()->devopen()->...->panic()->closeall(). --- sys/lib/libsa/close.c | 6 +++--- sys/lib/libsa/open.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/lib/libsa/close.c b/sys/lib/libsa/close.c index c60536cc1d6b..ffcef14f05c5 100644 --- a/sys/lib/libsa/close.c +++ b/sys/lib/libsa/close.c @@ -1,4 +1,4 @@ -/* $NetBSD: close.c,v 1.4 1994/10/26 05:44:40 cgd Exp $ */ +/* $NetBSD: close.c,v 1.5 1995/09/06 19:53:29 pk Exp $ */ /*- * Copyright (c) 1993 @@ -77,9 +77,9 @@ close(fd) errno = EBADF; return (-1); } - if (!(f->f_flags & F_RAW)) + if (!(f->f_flags & F_RAW) && f->f_ops) err1 = (f->f_ops->close)(f); - if (!(f->f_flags & F_NODEV)) + if (!(f->f_flags & F_NODEV) && f->f_dev) err2 = (f->f_dev->dv_close)(f); f->f_flags = 0; if (err1) { diff --git a/sys/lib/libsa/open.c b/sys/lib/libsa/open.c index b827a9e1665d..e394720b283a 100644 --- a/sys/lib/libsa/open.c +++ b/sys/lib/libsa/open.c @@ -1,4 +1,4 @@ -/* $NetBSD: open.c,v 1.6 1995/04/22 13:57:03 cgd Exp $ */ +/* $NetBSD: open.c,v 1.7 1995/09/06 19:53:27 pk Exp $ */ /*- * Copyright (c) 1993 @@ -93,6 +93,7 @@ fnd: */ f->f_flags = mode + 1; f->f_dev = (struct devsw *)0; + f->f_ops = (struct fs_ops *)0; file = (char *)0; error = devopen(f, fname, &file); if (error ||