diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2012-04-24 17:11:17 -0500 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2012-04-24 17:11:17 -0500 |
commit | 675d3a4816ecfd4e0cdd77bd41f68ebdf28ea1fc (patch) | |
tree | 4199dc2342ed423c752b8f33d06e38b75e3d874c /src | |
parent | a207593ba7a59191ff7b96715fbc8c10065e8db7 (diff) |
Added foofs.filesystembackend.FilesystemBackend/readfile.
Diffstat (limited to 'src')
-rw-r--r-- | src/clojure/foofs/filesystem.clj | 10 | ||||
-rw-r--r-- | src/clojure/foofs/filesystembackend.clj | 2 | ||||
-rw-r--r-- | src/clojure/foofs/fuse/protocol.clj | 2 | ||||
-rw-r--r-- | src/clojure/foofs/memorybackend.clj | 9 |
4 files changed, 19 insertions, 4 deletions
diff --git a/src/clojure/foofs/filesystem.clj b/src/clojure/foofs/filesystem.clj index 7a94984..e5fc7f7 100644 --- a/src/clojure/foofs/filesystem.clj +++ b/src/clojure/foofs/filesystem.clj @@ -61,7 +61,15 @@ (continuation! {:handle 0 :flags 0}))))) (readfile [this request continuation!] - (continuation! [])) + (let [arg (:arg request) + offset (:offset arg) + size (:size arg)] + (.readfile + backend (:nodeid request) offset size + (fn [buffer] + (if (nil? buffer) + (continuation! errno-noent) + (continuation! buffer)))))) (statfs [this request continuation!] (continuation! {:blocks 0 diff --git a/src/clojure/foofs/filesystembackend.clj b/src/clojure/foofs/filesystembackend.clj index 4e0dc30..f7a9814 100644 --- a/src/clojure/foofs/filesystembackend.clj +++ b/src/clojure/foofs/filesystembackend.clj @@ -27,5 +27,7 @@ "Decrement link count of an inode.") (clonedir [this inode continuation!] "Return a lazy sequence of directory entries.") + (readfile [this inode offset size continuation!] + "Return a ByteBuffer or sequence of bytes.") ;; and so on ) diff --git a/src/clojure/foofs/fuse/protocol.clj b/src/clojure/foofs/fuse/protocol.clj index 1f1ed4c..3fb4ad8 100644 --- a/src/clojure/foofs/fuse/protocol.clj +++ b/src/clojure/foofs/fuse/protocol.clj @@ -244,7 +244,7 @@ (defn process-read! [fuse request] - (.read + (.readfile (:filesystem fuse) request (fn [result] diff --git a/src/clojure/foofs/memorybackend.clj b/src/clojure/foofs/memorybackend.clj index d260f7a..886eb08 100644 --- a/src/clojure/foofs/memorybackend.clj +++ b/src/clojure/foofs/memorybackend.clj @@ -73,5 +73,10 @@ {:name name :nodeid inode :type (:mode attr)})) - children))))) - + children)))) + (readfile [this inode offset size continuation!] + (let [state (deref state-agent) + file (get (:file-table state) inode)] + (if (nil? file) + (continuation! nil) + (continuation! (take size (drop offset file))))))) |