Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/pax When writing (-w) or copying (-rw), and using -M (st...



details:   https://anonhg.NetBSD.org/src/rev/423e13b62e62
branches:  trunk
changeset: 543260:423e13b62e62
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Feb 21 01:25:11 2003 +0000

description:
When writing (-w) or copying (-rw), and using -M (stdin file list is
mtree(8) specfile), compare the "post write/copy" mtime against the
actual "pre write/copy" mtime instead of the mtime from the specfile.

This prevents warnings such as:
        pax: File ./foo was modified during copy to archive
if the file's mtime in the file system is different to what's in the specfile.
(The resultant file will still get the specfile mtime ...)

diffstat:

 bin/pax/buf_subs.c |  30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diffs (79 lines):

diff -r 5771bf542e80 -r 423e13b62e62 bin/pax/buf_subs.c
--- a/bin/pax/buf_subs.c        Fri Feb 21 01:12:56 2003 +0000
+++ b/bin/pax/buf_subs.c        Fri Feb 21 01:25:11 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf_subs.c,v 1.19 2003/02/09 18:27:10 grant Exp $      */
+/*     $NetBSD: buf_subs.c,v 1.20 2003/02/21 01:25:11 lukem Exp $      */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: buf_subs.c,v 1.19 2003/02/09 18:27:10 grant Exp $");
+__RCSID("$NetBSD: buf_subs.c,v 1.20 2003/02/21 01:25:11 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -615,7 +615,16 @@
        int cnt;
        int res = 0;
        off_t size = arcn->sb.st_size;
-       struct stat sb;
+       struct stat origsb, sb;
+
+       /*
+        * by default, remember the previously obtained stat information
+        * (in arcn->sb) for comparing the mtime after reading.
+        * if Mflag is set, use the actual mtime instead.
+        */
+       origsb = arcn->sb;
+       if (Mflag && (fstat(ifd, &origsb) < 0))
+               syswarn(1, errno, "Failed stat on %s", arcn->org_name);
 
        /*
         * while there are more bytes to write
@@ -643,7 +652,7 @@
                tty_warn(1, "File changed size during read %s", arcn->org_name);
        else if (fstat(ifd, &sb) < 0)
                syswarn(1, errno, "Failed stat on %s", arcn->org_name);
-       else if (arcn->sb.st_mtime != sb.st_mtime)
+       else if (origsb.st_mtime != sb.st_mtime)
                tty_warn(1, "File %s was modified during copy to archive",
                        arcn->org_name);
        *left = size;
@@ -773,7 +782,7 @@
        int isem = 1;
        int rem;
        int sz = MINFBSZ;
-       struct stat sb;
+       struct stat sb, origsb;
 
        /*
         * check for holes in the source file. If none, we will use regular
@@ -783,6 +792,15 @@
                ++no_hole;
 
        /*
+        * by default, remember the previously obtained stat information
+        * (in arcn->sb) for comparing the mtime after reading.
+        * if Mflag is set, use the actual mtime instead.
+        */
+       origsb = arcn->sb;
+       if (Mflag && (fstat(fd1, &origsb) < 0))
+               syswarn(1, errno, "Failed stat on %s", arcn->org_name);
+
+       /*
         * pass the blocksize of the file being written to the write routine,
         * if the size is zero, use the default MINFBSZ
         */
@@ -820,7 +838,7 @@
                        arcn->org_name, arcn->name);
        else if (fstat(fd1, &sb) < 0)
                syswarn(1, errno, "Failed stat of %s", arcn->org_name);
-       else if (arcn->sb.st_mtime != sb.st_mtime)
+       else if (origsb.st_mtime != sb.st_mtime)
                tty_warn(1, "File %s was modified during copy to %s",
                        arcn->org_name, arcn->name);
 



Home | Main Index | Thread Index | Old Index