mirror of
https://git.openafs.org/openafs.git
synced 2025-01-21 00:10:15 +00:00
vol: fix CreateFile params nt_unlink and nt_open
nt_unlink: when opening a file handle to assign delete on close status the caller must request DELETE permission. nt_open: make sure that DELETE permission along with FILE_SHARE_DELETE is requested if we wish to permit another CreateFile call in the future to assign delete on close. Change-Id: Ib971ecc098dbc5eb64dcbfed93c334397c9d8ac9 Reviewed-on: http://gerrit.openafs.org/3711 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
d6528628b4
commit
5fdc2679dc
@ -46,20 +46,21 @@
|
||||
*
|
||||
* This nt_unlink has the delete on last close semantics of the Unix unlink
|
||||
* with a minor twist. Subsequent CreateFile calls on this file can succeed
|
||||
* if they open for delete. It's also unclear what happens if a CreateFile
|
||||
* call tries to create a new file with the same name. Fortunately, neither
|
||||
* case should occur as part of nt_dec.
|
||||
* if they open for delete. If a CreateFile call tries to create a new file
|
||||
* with the same name it will fail. Fortunately, neither case should occur
|
||||
* as part of nt_dec.
|
||||
*/
|
||||
int
|
||||
nt_unlink(char *name)
|
||||
{
|
||||
HANDLE fh;
|
||||
|
||||
fh = CreateFile(name, GENERIC_READ | GENERIC_WRITE,
|
||||
fh = CreateFile(name,
|
||||
GENERIC_READ | GENERIC_WRITE | DELETE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
NULL, OPEN_EXISTING,
|
||||
BASEFILEATTRIBUTE | FILE_FLAG_DELETE_ON_CLOSE |
|
||||
FILE_FLAG_POSIX_SEMANTICS, NULL);
|
||||
BASEFILEATTRIBUTE | FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_POSIX_SEMANTICS,
|
||||
NULL);
|
||||
if (fh != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(fh);
|
||||
else {
|
||||
@ -79,14 +80,16 @@ nt_open(char *name, int flags, int mode)
|
||||
{
|
||||
HANDLE fh;
|
||||
DWORD nt_access = 0;
|
||||
DWORD nt_share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
DWORD nt_share = FILE_SHARE_READ;
|
||||
DWORD nt_create = 0;
|
||||
/* Really use the sequential one for data files, random for meta data. */
|
||||
DWORD FandA = BASEFILEATTRIBUTE | FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
|
||||
/* set access */
|
||||
if ((flags & O_RDWR) || (flags & O_WRONLY))
|
||||
if ((flags & O_RDWR) || (flags & O_WRONLY)) {
|
||||
nt_access |= GENERIC_WRITE;
|
||||
nt_share |= FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
}
|
||||
if ((flags & O_RDWR) || (flags == O_RDONLY))
|
||||
nt_access |= GENERIC_READ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user