From: Volker Lendecke Date: Thu, 13 Sep 2018 04:21:37 +0000 (+0200) Subject: smbd: Remove "file_sync_all" function X-Git-Tag: tdb-1.3.17~1625 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=aa30fd54a22db8535b661563cab1adb15826239d smbd: Remove "file_sync_all" function Replace with a call to files_forall. Why? I just came across this function that only has one pretty obscure user. This does not justify a full library function, IMHO at least. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 303ab7bb926..397baea84cb 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -454,22 +454,6 @@ bool file_find_subpath(files_struct *dir_fsp) return false; } -/**************************************************************************** - Sync open files on a connection. -****************************************************************************/ - -void file_sync_all(connection_struct *conn) -{ - files_struct *fsp, *next; - - for (fsp=conn->sconn->files; fsp; fsp=next) { - next=fsp->next; - if ((conn == fsp->conn) && (fsp->fh->fd != -1)) { - sync_file(conn, fsp, True /* write through */); - } - } -} - /**************************************************************************** Free up a fsp. ****************************************************************************/ diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 5399c5ab483..d49cd5c2251 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -402,7 +402,6 @@ struct files_struct *file_find_one_fsp_from_lease_key( struct smbd_server_connection *sconn, const struct smb2_lease_key *lease_key); bool file_find_subpath(files_struct *dir_fsp); -void file_sync_all(connection_struct *conn); void fsp_free(files_struct *fsp); void file_free(struct smb_request *req, files_struct *fsp); files_struct *file_fsp(struct smb_request *req, uint16_t fid); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 4c6456c88f6..49ca1d70411 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5267,6 +5267,23 @@ void reply_lseek(struct smb_request *req) return; } +static struct files_struct *file_sync_one_fn(struct files_struct *fsp, + void *private_data) +{ + connection_struct *conn = talloc_get_type_abort( + private_data, connection_struct); + + if (conn != fsp->conn) { + return NULL; + } + if (fsp->fh->fd == -1) { + return NULL; + } + sync_file(conn, fsp, True /* write through */); + + return NULL; +} + /**************************************************************************** Reply to a flush. ****************************************************************************/ @@ -5292,7 +5309,7 @@ void reply_flush(struct smb_request *req) } if (!fsp) { - file_sync_all(conn); + files_forall(req->sconn, file_sync_one_fn, conn); } else { NTSTATUS status = sync_file(conn, fsp, True); if (!NT_STATUS_IS_OK(status)) {