diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2008-05-06 06:54:29 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2008-05-06 06:54:29 +0000 |
commit | b04779acb0d7f4ae3a8dd44489f89e833a660684 (patch) | |
tree | 5b8897aca7639a405448665b1fea95262d6e6baf /bin/pax | |
parent | e9407bb95e8d4e9ba1b04233edf249b562699db3 (diff) |
when pax is running in -u mode, and no files are beeing updated because
not one changed, we should not exit with an error but zero to indicate
success (matches solaris behaviour).
need to track wether files were skipped because of the -u checks for that
and take that into account later when taking the exit code decision.
ok theo, comments from otto and miod
Diffstat (limited to 'bin/pax')
-rw-r--r-- | bin/pax/ar_subs.c | 9 | ||||
-rw-r--r-- | bin/pax/extern.h | 3 | ||||
-rw-r--r-- | bin/pax/ftree.c | 20 | ||||
-rw-r--r-- | bin/pax/ftree.h | 3 |
4 files changed, 27 insertions, 8 deletions
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index 3561dcd49c9..73aefdabb48 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar_subs.c,v 1.31 2006/11/17 08:38:04 otto Exp $ */ +/* $OpenBSD: ar_subs.c,v 1.32 2008/05/06 06:54:28 henning Exp $ */ /* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.31 2006/11/17 08:38:04 otto Exp $"; +static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.32 2008/05/06 06:54:28 henning Exp $"; #endif #endif /* not lint */ @@ -441,8 +441,10 @@ wr_archive(ARCHD *arcn, int is_app) */ if ((res = chk_ftime(arcn)) < 0) break; - if (res > 0) + if (res > 0) { + ftree_skipped_newer(arcn); continue; + } } /* @@ -853,6 +855,7 @@ copy(void) *dest_pt = '\0'; if (res == 0) { + ftree_skipped_newer(arcn); if (uflag && Dflag) { if ((arcn->sb.st_mtime<=sb.st_mtime) && (arcn->sb.st_ctime<=sb.st_ctime)) diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 77aad215203..acdfafca2d2 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.32 2006/11/17 08:38:04 otto Exp $ */ +/* $OpenBSD: extern.h,v 1.33 2008/05/06 06:54:28 henning Exp $ */ /* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */ /*- @@ -162,6 +162,7 @@ int set_crc(ARCHD *, int); int ftree_start(void); int ftree_add(char *, int); void ftree_sel(ARCHD *); +void ftree_skipped_newer(ARCHD *); void ftree_chk(void); int next_file(ARCHD *); diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index d32f134b6af..1ca2a7a1d63 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftree.c,v 1.27 2006/12/26 20:58:25 otto Exp $ */ +/* $OpenBSD: ftree.c,v 1.28 2008/05/06 06:54:28 henning Exp $ */ /* $NetBSD: ftree.c,v 1.4 1995/03/21 09:07:21 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: ftree.c,v 1.27 2006/12/26 20:58:25 otto Exp $"; +static const char rcsid[] = "$OpenBSD: ftree.c,v 1.28 2008/05/06 06:54:28 henning Exp $"; #endif #endif /* not lint */ @@ -170,6 +170,7 @@ ftree_add(char *str, int chflg) str[len] = '\0'; ft->fname = str; ft->refcnt = 0; + ft->newercnt = 0; ft->chflg = chflg; ft->fow = NULL; if (fthead == NULL) { @@ -215,6 +216,19 @@ ftree_sel(ARCHD *arcn) } /* + * ftree_skipped_newer() + * file has been skipped because a newer file exists and -u/-D given + */ + +void +ftree_skipped_newer(ARCHD *arcn) +{ + /* skipped due to -u/-D, mark accordingly */ + if (ftcur != NULL) + ftcur->newercnt = 1; +} + +/* * ftree_chk() * called at end on pax execution. Prints all those file args that did not * have a selected member (reference count still 0) @@ -237,7 +251,7 @@ ftree_chk(void) * that never had a match */ for (ft = fthead; ft != NULL; ft = ft->fow) { - if ((ft->refcnt > 0) || ft->chflg) + if ((ft->refcnt > 0) || ft->newercnt > 0 || ft->chflg) continue; if (wban == 0) { paxwarn(1,"WARNING! These file names were not selected:"); diff --git a/bin/pax/ftree.h b/bin/pax/ftree.h index 0507aab1873..9b4cffcc78f 100644 --- a/bin/pax/ftree.h +++ b/bin/pax/ftree.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ftree.h,v 1.4 2003/06/02 23:32:08 millert Exp $ */ +/* $OpenBSD: ftree.h,v 1.5 2008/05/06 06:54:28 henning Exp $ */ /* $NetBSD: ftree.h,v 1.3 1995/03/21 09:07:23 cgd Exp $ */ /*- @@ -45,6 +45,7 @@ typedef struct ftree { char *fname; /* file tree name */ int refcnt; /* has tree had a selected file? */ + int newercnt; /* skipped due to -u/-D */ int chflg; /* change directory flag */ struct ftree *fow; /* pointer to next entry on list */ } FTREE; |