summaryrefslogtreecommitdiff
path: root/archivers/pax
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2008-02-07 22:27:53 +0000
committerjoerg <joerg@pkgsrc.org>2008-02-07 22:27:53 +0000
commit70ffcd5e5e77d283fa835cbc2dba810b49d88f2a (patch)
treeb4c000285ca73a7d9ccec5f89418b28d69bea0e1 /archivers/pax
parentc25680feca36ae13ba72596a1e5c5e358b884843 (diff)
downloadpkgsrc-70ffcd5e5e77d283fa835cbc2dba810b49d88f2a.tar.gz
Merge a fix from NetBSD's src/bin/pax by tls:
Teach set_ftime about symbolic links, because it has to know: on some Linux systems, when we build as a tool we think we have lutimes but it doesn't work on some filesystems at runtime. A bit ugly but effective and without use of AC_TRY_RUN in the tool build. Tidier (than mine) set_ftime reorganization from christos. Bump version to 20080110.
Diffstat (limited to 'archivers/pax')
-rw-r--r--archivers/pax/Makefile3
-rw-r--r--archivers/pax/Makefile.common4
-rw-r--r--archivers/pax/files/extern.h4
-rw-r--r--archivers/pax/files/file_subs.c39
-rw-r--r--archivers/pax/files/ftree.c8
-rw-r--r--archivers/pax/files/tables.c10
6 files changed, 38 insertions, 30 deletions
diff --git a/archivers/pax/Makefile b/archivers/pax/Makefile
index 2d8dc8e40a7..10aebd8dfda 100644
--- a/archivers/pax/Makefile
+++ b/archivers/pax/Makefile
@@ -1,11 +1,10 @@
-# $NetBSD: Makefile,v 1.33 2007/11/11 16:51:27 joerg Exp $
+# $NetBSD: Makefile,v 1.34 2008/02/07 22:27:53 joerg Exp $
USE_FEATURES= nbcompat
.include "Makefile.common"
CATEGORIES= archivers
-PKGREVISION= 3
# pax installs "tar" and "cpio"
.if defined(GNU_PROGRAM_PREFIX) && ${GNU_PROGRAM_PREFIX} == ""
diff --git a/archivers/pax/Makefile.common b/archivers/pax/Makefile.common
index 3d68ec85c8e..a2d44d79b63 100644
--- a/archivers/pax/Makefile.common
+++ b/archivers/pax/Makefile.common
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.common,v 1.3 2006/07/14 20:11:10 jlam Exp $
+# $NetBSD: Makefile.common,v 1.4 2008/02/07 22:27:53 joerg Exp $
#
# This Makefile fragment is included by:
#
@@ -6,7 +6,7 @@
# pkgsrc/pkgtools/pax/Makefile
#
-DISTNAME= pax-20060202
+DISTNAME= pax-20080110
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/archivers/pax/files/extern.h b/archivers/pax/files/extern.h
index c6f44633fb8..68ccf228ecc 100644
--- a/archivers/pax/files/extern.h
+++ b/archivers/pax/files/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.6 2005/12/01 03:00:01 minskim Exp $ */
+/* $NetBSD: extern.h,v 1.7 2008/02/07 22:27:53 joerg Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -165,7 +165,7 @@ int chk_same(ARCHD *);
int node_creat(ARCHD *);
int unlnk_exist(char *, int);
int chk_path(char *, uid_t, gid_t);
-void set_ftime(char *fnm, time_t mtime, time_t atime, int frc);
+void set_ftime(char *fnm, time_t mtime, time_t atime, int frc, int slk);
int set_ids(char *, uid_t, gid_t);
void set_pmode(char *, mode_t);
void set_chflags(char *fnm, u_int32_t flags);
diff --git a/archivers/pax/files/file_subs.c b/archivers/pax/files/file_subs.c
index 7975c2809e1..dd254d91a75 100644
--- a/archivers/pax/files/file_subs.c
+++ b/archivers/pax/files/file_subs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: file_subs.c,v 1.12 2007/03/08 17:18:18 rillig Exp $ */
+/* $NetBSD: file_subs.c,v 1.13 2008/02/07 22:27:53 joerg Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -48,7 +48,7 @@
#if 0
static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: file_subs.c,v 1.12 2007/03/08 17:18:18 rillig Exp $");
+__RCSID("$NetBSD: file_subs.c,v 1.13 2008/02/07 22:27:53 joerg Exp $");
#endif
#endif /* not lint */
@@ -238,7 +238,8 @@ file_close(ARCHD *arcn, int fd)
else
set_pmode(tmp_name, arcn->sb.st_mode & FILEBITS(0));
if (patime || pmtime)
- set_ftime(tmp_name, arcn->sb.st_mtime, arcn->sb.st_atime, 0);
+ set_ftime(tmp_name, arcn->sb.st_mtime,
+ arcn->sb.st_atime, 0, 0);
/* Did we write directly to the target file? */
if (arcn->tmp_name == NULL)
@@ -625,12 +626,9 @@ badlink:
add_dir(nm, arcn->nlen, &(arcn->sb), 0);
}
-#if HAVE_LUTIMES
if (patime || pmtime)
-#else
- if ((patime || pmtime) && arcn->type != PAX_SLK)
-#endif
- set_ftime(arcn->name, arcn->sb.st_mtime, arcn->sb.st_atime, 0);
+ set_ftime(arcn->name, arcn->sb.st_mtime,
+ arcn->sb.st_atime, 0, (arcn->type == PAX_SLK) ? 1 : 0);
#if HAVE_FILE_FLAGS
if (pfflags && arcn->type != PAX_SLK)
@@ -799,10 +797,16 @@ chk_path(char *name, uid_t st_uid, gid_t st_gid)
* other ones are left alone. We do not assume the un-documented feature
* of many utimes() implementations that consider a 0 time value as a do
* not set request.
+ *
+ * Unfortunately, there are systems where lutimes() is present but does
+ * not work on some filesystem types, which cannot be detected at
+ * compile time. This requires passing down symlink knowledge into
+ * this function to obtain correct operation. Linux with XFS is one
+ * example of such a system.
*/
void
-set_ftime(char *fnm, time_t mtime, time_t atime, int frc)
+set_ftime(char *fnm, time_t mtime, time_t atime, int frc, int slk)
{
struct timeval tv[2];
struct stat sb;
@@ -836,13 +840,18 @@ set_ftime(char *fnm, time_t mtime, time_t atime, int frc)
* set the times
*/
#if HAVE_LUTIMES
- if (lutimes(fnm, tv))
-#else
- if (utimes(fnm, tv))
+ if (lutimes(fnm, tv) == 0)
+ return;
+ if (errno != ENOSYS) /* XXX linux: lutimes is per-FS */
+ goto bad;
#endif
- syswarn(1, errno, "Access/modification time set failed on: %s",
- fnm);
+ if (slk)
+ return;
+ if (utimes(fnm, tv) == -1)
+ goto bad;
return;
+bad:
+ syswarn(1, errno, "Access/modification time set failed on: %s", fnm);
}
/*
@@ -1100,7 +1109,7 @@ rdfile_close(ARCHD *arcn, int *fd)
/*
* user wants last access time reset
*/
- set_ftime(arcn->org_name, arcn->sb.st_mtime, arcn->sb.st_atime, 1);
+ set_ftime(arcn->org_name, arcn->sb.st_mtime, arcn->sb.st_atime, 1, 0);
return;
}
diff --git a/archivers/pax/files/ftree.c b/archivers/pax/files/ftree.c
index e23a144ca94..224cdffcaaf 100644
--- a/archivers/pax/files/ftree.c
+++ b/archivers/pax/files/ftree.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ftree.c,v 1.10 2007/03/08 17:18:18 rillig Exp $ */
+/* $NetBSD: ftree.c,v 1.11 2008/02/07 22:27:53 joerg Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -84,7 +84,7 @@
#if 0
static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
#else
-__RCSID("$NetBSD: ftree.c,v 1.10 2007/03/08 17:18:18 rillig Exp $");
+__RCSID("$NetBSD: ftree.c,v 1.11 2008/02/07 22:27:53 joerg Exp $");
#endif
#endif /* not lint */
@@ -577,7 +577,7 @@ next_file(ARCHD *arcn)
(get_atdir(MFTENT_DUMMY_DEV, ftnode->lineno,
&mtime, &atime) == 0)) {
set_ftime(ftent->fts_path,
- mtime, atime, 1);
+ mtime, atime, 1, 0);
}
ftnode = ftnode->parent;
if (ftnode->parent == ftnode)
@@ -655,7 +655,7 @@ next_file(ARCHD *arcn)
#endif
&mtime, &atime) < 0))
continue;
- set_ftime(ftent->fts_path, mtime, atime, 1);
+ set_ftime(ftent->fts_path, mtime, atime, 1, 0);
continue;
case FTS_DC:
/*
diff --git a/archivers/pax/files/tables.c b/archivers/pax/files/tables.c
index c117ce9cd7d..25cacc514b5 100644
--- a/archivers/pax/files/tables.c
+++ b/archivers/pax/files/tables.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tables.c,v 1.7 2007/03/08 17:18:18 rillig Exp $ */
+/* $NetBSD: tables.c,v 1.8 2008/02/07 22:27:53 joerg Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -48,7 +48,7 @@
#if 0
static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: tables.c,v 1.7 2007/03/08 17:18:18 rillig Exp $");
+__RCSID("$NetBSD: tables.c,v 1.8 2008/02/07 22:27:53 joerg Exp $");
#endif
#endif /* not lint */
@@ -982,7 +982,7 @@ atdir_end(void)
* not read by pax. Read time reset is controlled by -t.
*/
for (; pt != NULL; pt = pt->fow)
- set_ftime(pt->name, pt->mtime, pt->atime, 1);
+ set_ftime(pt->name, pt->mtime, pt->atime, 1, 0);
}
}
@@ -1280,7 +1280,7 @@ proc_dir(void)
if (pmode || dblk.frc_mode)
set_pmode(name, dblk.mode);
if (patime || pmtime)
- set_ftime(name, dblk.mtime, dblk.atime, 0);
+ set_ftime(name, dblk.mtime, dblk.atime, 0, 0);
if (pfflags)
set_chflags(name, dblk.fflags);
}
@@ -1304,7 +1304,7 @@ proc_dir(void)
if (pmode || dblk->frc_mode)
set_pmode(dblk->name, dblk->mode);
if (patime || pmtime)
- set_ftime(dblk->name, dblk->mtime, dblk->atime, 0);
+ set_ftime(dblk->name, dblk->mtime, dblk->atime, 0, 0);
if (pfflags)
set_chflags(dblk->name, dblk->fflags);