diff -ur libfat/include/fat.h libfat-attr/include/fat.h --- libfat/include/fat.h 2006-07-25 09:19:54.000000000 -0400 +++ libfat-attr/include/fat.h 2007-04-17 00:08:26.000000000 -0400 @@ -110,6 +110,15 @@ */ bool fatSetDefaultInterface (PARTITION_INTERFACE partitionNumber); +/* +Enable extra msdos specific attributes to be expressed with the exec bits +in stat() and fopen() +System = World Exec +Archive = Group Exec +Hidden = User Exec +*/ +void fatEnableExtraAttributes(); + #ifdef __cplusplus } #endif diff -ur libfat/source/directory.c libfat-attr/source/directory.c --- libfat/source/directory.c 2006-12-30 20:04:31.000000000 -0500 +++ libfat-attr/source/directory.c 2007-04-17 00:18:10.000000000 -0400 @@ -56,6 +56,7 @@ #define DIR_ENTRY_LAST 0x00 #define DIR_ENTRY_FREE 0xE5 +bool _FAT_extra_attributes = 0; // Long file name directory entry enum LFN_offset { @@ -874,6 +875,11 @@ st->st_ino = (ino_t)(_FAT_directory_entryGetCluster(entry->entryData)); // The file serial number is the start cluster st->st_mode = (_FAT_directory_isDirectory(entry) ? S_IFDIR : S_IFREG) | (S_IRUSR | S_IRGRP | S_IROTH) | + (_FAT_extra_attributes ? ( + (_FAT_directory_isHidden(entry) ? S_IXUSR : 0) | + (_FAT_directory_isArchive(entry) ? S_IXGRP : 0) | + (_FAT_directory_isSystem(entry) ? S_IXOTH : 0) + ) : 0) | (_FAT_directory_isWritable (entry) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0); // Mode bits based on dirEntry ATTRIB byte st->st_nlink = 1; // Always one hard link on a FAT file st->st_uid = 1; // Faked for FAT @@ -900,3 +906,7 @@ st->st_spare4[0] = 0; st->st_spare4[1] = 0; } + +void fatEnableExtraAttributes() { + _FAT_extra_attributes = 1; +} diff -ur libfat/source/directory.h libfat-attr/source/directory.h --- libfat/source/directory.h 2006-07-13 22:42:36.000000000 -0400 +++ libfat-attr/source/directory.h 2007-04-17 00:13:11.000000000 -0400 @@ -94,6 +94,18 @@ return ((entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) != 0); } +static inline bool _FAT_directory_isHidden (DIR_ENTRY* entry) { + return ((entry->entryData[DIR_ENTRY_attributes] & ATTRIB_HID) != 0); +} + +static inline bool _FAT_directory_isSystem (DIR_ENTRY* entry) { + return ((entry->entryData[DIR_ENTRY_attributes] & ATTRIB_SYS) != 0); +} + +static inline bool _FAT_directory_isArchive (DIR_ENTRY* entry) { + return ((entry->entryData[DIR_ENTRY_attributes] & ATTRIB_ARCH) != 0); +} + static inline bool _FAT_directory_isWritable (DIR_ENTRY* entry) { return ((entry->entryData[DIR_ENTRY_attributes] & ATTRIB_RO) == 0); }