]> wimlib.net Git - wimlib/blobdiff - src/dentry.h
More ADS and dentry alignment and padding issues
[wimlib] / src / dentry.h
index be0b058605c0a6e869cd9dfdfa0410454ce92fb8..74776420351f0dba418d387a060fee720decb4b6 100644 (file)
@@ -89,7 +89,9 @@ struct ads_entry {
  * entry to align the next one (or the next dentry) on an 8-byte boundary. */
 static inline u64 ads_entry_total_length(const struct ads_entry *entry)
 {
-       u64 len = WIM_ADS_ENTRY_DISK_SIZE + entry->stream_name_len + 2;
+       u64 len = WIM_ADS_ENTRY_DISK_SIZE;
+       if (entry->stream_name_len)
+               len += entry->stream_name_len + 2;
        return (len + 7) & ~7;
 }
 
@@ -155,7 +157,11 @@ struct dentry {
         * The length here includes the base directory entry on disk as well as
         * the long and short filenames.  It does NOT include any alternate
         * stream entries that may follow the directory entry, even though the
-        * size of those needs to be considered.
+        * size of those needs to be considered.  The length SHOULD be 8-byte
+        * aligned, although we don't require it to be.  We do require the
+        * length to be large enough to hold the file name(s) of the dentry;
+        * additionally, a warning is issued if this field is larger than the
+        * aligned size.
         */
        u64 length;