Browse Source

Plan 9 from Bell Labs 2004-01-03

David du Colombier 18 years ago
parent
commit
a83297add6
4 changed files with 37 additions and 17 deletions
  1. 1 1
      dist/replica/plan9.db
  2. 1 0
      dist/replica/plan9.log
  3. 34 16
      sys/src/cmd/history.c
  4. 1 0
      sys/src/mkfile

+ 1 - 1
dist/replica/plan9.db

@@ -12312,7 +12312,7 @@ sys/src/libventi/session.h - 664 sys sys 1063853749 936
 sys/src/libventi/strdup.c - 664 sys sys 1045502096 203
 sys/src/libventi/venti.txt - 664 sys sys 1045502097 4347
 sys/src/libventi/zero.c - 664 sys sys 1045502097 1509
-sys/src/mkfile - 664 sys sys 1045589241 992
+sys/src/mkfile - 664 sys sys 1073061130 1006
 sys/src/mkfile.proto - 664 sys sys 1045502130 269
 tmp - 20000000555 sys sys 953999902 0
 usr - 20000000775 sys sys 953406542 0

+ 1 - 0
dist/replica/plan9.log

@@ -13269,3 +13269,4 @@
 1073008876 0 a sys/src/cmd/usb/print - 20000000775 sys sys 1073007760 0
 1073008876 1 a sys/src/cmd/usb/print/mkfile - 664 sys sys 1073007760 197
 1073008876 2 a sys/src/cmd/usb/print/usbprint - 775 sys sys 1073007760 222
+1073061099 0 c sys/src/mkfile - 664 sys sys 1073061130 1006

+ 34 - 16
sys/src/cmd/history.c

@@ -198,6 +198,7 @@ lastbefore(ulong t, char *f, char *b, char *ndump)
 	Dir *dir;
 	int vers, try;
 	ulong t0, mtime;
+	int i, n, fd;
 
 	t0 = t;
 	if(verb)
@@ -218,24 +219,41 @@ lastbefore(ulong t, char *f, char *b, char *ndump)
 			t -= HOUR(24);
 			continue;
 		}
-		for(vers=0;; vers++) {
-			sprint(b, "/n/%s/%.4d/%.2d%.2d%d", ndump,
-				tm->year+1900, tm->mon+1, tm->mday, vers+1);
-			dir = dirstat(b);
-			if(dir){
-				mtime = dir->mtime;
-				free(dir);
+		if(strstr(ndump, "snap")){
+			fd = open(b, OREAD);
+			if(fd < 0)
+				continue;
+			n = dirreadall(fd, &dir);
+			close(fd);
+			if(n == 0)
+				continue;
+			for(i = n-1; i > 0; i--){
+				if(dir[i].mtime > t0)
+					break;
 			}
-			if(dir==nil || mtime > t0)
-				break;
-			if(verb)
-				print("%ld later %s\n", mtime, b);
+			sprint(b, "/n/%s/%.4d/%.2d%.2d/%s%s", ndump,
+				tm->year+1900, tm->mon+1, tm->mday, dir[i].name, f);
+			free(dir);
+		} else {
+			for(vers=0;; vers++) {
+				sprint(b, "/n/%s/%.4d/%.2d%.2d%d", ndump,
+					tm->year+1900, tm->mon+1, tm->mday, vers+1);
+				dir = dirstat(b);
+				if(dir){
+					mtime = dir->mtime;
+					free(dir);
+				}
+				if(dir==nil || mtime > t0)
+					break;
+				if(verb)
+					print("%ld later %s\n", mtime, b);
+			}
+			sprint(b, "/n/%s/%.4d/%.2d%.2d%s", ndump,
+				tm->year+1900, tm->mon+1, tm->mday, f);
+			if(vers)
+				sprint(b, "/n/%s/%.4d/%.2d%.2d%d%s", ndump,
+					tm->year+1900, tm->mon+1, tm->mday, vers, f);
 		}
-		sprint(b, "/n/%s/%.4d/%.2d%.2d%s", ndump,
-			tm->year+1900, tm->mon+1, tm->mday, f);
-		if(vers)
-			sprint(b, "/n/%s/%.4d/%.2d%.2d%d%s", ndump,
-				tm->year+1900, tm->mon+1, tm->mday, vers, f);
 		return;
 	}
 	strcpy(b, "XXX");	/* error */

+ 1 - 0
sys/src/mkfile

@@ -8,6 +8,7 @@ LIBS=\
 	libbin\
 	libbio\
 	libc\
+	libcomplete\
 	libcontrol\
 	libdisk\
 	libdraw\