From 8179daee4adf1a3224d3e2666a8a296d76ea6179 Mon Sep 17 00:00:00 2001
From: robk-tahoe <robk-tahoe@allmydata.com>
Date: Wed, 7 May 2008 16:40:09 -0700
Subject: [PATCH] tahoefuse: return bogus but useful data to statfs call

previously tahoefuse returned the fs stat for the filesystem the fuse plugin
was running upon (e.g. '/').  this works ok until you need to copy more to
tahoe than the local machine has free disk space, at which point Finder will
refuse to copy 'too much' data.

this changes it so that tahoe always reports 2TiB used of an 8TiB filesystem
this is entirely bogus, but allows copies of up to 2TiB to be initiated.
---
 mac/tahoefuse.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/mac/tahoefuse.py b/mac/tahoefuse.py
index fe97577c..5fce5d44 100644
--- a/mac/tahoefuse.py
+++ b/mac/tahoefuse.py
@@ -329,7 +329,22 @@ class TahoeFuse(fuse.Fuse):
             - f_ffree - nunber of free file inodes
         """
 
-        return os.statvfs(".")
+        block_size = 4096 # 4k
+        preferred_block_size = 131072 # 128k, c.f. seg_size
+        fs_size = 8*2**40 # 8Tb
+        fs_free = 2*2**40 # 2Tb
+
+        s = fuse.StatVfs(f_bsize = preferred_block_size,
+                         f_frsize = block_size,
+                         f_blocks = fs_size / block_size,
+                         f_bfree = fs_free / block_size,
+                         f_bavail = fs_free / block_size,
+                         f_files = 2**30, # total files
+                         f_ffree = 2**20, # available files
+                         f_favail = 2**20, # available files (root)
+                         f_flag = 2, # no suid
+                         f_namemax = 255) # max name length
+        return s
 
     def fsinit(self):
         self.log("fsinit()")
-- 
2.45.2