Menu

#553 Use of FILE_ATTRIBUTE_UNIX_EXTENSION

open
nobody
None
5
2024-04-15
2024-04-14
No

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?

Discussion

  • Igor Pavlov

    Igor Pavlov - 2024-04-15

    It's flag that shows that high 16-bit contain unix attributes.

     
  • Paul Marquess

    Paul Marquess - 2024-04-15

    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.

     
    • Igor Pavlov

      Igor Pavlov - 2024-04-15

      p7zipwrote 0x8000.
      Probably it was used by p7zip before introducing of FILE_ATTRIBUTE_INTEGRITY_STREAM.
      7-Zip writes 0x8000 to be compatible with p7zip.
      I don't remember how it useful now.

      Maybe some zip programs in macos wrote another bit 0x4000 in zip.

       
  • Paul Marquess

    Paul Marquess - 2024-04-15

    Thanks. I'll have a look at p7Zip and see if I can see track down the origin

     
  • Paul Marquess

    Paul Marquess - 2024-04-15

    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?

     
  • Igor Pavlov

    Igor Pavlov - 2024-04-15

    7-Zip (and p7zip) use it for 7z and wimarchives that do not support any hints for "HOST OS".

     
  • Paul Marquess

    Paul Marquess - 2024-04-15

    Ok, but that shouldn't mean it is needed when 7z creates zip files.

     
  • Igor Pavlov

    Igor Pavlov - 2024-04-15

    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.

     
  • Paul Marquess

    Paul Marquess - 2024-04-15

    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 using ditto. All have this bit set.

    Do you happen to know if the 0x4000 bit serves the same purpose as the 0x8000 use-case with p7Zip?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.