Bug 219467 - `mtree -R type -k flags` prints out type= keyword attributes, contrary to what the manpage says it should do
Summary: `mtree -R type -k flags` prints out type= keyword attributes, contrary to wha...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Jose Luis Duran
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-23 01:22 UTC by Enji Cooper
Modified: 2026-01-18 03:58 UTC (History)
3 users (show)

See Also:
jlduran: mfc-stable15+
jlduran: mfc-stable14+
jlduran: mfc-stable13+


Attachments
Initial proposed fix (2.31 KB, patch)
2025-12-15 05:00 UTC, Jose Luis Duran
no flags Details | Diff
Initial proposed fix (2.26 KB, patch)
2025-12-18 14:48 UTC, Jose Luis Duran
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2017-05-23 01:22:59 UTC
Per mtree(8), passing `-R type -k flags` should clear omit type keywords from
the spec created via mtree:

     -k keywords        Use the type keyword plus the specified (whitespace or
                        comma separated) keywords instead of the current set
                        of keywords.  If `all' is specified, use all of the
                        other keywords.  If the type keyword is not desired,
                        suppress it with -R type.

Trying this though, demonstrates that that is not the case:

$ sudo mtree -cn -R type -k flags -p /usr/bin/ -x | grep type=
/set type=file flags=uarch
.               type=dir
    chfn        type=link
    chsh        type=link
    cpio        type=link
    mailq       type=link
    newaliases  type=link
    perl        type=link
    perl5       type=link
    pgrep       type=link
    pkill       type=link
    stelnet     type=link
    tar         type=link
    ypchfn      type=link
    ypchpass    type=link
    ypchsh      type=link
    yppasswd    type=link
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2017-05-23 01:23:36 UTC
(In reply to Ngie Cooper from comment #0)

*clear omit -> omit
Comment 2 Jose Luis Duran freebsd_committer freebsd_triage 2025-12-15 05:00:14 UTC
Created attachment 266206 [details]
Initial proposed fix

mtree: Fix parsing 'K', 'k', and 'R' flags

Move the parsing of the keywords for the 'K', 'k', and 'R' flags outside the getopt loop, so that the order of the flags does not matter.

Also, check for the presence of the F_TYPE flag before printing the type keyword.
Comment 3 Jose Luis Duran freebsd_committer freebsd_triage 2025-12-15 05:23:43 UTC
Submitted a bug report (bin/59838) upstream.
Comment 4 Jose Luis Duran freebsd_committer freebsd_triage 2025-12-18 14:48:50 UTC
Created attachment 266329 [details]
Initial proposed fix

Remove leftovers.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-12-19 20:17:54 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8cee1f2c2dfba6223385fd711cce9faeca76451

commit f8cee1f2c2dfba6223385fd711cce9faeca76451
Merge: fe53a8a82c81 eb2ccba0c11b
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-12-19 20:14:35 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2025-12-19 20:14:35 +0000

    Import latest mtree from NetBSD

    Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

    PR:             192839
    PR:             219467
    MFC after:      1 week

 contrib/mtree/compare.c | 16 ++++++----------
 contrib/mtree/create.c  |  7 ++++---
 contrib/mtree/mtree.c   | 36 ++++++++++++++++++++++--------------
 contrib/mtree/spec.c    | 25 +++++++++++--------------
 4 files changed, 43 insertions(+), 41 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-12-27 16:30:41 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=791fb098c9e84282b7d061c5708569757e6c65a3

commit 791fb098c9e84282b7d061c5708569757e6c65a3
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-12-19 20:14:35 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2025-12-27 16:28:01 +0000

    Import latest mtree from NetBSD

    Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

    PR:             192839
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit f8cee1f2c2dfba6223385fd711cce9faeca76451)

 contrib/mtree/compare.c | 16 ++++++----------
 contrib/mtree/create.c  |  7 ++++---
 contrib/mtree/mtree.c   | 36 ++++++++++++++++++++++--------------
 contrib/mtree/spec.c    | 25 +++++++++++--------------
 4 files changed, 43 insertions(+), 41 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-12-27 16:30:42 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f9d671f726ac2199b906fc406b46b57cd2a11cf7

commit f9d671f726ac2199b906fc406b46b57cd2a11cf7
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-12-19 20:14:35 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2025-12-27 16:28:35 +0000

    Import latest mtree from NetBSD

    Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

    PR:             192839
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit f8cee1f2c2dfba6223385fd711cce9faeca76451)

 contrib/mtree/compare.c | 16 ++++++----------
 contrib/mtree/create.c  |  7 ++++---
 contrib/mtree/mtree.c   | 36 ++++++++++++++++++++++--------------
 contrib/mtree/spec.c    | 25 +++++++++++--------------
 4 files changed, 43 insertions(+), 41 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-12-27 16:30:45 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5ea3ad01e6f511ee573e993e89810c27a7cf4198

commit 5ea3ad01e6f511ee573e993e89810c27a7cf4198
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-12-19 20:14:35 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2025-12-27 16:29:02 +0000

    Import latest mtree from NetBSD

    Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

    PR:             192839
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit f8cee1f2c2dfba6223385fd711cce9faeca76451)

 contrib/mtree/compare.c | 16 ++++++----------
 contrib/mtree/create.c  |  7 ++++---
 contrib/mtree/mtree.c   | 36 ++++++++++++++++++++++--------------
 contrib/mtree/spec.c    | 25 +++++++++++--------------
 4 files changed, 43 insertions(+), 41 deletions(-)
Comment 9 Jose Luis Duran freebsd_committer freebsd_triage 2025-12-27 16:32:50 UTC
Thank you for the bug report!
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-01-11 16:51:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4250d2ad991b7bb9915e4c6b6d93b17369747ff0

commit 4250d2ad991b7bb9915e4c6b6d93b17369747ff0
Merge: 717ae163919e 7e59b238fcf3
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-11 16:42:18 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-11 16:42:18 +0000

    Import latest mtree from NetBSD

    Merge commit '7e59b238fcf32f3d365e78ddc702ca494e1ff68d'

    This commit partially reverts the previous vendor import, given that the
    "type" keyword has been historically mandatory and should not be removed
    by "-R all".  This was clarified in the man page.

    Reported by:    glebius
    PR:             219467
    MFC after:      1 week

 contrib/mtree/create.c |  7 +++----
 contrib/mtree/mtree.8  | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-01-18 03:57:55 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2e7269461e94c56792801a6447ddee18baab52f

commit e2e7269461e94c56792801a6447ddee18baab52f
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-11 16:42:18 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-18 03:56:23 +0000

    Import latest mtree from NetBSD

    Merge commit '7e59b238fcf32f3d365e78ddc702ca494e1ff68d'

    This commit partially reverts the previous vendor import, given that the
    "type" keyword has been historically mandatory and should not be removed
    by "-R all".  This was clarified in the man page.

    Reported by:    glebius
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit 4250d2ad991b7bb9915e4c6b6d93b17369747ff0)

 contrib/mtree/create.c |  7 +++----
 contrib/mtree/mtree.8  | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-01-18 03:58:56 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f957857c48351396dbd0127bc0fdd47f69e82f6d

commit f957857c48351396dbd0127bc0fdd47f69e82f6d
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-11 16:42:18 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-18 03:55:38 +0000

    Import latest mtree from NetBSD

    Merge commit '7e59b238fcf32f3d365e78ddc702ca494e1ff68d'

    This commit partially reverts the previous vendor import, given that the
    "type" keyword has been historically mandatory and should not be removed
    by "-R all".  This was clarified in the man page.

    Reported by:    glebius
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit 4250d2ad991b7bb9915e4c6b6d93b17369747ff0)

 contrib/mtree/create.c |  7 +++----
 contrib/mtree/mtree.8  | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)
Comment 13 commit-hook freebsd_committer freebsd_triage 2026-01-18 03:58:57 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fc614b08ef6cce1568f449de1bf562d0b2d5f777

commit fc614b08ef6cce1568f449de1bf562d0b2d5f777
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-11 16:42:18 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-18 03:57:12 +0000

    Import latest mtree from NetBSD

    Merge commit '7e59b238fcf32f3d365e78ddc702ca494e1ff68d'

    This commit partially reverts the previous vendor import, given that the
    "type" keyword has been historically mandatory and should not be removed
    by "-R all".  This was clarified in the man page.

    Reported by:    glebius
    PR:             219467
    MFC after:      1 week

    (cherry picked from commit 4250d2ad991b7bb9915e4c6b6d93b17369747ff0)

 contrib/mtree/create.c |  7 +++----
 contrib/mtree/mtree.8  | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)