shithub: plan9front

Download patch

ref: 1af2546e96fa96ec5341026dd509c9e4ed54c6db
parent: 3858b49942afb68d29e1ad02e6210bc5aba84c6e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun May 30 08:30:50 EDT 2021

vac: add -t flag to exclude temporary files and directories (thanks foura)

--- a/sys/man/1/vac	Sun May 30 08:26:28 2021
+++ b/sys/man/1/vac	Sun May 30 08:30:50 2021
@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B vac
 [
-.B -mqsv
+.B -mqstv
 ] [
 .B -a
 .I vacfile
@@ -165,6 +165,9 @@
 .TP
 .B -s
 Print out various statistics on standard error.
+.TP
+.B -t
+Exclude files and directories with the temporary flag set.
 .TP
 .B -v
 Produce more verbose output on standard error, including the name of the files added to the archive
--- a/sys/src/cmd/vac/vac.c	Sun May 30 08:26:28 2021
+++ b/sys/src/cmd/vac/vac.c	Sun May 30 08:30:50 2021
@@ -8,7 +8,7 @@
 void
 usage(void)
 {
-	fprint(2, "vac [-imqsv] [-a archive.vac] [-b bsize] [-d old.vac] [-e exclude] [-f new.vac] [-i name] [-h host] [-x excludefile] file...\n");
+	fprint(2, "vac [-imqstv] [-a archive.vac] [-b bsize] [-d old.vac] [-e exclude] [-f new.vac] [-i name] [-h host] [-x excludefile] file...\n");
 	threadexitsall("usage");
 }
 
@@ -29,6 +29,7 @@
 int qdiff;
 int merge;
 int verbose;
+int notmp;
 char *host;
 VtConn *z;
 VacFs *fs;
@@ -109,6 +110,9 @@
 	case 's':
 		printstats++;
 		break;
+	case 't':
+		notmp++;
+		break;
 	case 'v':
 		verbose++;
 		break;
@@ -422,7 +426,7 @@
 	VacFile *f, *fdiff;
 	VtEntry e;
 
-	if(!includefile(name)){
+	if(!includefile(name) || (notmp && (d->qid.type&QTTMP))) {
 		warn("excluding %s%s", name, (d->mode&DMDIR) ? "/" : "");
 		return;
 	}