I tried to reply by email to jira@mariadb.org but that failed. Pasting my reply here instead.
> Sergei Golubchik commented on MDEV-12778:
> -----------------------------------------
>
> What was the issue with O_EXEC?
The issue is that O_PATH is not defined on GNU/Hurd and O_EXEC is not either
while on FreeBSD O_PATH is not defined but O_EXEC is.
> Why _GNU_SOURCE in mysys_priv.h? It's already redundantly defined in
> my_config.h and my_global.h.
If _GNU_SOURCE is already defined this part is not needed and can safely be
omitted from the patch.
> It seems like groonga preferred select, when both poll and select were
> available, and you've changed it to prefer poll. Why?
Well, the build on GNU/Hurd defined USE_POLL, not USE_SELECT. I did not take the
time to find out how it could happen, since POLL or SELECT can be arbitrarily
chosen. So I chose to correct the conditions for the USE_POLL case to make
things working.
> What's the PATH_MAX issue that you fix? No PATH_MAX on GNU/Hurd? I can
> simply define PATH_MAX to be 512 if it isn't defined. Would that work for
> you? _Besides, your realpath() changes in NOSYMLINK_FUNCTION_BODY are
> broken, realpath() needs only one argument being NULL, not both — how
> would it know what path to convert? — and even if it'd work, you forgot to
> free buf at the end_
PATH_MAX is never and will never be defined on GNU/Hurd it's bad coding to use
it at all, see http://insanecoding.blogspot.se/2007/11/pathmax-simply-isnt.html
realpath(3) use 2 arguments:
char *realpath(const char *path, char *resolved_path)
|
and the patch use two too:
- char buf[PATH_MAX+1]; \
|
- if (realpath(pathname, buf) == NULL) return -1; \
|
+ char *buf = realpath(NULL, 0); \
|
+ if (buf == NULL) return -1; \
|
The usage of the function CREATE_NOSYMLINK_FUNCTION defined in mysys_priv.h
using NOSYMLINK_FUNCTION_BODY are in mysys/my_open.c and mysys/my_delete.c.
The eventual need of freeing the buffer happen at my_delete.c:
CREATE_NOSYMLINK_FUNCTION(
|
unlink_nosymlinks(const char *pathname),
|
unlinkat(dfd, filename, 0),
|
unlink(pathname)
|
);
|
There a free(pathname); would be eventually needed. In the original code
pathname is allocated on the stack, while with realpath(NULL, 0) it will be
allocated on the heap. Depending on how much this call is used, an added free
might be needed. You know how the code works, not me. Perhaps you can show me a
test case so I can check the patch with valgrind (on GNU/Linux, unfortunately it
is not available on GNU/Hurd).
Thanks for your review. Hope things are clearer by now. I'm looking forward to
your further comments on this.
What was the issue with O_EXEC?
Why _GNU_SOURCE in mysys_priv.h? It's already redundantly defined in my_config.h and my_global.h.
It seems like groonga preferred select, when both poll and select were available, and you've changed it to prefer poll. Why?
What's the PATH_MAX issue that you fix? No PATH_MAX on GNU/Hurd? I can simply define PATH_MAX to be 512 if it isn't defined. Would that work for you? Besides, your realpath() changes in NOSYMLINK_FUNCTION_BODY are broken, realpath() needs only one argument being NULL, not both — how would it know what path to convert? — and even if it'd work, you forgot to free buf at the end