The recent change 3fde6ce is not conforming to POSIX. In fact, EPERM is not only used for "the user didn't
have the (write) permission to remove the directory", and it was perfectly valid in sense of conformance. Note Linux also behaves differently, however, not ENOTEMPTY for this case. The changed behavior might introduce confusion, so please clarify it explicitly.