On 12/23 08:36, Jeremy Evans wrote:
> On 11/22 11:15, Jeremy Evans wrote:
> > On 10/19 09:34, Jeremy Evans wrote:
> > > Currently, when creating an archive file with pax(1), pax will attempt
> > > to open a file even if the file will be skipped due to an -s
> > > replacement with the empty string. With this change, pax will not
> > > attempt to open files that it knows will be skipped.
> > >
> > > When doing direct copies to a directory (-rw), pax already skips
> > > the file before attempting to open it. So this makes the behavior
> > > more consistent.
> > >
> > > My main reason for this change is to be able to silence the following
> > > warning when backing up:
> > >
> > > pax: Unable to open /etc/spwd.db to read: Operation not permitted
> > >
> > > One other possible benefit is if you are skipping a lot of files,
> > > avoiding the open syscall for each file may make pax faster.
> > >
> > > OKs?
> >
> > Ping. I still think this is worth doing. I've tested and it is also
> > measurably faster (25%) if you are excluding a lot of files:
> >
> > $ doas time obj/pax -f /dev/null -w -x cpio -s '/^.*$//' /some-path
> > 2.65 real 1.95 user 0.73 sys
> > $ doas time pax -f /dev/null -w -x cpio -s '/^.*$//' /some-path
> > 3.34 real 2.04 user 1.30 sys
> >
> > OKs?
Still looking for a review/OK for this. Resending as there was a
recent commit to pax during g2k23.
Thanks,
Jeremy
Index: ar_subs.c
===================================================================
RCS file: /cvs/src/bin/pax/ar_subs.c,v
retrieving revision 1.50
diff -u -p -r1.50 ar_subs.c
--- ar_subs.c 24 Oct 2021 21:24:21 -0000 1.50
+++ ar_subs.c 7 Jul 2023 00:33:18 -0000
@@ -441,6 +441,23 @@ wr_archive(ARCHD *arcn, int is_app)
if (hlk && (chk_lnk(arcn) < 0))
break;
+ /*
+ * Modify the name as requested by the user
+ */
+ if ((res = mod_name(arcn)) < 0) {
+ /*
+ * pax finished, purge link table entry and stop
+ */
+ purg_lnk(arcn);
+ break;
+ } else if (res > 0) {
+ /*
+ * skipping file, purge link table entry
+ */
+ purg_lnk(arcn);
+ continue;
+ }
+
if (PAX_IS_REG(arcn->type) || (arcn->type == PAX_HRG)) {
/*
* we will have to read this file. by opening it now we
@@ -456,20 +473,7 @@ wr_archive(ARCHD *arcn, int is_app)
}
}
- /*
- * Now modify the name as requested by the user
- */
- if ((res = mod_name(arcn)) < 0) {
- /*
- * name modification says to skip this file, close the
- * file and purge link table entry
- */
- rdfile_close(arcn, &fd);
- purg_lnk(arcn);
- break;
- }
-
- if ((res > 0) || (docrc && (set_crc(arcn, fd) < 0))) {
+ if (docrc && (set_crc(arcn, fd) < 0)) {
/*
* unable to obtain the crc we need, close the file,
* purge link table entry