Setting 'x' flag

David Collier-Brown David.Collier-Brown at
Mon Nov 13 13:53:19 GMT 2000

Tine Smukavec wrote: 
> I need an opinion or explanation of following code fragment
> taken from smbd/dosmode.c:unix_mode() function body:

>       /* Apply mode mask */
>       result &= lp_create_mask(SNUM(conn)); /* SUSPICIOUS!!!! */
>       /* Add in force bits */
>       result |= lp_force_create_mode(SNUM(conn));

>				I see the problematic code in
> the line marked with /* SUSPICIOUS !!!!*/. My opinion is that create mask
> should be placed into result with 'or' operation instead with 'and'. Because
> 'and' overrides the settings derived from 'archive', 'system' and
> 'hiddedn' flags if correspondend mapping is turned on.

	That's right: the "and" operator is the force mode
	option.  In order to be able to fully control the
	bits set you need both an "and" and an "or" mask, which
	this code provides.

>			I'm asking that because this mapping from dos
> flags into unix flags and vica verse seems quite complicated to me.

	Yes: it's a tricky mapping to implement: the force
	mode options got added only fairly recently, to make
	sure you could both set and unset bits, and the
	inheritance option even more recently.

--dave (not a developer: a documenter) c-b
David Collier-Brown,  | Always do right. This will gratify some people
185 Ellerslie Ave.,   | and astonish the rest.        -- Mark Twain
Willowdale, Ontario   | //
Work: (905) 415-2849 Home: (416) 223-8968 Email: davecb at

More information about the samba-technical mailing list