diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8 --- a/usr.sbin/makefs/makefs.8 +++ b/usr.sbin/makefs/makefs.8 @@ -259,9 +259,13 @@ .Pa pathname , where the timestamps are derived from that file, or an integer value interpreted as the number of seconds from the Epoch. -Note that timestamps specified in an +Timestamps in a .Xr mtree 5 -spec file, override the default timestamp. +specfile (specified with +.Fl F ) +are used even if a default timestamp is specified. +However, the timestamps in an mtree manifest are ignored +if a default timestamp is specified. .It Fl t Ar fs-type Create an .Ar fs-type diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c --- a/usr.sbin/makefs/mtree.c +++ b/usr.sbin/makefs/mtree.c @@ -633,6 +633,9 @@ } /* Ignore. */ } else if (strcmp(keyword, "time") == 0) { + /* Ignore if a default timestamp is present. */ + if (stampst.st_ino != 0) + break; if (value == NULL) { error = ENOATTR; break; @@ -722,7 +725,17 @@ return (error); st->st_mode = (st->st_mode & ~S_IFMT) | node->type; - + /* Store default timestamp, if present. */ + if (stampst.st_ino != 0) { + st->st_atime = stampst.st_atime; + st->st_ctime = stampst.st_ctime; + st->st_mtime = stampst.st_mtime; +#if HAVE_STRUCT_STAT_ST_MTIMENSEC + st->st_atimensec = stampst.st_atimensec; + st->st_mtimensec = stampst.st_mtimensec; + st->st_ctimensec = stampst.st_ctimensec; +#endif + } /* Nothing more to do for the global defaults. */ if (node->name == NULL) return (0);