aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/buff.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2017-10-10 13:49:37 -0400
committerRuss Cox <rsc@swtch.com>2017-10-10 13:51:24 -0400
commit67dbeee5fe9e2a855384048615bafe100e876f4c (patch)
treef5e2960b2bf7abcc774678b65f947aac792c7fd0 /src/cmd/acme/buff.c
parent680c57a15c51c302d89aec134e25f08820d3f30d (diff)
downloadplan9port-67dbeee5fe9e2a855384048615bafe100e876f4c.tar.gz
plan9port-67dbeee5fe9e2a855384048615bafe100e876f4c.tar.bz2
plan9port-67dbeee5fe9e2a855384048615bafe100e876f4c.zip
acme: check file content before declaring file "modified since last read"
Bad remote file systems can change mtime unexpectedly, and then there is the problem that git rebase and similar operations like to change the files and then change them back, modifying the mtimes but not the content. Avoid spurious Put errors on both of those by checking file content. (False positive "modified since last read" make the real ones difficult to notice.)
Diffstat (limited to 'src/cmd/acme/buff.c')
-rw-r--r--src/cmd/acme/buff.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cmd/acme/buff.c b/src/cmd/acme/buff.c
index 875bb0b0..bb938ca4 100644
--- a/src/cmd/acme/buff.c
+++ b/src/cmd/acme/buff.c
@@ -8,6 +8,7 @@
#include <frame.h>
#include <fcall.h>
#include <plumb.h>
+#include <libsec.h>
#include "dat.h"
#include "fns.h"
@@ -231,7 +232,7 @@ bufloader(void *v, uint q0, Rune *r, int nr)
}
uint
-loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *arg)
+loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *arg, DigestState *h)
{
char *p;
Rune *r;
@@ -253,6 +254,8 @@ loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *ar
warning(nil, "read error in Buffer.load");
break;
}
+ if(h != nil)
+ sha1((uchar*)p+m, n, nil, h);
m += n;
p[m] = 0;
l = m;
@@ -269,11 +272,11 @@ loadfile(int fd, uint q0, int *nulls, int(*f)(void*, uint, Rune*, int), void *ar
}
uint
-bufload(Buffer *b, uint q0, int fd, int *nulls)
+bufload(Buffer *b, uint q0, int fd, int *nulls, DigestState *h)
{
if(q0 > b->nc)
error("internal error: bufload");
- return loadfile(fd, q0, nulls, bufloader, b);
+ return loadfile(fd, q0, nulls, bufloader, b, h);
}
void