aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2012-05-22 20:30:47 -0500
committerDavid Barksdale <amatus.amongus@gmail.com>2012-05-22 20:30:47 -0500
commit96408a51306327a6bfda772a29ae4b2607eaee1c (patch)
tree41f858420aa5f2f4093052d9e435bdc93c29f47c
parent8e006c53f030ea6cc9f3ce767bf02aca1aee4253 (diff)
Started on op-rename. Made some important notes about the backend.
-rw-r--r--src/clojure/foofs/filesystem.clj11
-rw-r--r--src/clojure/foofs/filesystembackend.clj1
-rw-r--r--src/clojure/foofs/fuse/filesystem.clj1
-rw-r--r--src/clojure/foofs/fuse/protocol.clj13
-rw-r--r--src/clojure/foofs/memorybackend.clj5
5 files changed, 30 insertions, 1 deletions
diff --git a/src/clojure/foofs/filesystem.clj b/src/clojure/foofs/filesystem.clj
index 63302bc..228d77a 100644
--- a/src/clojure/foofs/filesystem.clj
+++ b/src/clojure/foofs/filesystem.clj
@@ -30,6 +30,12 @@
:attr attr})
;; TODO - make use of argument destructuring
+;; TODO - the backend operations will eventually be interleaved with operations
+;; from other clients. These need to be transformed to not operate on inode
+;; numbers, because those will not be the same between clients. It seems like
+;; a bad idea to call backend operations conditionally on the results of other
+;; backend operations since they may return different results on different
+;; clients.
(defrecord FooFilesystem
[^foofs.filesystembackend.FilesystemBackend backend
^clojure.lang.Agent readdir-agent]
@@ -131,6 +137,8 @@
(continuation! (fill-entry attr)))))))
(mkdir [this request continuation!]
(let [arg (:arg request)]
+ ;; TODO: this probably should be a backend op. the parent dir could go
+ ;; away before we can ref it with the .. link.
(.mknod
backend (:nodeid request) (:filename arg)
(bit-or stat-type-directory (:mode arg))
@@ -146,6 +154,9 @@
(.unlink backend (:nodeid request) (:arg request) continuation!))
(rmdir [this request continuation!]
(.rmdir backend (:nodeid request) (:arg request) continuation!))
+ (rename [this {:keys [nodeid arg]} continuation!]
+ (.rename backend nodeid (:target-inode arg) (:filename arg)
+ (:target-filename arg) continuation!))
(link [this request continuation!]
(let [arg (:arg request)]
(.link
diff --git a/src/clojure/foofs/filesystembackend.clj b/src/clojure/foofs/filesystembackend.clj
index cfaa1a2..2736ad8 100644
--- a/src/clojure/foofs/filesystembackend.clj
+++ b/src/clojure/foofs/filesystembackend.clj
@@ -45,5 +45,6 @@
(truncate [this inode size continuation!])
(setatime [this inode seconds nseconds continuation!])
(setmtime [this inode seconds nseconds continuation!])
+ (rename [this inode target-inode filename target-filename continuation!])
;; and so on
)
diff --git a/src/clojure/foofs/fuse/filesystem.clj b/src/clojure/foofs/fuse/filesystem.clj
index 4430dce..83f0ad3 100644
--- a/src/clojure/foofs/fuse/filesystem.clj
+++ b/src/clojure/foofs/fuse/filesystem.clj
@@ -25,6 +25,7 @@
(mkdir [this request continuation!] "Create directory.")
(unlink [this request continuation!] "Unlink a file.")
(rmdir [this request continuation!] "Remove an empty directory.")
+ (rename [this request continuation!] "Rename.")
(link [this request continuation!] "Create hardlink.")
(open [this request continuation!] "Open file.")
(readfile [this request continuation!] "Read file.")
diff --git a/src/clojure/foofs/fuse/protocol.clj b/src/clojure/foofs/fuse/protocol.clj
index 3635252..c9c39f7 100644
--- a/src/clojure/foofs/fuse/protocol.clj
+++ b/src/clojure/foofs/fuse/protocol.clj
@@ -182,6 +182,16 @@
{:mode mode
:filename filename}))
+(def parse-rename-in
+ (domonad
+ parser-m
+ [target-inode parse-opaque64
+ filename parse-utf8
+ target-filename parse-utf8]
+ {:target-inode target-inode
+ :filename filename
+ :target-filename target-filename}))
+
(def parse-link-in
(domonad
parser-m
@@ -433,6 +443,9 @@
op-rmdir {:arg-parser parse-utf8
:processor! (partial process-generic!
#(.rmdir %1 %2 %3) write-skip)}
+ op-rename {:arg-parser parse-rename-in
+ :processor! (partial process-generic!
+ #(.rename %1 %2 %3) write-skip)}
op-link {:arg-parser parse-link-in
:processor! (partial process-generic!
#(.link %1 %2 %3) write-entry-out)}
diff --git a/src/clojure/foofs/memorybackend.clj b/src/clojure/foofs/memorybackend.clj
index d03c262..b3ad444 100644
--- a/src/clojure/foofs/memorybackend.clj
+++ b/src/clojure/foofs/memorybackend.clj
@@ -218,6 +218,7 @@
(do (continuation! errno-notdir) state)
(if (not (empty? (dissoc child-children "." "..")))
(do (continuation! errno-notempty) state)
+ ;; TODO: 3 is wrong if . or .. don't exist
(let [nlink (- (:nlink child-attr) 3)]
(agent-do state-agent (continuation! 0))
(assoc state
@@ -272,4 +273,6 @@
(attr-modifier! state-agent inode
(fn [attr]
(assoc attr :mtime seconds :mtimensec nseconds))
- continuation!)))
+ continuation!))
+ (rename [this inode target-inode filename target-filename continuation!]
+ (continuation! errno-nosys)))