Skip to content

Conversation

@IgorTodorovskiIBM
Copy link
Collaborator

@IgorTodorovskiIBM IgorTodorovskiIBM commented Apr 22, 2024

  • pthread_create-created threads do not set autocvt by default. This can be problematic if _BPXK_AUTOCVT is unset in the user environment. This PR adds a change to override pthread_create which sets AUTOCVT=ON in a similar way to the startup routine in zos.cc.
  • adds netinet/in_systm.h is missing, affects honggfuzz and nmap
  • adds getline and getdelim - affects honggfuzz, libssh2 and moreutils
  • Adds _SC_NPROCESSORS_ONLN to sysconf - encountered too many times and rather than editing the application code, I extended sysconf to support _SC_NPROCESSORS_ONLN
  • It also modifies the untagged read heuristic to remove the restriction on the min required bytes (currently set to 8 bytes). The reason for this is that there are <8 byte EBCDIC files such as /etc/syslog.pid and /etc/sshd.pid and based on user experience, untagged files which are small in size typically contain EBCDIC data and not binary data or ascii data so we should lean towards marking it as EBCDIC. Additionally, all z/OS Open Tools tag their data. Note, the __UNTAGGED_READ_MODE environment variable still takes precedence when set but most users do not set this environment variable.
  • Also changes chgfdccsid to not set the txtflag when ccsid = 0
  • Adds more tests

@IgorTodorovskiIBM IgorTodorovskiIBM marked this pull request as draft April 22, 2024 23:47
if (ccsid == 1047 && len == cnt) {
if (no_tag_read_behaviour == __NO_TAG_READ_DEFAULT_WITHWARNING) {
if (name) {
len = strlen(name) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor thing but i would typically have len be the strlen and then allocate the buffer to len+1 since you don't need to convert a 0 to a 0.
But perhaps just me.

return 1;
}
} // cnt > 8
fdcache.set_attribute(fd, 0x0000000000020000UL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a name for the magic number?

src/zos-io.cc Outdated
size_t pos = 0;

if (*lineptr == NULL || *n == 0) {
*n = 128;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 128? and why 2 farther down? would those be good to have as buffer length and growth size macros (assuming that's what they are?)

src/zos-io.cc Outdated
int c;

if (buf == NULL || bufsize == 0) {
bufsize = 128;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above.

Copy link
Collaborator

@MikeFultonDev MikeFultonDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed - minor comments.

@IgorTodorovskiIBM
Copy link
Collaborator Author

Added a readlink override to address zopencommunity/coreutilsport#74 and zopencommunity/gitport#122

src/zos-io.cc Outdated
*lineptr = (char *)malloc(*n);
if (*lineptr == NULL || *n == 0) {
*n = 120;
*lineptr = (char *)realloc(*lineptr, *n);
Copy link

@AnthonyGiorgio AnthonyGiorgio Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling realloc() this way is incorrect. If the memory allocation fails, then the original value of lineptr is lost, and the memory it pointed to is leaked. cppcheck complains about this, and suggests you use a temporary pointer to hold the return value, and then assign it to lineptr after validation.

https://stackoverflow.com/questions/21006707/proper-usage-of-realloc

@IgorTodorovskiIBM IgorTodorovskiIBM marked this pull request as ready for review July 16, 2024 17:43
Comment on lines +14 to +16
#if (__TARGET_LIB__ < 0x42050000) || \
(__TARGET_LIB__ >= 0x42050000 && \
(((_POSIX_C_SOURCE + 0) < 200809L) && !defined(_XPLATFORM_SOURCE)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if (__TARGET_LIB__ < 0x42050000) || \
(__TARGET_LIB__ >= 0x42050000 && \
(((_POSIX_C_SOURCE + 0) < 200809L) && !defined(_XPLATFORM_SOURCE)))
#if (__TARGET_LIB__ < 0x42050000) || \
(((_POSIX_C_SOURCE + 0) < 200809L) && !defined(_XPLATFORM_SOURCE))

If a is not < b then a >= b. Same applies to the change in zos-getentropy.h (and a few other places).

IgorTodorovskiIBM and others added 18 commits June 5, 2025 17:49
* fix: fdopendir and statfs conflict override

* feat: strerror without EDC prefix

* fix: get rid of fdopendir

* fix: get rid of _Packed (maintenance)

* refactor: igor - make changes consistent with zoslib

* fix: strerror not working due to linker

* Update include/zos-v2r5-symbolfixes.h

Co-authored-by: Igor Todorovski <[email protected]>

* Update include/dirent.h

Co-authored-by: Igor Todorovski <[email protected]>

* document statfs override

---------

Co-authored-by: Igor Todorovski <[email protected]>
* feat: aligned operator new and delete

* add todo
* Add initial implementation of ptrace and tests

* Guard clock_gettime and nanosleep in time.h to fix build error in zstd

* Use _Z_EXPORT in ptrace
* Add error function

* Fix various warnings

* revert issue

* Further updates
* Add mount readonly flag, spawn setsigdefault

* Add duplocale. Introduce macro to use zoslib locale
* Add scandir, timegm implementation

* Add portable remove_all function

* Define FNM_EXTMATCH

* Add cpp guard for filesystem header
sachintu47 and others added 5 commits November 17, 2025 20:10
This commit introduces the `__UNTAGGED_FILE_ENCODING` environment variable, which deprecates `__UNTAGGED_READ_MODE`, to control the handling of untagged files.

The implementation prioritizes the new variable, falling back to the old one for compatibility.

Documentation and tests have been updated accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.