diff --git a/lib/oofatfs/ff.c b/lib/oofatfs/ff.c
index 346f3df97097a10db96f69c3b604271341f3d00b..b0984756bf7fabcee70da748549a748fb97e59ce 100644
--- a/lib/oofatfs/ff.c
+++ b/lib/oofatfs/ff.c
@@ -27,6 +27,8 @@
 #include "ff.h"         /* Declarations of FatFs API */
 #include "diskio.h"     /* Declarations of device I/O functions */
 
+// DIR has been renamed FF_DIR in the public API so it doesn't clash with POSIX
+#define DIR FF_DIR
 
 /*--------------------------------------------------------------------------
 
@@ -3104,7 +3106,7 @@ FRESULT f_mount (
 
     fs->fs_type = 0;                    /* Clear new fs object */
 #if _FS_REENTRANT                       /* Create sync object for the new volume */
-    if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR;
+    if (!ff_cre_syncobj(fs, &fs->sobj)) return FR_INT_ERR;
 #endif
 
     res = find_volume(fs, 0);           /* Force mounted the volume */
@@ -3562,7 +3564,9 @@ FRESULT f_sync (
     FATFS *fs;
     DWORD tm;
     BYTE *dir;
+#if _FS_EXFAT
     DEF_NAMBUF
+#endif
 
 
     res = validate(&fp->obj, &fs);  /* Check validity of the file object */
diff --git a/lib/oofatfs/ff.h b/lib/oofatfs/ff.h
index 74f9fc9941717c814a73a26d3a6deb3a8e78f5f5..068de116609570548a2cd8b350f8b55ab0292449 100644
--- a/lib/oofatfs/ff.h
+++ b/lib/oofatfs/ff.h
@@ -197,7 +197,7 @@ typedef struct {
 
 
 
-/* Directory object structure (DIR) */
+/* Directory object structure (FF_DIR) */
 
 typedef struct {
     _FDID   obj;            /* Object identifier */
@@ -212,7 +212,7 @@ typedef struct {
 #if _USE_FIND
     const TCHAR* pat;       /* Pointer to the name matching pattern */
 #endif
-} DIR;
+} FF_DIR;
 
 
 
@@ -270,11 +270,11 @@ FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw);    /* Write dat
 FRESULT f_lseek (FIL* fp, FSIZE_t ofs);                             /* Move file pointer of the file object */
 FRESULT f_truncate (FIL* fp);                                       /* Truncate the file */
 FRESULT f_sync (FIL* fp);                                           /* Flush cached data of the writing file */
-FRESULT f_opendir (FATFS *fs, DIR* dp, const TCHAR* path);          /* Open a directory */
-FRESULT f_closedir (DIR* dp);                                       /* Close an open directory */
-FRESULT f_readdir (DIR* dp, FILINFO* fno);                          /* Read a directory item */
-FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);   /* Find first file */
-FRESULT f_findnext (DIR* dp, FILINFO* fno);                         /* Find next file */
+FRESULT f_opendir (FATFS *fs, FF_DIR* dp, const TCHAR* path);       /* Open a directory */
+FRESULT f_closedir (FF_DIR* dp);                                    /* Close an open directory */
+FRESULT f_readdir (FF_DIR* dp, FILINFO* fno);                       /* Read a directory item */
+FRESULT f_findfirst (FF_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
+FRESULT f_findnext (FF_DIR* dp, FILINFO* fno);                      /* Find next file */
 FRESULT f_mkdir (FATFS *fs, const TCHAR* path);                     /* Create a sub directory */
 FRESULT f_unlink (FATFS *fs, const TCHAR* path);                    /* Delete an existing file or directory */
 FRESULT f_rename (FATFS *fs, const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
@@ -327,7 +327,7 @@ void ff_memfree (void* mblock);         /* Free memory block */
 
 /* Sync functions */
 #if _FS_REENTRANT
-int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj);   /* Create a sync object */
+int ff_cre_syncobj (FATFS *fatfs, _SYNC_t* sobj); /* Create a sync object */
 int ff_req_grant (_SYNC_t sobj);                /* Lock sync object */
 void ff_rel_grant (_SYNC_t sobj);               /* Unlock sync object */
 int ff_del_syncobj (_SYNC_t sobj);              /* Delete a sync object */