set_ea_dos_attribute always called now

Jeremy Allison jra at samba.org
Fri Mar 22 14:28:08 MDT 2013


On Fri, Mar 22, 2013 at 01:24:24PM -0700, Richard Sharpe wrote:
> Hi folks,
> 
> Somewhere between 3.4.5 and 3.6.6 the following unfortunate change was made:
> 
> @@ -615,39 +750,37 @@ int file_set_dosmode(connection_struct *
>         dosmode  &= ~FILE_ATTRIBUTE_OFFLINE;
>         old_mode &= ~FILE_ATTRIBUTE_OFFLINE;
> 
> -       if (old_mode == dosmode) {
> -               st->st_mode = unixmode;
> -               return(0);
> -       }
> +       smb_fname->st.st_ex_btime = new_create_timespec;
> 
>  #ifdef HAVE_STAT_DOS_FLAGS
>         {
>                 bool attributes_changed;
> 
> -               if (set_stat_dos_flags(conn, fname, st, dosmode,
> +               if (set_stat_dos_flags(conn, smb_fname, dosmode,
>                                        &attributes_changed))
>                 {
>                         if (!newfile && attributes_changed) {
>                                 notify_fname(conn, NOTIFY_ACTION_MODIFIED,
> -                                   FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
> +                                   FILE_NOTIFY_CHANGE_ATTRIBUTES,
> +                                   smb_fname->base_name);
>                         }
> -                       st->st_mode = unixmode;
> +                       smb_fname->st.st_ex_mode = unixmode;
>                         return 0;
>                 }
>         }
>  #endif
> -
>         /* Store the DOS attributes in an EA by preference. */
> -       if (set_ea_dos_attribute(conn, fname, st, dosmode)) {
> +       if (set_ea_dos_attribute(conn, smb_fname, dosmode)) {
>                 if (!newfile) {
>                         notify_fname(conn, NOTIFY_ACTION_MODIFIED,
> -                               FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
> +                                    FILE_NOTIFY_CHANGE_ATTRIBUTES,
> +                                    smb_fname->base_name);
>                 }
> -               st->st_mode = unixmode;
> +               smb_fname->st.st_ex_mode = unixmode;
>                 return 0;
>         }
> 
> It results in set_ea_dos_attribute always being called. For those who
> do not store dos attributes, it does not matter, but for those of us
> who do, it does matter.

But that's the right thing to do IMHO. Look at the top of the
function.

static bool set_ea_dos_attribute(connection_struct *conn,
                                 struct smb_filename *smb_fname,
                                 uint32 dosmode)
{
        struct xattr_DOSATTRIB dosattrib;
        enum ndr_err_code ndr_err;
        DATA_BLOB blob;

        if (!lp_store_dos_attributes(SNUM(conn))) {
                return False;
        }

When it returns false (which it will if you turn off
storing DOS attributes) then it falls back to the older
mapping. We dont' really want to do the older lossy
mapping unless we have to, so we always want to try
using EA's first.

Jeremy.


More information about the samba-technical mailing list