summaryrefslogtreecommitdiff
path: root/firmware/common/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r--firmware/common/file.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index f04f787b45..795fc7df7e 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -660,3 +660,23 @@ off_t filesize(int fd)
660 660
661 return file->size; 661 return file->size;
662} 662}
663
664
665#ifdef HAVE_HOTSWAP
666// release all file handles on a given volume "by force", to avoid leaks
667int release_files(int volume)
668{
669 struct filedesc* pfile = openfiles;
670 int fd;
671 int closed = 0;
672 for ( fd=0; fd<MAX_OPEN_FILES; fd++, pfile++)
673 {
674 if (pfile->fatfile.volume == volume)
675 {
676 pfile->busy = false; /* mark as available, no further action */
677 closed++;
678 }
679 }
680 return closed; /* return how many we did */
681}
682#endif /* #ifdef HAVE_HOTSWAP */