Bug 212193 - dirname //usr//bin// -> /usr, not //usr
Summary: dirname //usr//bin// -> /usr, not //usr
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Schouten
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-27 08:09 UTC by Enji Cooper
Modified: 2016-09-19 06:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2016-08-27 08:09:04 UTC
On older versions of FreeBSD/NetBSD:

$ dirname //usr//bin
//usr
$ uname -a
FreeBSD fbsd10 10.3-STABLE FreeBSD 10.3-STABLE #52 r302447M: Fri Jul  8 12:44:14 PDT 2016     ngie@fbsd10:/usr/obj/usr/src/sys/GENERIC  amd64

On newer versions (post the recent basename/dirname changes):

$ dirname //usr//bin
/usr
$ uname -a
FreeBSD fbsd11 12.0-CURRENT FreeBSD 12.0-CURRENT #6 r304831: Thu Aug 25 23:47:28 PDT 2016     ngie@fbsd11:/usr/obj/usr/src/svn/sys/GENERIC  amd64
Comment 1 Ed Schouten freebsd_committer freebsd_triage 2016-08-27 09:37:13 UTC
Yes, that's expected. The new dirname() implementation is guaranteed to generate a normalized pathname string. Redundant slashes and dot components are removed.

Is this causing any problems?
Comment 2 Ed Schouten freebsd_committer freebsd_triage 2016-08-27 11:30:06 UTC
Oh, wow. This is interesting. It looks like POSIX puts stronger requirements on the output of dirname(1) than on dirname(3). The example that you gave *must* return a path with the exact number of leading slashes left intact.

Let me think of a way to solve this cleanly.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-08-29 17:51:38 UTC
A commit references this bug:

Author: ngie
Date: Mon Aug 29 17:50:36 UTC 2016
New revision: 305007
URL: https://svnweb.freebsd.org/changeset/base/305007

Log:
  Expect :basic to fail due to recent output changes in dirname(3)

  The dirname output change bug is actively being worked on, and this
  commit will need to be reverted once it's fixed.

  MFC after:	never
  PR:		212193
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Comment 4 Ed Maste freebsd_committer freebsd_triage 2016-08-29 18:02:22 UTC
Ideally the Austin Group can be convinced that it's silly to specify different behaviour for dirname(1) and dirname(3).
Comment 5 Ed Schouten freebsd_committer freebsd_triage 2016-08-29 20:19:12 UTC
Bug report at the Austin Group: http://austingroupbugs.net/view.php?id=1073
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-08-29 22:35:06 UTC
A commit references this bug:

Author: ngie
Date: Mon Aug 29 22:34:31 UTC 2016
New revision: 305030
URL: https://svnweb.freebsd.org/changeset/base/305030

Log:
  Fix typo

  atf_tc_expect_fail should have been atf_expect_fail per atf-sh-api(3)

  PR:		212193
  Pointyhat to:	ngie
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  projects/netbsd-tests-update-12/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Comment 7 commit-hook freebsd_committer freebsd_triage 2016-08-29 22:39:08 UTC
A commit references this bug:

Author: ngie
Date: Mon Aug 29 22:38:18 UTC 2016
New revision: 305031
URL: https://svnweb.freebsd.org/changeset/base/305031

Log:
  Fix typo

  atf_tc_expect_fail should have been atf_expect_fail per atf-sh-api(3)

  PR:		212193
  Pointyhat to:	ngie
  Sponsored by:	EMC / Isilon Storage Division

Changes:
_U  head/
  head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-09-18 20:48:08 UTC
A commit references this bug:

Author: ed
Date: Sun Sep 18 20:47:55 UTC 2016
New revision: 305952
URL: https://svnweb.freebsd.org/changeset/base/305952

Log:
  Replace dirname(3) by a copy that complies to POSIX.

  It turns out that the path normalization that our brand new copy of
  dirname(3) does is actually not allowed by the draft version of the
  upcoming version of POSIX. It has to behave identically to the
  dirname(1) utility.

  This change replaces our new dirname(3) implementation by yet another
  version that doesn't implement the path normalization logic; it merely
  looks for the end of the directory name and overwrites that with a null
  byte.

  More details: See note #3370 at http://austingroupbugs.net/view.php?id=1073

  PR:		212193
  Reviewed by:	emaste, jilles
  Differential Revision:	https://reviews.freebsd.org/D7790

Changes:
  head/lib/libc/gen/dirname.3
  head/lib/libc/gen/dirname.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2016-09-19 06:39:38 UTC
A commit references this bug:

Author: ngie
Date: Mon Sep 19 06:39:08 UTC 2016
New revision: 305958
URL: https://svnweb.freebsd.org/changeset/base/305958

Log:
  Remove expected failure for :basic (effectively reverting r305007, r305031)

  This no longer fails as of r305952

  PR:		212193
  Sponsored by:	Dell EMC Isilon

Changes:
  head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Comment 10 Enji Cooper freebsd_committer freebsd_triage 2016-09-19 06:40:22 UTC
Closing bug (now fixed). Thanks ed!