summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/init.c b/init.c
index 65b8d9e..af154b7 100644
--- a/init.c
+++ b/init.c
@@ -505,7 +505,15 @@ char getDrive(Stream_t *Stream)
return This->drive;
}
-int fsPreallocateClusters(Fs_t *Fs, size_t size)
+/*
+ * Upper layer asks to pre-allocated more additional clusters
+ * Parameters:
+ * size: new additional clusters to pre-allocate
+ * Return:
+ * 0 if pre-allocation was granted
+ * -1 if not enough clusters could be found
+ */
+int fsPreallocateClusters(Fs_t *Fs, uint32_t size)
{
if(size > 0 && getfreeMinClusters((Stream_t *)Fs, size) != 1)
return -1;
@@ -513,3 +521,16 @@ int fsPreallocateClusters(Fs_t *Fs, size_t size)
Fs->preallocatedClusters += size;
return 0;
}
+
+/*
+ * Upper layer wants to release some clusters that it had
+ * pre-allocated before Usually done because they have now been really
+ * allocated, and thus pre-allocation needs to be released to prevent
+ * counting them twice.
+ * Parameters:
+ * size: new additional clusters to pre-allocate
+ */
+void fsReleasePreallocateClusters(Fs_t *Fs, uint32_t size)
+{
+ Fs->preallocatedClusters -= size;
+}