Re: cygwin-doc html/ missing docbook.css and index dups cygwin-{api,ug-net}

2017-04-22 Thread Brian Inglis
On 2017-04-22 02:59, Corinna Vinschen wrote:
> Hi Brian,
> On Apr 20 21:00, Brian Inglis wrote:
>> On 2017-04-19 15:47, Jon Turney wrote:
>>> On 19/04/2017 16:42, Brian Inglis wrote:
 On 2017-04-19 04:58, Corinna Vinschen wrote:
> On Apr 16 12:22, Brian Inglis wrote:
>> Could you please consider having setup-x86{,_64} install Windows
>> shortcuts to at least the UG .pdf and index.html if present, in
>> the .../Start Menu/Programs/Cygwin folder?
>> A Windows URL shortcut to https://cygwin.com would also be helpful
>> for some.
> That requires to change setup or to provide a postinstall script.
> Are you willing to provide the latter?
>>
>> Darn - hoped you wouldn't ask - attached, and preremove (if not filtered).
>> Both tested on W10 without, and with CYGWINFORALL=-A and elevated/admin 
>> rights.
>> Comments or improvements you could suggest, or changes you need made?
> 
> Only whitespace which I fixed locally.
> 
> But this is going to become part of the Cygwin repo (the cygwin-docs 
> package is created from there), so I need a BSD copyright waiver
> from you. See https://cygwin.com/contrib.html and the CONTRIBUTORS
> file in the Cygwin repo:
> https://cygwin.com/git/?p=newlib-cygwin.git;f=winsup/CONTRIBUTORS;hb=HEAD

All my previous and subsequent contributions to Cygwin and related projects 
are provided subject to the the 2-clause BSD licence as below:

Copyright (c) , 
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada


0xB1871A93.asc
Description: application/pgp-keys


signature.asc
Description: OpenPGP digital signature


Re: cygwin-doc html/ missing docbook.css and index dups cygwin-{api,ug-net}

2017-04-22 Thread Corinna Vinschen
On Apr 22 03:30, Brian Inglis wrote:
> On 2017-04-22 02:59, Corinna Vinschen wrote:
> > But this is going to become part of the Cygwin repo (the cygwin-docs 
> > package is created from there), so I need a BSD copyright waiver
> > from you. See https://cygwin.com/contrib.html and the CONTRIBUTORS
> > file in the Cygwin repo:
> > https://cygwin.com/git/?p=newlib-cygwin.git;f=winsup/CONTRIBUTORS;hb=HEAD
> 
> All my previous and subsequent contributions to Cygwin and related projects 
> are provided subject to the the 2-clause BSD licence as below:
> 
> Copyright (c) , 
> All rights reserved.
> 
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are
> met:
> 
> 1. Redistributions of source code must retain the above copyright
>notice, this list of conditions and the following disclaimer.
> 
> 2. Redistributions in binary form must reproduce the above copyright
>notice, this list of conditions and the following disclaimer in the
>documentation and/or other materials provided with the distribution.
> 
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.

Thanks.  I applied your patch with a matching Makefile change.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


[PATCH] Fix stat.st_blocks for files compressed with CompactOS method

2017-04-22 Thread Christian Franke
Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with 
CompactOS method (at least on Win10 1607):


Testcase:

$ ls -ls file
280 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

$ compact /c file
...
$ ls -ls file
56 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

$ compact /u file
...
$ compact /c /exe file
...
$ ls -ls file
0 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

This is because StandardInformation.AllocationSize is always 0 for 
theses files. CompressedFileSize returns the correct value.


This is likely related to the interesting method how these files are 
encoded in the MFT:
The default $DATA stream is a sparse stream with original size but no 
allocated blocks.

An alternate $DATA stream WofCompressedData contains the compressed data.
An additional $REPARSE_POINT possibly marks this file a special and lets 
accesses fail on older Windows releases (and on Linux, most current 
forensic tools, ...).


With the attached patch, stat.st_blocks work as expected:

$ ls -ls file
48 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

The only drawback is an unnecessary FileCompressionInformation query for 
sparse files with no blocks.


Christian

Always retrieve FileCompressionInformation for non-empty
files if FileStandardInformation returns 0 allocated blocks.
This fixes stat.st_blocks for files compressed with CompactOS method.

Signed-off-by: Christian Franke 
---
 winsup/cygwin/fhandler_disk_file.cc | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/fhandler_disk_file.cc 
b/winsup/cygwin/fhandler_disk_file.cc
index fcbe15c..bf5f988 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -463,18 +463,25 @@ fhandler_base::fstat_helper (struct stat *buf)
 
   buf->st_blksize = PREFERRED_IO_BLKSIZE;
 
-  if (pfai->StandardInformation.AllocationSize.QuadPart >= 0LL)
+  if (buf->st_size == 0
+  && pfai->StandardInformation.AllocationSize.QuadPart == 0LL)
+/* File is empty and no blocks are preallocated. */
+buf->st_blocks = 0;
+  else if (pfai->StandardInformation.AllocationSize.QuadPart > 0LL)
 /* A successful NtQueryInformationFile returns the allocation size
-   correctly for compressed and sparse files as well. */
+   correctly for compressed and sparse files as well.
+   Allocation size 0 is ignored here because (at least) Windows 10
+   1607 always returns 0 for CompactOS compressed files. */
 buf->st_blocks = (pfai->StandardInformation.AllocationSize.QuadPart
  + S_BLKSIZE - 1) / S_BLKSIZE;
