From 37f3aabd9f6f41dd722014ace146014b1340c0a1 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Fri, 19 Mar 2010 22:13:41 -0400 Subject: [PATCH] Windows: Use a timestamp for the minidump filename Set the name of the minidump file to : %TMP%\afsd---
-__.dmp This prevents new minidump files from overwriting older ones. Change-Id: I057963bedf618eb23720f17d62c8473790569273 Reviewed-on: http://gerrit.openafs.org/1633 Reviewed-by: Asanka Herath Tested-by: Asanka Herath Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/afsd_init.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index d2a9655ff8..5b79c6d2ce 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -1679,16 +1679,21 @@ static BOOL (WINAPI *pMiniDumpWriteDump)(HANDLE hProcess,DWORD ProcessId,HANDLE static HANDLE OpenDumpFile(void) { + char tmp[256]; char wd[256]; + SYSTEMTIME st; DWORD code; - code = GetEnvironmentVariable("TEMP", wd, sizeof(wd)); - if ( code == 0 || code > sizeof(wd) ) + code = GetEnvironmentVariable("TEMP", tmp, sizeof(tmp)); + if ( code == 0 || code > sizeof(tmp) ) { - if (!GetWindowsDirectory(wd, sizeof(wd))) + if (!GetWindowsDirectory(tmp, sizeof(tmp))) return NULL; } - StringCbCatA(wd, sizeof(wd), "\\afsd.dmp"); + GetLocalTime(&st); + StringCbPrintfA(wd, sizeof(wd), + "%s\\afsd-%04d-%02d-%02d-%02d_%02d_%02d.dmp", tmp, + st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); return CreateFile( wd, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); }