Skip to content

Commit

Permalink
Fix restore of compressed files
Browse files Browse the repository at this point in the history
The compressed file restoration failed before on Windows 2008.

We now use the variable types from the microsoft documentation,
also now have a bytesreturned variable which is mandatory
if lpOverlapped is NULL according to the documentation.

See documentation of FSCTL_SET_COMPRESSION control code at Microsoft:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364592%28v=vs.85%29.aspx

Fixes #463: Crash when restore compressed files
  • Loading branch information
pstorz authored and Marco van Wieringen committed May 6, 2015
1 parent c02e573 commit 49f2f39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/findlib/attribs.c
Expand Up @@ -717,10 +717,13 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
* Restore the compressed file attribute on the restored file.
*/
if (atts.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) {
uint16_t format = COMPRESSION_FORMAT_DEFAULT;
USHORT format = COMPRESSION_FORMAT_DEFAULT;
DWORD bytesreturned;

Dmsg1(100, "Restore FILE_ATTRIBUTE_COMPRESSED on %s\n", attr->ofname);
DeviceIoControl(ofd->fh, FSCTL_SET_COMPRESSION, &format, sizeof(format), NULL, 0, NULL, NULL);
if (!DeviceIoControl(ofd->fh, FSCTL_SET_COMPRESSION, &format, sizeof(format), NULL, 0, &bytesreturned, NULL)) {
win_error(jcr, "DeviceIoControl FSCTL_SET_COMPRESSION", win32_ofile);
}
}

bclose(ofd);
Expand Down

0 comments on commit 49f2f39

Please sign in to comment.