Skip to content

Add _ENCODE_FILE_EXISTING variable#5

Open
sabi789 wants to merge 1 commit into
zopencommunity:zopen2from
sabi789:zopen2
Open

Add _ENCODE_FILE_EXISTING variable#5
sabi789 wants to merge 1 commit into
zopencommunity:zopen2from
sabi789:zopen2

Conversation

@sabi789
Copy link
Copy Markdown
Member

@sabi789 sabi789 commented May 12, 2026

No description provided.

Signed-off-by: sabi789 <sabithac6298@gmail.com>
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 12, 2026

🤖 Augment PR Summary

Summary: Adds a new environment variable to control how existing files are tagged/translated when opened through the zoslib CLIB overrides.

Changes:

  • Documented UTF-8 as an option for _ENCODE_FILE_NEW and introduced _ENCODE_FILE_EXISTING options (ISO8859-1/IBM-1047/BINARY/UTF-8) in the manpage.
  • Implemented __tag_existing_file() and invoked it from __open_ascii / __fopen_ascii for regular files.
  • Extended the CLIB override tests to cover UTF-8 new-file tagging and the new _ENCODE_FILE_EXISTING behaviors.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 5 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread man/zoslib.1
.B _ENCODE_FILE_NEW=BINARY

.TP
.B _ENCODE_FILE_NEW=UTF-8
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 12, 2026

Choose a reason for hiding this comment

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

man/zoslib.1:26: The BINARY description line ("New files are created without translation and are tagged as BINARY.") now appears after the UTF-8 stanza, so it likely renders as the UTF-8 description and leaves the BINARY option undocumented.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread man/zoslib.1
New files are created without translation and are tagged as BINARY.

.TP
.B _ENCODE_FILE_EXISTING=ISO8859-1
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 12, 2026

Choose a reason for hiding this comment

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

man/zoslib.1:33: Marking _ENCODE_FILE_EXISTING=ISO8859-1 as "(Default)" seems inconsistent with the implementation (when _ENCODE_FILE_EXISTING is unset, __tag_existing_file() is a no-op and existing file behavior depends on the file’s current tag/heuristics).

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread src/zos-io.cc
}
// Enable auto-conversion of untagged files
else if (S_ISREG(sb.st_mode)) {
__tag_existing_file(fd);
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 12, 2026

Choose a reason for hiding this comment

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

src/zos-io.cc:894: After retagging the FD via _ENCODE_FILE_EXISTING, the auto-conversion decision still consults sb.st_tag from the pre-open stat(), so previously-untagged files can still trigger the heuristic and enable conversion (potentially overriding _ENCODE_FILE_EXISTING, especially BINARY).

Severity: high

Other Locations
  • src/zos-io.cc:939

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

read(fd, buff2, sizeof(buff));

// Delete and re-open temp_path _ENCODE_FILE_NEW=UTF-8
setenv("_ENCODE_FILE_NEW", "UTF-8", 1);
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 12, 2026

Choose a reason for hiding this comment

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

test/test-clib-override.cc:184: The fd from the preceding ISO8859-1 open(temp_path, O_RDONLY) isn’t closed before remove()/reusing fd, and the later UTF-8 open(temp_path, O_RDONLY) also isn’t closed; this can leak descriptors and make the test flaky.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

fd = open(temp_path, O_RDONLY);
EXPECT_EQ(__getfdccsid(fd), 0x10000 + 1047);
memset(buff2, 1, sizeof(buff));
read(fd, buff2, sizeof(buff));
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 12, 2026

Choose a reason for hiding this comment

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

test/test-clib-override.cc:208: These tests don’t check the return value from read() and then use strcmp(buff, buff2); if a short read occurs, buff2 may not be NUL-terminated and strcmp can read past the buffer (undefined behavior).

Severity: medium

Other Locations
  • test/test-clib-override.cc:194
  • test/test-clib-override.cc:217
  • test/test-clib-override.cc:226
  • test/test-clib-override.cc:235

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

1 participant