From 3ec0740b1ba312d4b2a5e7dc34d50fd69813bcf7 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 6 Jun 2007 19:41:55 +0000 Subject: [PATCH] Make sure that all open directory handles are closed on DISK-RESTORE. --- v7/src/microcode/uxfs.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/v7/src/microcode/uxfs.c b/v7/src/microcode/uxfs.c index f726a9bc4..42509c280 100644 --- a/v7/src/microcode/uxfs.c +++ b/v7/src/microcode/uxfs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxfs.c,v 1.30 2007/04/22 16:31:23 cph Exp $ +$Id: uxfs.c,v 1.31 2007/06/06 19:41:55 cph Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -25,6 +25,7 @@ USA. */ +#include "scheme.h" #include "ux.h" #include "osfs.h" #include "osfile.h" @@ -520,12 +521,30 @@ protect_fd (int fd) static DIR ** directory_pointers; static unsigned int n_directory_pointers; +static void +close_all_directories (void) +{ + DIR ** scan = directory_pointers; + DIR ** end = (scan + n_directory_pointers); + while (scan < end) + { + if ((*scan) != 0) + { + closedir (*scan); + (*scan) = 0; + } + scan += 1; + } + directory_pointers = 0; + n_directory_pointers = 0; +} + void UX_initialize_directory_reader (void) { directory_pointers = 0; n_directory_pointers = 0; - return; + add_reload_cleanup (close_all_directories); } static unsigned int -- 2.25.1