shithub: riscv

Download patch

ref: 8099d78f447fd77b215e2cc6a6bab2097a0d4d54
parent: b494f61baa98f9ebb17cae13257d056af995b9f3
author: cinap_lenrek <[email protected]>
date: Sat Jul 14 19:49:17 EDT 2012

cwfs: noatime flag

--- a/sys/src/cmd/cwfs/all.h
+++ b/sys/src/cmd/cwfs/all.h
@@ -84,6 +84,7 @@
 ulong	authdebugflag;
 int	noattach;		/* attach is disabled */
 int	noauth;			/* auth is disable */
+int	noatime;		/* atime is disabled */
 int	wstatallow;		/* set to circumvent wstat permissions */
 int	writeallow;		/* set to circumvent write permissions */
 int	duallow;		/* single user to allow du */
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -690,10 +690,17 @@
 cmd_noauth(int, char *[])
 {
 	noauth = !noauth;
-	print("authentication %s\n", noauth ? "disabled" : "enabled");
+	print("auth %s\n", noauth ? "disabled" : "enabled");
 }
 
 void
+cmd_noatime(int, char *[])
+{
+	noatime = !noatime;
+	print("atime %s\n", noatime ? "disabled" : "enabled");
+}
+
+void
 cmd_noattach(int, char *[])
 {
 	noattach = !noattach;
@@ -767,6 +774,7 @@
 	cmd_install("hangup", "chan -- clunk files", cmd_hangup);
 	cmd_install("printconf", "-- print configuration", cmd_printconf);
 	cmd_install("noauth", "toggle noauth flag", cmd_noauth);
+	cmd_install("noatime", "toggle noatime flag", cmd_noatime);
 	cmd_install("noattach", "toggle noattach flag", cmd_noattach);
 	cmd_install("files", "report on files structure", cmd_files);
 
--- a/sys/src/cmd/cwfs/config.c
+++ b/sys/src/cmd/cwfs/config.c
@@ -22,6 +22,7 @@
 static char *src, *dest;
 
 static int noauthset = 0;
+static int noatimeset = 0;
 static int readonlyset = 0;
 static int resetparams;
 
@@ -432,6 +433,8 @@
 
 	if(!noauthset)
 		noauth = 0;
+	if(!noatimeset)
+		noatime = 0;
 	if(!readonlyset)
 		readonly = 0;
 	for (cp = p->iobuf; *cp != '\0'; cp++) {
@@ -448,6 +451,9 @@
 		} else if(strcmp(word, "noauth") == 0){
 			if(!noauthset)
 				noauth = 1;
+		} else if(strcmp(word, "noatime") == 0){
+			if(!noatimeset)
+				noatime = 1;
 		} else if(strcmp(word, "readonly") == 0){
 			if(!readonlyset)
 				readonly = 1;
@@ -595,6 +601,8 @@
 					fs->conf);
 		if(noauth)
 			cp = seprint(cp, ep, "noauth\n");
+		if(noatime)
+			cp = seprint(cp, ep, "noatime\n");
 		if(readonly)
 			cp = seprint(cp, ep, "readonly\n");
 		if(conf.newcache)
@@ -605,7 +613,7 @@
 
 		putbuf(p);
 		f.modconf = f.newconf = 0;
-		noauthset = readonlyset = 0;
+		noauthset = noatimeset = readonlyset = 0;
 		goto start;
 	}
 	putbuf(p);
@@ -993,19 +1001,26 @@
 		}
 		if(strcmp(word, "noattach") == 0) {
 			noattach = !noattach;
-			print("attach is now %s\n", noattach ? "disallowed" : "allowed");
+			print("attach %s\n", noattach ? "disallowed" : "allowed");
 			continue;
 		}
 		if(strcmp(word, "noauth") == 0) {
 			noauth = !noauth;
-			print("auth is now %s\n", noauth ? "disabled" : "enabled");
+			print("auth %s\n", noauth ? "disabled" : "enabled");
 			noauthset++;
 			f.modconf = 1;
 			continue;
 		}
+		if(strcmp(word, "noatime") == 0) {
+			noatime = !noatime;
+			print("atime %s\n", noatime ? "disabled" : "enabled");
+			noatimeset++;
+			f.modconf = 1;
+			continue;
+		}
 		if(strcmp(word, "readonly") == 0) {
 			readonly = !readonly;
-			print("filesystem is now %s\n", readonly ? "readonly" : "writable");
+			print("filesystem %s\n", readonly ? "readonly" : "writable");
 			readonlyset++;
 			f.modconf = 1;
 			continue;
--- a/sys/src/cmd/cwfs/dentry.c
+++ b/sys/src/cmd/cwfs/dentry.c
@@ -13,16 +13,18 @@
 {
 	Timet t;
 
-	if(p && p->dev->type != Devro) {
-		p->flags |= Bmod;
-		t = time(nil);
-		if(f & (FREAD|FWRITE))
-			d->atime = t;
-		if(f & FWRITE) {
-			d->mtime = t;
-			d->muid = uid;
-			d->qid.version++;
-		}
+	if(p == nil || p->dev->type == Devro)
+		return;
+	f &= FREAD|FWRITE;
+	if(f != FWRITE && noatime)
+		return;
+	p->flags |= Bmod;
+	t = time(nil);
+	d->atime = t;
+	if(f & FWRITE){
+		d->mtime = t;
+		d->muid = uid;
+		d->qid.version++;
 	}
 }