[PATCH] s3:smbd:open: Skip redundant call to file_set_dosmode when creating a new file.

Jeremy Allison jra at samba.org
Thu Jan 28 22:02:01 UTC 2016


On Tue, Jan 26, 2016 at 07:28:16AM -0600, José A. Rivera wrote:
> Hey folks,
> 
> Attached is a tiny, seemingly benign patch to open.c. Yes, that open.c. :)
> The patch has been pair-programmed with Ira and already reviewed by Jeremy,
> but this is definitely a case where more eyes can't hurt.
> 
> The patch changes an if clause to only set the DOS archive attribute after
> open if the file was overwritten. We believe this logic makes sense, given
> that opened files don't need to have the archive bit re-set and newly
> created
> files are taken care of by the logic around line 2468.

No one commented - push please ! :-).

> From 264694c94c545723f4cae3d11c77fd4311a2aa59 Mon Sep 17 00:00:00 2001
> From: "Jose A. Rivera" <jarrpa at samba.org>
> Date: Tue, 19 Jan 2016 14:32:21 -0600
> Subject: [PATCH] s3:smbd:open: Skip redundant call to file_set_dosmode when
>  creating a new file.
> 
> Signed-off-by: Jose A. Rivera <jarrpa at samba.org>
> Pair-programmed-with: Ira Cooper <ira at samba.org>
> Reviewed-by: Jeremy Allison <jra at samba.org>
> ---
>  source3/smbd/open.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/source3/smbd/open.c b/source3/smbd/open.c
> index 3c0a7a3..b654fad 100644
> --- a/source3/smbd/open.c
> +++ b/source3/smbd/open.c
> @@ -3168,8 +3168,14 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
>  		fsp->initial_delete_on_close = True;
>  	}
>  
> -	if (info != FILE_WAS_OPENED) {
> -		/* Files should be initially set as archive */
> +	/*
> +	 * All new files should initially have the DOS archive bit set. This
> +	 * is already taken care of for created files (and does not apply to
> +	 * normally opened files), but overwritten files still carry the DOS
> +	 * attributes of the old file. Thus, we should make sure the archive
> +	 * bit is set.
> +	 */
> +	if (info == FILE_WAS_OVERWRITTEN) {
>  		if (lp_map_archive(SNUM(conn)) ||
>  		    lp_store_dos_attributes(SNUM(conn))) {
>  			if (!posix_open) {
> -- 
> 2.5.0
> 




More information about the samba-technical mailing list