diff options
| author | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-10-31 13:39:19 +0000 |
|---|---|---|
| committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-10-31 13:39:19 +0000 |
| commit | 671d15ef2ac4627e10c00afa1bfe43a5da196e5d (patch) | |
| tree | 4913a6045b220629ada65dbb52134d9039d6bc9a /usr.sbin | |
| parent | fba6dd7f1811232d2d0fd8d37329a2a34397e105 (diff) | |
Notes
Diffstat (limited to 'usr.sbin')
| -rw-r--r-- | usr.sbin/mtree/compare.c | 15 | ||||
| -rw-r--r-- | usr.sbin/mtree/mtree.8 | 5 | ||||
| -rw-r--r-- | usr.sbin/mtree/test/test02.sh | 36 |
3 files changed, 53 insertions, 3 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 8fad8a488953..fbe9775d6ae2 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -184,8 +184,21 @@ typeerr: LABEL; LABEL; (void)printf("%smodification time expected %.24s ", tab, ctime(&s->st_mtimespec.tv_sec)); - (void)printf("found %.24s\n", + (void)printf("found %.24s", ctime(&p->fts_statp->st_mtimespec.tv_sec)); + if (uflag) { + struct timeval tv[2]; + tv[0].tv_sec = s->st_mtimespec.tv_sec; + tv[0].tv_usec = s->st_mtimespec.tv_nsec / 1000; + tv[1] = tv[0]; + if (utimes(p->fts_accpath, tv)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else + (void)printf("\n"); + tab = "\t"; } if (s->flags & F_CKSUM) { diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8 index c90cf2c8ffaa..e083b2c28431 100644 --- a/usr.sbin/mtree/mtree.8 +++ b/usr.sbin/mtree/mtree.8 @@ -76,8 +76,9 @@ Follow all symbolic links in the file hierarchy. Don't follow symbolic links in the file hierarchy, instead consider the symbolic link itself in any comparisons. This is the default. .It Fl U -Modify the owner, group and permissions of existing files to match -the specification and create any missing directories or symbolic links. +Modify the owner, group, permissions, and modification time of existing +files to match the specification and create any missing directories or +symbolic links. User, group and permissions must all be specified for missing directories to be created. Corrected mismatches are not considered errors. diff --git a/usr.sbin/mtree/test/test02.sh b/usr.sbin/mtree/test/test02.sh new file mode 100644 index 000000000000..a7aa9168382c --- /dev/null +++ b/usr.sbin/mtree/test/test02.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Copyright (c) 2003 Dan Nelson +# All rights reserved. +# +# Please see src/share/examples/etc/bsd-style-copyright. +# +# $FreeBSD$ +# + +set -e + +TMP=/tmp/mtree.$$ + +rm -rf ${TMP} +mkdir -p ${TMP} ${TMP}/mr ${TMP}/mt + +touch -t 199901020304 ${TMP}/mr/oldfile +touch ${TMP}/mt/oldfile + +mtree -c -p ${TMP}/mr > ${TMP}/_ + +mtree -U -r -p ${TMP}/mt < ${TMP}/_ > /dev/null + +x=x`(cd ${TMP}/mr ; ls -l 2>&1) || true` +y=x`(cd ${TMP}/mt ; ls -l 2>&1) || true` + +if [ "$x" != "$y" ] ; then + echo "ERROR Update of mtime failed" 1>&2 + rm -rf ${TMP} + exit 1 +fi + +rm -rf ${TMP} +exit 0 + |
