SAMBA 2.0.6 / Module open.c Enhancment needed.

Jeremy Allison jeremy at
Tue Feb 29 02:37:23 GMT 2000

"John E. Malmberg" wrote:
> I would like an enhancement to reply.c that it's behavior of attempting to
> open all files read/write be either a parameter in smb.conf, or a compile
> time option in config.h.
> It's current behavior is bad on OpenVMS, and possibly other platforms, as
> explained below.
>     Extracted from open.c:
>     /*
>      * Whatever the requested flags, attempt read/write access,
>      * as we don't know what flags future file opens may require.
>      * If this fails, try again with the required flags.
>      * Even if we open read/write when only read access was
>      * requested the setting of the can_write flag in
>      * the file_struct will protect us from errant
>      * write requests. We never need to worry about O_APPEND
>      * as this is not set anywhere in Samba.
>      */
> Unfortunately, opening a file with any type of WRITE access updates it's
> modification date.
> And on OpenVMS it clears the backup date!
> This causes problems with incremental backups, and other maintenance tools
> such as "make" that rely on the file modification date.
> The Windows Explorer also opens many types of files to search for an icon to
> display as it runs, with this algorithm, they are all marked as modified,
> even though they never really were.

This is something we intend to address for HEAD, but it will
be left as-is in the 2.0.x branch.

The reason behind it is the multiplexing of fd's into
a reference counted structure due to the POSIX file
locking problems. Under POSIX, locks are held *per 
process*, not per file descriptor (this is braindead IMHO).

This means we need to ask for maximum permissible access
on the first open, as we don't know if subsequent opens
will require r/w access or not, even if the first open is
r/o. So long as any client process has the file open the
first fd is used.

When the tdb lock database is used instead of the posix
locks in HEAD this will be solved, but this is a subtle
issue and not one we want to mess with for 2.0.x.

Hope this helps,

	Jeremy Allison,
	Samba Team.

Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.

More information about the samba-technical mailing list