Make mtree's update function update the modification time too.

Submitted by:	Dan Nelson <dnelson@allantgroup.com>
PR:	53063
This commit is contained in:
Poul-Henning Kamp 2003-10-31 13:39:19 +00:00
parent fba6dd7f18
commit 671d15ef2a
3 changed files with 53 additions and 3 deletions

View File

@ -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) {

View File

@ -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.

View File

@ -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