Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c0190832
Commit
c0190832
authored
Dec 04, 2012
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 04, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Implement SetFileValidData.
parent
67230fc0
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
188 additions
and
2 deletions
+188
-2
configure
configure
+1
-0
configure.ac
configure.ac
+1
-0
file.c
dlls/kernel32/file.c
+10
-2
file.c
dlls/kernel32/tests/file.c
+136
-0
file.c
dlls/ntdll/file.c
+31
-0
config.h.in
include/config.h.in
+3
-0
ntddk.h
include/ddk/ntddk.h
+5
-0
winbase.h
include/winbase.h
+1
-0
No files found.
configure
View file @
c0190832
...
...
@@ -12931,6 +12931,7 @@ for ac_func in \
chsize
\
dlopen
\
epoll_create
\
fallocate
\
ffs
\
finite
\
fnmatch
\
...
...
configure.ac
View file @
c0190832
...
...
@@ -1976,6 +1976,7 @@ AC_CHECK_FUNCS(\
chsize \
dlopen \
epoll_create \
fallocate \
ffs \
finite \
fnmatch \
...
...
dlls/kernel32/file.c
View file @
c0190832
...
...
@@ -40,6 +40,7 @@
#include "winternl.h"
#include "winioctl.h"
#include "wincon.h"
#include "ddk/ntddk.h"
#include "kernel_private.h"
#include "wine/exception.h"
...
...
@@ -1086,8 +1087,15 @@ error:
*/
BOOL
WINAPI
SetFileValidData
(
HANDLE
hFile
,
LONGLONG
ValidDataLength
)
{
FIXME
(
"stub: %p, %s
\n
"
,
hFile
,
wine_dbgstr_longlong
(
ValidDataLength
));
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
FILE_VALID_DATA_LENGTH_INFORMATION
info
;
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
info
.
ValidDataLength
.
QuadPart
=
ValidDataLength
;
status
=
NtSetInformationFile
(
hFile
,
&
io
,
&
info
,
sizeof
(
info
),
FileValidDataLengthInformation
);
if
(
status
==
STATUS_SUCCESS
)
return
TRUE
;
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
}
...
...
dlls/kernel32/tests/file.c
View file @
c0190832
...
...
@@ -42,6 +42,7 @@ static BOOL (WINAPI *pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
static
DWORD
(
WINAPI
*
pQueueUserAPC
)(
PAPCFUNC
pfnAPC
,
HANDLE
hThread
,
ULONG_PTR
dwData
);
static
BOOL
(
WINAPI
*
pGetFileInformationByHandleEx
)(
HANDLE
,
FILE_INFO_BY_HANDLE_CLASS
,
LPVOID
,
DWORD
);
static
HANDLE
(
WINAPI
*
pOpenFileById
)(
HANDLE
,
LPFILE_ID_DESCRIPTOR
,
DWORD
,
DWORD
,
LPSECURITY_ATTRIBUTES
,
DWORD
);
static
BOOL
(
WINAPI
*
pSetFileValidData
)(
HANDLE
,
LONGLONG
);
/* keep filename and filenameW the same */
static
const
char
filename
[]
=
"testfile.xxx"
;
...
...
@@ -78,6 +79,7 @@ static void InitFunctionPointers(void)
pQueueUserAPC
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueueUserAPC"
);
pGetFileInformationByHandleEx
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"GetFileInformationByHandleEx"
);
pOpenFileById
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"OpenFileById"
);
pSetFileValidData
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"SetFileValidData"
);
}
static
void
test__hread
(
void
)
...
...
@@ -3438,6 +3440,139 @@ static void test_OpenFileById(void)
DeleteFile
(
tempFileName
);
}
static
void
test_SetFileValidData
(
void
)
{
BOOL
ret
;
HANDLE
handle
;
DWORD
error
,
count
;
char
path
[
MAX_PATH
],
filename
[
MAX_PATH
];
TOKEN_PRIVILEGES
privs
;
HANDLE
token
=
NULL
;
if
(
!
pSetFileValidData
)
{
win_skip
(
"SetFileValidData is missing
\n
"
);
return
;
}
GetTempPathA
(
sizeof
(
path
),
path
);
GetTempFileNameA
(
path
,
"tst"
,
0
,
filename
);
handle
=
CreateFileA
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
WriteFile
(
handle
,
"test"
,
sizeof
(
"test"
)
-
1
,
&
count
,
NULL
);
CloseHandle
(
handle
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
INVALID_HANDLE_VALUE
,
0
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_HANDLE
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
INVALID_HANDLE_VALUE
,
-
1
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_HANDLE
,
"got %u
\n
"
,
error
);
/* file opened for reading */
handle
=
CreateFileA
(
filename
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
0
);
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
error
=
GetLastError
();
ok
(
error
==
ERROR_ACCESS_DENIED
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
-
1
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_ACCESS_DENIED
,
"got %u
\n
"
,
error
);
CloseHandle
(
handle
);
handle
=
CreateFileA
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
0
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
todo_wine
ok
(
error
==
ERROR_PRIVILEGE_NOT_HELD
,
"got %u
\n
"
,
error
);
CloseHandle
(
handle
);
privs
.
PrivilegeCount
=
1
;
privs
.
Privileges
[
0
].
Attributes
=
SE_PRIVILEGE_ENABLED
;
if
(
!
OpenProcessToken
(
GetCurrentProcess
(),
TOKEN_ADJUST_PRIVILEGES
,
&
token
)
||
!
LookupPrivilegeValue
(
NULL
,
SE_MANAGE_VOLUME_NAME
,
&
privs
.
Privileges
[
0
].
Luid
)
||
!
AdjustTokenPrivileges
(
token
,
FALSE
,
&
privs
,
sizeof
(
privs
),
NULL
,
NULL
))
{
win_skip
(
"cannot enable SE_MANAGE_VOLUME_NAME privilege
\n
"
);
CloseHandle
(
token
);
return
;
}
handle
=
CreateFileA
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
0
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
-
1
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
2
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
ret
=
pSetFileValidData
(
handle
,
4
);
ok
(
ret
,
"SetFileValidData failed %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
8
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
count
=
SetFilePointer
(
handle
,
1024
,
NULL
,
FILE_END
);
ok
(
count
!=
INVALID_SET_FILE_POINTER
,
"SetFilePointer failed %u
\n
"
,
GetLastError
());
ret
=
SetEndOfFile
(
handle
);
ok
(
ret
,
"SetEndOfFile failed %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
pSetFileValidData
(
handle
,
2
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
ret
=
pSetFileValidData
(
handle
,
4
);
ok
(
ret
,
"SetFileValidData failed %u
\n
"
,
GetLastError
());
ret
=
pSetFileValidData
(
handle
,
8
);
ok
(
ret
,
"SetFileValidData failed %u
\n
"
,
GetLastError
());
ret
=
pSetFileValidData
(
handle
,
4
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
ret
=
pSetFileValidData
(
handle
,
1024
);
ok
(
ret
,
"SetFileValidData failed %u
\n
"
,
GetLastError
());
ret
=
pSetFileValidData
(
handle
,
2048
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetFileValidData succeeded
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
privs
.
Privileges
[
0
].
Attributes
=
0
;
AdjustTokenPrivileges
(
token
,
FALSE
,
&
privs
,
sizeof
(
privs
),
NULL
,
NULL
);
CloseHandle
(
token
);
DeleteFile
(
filename
);
}
START_TEST
(
file
)
{
InitFunctionPointers
();
...
...
@@ -3479,4 +3614,5 @@ START_TEST(file)
test_ReplaceFileW
();
test_GetFileInformationByHandleEx
();
test_OpenFileById
();
test_SetFileValidData
();
}
dlls/ntdll/file.c
View file @
c0190832
...
...
@@ -81,6 +81,7 @@
#include "winternl.h"
#include "winioctl.h"
#include "ddk/ntddk.h"
#include "ddk/ntddser.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
ntdll
);
...
...
@@ -2245,6 +2246,36 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
io
->
u
.
Status
=
STATUS_INVALID_INFO_CLASS
;
break
;
case
FileValidDataLengthInformation
:
if
(
len
>=
sizeof
(
FILE_VALID_DATA_LENGTH_INFORMATION
))
{
struct
stat
st
;
const
FILE_VALID_DATA_LENGTH_INFORMATION
*
info
=
ptr
;
if
((
io
->
u
.
Status
=
server_get_unix_fd
(
handle
,
FILE_WRITE_DATA
,
&
fd
,
&
needs_close
,
NULL
,
NULL
)))
return
io
->
u
.
Status
;
if
(
fstat
(
fd
,
&
st
)
==
-
1
)
io
->
u
.
Status
=
FILE_GetNtStatus
();
else
if
(
info
->
ValidDataLength
.
QuadPart
<=
0
||
(
off_t
)
info
->
ValidDataLength
.
QuadPart
>
st
.
st_size
)
io
->
u
.
Status
=
STATUS_INVALID_PARAMETER
;
else
{
#ifdef HAVE_FALLOCATE
if
(
fallocate
(
fd
,
0
,
0
,
(
off_t
)
info
->
ValidDataLength
.
QuadPart
)
==
-
1
)
{
NTSTATUS
status
=
FILE_GetNtStatus
();
if
(
status
==
STATUS_NOT_SUPPORTED
)
WARN
(
"fallocate not supported on this filesystem
\n
"
);
else
io
->
u
.
Status
=
status
;
}
#else
FIXME
(
"setting valid data length not supported
\n
"
);
#endif
}
if
(
needs_close
)
close
(
fd
);
}
else
io
->
u
.
Status
=
STATUS_INVALID_PARAMETER_3
;
break
;
default:
FIXME
(
"Unsupported class (%d)
\n
"
,
class
);
io
->
u
.
Status
=
STATUS_NOT_IMPLEMENTED
;
...
...
include/config.h.in
View file @
c0190832
...
...
@@ -98,6 +98,9 @@
/* Define to 1 if you have the `epoll_create' function. */
#undef HAVE_EPOLL_CREATE
/* Define to 1 if you have the `fallocate' function. */
#undef HAVE_FALLOCATE
/* Define to 1 if you have the `ffs' function. */
#undef HAVE_FFS
...
...
include/ddk/ntddk.h
View file @
c0190832
...
...
@@ -127,6 +127,11 @@ typedef struct _IMAGE_INFO
ULONG
ImageSectionNumber
;
}
IMAGE_INFO
,
*
PIMAGE_INFO
;
typedef
struct
_FILE_VALID_DATA_LENGTH_INFORMATION
{
LARGE_INTEGER
ValidDataLength
;
}
FILE_VALID_DATA_LENGTH_INFORMATION
,
*
PFILE_VALID_DATA_LENGTH_INFORMATION
;
typedef
VOID
(
WINAPI
*
PDRIVER_REINITIALIZE
)(
PDRIVER_OBJECT
,
PVOID
,
ULONG
);
typedef
VOID
(
WINAPI
*
PLOAD_IMAGE_NOTIFY_ROUTINE
)(
PUNICODE_STRING
,
HANDLE
,
PIMAGE_INFO
);
typedef
NTSTATUS
(
WINAPI
*
PIO_QUERY_DEVICE_ROUTINE
)(
PVOID
,
PUNICODE_STRING
,
INTERFACE_TYPE
,
ULONG
,
...
...
include/winbase.h
View file @
c0190832
...
...
@@ -2188,6 +2188,7 @@ WINADVAPI BOOL WINAPI SetFileSecurityA(LPCSTR,SECURITY_INFORMATION,PSECU
WINADVAPI
BOOL
WINAPI
SetFileSecurityW
(
LPCWSTR
,
SECURITY_INFORMATION
,
PSECURITY_DESCRIPTOR
);
#define SetFileSecurity WINELIB_NAME_AW(SetFileSecurity)
WINBASEAPI
BOOL
WINAPI
SetFileTime
(
HANDLE
,
const
FILETIME
*
,
const
FILETIME
*
,
const
FILETIME
*
);
WINBASEAPI
BOOL
WINAPI
SetFileValidData
(
HANDLE
,
LONGLONG
);
WINBASEAPI
UINT
WINAPI
SetHandleCount
(
UINT
);
WINBASEAPI
BOOL
WINAPI
SetHandleInformation
(
HANDLE
,
DWORD
,
DWORD
);
WINBASEAPI
BOOL
WINAPI
SetInformationJobObject
(
HANDLE
,
JOBOBJECTINFOCLASS
,
LPVOID
,
DWORD
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment