From b2f45f20b0108ba6c834f813386ab3d29a729abd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 22 Mar 2010 11:19:10 +0100 Subject: s3: Add "log writeable files on exit" parameter This boolean option controls whether at exit time the server dumps a list of files with debug level 0 that were still open for write. This is an administrative aid to find the files that were potentially corrupt if the network connection died. --- source3/smbd/server.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source3/smbd/server.c') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 400edcf202..81d75b13a0 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -847,6 +847,32 @@ bool reload_services(bool test) return(ret); } +static struct files_struct *log_writeable_file_fn( + struct files_struct *fsp, void *private_data) +{ + bool *found = (bool *)private_data; + char *path; + + if (!fsp->can_write) { + return NULL; + } + if (!(*found)) { + DEBUG(0, ("Writable files open at exit:\n")); + *found = true; + } + + path = talloc_asprintf(talloc_tos(), "%s/%s", fsp->conn->connectpath, + smb_fname_str_dbg(fsp->fsp_name)); + if (path == NULL) { + DEBUGADD(0, ("\n")); + } + + DEBUGADD(0, ("%s\n", path)); + + TALLOC_FREE(path); + return NULL; +} + /**************************************************************************** Exit the server. ****************************************************************************/ @@ -874,6 +900,11 @@ static void exit_server_common(enum server_exit_reason how, a->free(&sconn->smb1.negprot.auth_context); } + if (lp_log_writeable_files_on_exit()) { + bool found = false; + files_forall(log_writeable_file_fn, &found); + } + if (sconn) { had_open_conn = conn_close_all(sconn); invalidate_all_vuids(sconn); -- cgit