add flag to turn off hiding removed but open files
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 13 Jul 2004 15:36:52 +0000 (15:36 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Tue, 13 Jul 2004 15:36:52 +0000 (15:36 +0000)
ChangeLog
include/fuse.h
lib/fuse.c
lib/helper.c

index 7918c83099b165c4bb4e7efe76d43a6307baf2ea..e4198f9445dfa8fddd3b533482ddd81f11250092 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-13  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Add FUSE_HARD_REMOVE flag, and '-i' option to fuse main, which
+       disable the "hide if open" behavior of unlink/rename. 
+       
 2004-07-12  Miklos Szeredi <miklos@szeredi.hu>
 
        * Fix bug in do_open() in libfuse: open count was incremented
index 7bb5a5a5cce0db60ae799aa12f6b3808eabd8645..782a51c6f2fda84d4d0b996c82dc2b5935c91fab 100644 (file)
@@ -144,6 +144,10 @@ struct fuse_context {
 /** Enable debuging output */
 #define FUSE_DEBUG       (1 << 1)
 
+/** If a file is removed but it's still open, don't hide the file but
+    remove it immediately */
+#define FUSE_HARD_REMOVE (1 << 2)
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 6689bf3c61b0ff21fd928551b117ea37a8125741..cebca070aa5919d27df95638929a7bf5cbe056f2 100644 (file)
@@ -814,7 +814,7 @@ static void do_unlink(struct fuse *f, struct fuse_in_header *in, char *name)
     if (path != NULL) {
         res = -ENOSYS;
         if (f->op.unlink) {
-            if (is_open(f, in->ino, name))
+            if (!(f->flags & FUSE_HARD_REMOVE) && is_open(f, in->ino, name))
                 res = hide_node(f, path, in->ino, name);
             else {
                 res = f->op.unlink(path);
@@ -894,7 +894,8 @@ static void do_rename(struct fuse *f, struct fuse_in_header *in,
             res = -ENOSYS;
             if (f->op.rename) {
                 res = 0;
-                if (is_open(f, newdir, newname))
+                if (!(f->flags & FUSE_HARD_REMOVE) && 
+                    is_open(f, newdir, newname))
                     res = hide_node(f, newpath, newdir, newname);
                 if (res == 0) {
                     res = f->op.rename(oldpath, newpath);
index e639d6897714aec0db1eae73a34509099460c862..d597c468cf0ad7c1f0609642a88c0fd4d28e8876 100644 (file)
@@ -30,6 +30,7 @@ static void usage(char *progname)
             "    -d      enable debug output (implies -f)\n"
             "    -f      foreground operation\n"
             "    -s      disable multithreaded operation\n"
+            "    -i      immediate removal (don't delay until last release)\n"
             "    -h      print help\n"
             "\n"
             "Fusermount options:\n"
@@ -134,6 +135,10 @@ void fuse_main(int argc, char *argv[], const struct fuse_operations *op)
                     background = 0;
                     break;
                     
+                case 'i':
+                    flags |= FUSE_HARD_REMOVE;
+                    break;
+
                 case 'f':
                     background = 0;
                     break;