Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dirent-util: Remove asserts on dirent64 == dirent #25809

Closed
wants to merge 1 commit into from

Conversation

kraj
Copy link
Contributor

@kraj kraj commented Dec 21, 2022

We already have assert_cc(_FILE_OFFSET_BITS == 64) which ensures that 64bit LFS functions are same as their original counterparts

Signed-off-by: Khem Raj raj.khem@gmail.com

@github-actions github-actions bot added the please-review PR is ready for (re-)review by a maintainer label Dec 21, 2022
@yuwata
Copy link
Member

yuwata commented Dec 21, 2022

These lines are just for safety. Even if they are redundant, they should not hurt anything. Why do you want to drop them?

@kraj
Copy link
Contributor Author

kraj commented Dec 21, 2022

the lfs64 functions like dirent64 are guarded under -D_LARGEFILE64_SOURCE feature test macro which is indrectly defined with _GNU_SOURCE on glibc but not on musl. This make it work without -D_LARGEFILE64_SOURCE

@yuwata
Copy link
Member

yuwata commented Dec 21, 2022

Hmm, but, the relation between _FILE_OFFSET_BITS == 64 vs the equivalence of dirent and dirent64 is not trivial.
So, I'd like to keep the current assertions.

This sounds mostly for musl. Then, I'd like to request to add -D_LARGEFILE64_SOURCE when build with musl.

@yuwata yuwata added needs-discussion 🤔 and removed please-review PR is ready for (re-)review by a maintainer labels Dec 21, 2022
@kraj
Copy link
Contributor Author

kraj commented Dec 21, 2022

Hmm, but, the relation between _FILE_OFFSET_BITS == 64 vs the equivalence of dirent and dirent64 is not trivial. So, I'd like to keep the current assertions.

Can you explain whats non-trivial ? In musl dirent64 is same as dirent when _LARGEFILE64_SOURCE is set. I see
glibc is similar. Maybe I am missing something

This sounds mostly for musl. Then, I'd like to request to add -D_LARGEFILE64_SOURCE when build with musl.

Sure, I have that already. This was just trying to clean up systemd.

@poettering
Copy link
Member

Hmm, this is just safety stuff that doesnt do anything. It just checks that lfs support works the way it should. Sre you suggesting this breaks on musl? Or why the change?

@yuwata
Copy link
Member

yuwata commented Dec 21, 2022

Hmm, but, the relation between _FILE_OFFSET_BITS == 64 vs the equivalence of dirent and dirent64 is not trivial. So, I'd like to keep the current assertions.

Can you explain whats non-trivial ? In musl dirent64 is same as dirent when _LARGEFILE64_SOURCE is set. I see glibc is similar. Maybe I am missing something

The difference between dirent and dirent64 is simple, but it is not simple when the guards __USE_FILE_OFFSET64 and __USE_LARGEFILE64 defined or set. People may set them or related guards explicitly in a wrong (at least, unexpected) way. Hence, I'd like to keep the conditions.

This sounds mostly for musl. Then, I'd like to request to add -D_LARGEFILE64_SOURCE when build with musl.

Sure, I have that already. This was just trying to clean up systemd.

So, I do not think this is a good cleanup... This potentially reduces safety.

@poettering
Copy link
Member

Anyway, please explain what the rationale behind this is? Does this fix anything for you on musl? Or is this merely about cleaning up a test that is redundant in your eyes?

@poettering
Copy link
Member

so, the reason why i think we should keep this extra safety net is mostly because _FILE_OFFSET_BITS is a generic cross-platform thing, and getdents() is a Linux-specific thing that various libcs are known to define differently even. Hence the assumption that the generic, widely-accepted concept also covers the Linux-specific function/structure here seems a bit too much of a stretch to me, hence the extra safety net.

@kraj
Copy link
Contributor Author

kraj commented Jan 3, 2023

it is one patch less to keep systemd working with latest musl. Since latest musl has deprecated LFS64 functions, this patch is required.

@poettering
Copy link
Member

christ, musl doesn't care the least bit about compatibility, does it?

@poettering
Copy link
Member

so does musl also get rid of getdents64() given the "64" in its name?

honestly it appears to me that musl builds should really just do #define dirent64 dirent locally, to maintain compat with glibc

@poettering
Copy link
Member

@kraj btw, while i have you:

With 45519d1 you can drop https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch

Also, current kernels have faccessat2(), hence https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch is actively breaking things on current kernels (and a terrible idea anyway)

Also this is entirely redundant: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd/0002-Add-sys-stat.h-for-S_IFDIR.patch – since quite a while sys/stat.h is included already, just a few lines up

We already have assert_cc(_FILE_OFFSET_BITS == 64) which ensures that
64bit LFS functions are same as their original counterparts

Signed-off-by: Khem Raj <raj.khem@gmail.com>
@github-actions github-actions bot added the please-review PR is ready for (re-)review by a maintainer label Jan 24, 2023
@keszybz
Copy link
Member

keszybz commented Jan 24, 2023

I agree with @yuwata: this change increases risk. Ifdefs are easy to get wrong.

Maybe instead add a meson check if struct dirent64 is available and put #if !HAVE_STRUCT_DIRENT64 around this.

@keszybz keszybz removed the please-review PR is ready for (re-)review by a maintainer label Jan 24, 2023
thesamesam added a commit to thesamesam/systemd that referenced this pull request May 10, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd#25809
@yuwata
Copy link
Member

yuwata commented May 10, 2023

Superseded by #27599.

@yuwata yuwata closed this May 10, 2023
yuwata pushed a commit that referenced this pull request May 10, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: #25809
keszybz pushed a commit to systemd/systemd-stable that referenced this pull request May 11, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
keszybz pushed a commit to systemd/systemd-stable that referenced this pull request May 11, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
keszybz pushed a commit to systemd/systemd-stable that referenced this pull request May 12, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
bluca pushed a commit to bluca/systemd-stable that referenced this pull request Jun 1, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
(cherry picked from commit 4984f70)
bluca pushed a commit to systemd/systemd-stable that referenced this pull request Jun 2, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
(cherry picked from commit 4984f70)
bluca pushed a commit to bluca/systemd-stable that referenced this pull request Jun 2, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
(cherry picked from commit 4984f70)
(cherry picked from commit bff6cef)
bluca pushed a commit to systemd/systemd-stable that referenced this pull request Jun 2, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296)
(cherry picked from commit 4984f70)
(cherry picked from commit bff6cef)
timkenhan pushed a commit to timkenhan/elogind that referenced this pull request Oct 24, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
Yamakuzure pushed a commit to elogind/elogind that referenced this pull request Nov 11, 2023
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
Yamakuzure pushed a commit to elogind/elogind that referenced this pull request Feb 18, 2024
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: systemd/systemd#25809
(cherry picked from commit eb29296937b268e0140a2ab1cf204c2ebb72fa5a)
(cherry picked from commit 4984f70db5b1ce3103dfb6b2ecdbced86bf92703)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants