aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2012-04-26 21:30:21 -0500
committerDavid Barksdale <amatus.amongus@gmail.com>2012-04-26 21:30:21 -0500
commit8f0ce277dd6c28c13b6680f9c7767bada776fcb3 (patch)
treeab80b2c927796d8722b9aefe21921265667734fb /src
parente759ac19e86f55d190a1231e4ddd70a53b93f6bd (diff)
Simplified reply logic.
Diffstat (limited to 'src')
-rw-r--r--src/clojure/foofs/filesystem.clj4
-rw-r--r--src/clojure/foofs/fuse/protocol.clj74
2 files changed, 29 insertions, 49 deletions
diff --git a/src/clojure/foofs/filesystem.clj b/src/clojure/foofs/filesystem.clj
index 1f8d0e4..dc41ac9 100644
--- a/src/clojure/foofs/filesystem.clj
+++ b/src/clojure/foofs/filesystem.clj
@@ -96,7 +96,7 @@
(fn [link]
(if (nil? link)
(continuation! errno-noent)
- (continuation! nil)))))
+ (continuation! 0)))))
(init [this request]
(.println *err* "init called")
(send
@@ -157,7 +157,7 @@
(fn [link]
(if (nil? link)
(continuation! errno-noent)
- (continuation! nil))
+ (continuation! 0))
(send
readdir-agent
(fn [state]
diff --git a/src/clojure/foofs/fuse/protocol.clj b/src/clojure/foofs/fuse/protocol.clj
index 3d57d40..74bc210 100644
--- a/src/clojure/foofs/fuse/protocol.clj
+++ b/src/clojure/foofs/fuse/protocol.clj
@@ -159,12 +159,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok!
- fuse
- request
- (write-entry-out result))
- (integer? result) (reply-error! fuse request result)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-entry-out result))))))
(def parse-forget-in
(domonad
@@ -192,17 +189,13 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok!
- fuse
- request
- (domonad
- state-m
- [_ (write-attr-out 0 0)
- _ (write-fuse-attr result)]
- nil))
- (integer? result) (reply-error! fuse request result)
- true (reply-error! fuse request errno-nosys)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request
+ (domonad
+ state-m
+ [_ (write-attr-out 0 0)
+ _ (write-fuse-attr result)] nil))))))
(def parse-mknod-in
(domonad
@@ -220,12 +213,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok!
- fuse
- request
- (write-entry-out result))
- (integer? result) (reply-error! fuse request result)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-entry-out result))))))
(def parse-open-in
(domonad parser-m
@@ -248,10 +238,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok! fuse request (write-open-out result))
- (integer? result) (reply-error! fuse request result)
- true (reply-error! fuse request errno-nosys)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-open-out result))))))
(def parse-read-in
(domonad
@@ -296,10 +285,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok! fuse request (write-statfs-out result))
- (integer? result) (reply-error! fuse request result)
- true (reply-error! fuse request errno-nosys)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-statfs-out result))))))
(def parse-release-in
(domonad
@@ -316,10 +304,7 @@
(.release
(:filesystem fuse)
request
- (fn [result]
- (if (integer? result)
- (reply-error! fuse request result)
- (reply-error! fuse request 0)))))
+ (partial reply-error! fuse request)))
(def parse-init-in
(domonad
@@ -389,10 +374,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok! fuse request (write-open-out result))
- (integer? result) (reply-error! fuse request result)
- true (reply-error! fuse request errno-nosys)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-open-out result))))))
(def name-offset 24)
(defn dirent-align
@@ -441,10 +425,7 @@
(.releasedir
(:filesystem fuse)
request
- (fn [result]
- (if (integer? result)
- (reply-error! fuse request result)
- (reply-error! fuse request 0)))))
+ (partial reply-error! fuse request)))
(def parse-create-in
(domonad
@@ -469,10 +450,9 @@
(:filesystem fuse)
request
(fn [result]
- (cond
- (map? result) (reply-ok! fuse request (write-create-out result))
- (integer? result) (reply-error! fuse request result)
- true (reply-error! fuse request errno-nosys)))))
+ (if (integer? result)
+ (reply-error! fuse request result)
+ (reply-ok! fuse request (write-create-out result))))))
(defn process-destroy!
[fuse request]