]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Improve and document file flag and file attribute support
authorMartin Matuska <martin@matuska.org>
Tue, 12 Mar 2019 22:11:45 +0000 (23:11 +0100)
committerMartin Matuska <martin@matuska.org>
Wed, 13 Mar 2019 00:18:37 +0000 (01:18 +0100)
Removed read-only FreeBSD fflags: snapshot

Removed read-only Linux file attributes:
FS_BTREE_FL, FS_ECOMPR_FL, FS_DIRTY_FL, FS_COMPRBLK_FL, FS_INDEX_FL,
FS_IMAGIC_FL, FS_ENCRYPT_FL, FS_HUGE_FILE_FL, FS_EA_INODE_FL,
FS_EOFBLOCKS_FL, FS_INLINE_DATA_FL

Add missing FreeBSD fflags: uarch, offline, rdonly, sparse, reparse, system

Document in code supported file flags and their mapping

libarchive/archive_entry.c
libarchive/test/test_entry.c

index 15a737c800d39f56422b9445b825ddda9c102698..12dfa1da126d9312ddd7b737cf0a9faffcf8497f 100644 (file)
@@ -1632,6 +1632,54 @@ _archive_entry_acl_text_l(struct archive_entry *entry, int flags,
  * SUCH DAMAGE.
  */
 
+/*
+ * Supported file flags on FreeBSD and Mac OS:
+ * arch,archived               SF_ARCHIVED
+ * nodump                      UF_NODUMP
+ * opaque                      UF_OPAQUE
+ * sappnd,sappend              SF_APPEND
+ * schg,schange,simmutable     SF_IMMUTABLE
+ * sunlnk,sunlink              SF_NOUNLINK
+ * uappnd,uappend              UF_APPEND
+ * uarch,uarchive              UF_ARCHIVE
+ * uchg,uchange,uimmutable     UF_IMMUTABLE
+ * hidden,uhidden              UF_HIDDEN
+ * offline,uoffline            UF_OFFLINE      (FreeBSD only)
+ * rdonly,urdonly,readonly     UF_READONLY     (FreeBSD only)
+ * sparse,usparse              UF_SPARSE       (FreeBSD only)
+ * system,usystem                      UF_SYSTEM       (FreeBSD only)
+ * reparse,ureparse            UF_REPARSE      (FreeBSD only)
+ * uunlnk,uunlink              UF_NOUNLINK     (FreeBSD only)
+ * compressed                  UF_COMPRESSED   (Mac OS only)
+ *
+ * See chflags(2) for more information
+ *
+ * Supported file attributes on Linux:
+ * a   append only                     FS_APPEND_FL            sappnd
+ * A   no atime updates                FS_NOATME_FL            atime
+ * c   compress                        FS_COMPR_FL             compress
+ * C   no copy on write                FS_NOCOW_FL             cow
+ * d   no dump                         FS_NODUMP_FL            dump
+ * D   synchronous directory updates   FS_DIRSYNC_FL           dirsync
+ * e   extent format                   FS_EXTENT_FL            extent
+ * i   immutable                       FS_IMMUTABLE_FL         schg
+ * j   data journalling                FS_JOURNAL_DATA_FL      journal
+ * P   project hierarchy               FS_PROJINHERIT_FL       projinherit
+ * s   secure deletion                 FS_SECRM_FL             securedeletion
+ * S   synchronous updates             FS_SYNC_FL              sync
+ * t   no tail-merging                 FS_NOTAIL_FL            tail
+ * T   top of directory hierarchy      FS_TOPDIR_FL            topdir
+ * u   undeletable                     FS_UNRM_FL              uunlnk
+ *
+ * See ioctl_iflags(2) for more information
+ *
+ * Equivalent file flags supported on FreeBSD / Mac OS and Linux:
+ * SF_APPEND           FS_APPEND_FL            sappnd
+ * SF_IMMUTABLE                FS_IMMUTABLE_FL         schg
+ * UF_NODUMP           FS_NODUMP_FL            nodump
+ * UF_NOUNLINK         FS_UNRM_FL              uunlnk
+ */
+
 static const struct flag {
        const char      *name;
        const wchar_t   *wname;
@@ -1672,9 +1720,6 @@ static const struct flag {
        { "nosunlnk",   L"nosunlnk",            SF_NOUNLINK,    0},
        { "nosunlink",  L"nosunlink",           SF_NOUNLINK,    0},
 #endif
-#ifdef SF_SNAPSHOT
-       { "nosnapshot", L"nosnapshot",  SF_SNAPSHOT,    0},
-#endif
 #ifdef UF_APPEND
        { "nouappnd",   L"nouappnd",            UF_APPEND,      0},
        { "nouappend",  L"nouappend",           UF_APPEND,      0},
@@ -1689,148 +1734,113 @@ static const struct flag {
 #endif
 #if defined(FS_NODUMP_FL)      /* 'd' */
        { "nodump",     L"nodump",              0,              FS_NODUMP_FL},
-#elif defined(EXT2_NODUMP_FL)  /* 'd' */
+#elif defined(EXT2_NODUMP_FL)
        { "nodump",     L"nodump",              0,              EXT2_NODUMP_FL},
 #endif
 #ifdef UF_OPAQUE
        { "noopaque",   L"noopaque",            UF_OPAQUE,      0},
 #endif
+#ifdef UF_ARCHIVE
+       { "nouarch",    L"nouarch",             UF_ARCHIVE,     0},
+       { "nouarchive", L"nouarchive",          UF_ARCHIVE,     0},
+#endif
 #ifdef UF_NOUNLINK
        { "nouunlnk",   L"nouunlnk",            UF_NOUNLINK,    0},
        { "nouunlink",  L"nouunlink",           UF_NOUNLINK,    0},
        { "noundel",    L"noundel",             UF_NOUNLINK,    0},
 #endif
 #ifdef UF_COMPRESSED
-       { "nocompressed",L"nocompressed",       UF_COMPRESSED,  0},
+       /* Mac OS */
+       { "nocompressed",       L"nocompressed",        UF_COMPRESSED,  0},
 #endif
 #ifdef UF_HIDDEN
        { "nohidden",   L"nohidden",            UF_HIDDEN,      0},
+       { "nouhidden",  L"nouhidden",           UF_HIDDEN,      0},
 #endif
-#if defined(FS_UNRM_FL)
-       { "nouunlink",  L"nouunlink",           FS_UNRM_FL,     0},
+#ifdef UF_OFFLINE
+       { "nooffline",  L"nooffline",           UF_OFFLINE,     0},
+       { "nouoffline", L"nouoffline",          UF_OFFLINE,     0},
+#endif
+#ifdef UF_READONLY
+       { "nordonly",   L"nordonly",            UF_READONLY,    0},
+       { "nourdonly",  L"nourdonly",           UF_READONLY,    0},
+       { "noreadonly", L"noreadonly",          UF_READONLY,    0},
+#endif
+#ifdef UF_SPARSE
+       { "nosparse",   L"nosparse",            UF_SPARSE,      0},
+       { "nousparse",  L"nousparse",           UF_SPARSE,      0},
+#endif
+#ifdef UF_REPARSE
+       { "noreparse",  L"noreparse",           UF_REPARSE,     0},
+       { "noureparse", L"noureparse",          UF_REPARSE,     0},
+#endif
+#ifdef UF_SYSTEM
+       { "nosystem",   L"nosystem",            UF_SYSTEM,      0},
+       { "nousystem",  L"nousystem",           UF_SYSTEM,      0},
+#endif
+#if defined(FS_UNRM_FL)                /* 'u' */
        { "nouunlnk",   L"nouunlnk",            FS_UNRM_FL,     0},
+       { "nouunlink",  L"nouunlink",           FS_UNRM_FL,     0},
        { "noundel",    L"noundel",             FS_UNRM_FL,     0},
 #elif defined(EXT2_UNRM_FL)
-       { "nouunlink",  L"nouunlink",           EXT2_UNRM_FL,   0},
        { "nouunlnk",   L"nouunlnk",            EXT2_UNRM_FL,   0},
+       { "nouunlink",  L"nouunlink",           EXT2_UNRM_FL,   0},
        { "noundel",    L"noundel",             EXT2_UNRM_FL,   0},
 #endif
 
-#if defined(FS_BTREE_FL)
-       { "nobtree",    L"nobtree",             FS_BTREE_FL,    0},
-#elif defined(EXT2_BTREE_FL)
-       { "nobtree",    L"nobtree",             EXT2_BTREE_FL,  0},
-#endif
-
-#if defined(FS_ECOMPR_FL)
-       { "nocomperr",  L"nocomperr",           FS_ECOMPR_FL,   0},
-#elif defined(EXT2_ECOMPR_FL)
-       { "nocomperr",  L"nocomperr",           EXT2_ECOMPR_FL, 0},
-#endif
-
-#if defined(FS_COMPR_FL)                       /* 'c' */
+#if defined(FS_COMPR_FL)       /* 'c' */
        { "nocompress", L"nocompress",          FS_COMPR_FL,    0},
-#elif defined(EXT2_COMPR_FL)                   /* 'c' */
+#elif defined(EXT2_COMPR_FL)
        { "nocompress", L"nocompress",          EXT2_COMPR_FL,  0},
 #endif
 
-#if defined(FS_NOATIME_FL)                     /* 'A' */
+#if defined(FS_NOATIME_FL)     /* 'A' */
        { "noatime",    L"noatime",             0,              FS_NOATIME_FL},
-#elif defined(EXT2_NOATIME_FL)                 /* 'A' */
+#elif defined(EXT2_NOATIME_FL)
        { "noatime",    L"noatime",             0,              EXT2_NOATIME_FL},
 #endif
-
-#if defined(FS_DIRTY_FL)
-       { "nocompdirty",L"nocompdirty",         FS_DIRTY_FL,            0},
-#elif defined(EXT2_DIRTY_FL)
-       { "nocompdirty",L"nocompdirty",         EXT2_DIRTY_FL,          0},
-#endif
-
-#if defined(FS_COMPRBLK_FL)
-#if defined(FS_NOCOMPR_FL)
-       { "nocomprblk", L"nocomprblk",          FS_COMPRBLK_FL, FS_NOCOMPR_FL},
-#else
-       { "nocomprblk", L"nocomprblk",          FS_COMPRBLK_FL, 0},
-#endif
-#elif defined(EXT2_COMPRBLK_FL)
-#if defined(EXT2_NOCOMPR_FL)
-       { "nocomprblk", L"nocomprblk",          EXT2_COMPRBLK_FL, EXT2_NOCOMPR_FL},
-#else
-       { "nocomprblk", L"nocomprblk",          EXT2_COMPRBLK_FL,       0},
-#endif
-#endif
-#if defined(FS_DIRSYNC_FL)
-       { "nodirsync",  L"nodirsync",           FS_DIRSYNC_FL,  0},
+#if defined(FS_DIRSYNC_FL)     /* 'D' */
+       { "nodirsync",  L"nodirsync",           FS_DIRSYNC_FL,          0},
 #elif defined(EXT2_DIRSYNC_FL)
        { "nodirsync",  L"nodirsync",           EXT2_DIRSYNC_FL,        0},
 #endif
-#if defined(FS_INDEX_FL)
-       { "nohashidx",  L"nohashidx",           FS_INDEX_FL,            0},
-#elif defined(EXT2_INDEX_FL)
-       { "nohashidx",  L"nohashidx",           EXT2_INDEX_FL,          0},
-#endif
-#if defined(FS_IMAGIC_FL)
-       { "noimagic",   L"noimagic",            FS_IMAGIC_FL,           0},
-#elif defined(EXT2_IMAGIC_FL)
-       { "noimagic",   L"noimagic",            EXT2_IMAGIC_FL,         0},
-#endif
-#if defined(FS_JOURNAL_DATA_FL)
+#if defined(FS_JOURNAL_DATA_FL)        /* 'j' */
        { "nojournal",  L"nojournal",           FS_JOURNAL_DATA_FL,     0},
        { "nojournal-data",L"nojournal-data",   FS_JOURNAL_DATA_FL,     0},
 #elif defined(EXT3_JOURNAL_DATA_FL)
        { "nojournal",  L"nojournal",           EXT3_JOURNAL_DATA_FL,   0},
        { "nojournal-data",L"nojournal-data",   EXT3_JOURNAL_DATA_FL,   0},
 #endif
-#if defined(FS_SECRM_FL)
+#if defined(FS_SECRM_FL)       /* 's' */
        { "nosecuredeletion",L"nosecuredeletion",FS_SECRM_FL,           0},
        { "nosecdel",   L"nosecdel",            FS_SECRM_FL,            0},
 #elif defined(EXT2_SECRM_FL)
        { "nosecuredeletion",L"nosecuredeletion",EXT2_SECRM_FL,         0},
        { "nosecdel",   L"nosecdel",            EXT2_SECRM_FL,          0},
 #endif
-#if defined(FS_SYNC_FL)
+#if defined(FS_SYNC_FL)                /* 'S' */
        { "nosync",     L"nosync",              FS_SYNC_FL,             0},
 #elif defined(EXT2_SYNC_FL)
        { "nosync",     L"nosync",              EXT2_SYNC_FL,           0},
 #endif
-#if defined(FS_NOTAIL_FL)
+#if defined(FS_NOTAIL_FL)      /* 't' */
        { "notail",     L"notail",              0,              FS_NOTAIL_FL},
 #elif defined(EXT2_NOTAIL_FL)
        { "notail",     L"notail",              0,              EXT2_NOTAIL_FL},
 #endif
-#if defined(FS_TOPDIR_FL)
+#if defined(FS_TOPDIR_FL)      /* 'T' */
        { "notopdir",   L"notopdir",            FS_TOPDIR_FL,           0},
 #elif defined(EXT2_TOPDIR_FL)
        { "notopdir",   L"notopdir",            EXT2_TOPDIR_FL,         0},
 #endif
-#ifdef FS_ENCRYPT_FL
-       { "noencrypt",  L"noencrypt",           FS_ENCRYPT_FL,  0},
-#endif
-#ifdef FS_HUGE_FILE_FL
-       { "nohugefile", L"nohugefile",          FS_HUGE_FILE_FL,        0},
-#endif
-#ifdef FS_EXTENT_FL
+#ifdef FS_EXTENT_FL            /* 'e' */
        { "noextent",   L"noextent",            FS_EXTENT_FL,   0},
 #endif
-#ifdef FS_EA_INODE_FL
-       { "noeainode",  L"noeainode",           FS_EA_INODE_FL, 0},
+#ifdef FS_NOCOW_FL     /* 'C' */
+       { "nocow",      L"nocow",               0,      FS_NOCOW_FL},
 #endif
-#ifdef FS_EOFBLOCKS_FL
-       { "noeofblocks",L"noeofblocks",         FS_EOFBLOCKS_FL,        0},
-#endif
-#ifdef FS_NOCOW_FL
-       { "nocow",      L"nocow",               FS_NOCOW_FL,    0},
-#endif
-#ifdef FS_INLINE_DATA_FL
-       { "noinlinedata",L"noinlinedata",       FS_INLINE_DATA_FL,      0},
-#endif
-#ifdef FS_PROJINHERIT_FL
+#ifdef FS_PROJINHERIT_FL       /* 'P' */
        { "noprojinherit",L"noprojinherit",     FS_PROJINHERIT_FL,      0},
-#endif
-#if defined(FS_RESERVED_FL)
-       { "noreserved", L"noreserved",          FS_RESERVED_FL, 0},
-#elif defined(EXT2_RESERVED_FL)
-       { "noreserved", L"noreserved",          EXT2_RESERVED_FL,       0},
 #endif
        { NULL,         NULL,                   0,              0}
 };
index 0ccc9e8fb355f18ccd82135f77107a595bde1c28..a0a2607a156c362d232bc7e21a264e45dffd599e 100644 (file)
@@ -336,7 +336,7 @@ DEFINE_TEST(test_entry)
        /* Converting fflags bitmap to string is currently system-dependent. */
        /* TODO: Make this system-independent. */
        assertEqualString(archive_entry_fflags_text(e),
-           "uappnd,nouchg,nodump,noopaque,uunlnk");
+           "uappnd,nouchg,nodump,noopaque,uunlnk,nosystem");
        /* Test archive_entry_copy_fflags_text_w() */
        archive_entry_copy_fflags_text_w(e, L" ,nouappnd, nouchg, dump,uunlnk");
        archive_entry_fflags(e, &set, &clear);