From: Volker Lendecke Date: Thu, 23 Aug 2018 11:51:26 +0000 (+0200) Subject: smbd: Add "hide new files" option X-Git-Tag: tdb-1.3.17~837 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=593fdd21923b1065b7cfbedc69a214720f190e03;p=thirdparty%2Fsamba.git smbd: Add "hide new files" option See the manpage for the description Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml b/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml new file mode 100644 index 00000000000..ca93e726c33 --- /dev/null +++ b/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml @@ -0,0 +1,15 @@ + + + Setting this parameter to something but 0 hides files + that have been modified less than N seconds ago. + It can be used for ingest/process queue style workloads. A + processing application should only see files that are definitely + finished. As many applications do not have proper external workflow + control, this can be a way to make sure processing does not + interfere with file ingest. + +0 + diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index c3af5233e98..f05d7a290e5 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1536,6 +1536,7 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, bool hide_unreadable = lp_hide_unreadable(SNUM(conn)); bool hide_unwriteable = lp_hide_unwriteable_files(SNUM(conn)); bool hide_special = lp_hide_special_files(SNUM(conn)); + int hide_new_files_timeout = lp_hide_new_files_timeout(SNUM(conn)); char *entry = NULL; struct smb_filename *smb_fname_base = NULL; bool ret = false; @@ -1550,7 +1551,11 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, return False; } - if (hide_unreadable || hide_unwriteable || hide_special) { + if (hide_unreadable || + hide_unwriteable || + hide_special || + (hide_new_files_timeout != 0)) + { entry = talloc_asprintf(talloc_tos(), "%s/%s", dir_path, name); if (!entry) { ret = false; @@ -1603,6 +1608,17 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, ret = false; goto out; } + + if (hide_new_files_timeout != 0) { + + double age = timespec_elapsed( + &smb_fname_base->st.st_ex_mtime); + + if (age < (double)hide_new_files_timeout) { + ret = false; + goto out; + } + } } ret = true;