summaryrefslogtreecommitdiffhomepage
path: root/src/sys_zos.c
Commit message (Collapse)AuthorAgeFilesLines
* C23: nullptr for null pointers, constexpr for typed constantschore/c23-nullptr-constexprSean Kurtz5 days1-6/+6
| | | | | | | | | | | | | | nullptr in every place a null pointer constant was meant; NULL is gone from src/. constexpr where it improves on #define without costing anything: the IGGCSI00 work-area offsets and sizes, and the scalar sizes MVS_DSN_MAX, CSI_FIELD_LEN, CSI_WORK_MIN, PDS_DIRBLK, CSI_WORK, CSI_MAX_CALLS. A constexpr in C is a constant expression, so it still bounds the arrays that use it, and it now carries a type and can be checked with static_assert. Feature switches (#if), the CSIETYPE/EBCDIC byte constants read as octets, and the related-constant enum sets stay as they were.
* build: 64-bit on z/OSSean Kurtz5 days1-18/+19
| | | | | | | | | | | | | | | | | | The 31-bit choice existed for one reason: a 64-bit start cost 29 ms against 1 ms and a 64-bit fork() 4.2 ms against 0.10. That was the 64-bit C run-time being loaded out of CEE.SCEERUN2 on the linklist on every start; with CELQ* in the dynamic LPA both widths cost 1.5 ms and fork() 0.10 ms (notes/investigation.md has the before and after). So build the shell at the width IBM builds for: -m64 for both the ASCII and the EBCDIC build, and for the debug build. OS_UPSTACK does not exist at -m64, so the two AMODE 31 services (IGGCSI00, BPXWDY2) are declared with plain OS linkage, which is what the 64-bit glue implements. IGGCSI00's VL bit is set from the width of a pointer now, not with 0x80000000. Neither module loads on this system, so the linkage itself stays unverified; csi_call() still traps a program check and retires the catalog if it abends.
* z/OS: keep a close-on-exec pipe out of the child's fd mapSean Kurtz7 days1-5/+34
| | | | | | | | | | | | | | | | | | | | | | | sys_pipe() duplicates the shell's pipe ends above SYS_NFD and marks them FD_CLOEXEC, so that other children do not inherit them. spawn()'s fd_map hands the child the parent's descriptor as it is, without clearing the flag the way dup2() would, so a mapping onto the child's 0..2 carried FD_CLOEXEC into the child. The child could still write, but the next exec inside it lost stdout: ps printed FSUM6004 write error on standard output: EDC5113I Bad file descriptor and a #!/bin/sh shim lost the pipe it was given. Pass a plain duplicate, which fcntl F_DUPFD makes above SYS_NFD without the flag, for every map entry that names a different descriptor, and close the duplicates once spawn() has made the child. Entries that map a descriptor onto itself are untouched. tests/zos/fdmap.sh records the case: a pipe the shell made, read by a child that execs. Reported in #1.
* z/OS: run 31-bit and load IGGCSI00 through the C librarySean Kurtz7 days1-88/+111
| | | | | | | | | | | | | zash was AMODE 64, so calling the AMODE 31 IGGCSI00 needed assembler glue (zos_csi.s) that switched addressing mode around the branch. Built with -m32 the program is 31-bit itself: the call goes through a plain function pointer, the work area and the saved registers live in one 31-bit block in C, and the glue is gone. The rest of the tree follows the change: the build, the off-z/OS lint shim, DESIGN.md and README.md, the benches, the Lean spec of the pattern matcher, and the tests that recorded what the extra address bits had changed.
* z/OS: load IGGCSI00 once and keep the block for the shellSean Kurtz10 days1-30/+63
| | | | | | | | | | | | | | | | | | | | The search interface was reached through LINK, which asked the system to find and attach the module on every call -- and completion issues a call per Tab. The glue now LOADs the module on the first call, writes its entry point into the block, and branches to it directly afterwards, and the block itself is taken from 31-bit storage on the first search and kept, because IGGCSI00 is AMODE 31 and all three of its addresses have to stay below 2 GB. The block is declared packed, so the compiler cannot add padding the assembler's offsets do not know about, and aligned(8), so the save area starts on a doubleword. Its name field is spelled in IBM-1047 bytes rather than as a C string, so the module is named the same way whatever character mode this build runs in. Verified on the machine: SYS1.MA* returns SYS1.MACLIB, SYS1.* returns 135 names, and Tab in an interactive shell completes //'SYS1.MA to //'SYS1.MACLIB' and lists the members of that PDS.
* docs: say it in short sentencesSean Kurtz11 days1-13/+13
| | | | | | | | | | | | | DESIGN.md, README.md and the Doxygen comments leaned on semicolons to join clauses and on trailing "which" clauses to add afterthoughts. Both read as machine-written prose. Each joined clause is now its own sentence, and the afterthoughts are either part of the sentence or a sentence of their own. Also corrected: README said C11 in two places (the tree builds C17), the completion section still described the pre-HLQ-rule filters and the 64-call resume limit, and the z/OS job-control note still called SPAWN_SETTCPGRP unverified.
* z/OS: test a spawn with the script's whole descriptor range openSean Kurtz11 days1-11/+3
| | | | | | | A script owns descriptors 0..SYS_NFD-1 and the shell's own live above them, so filling 3..9 is as far as a script can go; the spawn map keeps the terminal duplicate reachable past them. The earlier '64' map was guessing at a case the shell cannot present: back to SYS_NFD+16.
* z/OS: bound the below-the-bar storage CSI completion usesSean Kurtz11 days1-5/+12
| | | | | | One 64 KB block, freed before the search returns, and a nested search is refused rather than given a second one. The second catalog search is skipped once the candidate list is full.
* z/OS: a wider spawn map, and the suite runs both buildsSean Kurtz12 days1-3/+11
| | | | | | | | | The map carried SYS_NFD+16 descriptors, so a script holding more pushed the terminal's duplicate out of reach and its commands lost the controlling terminal. 64 leaves room. `make zos-check` now builds the EBCDIC program too and runs the character-set tests against it, which nothing did before.
* z/OS: keep the terminal descriptor open for spawnSean Kurtz12 days1-2/+18
| | | | | | | | | | | | spawn() sets the child's foreground process group from inherit.ctlttyfd after it has closed every descriptor from fd_count up, so the shell's terminal descriptor -- which lives above the script's five or so -- was already gone by then. Every external command in an interactive shell died with EDC5113I Bad file descriptor, while the same command outside a terminal worked. Carry the terminal descriptor in the fd map, so the child has it open for exactly the tcsetpgrp() spawn() performs.
* sys_zos: no /* inside the block commentSean Kurtz12 days1-2/+2
| | | | | -Wcomment is right: a path spelled tests/zos/* starts a nested comment marker.
* Say the z/OS layer has been built and run thereSean Kurtz12 days1-3/+3
| | | | | | | | The docs and three source headers still claimed the z/OS layer had never been compiled. Both character modes build with ibm-clang, tests/zos/* run it on the machine, LE's heap checker stands in for ASan, and AMBLIST shows the CSI glue inside the program object. What is left is the set of things no test reaches, which the VERIFY notes already name.
* sys_info: return empty when an MVS control block is absentSean Kurtz12 days1-2/+10
| | | | | | | CVT, ASCB and now ECVT were dereferenced without a check; a null there would be an S0C4 in 'sysinfo', in 'read -t' timeouts and at job-table refresh. A shell may run where PSAAOLD or the ECVT pointer is not set, so report an empty field as sys_info() already does for a null job name.
* zos build changesSean Kurtz12 days1-1/+33
|
* z/OS ASCII build: convert own I/O to IBM-1047 on pipes, here-docs, ↵Sean Kurtz12 days1-5/+36
| | | | redirects, std streams
* change __free31()s to free is sys_zos.cSean Kurtz12 days1-2/+2
|
* fix issues with z/os build, header visibility, signalsSean Kurtz12 days1-0/+54
|
* z/OS: file tagging, catalog completion, time, and per-command optionsSean Kurtz2026-11-151-0/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tagging and conversion (sys_zos.c, redir.c, input.c, var.c, exec.c): - _TAG_REDIR_IN/OUT/ERR as /bin/sh documents them, cached by variable hooks so redirection tests a byte; honoured as a prefix on external commands and on pipeline stages. - ASCII builds tag new output and here-document files as text, tag pipes IBM-1047 (set +o pipetag to stop), and switch on autoconvert. - Scripts, . files, profile and ENV are read in either character set: tagged files get F_CONTROL_CVT, untagged ones are sniffed. - tag/chtag primitives (sys_tag_get/sys_tag_set) for a builtin to come. Data set completion (complete.c, mvsfmt.[ch], zos_csi.s): - //'HLQ.PART, "//'HLQ.PART, //NAME (user HLQ), //'DSN(MEM, //DD:NAME complete one qualifier at a time from the Catalog Search Interface, PDS directories and the TIOT. - IGGCSI00 is called through HLASM glue that switches to AMODE 31 and keeps every register and parameter below the bar (VERIFY). - The work-area, directory and TIOT decoders are portable and run on Linux against a stand-in catalog that produces the real EBCDIC bytes, including CSI resume and directory-block splits; fuzzed with libFuzzer (make fuzz). - A lone completion inside quotes now closes the quote. Other z/OS features: - time [-p] keyword with shell/children CPU split. - set -o jobnames (_BPX_JOBNAME per command), set -o shareas (_BPX_SHAREAS=YES for foreground commands only), set -o msgid (ZSHnnnnE/W message IDs), ulimit -M (MEMLIMIT), ZOS_SYSNAME, ZOS_SYSPLEX, ZOS_RELEASE, ZOS_ASID, ZOS_JOBNAME, prompt \S. - BPXWDYN entry point for an alloc builtin to come. Checking z/OS code off z/OS: - make zos-lint compiles sys_zos.c against declarations transcribed from the z/OS headers, and the rest with the MVS paths forced on. - make mvs-asan runs the suite with the MVS paths on, under ASan/UBSan. - make asan and make valgrind now check for leaks.
* Add extensions, job control and the interactive layer; convert to C11Sean Kurtz2026-11-131-9/+48
| | | | | | | | | | | | | | | | | Language: $'...', aliases, function keyword, (( )) and let, typeset and integer, print, whence, setvar, ulimit, read -t, RANDOM, SECONDS, the ERR trap, trap -p, chdir, and more set -o names. Job control: a job table, process groups, terminal hand-over through the spawn layer, jobs/fg/bg, wait %n and kill %n. Interactive: prompt expansion, a built-in line editor with emacs and vi modes, completion, history with fc and HISTFILE, and libedit as a compile-time alternative (make EDIT=libedit LDLIBS=-ledit). The source is now C11 (was C23), uses typedef'd structs and enums, and has Doxygen comments throughout. Adds .clang-tidy, .clangd and a Doxyfile.
* zash: scripting core, test suite and benchmarksSean Kurtz2026-11-121-0/+113
A clean-slate POSIX shell for z/OS UNIX in the Almquist tradition, written in C23 for Clang (Linux) and IBM Open XL C/C++ (z/OS). - Parser, expansion, arithmetic, redirection, traps and builtins. - Spawn-first execution: fd plans instead of fork+dup2, in-shell pure builtins for pipelines and command substitution, $(a | b) without a subshell. - Flat .POSIX Makefile; asan, valgrind, bench, compdb and z/OS targets. - Tests: posix (dash-generated), zash, process accounting, linux, zos. Nothing has been compiled or run on z/OS yet.