-  else if (::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
-   | FILE_ATTRIBUTE_SPARSE_FILE)
+  else if ((pfai->StandardInformation.AllocationSize.QuadPart == 0LL
+   || ::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
+ | FILE_ATTRIBUTE_SPARSE_FILE))
   && h && !is_fs_special ()
   && !NtQueryInformationFile (h, &st, (PVOID) &fci, sizeof fci,
   FileCompressionInformation))
 /* Otherwise we request the actual amount of bytes allocated for
-   compressed and sparsed files. */
+   compressed, sparsed and CompactOS files. */
 buf->st_blocks = (fci.CompressedFileSize.QuadPart + S_BLKSIZE - 1)
 / S_BLKSIZE;
   else


Re: [PATCH] Fix stat.st_blocks for files compressed with CompactOS method

2017-04-22 Thread Corinna Vinschen
Hi Christian,

On Apr 22 14:50, Christian Franke wrote:
> Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with
> CompactOS method (at least on Win10 1607):
> [...]
> This is because StandardInformation.AllocationSize is always 0 for theses
> files. CompressedFileSize returns the correct value.
> 
> This is likely related to the interesting method how these files are encoded
> in the MFT:
> The default $DATA stream is a sparse stream with original size but no
> allocated blocks.
> An alternate $DATA stream WofCompressedData contains the compressed data.
> An additional $REPARSE_POINT possibly marks this file a special and lets
> accesses fail on older Windows releases (and on Linux, most current forensic
> tools, ...).
> 
> With the attached patch, stat.st_blocks work as expected:
> [...]
> -  else if (::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
> - | FILE_ATTRIBUTE_SPARSE_FILE)
> +  else if ((pfai->StandardInformation.AllocationSize.QuadPart == 0LL
> + || ::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
> +   | FILE_ATTRIBUTE_SPARSE_FILE))

Are you saying these files actually have no FILE_ATTRIBUTE_COMPRESSED
bit set???


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: [PATCH] Fix stat.st_blocks for files compressed with CompactOS method

2017-04-22 Thread Christian Franke

Corinna Vinschen wrote:

Hi Christian,

On Apr 22 14:50, Christian Franke wrote:

Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with
CompactOS method (at least on Win10 1607):
[...]
This is because StandardInformation.AllocationSize is always 0 for theses
files. CompressedFileSize returns the correct value.

This is likely related to the interesting method how these files are encoded
in the MFT:
The default $DATA stream is a sparse stream with original size but no
allocated blocks.
An alternate $DATA stream WofCompressedData contains the compressed data.
An additional $REPARSE_POINT possibly marks this file a special and lets
accesses fail on older Windows releases (and on Linux, most current forensic
tools, ...).

With the attached patch, stat.st_blocks work as expected:
[...]
-  else if (::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
-   | FILE_ATTRIBUTE_SPARSE_FILE)
+  else if ((pfai->StandardInformation.AllocationSize.QuadPart == 0LL
+   || ::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
+ | FILE_ATTRIBUTE_SPARSE_FILE))

Are you saying these files actually have no FILE_ATTRIBUTE_COMPRESSED
bit set???



Yes. The only evidence is the CompressedSize.
There is also no visual emphasis in explorer listings.

Christian



Re: [PATCH] Fix stat.st_blocks for files compressed with CompactOS method

2017-04-22 Thread Corinna Vinschen
On Apr 22 16:34, Christian Franke wrote:
> Corinna Vinschen wrote:
> > Hi Christian,
> > 
> > On Apr 22 14:50, Christian Franke wrote:
> > > Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with
> > > CompactOS method (at least on Win10 1607):
> > > [...]
> > > This is because StandardInformation.AllocationSize is always 0 for theses
> > > files. CompressedFileSize returns the correct value.
> > > 
> > > This is likely related to the interesting method how these files are 
> > > encoded
> > > in the MFT:
> > > The default $DATA stream is a sparse stream with original size but no
> > > allocated blocks.
> > > An alternate $DATA stream WofCompressedData contains the compressed data.
> > > An additional $REPARSE_POINT possibly marks this file a special and lets
> > > accesses fail on older Windows releases (and on Linux, most current 
> > > forensic
> > > tools, ...).
> > > 
> > > With the attached patch, stat.st_blocks work as expected:
> > > [...]
> > > -  else if (::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
> > > - | FILE_ATTRIBUTE_SPARSE_FILE)
> > > +  else if ((pfai->StandardInformation.AllocationSize.QuadPart == 0LL
> > > + || ::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
> > > +   | FILE_ATTRIBUTE_SPARSE_FILE))
> > Are you saying these files actually have no FILE_ATTRIBUTE_COMPRESSED
> > bit set???
> > 
> 
> Yes. The only evidence is the CompressedSize.
> There is also no visual emphasis in explorer listings.

Weird.  Patch pushed.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature