Use of FILE_ATTRIBUTE_UNIX_EXTENSION
A free file archiver for extremely high compression
Brought to you by:
ipavlov
Looking at a zip file created by 7z on Linux, I see it setting an unexpected bit in the External Attributes from the Central Header
0176 0179 0004 20 80 ED 81 Ext File Attributes 81ED8020 (2179825696)
[Bit 5] Archive
[Bits 11-15] 8000 (32768) 'Unknown DOS attrib'
[Bits 16-24] 01ED (493) 'Unix attrib: rwxr-xr-x'
[Bits 28-31] 08 (8) 'Regular File'
I see this definition in 7zTypes.h
(from https://github.com/mcmilk/7-Zip)
#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */
That gets used in SetFromPosixAttrib
when WIN32
is NOT set
Attrib = (a << 16) | FILE_ATTRIBUTE_UNIX_EXTENSION;
As far as I can tell this bit is only set with the Linux version of 7z. On Windows it is not set. Also, don't see it set with PKZip or Info-ZIP's zip.
What is setting this bit supposed to achieve?
It's flag that shows that high 16-bit contain unix attributes.
Do you know where that usage of this bit came from? I don't see that bit being set in any other zip implementation (WinZip, Pkzip, infozip). Was it created for use in 7zip?
Looking in the 7zip source for the usage of
FILE_ATTRIBUTE_UNIX_EXTENSION
, I don't see it being used to determine that there are Unix attributes present.Also, looking at https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants it appears that that bit is already taken by
FILE_ATTRIBUTE_INTEGRITY_STREAM
.p7zip
wrote0x8000
.Probably it was used by p7zip before introducing of
FILE_ATTRIBUTE_INTEGRITY_STREAM
.7-Zip writes
0x8000
to be compatible withp7zip
.I don't remember how it useful now.
Maybe some zip programs in
macos
wrote another bit0x4000
in zip.Thanks. I'll have a look at p7Zip and see if I can see track down the origin
Looking in the pzZip source, it does appear that this bit is used in a few places as a flag to determine when to use the Unix attributes. Not sure why it doesn't just check the Version Made By Field.
I don't know windows well enough to know if using this bit would cause interoperability issues, given that the bit is supposed to signal
FILE_ATTRIBUTE_INTEGRITY_STREAM
.Should 7z deprecate/drop this bit?
7-Zip (and p7zip) use it for
7z
andwim
archives that do not support any hints for "HOST OS".Ok, but that shouldn't mean it is needed when 7z creates zip files.
I suppose I used it for p7zip compatibility.
But if p7zip (archive extracting) doesn't require it for zip files, we can drop it.
Alse macos used another flag
0x4000
.So If flag was used there, maybe there was some reason why such flag is useful.
I see a lot of uses of the
0x4000
in the MacOS zip files I have access to. For example, although I don't have a Mac, I got GitHub to create some zip files a while back usingditto
. All have this bit set.Do you happen to know if the
0x4000
bit serves the same purpose as the0x8000
use-case with p7Zip?