[2/2] server: Make sure that CreateFile(CREATE_ALWAYS) overwrites existing file attributes.
Dmitry Timoshkov
dmitry at codeweavers.com
Thu Mar 17 04:22:44 CDT 2011
---
dlls/advapi32/tests/security.c | 1 -
server/fd.c | 7 ++++++-
server/file.c | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 5409c35..6f73f8a 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -938,7 +938,6 @@ todo_wine {
rc = GetFileAttributes(file);
rc &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
-todo_wine
ok(rc == (FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY),
"expected FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY got %#x\n", rc);
diff --git a/server/fd.c b/server/fd.c
index e0ec708..84470a9 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1780,7 +1780,6 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
closed_fd->unix_fd = fd->unix_fd;
closed_fd->unlink[0] = 0;
fstat( fd->unix_fd, &st );
- *mode = st.st_mode;
/* only bother with an inode for normal files and directories */
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
@@ -1829,6 +1828,11 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
return NULL;
}
ftruncate( fd->unix_fd, 0 );
+ if (flags & O_CREAT)
+ {
+ fchmod( fd->unix_fd, *mode );
+ fstat( fd->unix_fd, &st );
+ }
}
}
else /* special file */
@@ -1846,6 +1850,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
free( closed_fd );
fd->cacheable = 1;
}
+ *mode = st.st_mode;
return fd;
error:
diff --git a/server/file.c b/server/file.c
index cca2633..9f993c8 100644
--- a/server/file.c
+++ b/server/file.c
@@ -178,7 +178,7 @@ static struct object *create_file( struct fd *root, const char *nameptr, data_si
switch(create)
{
case FILE_CREATE: flags = O_CREAT | O_EXCL; break;
- case FILE_OVERWRITE_IF: /* FIXME: the difference is whether we trash existing attr or not */
+ case FILE_OVERWRITE_IF: /* the difference is whether we trash existing attr or not */
case FILE_SUPERSEDE: flags = O_CREAT | O_TRUNC; break;
case FILE_OPEN: flags = 0; break;
case FILE_OPEN_IF: flags = O_CREAT; break;
--
1.7.3.5
More information about the wine-patches
mailing list