cwfs: noatime flag

This commit is contained in:
cinap_lenrek 2012-07-14 23:49:17 +02:00
parent b494f61baa
commit 8099d78f44
4 changed files with 41 additions and 15 deletions

View file

@ -84,6 +84,7 @@ ulong chatflag;
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 */

View file

@ -690,7 +690,14 @@ void
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
@ -767,6 +774,7 @@ installcmds(void)
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);

View file

@ -22,6 +22,7 @@ static int copyworm = 0, copydev = 0;
static char *src, *dest;
static int noauthset = 0;
static int noatimeset = 0;
static int readonlyset = 0;
static int resetparams;
@ -432,6 +433,8 @@ mergeconf(Iobuf *p)
if(!noauthset)
noauth = 0;
if(!noatimeset)
noatime = 0;
if(!readonlyset)
readonly = 0;
for (cp = p->iobuf; *cp != '\0'; cp++) {
@ -448,6 +451,9 @@ mergeconf(Iobuf *p)
} 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 @@ start:
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 @@ start:
putbuf(p);
f.modconf = f.newconf = 0;
noauthset = readonlyset = 0;
noauthset = noatimeset = readonlyset = 0;
goto start;
}
putbuf(p);
@ -993,19 +1001,26 @@ arginit(void)
}
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;

View file

@ -13,16 +13,18 @@ accessdir(Iobuf *p, Dentry *d, int f, int uid)
{
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++;
}
}