shithub: riscv

Download patch

ref: b19280009679f31bd3cf05a9a7df95ef121cef0b
parent: df6a30f3c0e2be41161101db0d62f5c02d93bbc0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Feb 14 15:35:36 EST 2018

ftpfs: no caching by default, add -c flag to enable it (patch by mycroftiv)

--- a/sys/man/4/ftpfs
+++ b/sys/man/4/ftpfs
@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B ftpfs
 [
-.B -/dqnt
+.B -/dqntc
 ]
 [
 .B -m
@@ -90,6 +90,10 @@
 To see all messages from the server use option
 .BR -d .
 .PP
+By default ftpfs only caches while a file operation is in progress. The
+.BR -c
+flag enables caching, increasing performance but allowing outdated file and directory data to persist.
+.PP
 Some systems will hangup an ftp connection that has no activity
 for a given period.  The
 .BR -K
@@ -183,13 +187,8 @@
 However, walking to any valid directory on that machine will succeed
 and cause that directory entry to appear under the mount point.
 .PP
-.I Ftpfs
-caches files and directories.  A directory will fall from the cache
-after 5 quiescent minutes or if the local user changes the
-directory by writing or removing a file.
-Otherwise, remote
-changes to the directory that occur after the directory has
-been cached might not be immediately visible.
+If caching is active, remote
+changes that have been cached will not be visible.
 Attempting to walk to
 .IB directory /.flush.ftpfs
 will flush
--- a/sys/src/cmd/ip/ftpfs/ftpfs.c
+++ b/sys/src/cmd/ip/ftpfs/ftpfs.c
@@ -85,6 +85,7 @@
 
 char *nosuchfile = "file does not exist";
 char *keyspec = "";
+int docache = 0;
 
 void
 usage(void)
@@ -149,6 +150,9 @@
 	case 'q':
 		quiet = 1;
 		break;
+	case 'c':
+		docache = 1;
+		break;
 	} ARGEND
 	if(argc != 1)
 		usage();
@@ -582,6 +586,8 @@
 		f->node->opens--;
 	}
 	f->busy = 0;
+	if(!docache && ISCACHED(f->node))
+		uncache(f->node);
 	return 0;
 }