Below are two mtree patches to improve compatibility with FreeBSD. The first one reverts mtree to only output size elements for regular files since that change was recently made to FreeBSD's mtree. The justification given is that the sizes of some non-files like directories depend on the underlying filesystem and just aren't appropriate for mtree to output. I think I mostly agree with this reasoning so the following patch inverts the flavor test and restores the old behavior to NetBSD's mtree. The second patch allows mtree files of the form: ---<cut>--- . /set type=dir ... dir1 dir2 ... ---<cut>--- Technically this mtree file is invalid because the root "." isn't type dir, but this sort of mtree file does exist in the FreeBSD ports tree to add subtrees to directories like /var. Since it's obvious that the root should be of type dir, the patch just sets the type. -- Brooks Index: create.c =================================================================== --- create.c (revision 256058) +++ create.c (working copy) @@ -221,7 +221,7 @@ if (keys & F_NLINK && p->fts_statp->st_nlink != 1) output(indent, &offset, "nlink=%u", p->fts_statp->st_nlink); if (keys & F_SIZE && - (flavor != F_NETBSD6 || S_ISREG(p->fts_statp->st_mode))) + (flavor == F_FREEBSD9 || S_ISREG(p->fts_statp->st_mode))) output(indent, &offset, "size=%lld", (long long)p->fts_statp->st_size); if (keys & F_TIME) Index: spec.c =================================================================== --- spec.c (revision 256058) +++ spec.c (working copy) @@ -217,6 +217,13 @@ /* * empty tree */ + /* + * Allow a bare "." root node by forcing it to + * type=dir for compatiblity with FreeBSD. + */ + if (strcmp(centry->name, ".") == 0 && + centry->type == 0) + centry->type = F_DIR; if (strcmp(centry->name, ".") != 0 || centry->type != F_DIR) mtree_err(
Attachment:
pgpiV9tQpfEdB.pgp
Description: PGP signature