summaryrefslogtreecommitdiffstats
path: root/src/fat_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fat_common.c')
-rw-r--r--src/fat_common.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/fat_common.c b/src/fat_common.c
index e6a6bee..ab1f181 100644
--- a/src/fat_common.c
+++ b/src/fat_common.c
@@ -23,9 +23,13 @@
#include <config.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
#include "types.h"
#include "common.h"
#include "fat.h"
+#include "fat_common.h"
unsigned int fat_sector_size(const struct fat_boot_sector *fat_header)
{ return (fat_header->sector_size[1]<<8)+fat_header->sector_size[0]; }
@@ -33,6 +37,19 @@ unsigned int fat_sector_size(const struct fat_boot_sector *fat_header)
unsigned int get_dir_entries(const struct fat_boot_sector *fat_header)
{ return (fat_header->dir_entries[1]<<8)+fat_header->dir_entries[0]; }
-unsigned int sectors(const struct fat_boot_sector *fat_header)
+unsigned int fat_sectors(const struct fat_boot_sector *fat_header)
{ return (fat_header->sectors[1]<<8)+fat_header->sectors[0]; }
+unsigned int fat_get_cluster_from_entry(const struct msdos_dir_entry *entry)
+{
+ return (((unsigned long int)le16(entry->starthi))<<16) | le16(entry->start);
+}
+
+int is_fat_directory(const unsigned char *buffer)
+{
+ return(buffer[0]=='.' &&
+ memcmp(buffer, ". ", 8+3)==0 &&
+ memcmp(&buffer[0x20], ".. ", 8+3)==0 &&
+ buffer[0xB]!=ATTR_EXT && (buffer[0xB]&ATTR_DIR)!=0 &&
+ buffer[1*0x20+0xB]!=ATTR_EXT && (buffer[1*0x20+0xB]&ATTR_DIR)!=0);
+}