Subject: RE: open/remove sequence

From: "Yoder, Alan" <[email-masked]>
Date: Tue, 25 Sep 2001 11:12:39 -0700

> > Windows scenario:
> > Client wants to use file as temporary, remove it on close 
> and does NOT allow
> > another clients to remove it
> > 1. Client (C1) OPENs file with DENY_REMOVE, REMOVE_ON_CLOSE 
> (add flags to
> > NFSv4 protocol)
> 
> If these are "standard" windows open flags we should consider adding
> them.
> There semantics would need to be clearly defined and check to see if
> they would cause conflicts with the Posix model of the directory
> controling remove permissions.

>From the MSDN library entry for CreateFile (this is the system
call that is echoed in CIFS):  I've elided most of the detail, 
which is better read in HTML format anyway.  

Note: the _open call uses flags from a POSIX standard fcntl.h file.
But CreateFile is what CIFS uses to open everything, including
pipes and other resources.

...
HANDLE CreateFile(
  LPCTSTR lpFileName,                         // file name
  DWORD dwDesiredAccess,                      // access mode
  DWORD dwShareMode,                          // share mode
  LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  DWORD dwCreationDisposition,                // how to create
  DWORD dwFlagsAndAttributes,                 // file attributes
  HANDLE hTemplateFile                        // handle to template file
);
Parameters
lpFileName 
...

dwDesiredAccess 
...
GENERIC_READ ...
GENERIC_WRITE ... 

In addition, you can specify the following access flags.
DELETE 
READ_CONTROL  
WRITE_DAC 
WRITE_OWNER 
SYNCHRONIZE 
STANDARD_RIGHTS_REQUIRED 
STANDARD_RIGHTS_READ 
STANDARD_RIGHTS_WRITE 
STANDARD_RIGHTS_EXECUTE
STANDARD_RIGHTS_ALL
SPECIFIC_RIGHTS_ALL ACCESS_MASK 
ACCESS_SYSTEM_SECURITY ACCESS_MASK 
MAXIMUM_ALLOWED ACCESS_MASK 
GENERIC_READ ACCESS_MASK 
GENERIC_WRITE ACCESS_MASK 
GENERIC_EXECUTE ACCESS_MASK 
GENERIC_ALL ACCESS_MASK 

dwShareMode 

0 (not shareable) ...
FILE_SHARE_DELETE Windows NT/2000: ... 
FILE_SHARE_READ ... 
FILE_SHARE_WRITE ... 

lpSecurityAttributes 
...

dwCreationDisposition 
CREATE_NEW ...
CREATE_ALWAYS ...
OPEN_EXISTING ...
OPEN_ALWAYS ...
TRUNCATE_EXISTING ...

dwFlagsAndAttributes 
FILE_ATTRIBUTE_NORMAL 
FILE_ATTRIBUTE_ARCHIVE ...
FILE_ATTRIBUTE_ENCRYPTED ...
FILE_ATTRIBUTE_HIDDEN ...
FILE_ATTRIBUTE_NORMAL ...
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED ...
FILE_ATTRIBUTE_OFFLINE ...
FILE_ATTRIBUTE_READONLY ...
FILE_ATTRIBUTE_SYSTEM ...
FILE_ATTRIBUTE_TEMPORARY ...

Also...
FILE_FLAG_WRITE_THROUGH ... 
FILE_FLAG_OVERLAPPED ...When FILE_FLAG_OVERLAPPED is specified, the system does not maintain the file pointer. The file position must be passed as part of the lpOverlapped parameter (pointing to an OVERLAPPED structure) to the file read and write functions.

This flag also enables more than one operation to be performed simultaneously with the handle (a simultaneous read and write operation, for example).
 
FILE_FLAG_NO_BUFFERING ...
FILE_FLAG_RANDOM_ACCESS ...(hint)
FILE_FLAG_SEQUENTIAL_SCAN ... (hint)

FILE_FLAG_DELETE_ON_CLOSE Indicates that the operating system 
  is to delete the file immediately after all of its handles 
  have been closed, not just the handle for which you specified 
  FILE_FLAG_DELETE_ON_CLOSE.  Subsequent open requests for the 
  file will fail, unless FILE_SHARE_DELETE is used. 
 
FILE_FLAG_BACKUP_SEMANTICS Windows NT/2000: Indicates that the 
  file is being opened or created for a backup or restore operation. 
  The system ensures that the calling process overrides file security 
  checks, provided it has the necessary privileges. The relevant 
  privileges are SE_BACKUP_NAME and SE_RESTORE_NAME.  You can also 
  set this flag to obtain a handle to a directory. A directory handle 
  can be passed to some Win32 functions in place of a file handle.
 
FILE_FLAG_POSIX_SEMANTICS Indicates that the file is to be accessed 
  according to POSIX rules. This includes allowing multiple files 
  with names, differing only in case, for file systems that support 
  such naming. Use care when using this option because files created 
  with this flag may not be accessible by applications written for 
  MS-DOS or 16-bit Windows. 

FILE_FLAG_OPEN_REPARSE_POINT Specifying this flag inhibits the reparse 
  behavior of NTFS reparse points. When the file is opened, a file 
  handle is returned, whether the filter that controls the reparse 
  point is operational or not. This flag cannot be used with the 
  CREATE_ALWAYS flag. 

FILE_FLAG_OPEN_NO_RECALL Indicates that the file data is requested, 
  but it should continue to reside in remote storage. It should not be 
  transported back to local storage. This flag is intended for use by 
  remote storage systems or the Hierarchical Storage Management system. 

Alan

===============================================================
Alan G. Yoder                                    [email-masked]
Network Appliance, Inc.                           
Sunnyvale, CA                                      408-822-6919
===============================================================