diff options
author | Volker Lendecke <vl@samba.org> | 2010-03-22 11:19:10 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-03-22 12:03:44 +0100 |
commit | b2f45f20b0108ba6c834f813386ab3d29a729abd (patch) | |
tree | fb434ca0775bdf00c15fb0ed382e75fb3f70dd49 /source3/smbd | |
parent | 0cf9d62f30218efcfddf2b00e6117fb670f0f911 (diff) | |
download | samba-b2f45f20b0108ba6c834f813386ab3d29a729abd.tar.gz samba-b2f45f20b0108ba6c834f813386ab3d29a729abd.tar.bz2 samba-b2f45f20b0108ba6c834f813386ab3d29a729abd.zip |
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.
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/server.c | 31 |
1 files changed, 31 insertions, 0 deletions
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, ("<NOMEM>\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); |