summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2022-08-08 16:56:11 +0000
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2022-08-08 16:56:11 +0000
commite55b6a5aff9788b1606a56c3666ecdc87f1712c3 (patch)
treedfa286b14f2ad8b28af5cd0badcf9f1acc121479 /rc
parent6d99af6f3455ebc1df29b13f8b1fe7f3338dc074 (diff)
Rewrite history: 9front was first
History was built using a heuristic where a file not present in the dump in 30 days was considered as a deleted file, without being important if those days had an actual dump. Having the file server off 30 days made all the files to be deleted from the history point of view. This new version is rewriten from scratch in rc and it does not try to detect deleted files since it can be derived only with fragile assumptions.
Diffstat (limited to 'rc')
-rw-r--r--rc/bin/history73
1 files changed, 73 insertions, 0 deletions
diff --git a/rc/bin/history b/rc/bin/history
new file mode 100644
index 000000000..e816035ae
--- /dev/null
+++ b/rc/bin/history
@@ -0,0 +1,73 @@
+#!/bin/rc
+rfork e
+
+nl='
+'
+
+fn prfile {
+ echo -n `{date $flagu -f 'MMM DD hh:mm:ss ZZZ YYYY' `{walk -e m $1}}
+ walk -e psM $1 | awk '{printf " %s %lld [%s]\n", $1,$2,$3,$4}'
+}
+
+fn diffflags {
+ t=()
+ for(f in a b c e m n w) {
+ flagname=flag$f
+ if(~ $$flagname 1)
+ t=(-$f $t)
+ }
+ echo $t
+}
+
+fn ysearch {
+ if(~ $1 /*)
+ file=$1
+ if not
+ file=`{pwd}^/$1
+
+ if(test -f $file)
+ prfile $file
+ if not
+ echo history: warning: $file does not exist >[1=2]
+
+ old=()
+ ls -qr /n/$dump/*/*/$file >[2] /dev/null |
+ sed 's/\(([^ ]*) *([^ ]*) *([^ ]*)\)/\1\2\3/p' |
+ awk '"/n/'$dump/$since'" <= $2 {next}
+ $1 != qid {
+ qid=$1
+ gsub($1, "")
+ print}' |
+ while(new=`$nl{read}){
+ prfile $new
+ if (~ $flagD 1 && ~ $#old 1)
+ diff `{diffflags} $new $old
+ old=$new
+ }
+}
+
+flagfmt='D,a,b,f,c,e,m,n,w,u,d:dump,s since'
+args='[ -Dabcemnw ] [ -uf ] [ -d dumpfilesystem ] [ -s yyyymmdd ] files ...'
+if(! ifs=() eval `{aux/getflags $*} ||
+ ~ $#* 0 ||
+ ! ~ $#dump 0 && ! ~ $#dump 1 ||
+ ! ~ $#flags 0 && ! ~ $#flags 1) {
+ aux/usage
+ exit usage
+}
+
+if(~ $#dump 0)
+ dump=dump
+
+if(~ $#flags 0)
+ flags=`{date -f 'YYYYMMDD'}
+
+if(~ $#flagu 1)
+ flagu=-u
+
+since=`{date -f 'YYYY\/MMDD' `{seconds -f 'YYYYMMDD' $flags}}
+
+9fs $dump
+
+for(arg in $*)
+ ysearch $arg