Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ee14ed
Integrate from datasetio. Modify open and close syscall
sachintu47 Feb 4, 2026
1f81165
Add write, read, mkstemp for dataset
sachintu47 Feb 4, 2026
69885a0
fopen override
sachintu47 Feb 5, 2026
d8f3bfc
lseek override
sachintu47 Feb 5, 2026
cad67d2
Add default unix fds to database
sachintu47 Feb 9, 2026
353de87
override stat, fstat
sachintu47 Feb 10, 2026
97bf2b5
Fix fseek and filesize
sachintu47 Feb 16, 2026
6100fb8
refactor datasetentry structure
sachintu47 Feb 25, 2026
3064bbe
feat(dsio): implement robust stream emulation for z/OS datasets
sachintu47 Mar 16, 2026
0db5380
fixes
sachintu47 Mar 16, 2026
2087f63
Implement unique st_dev/st_ino generation for datasets in fstat_datas…
sachintu47 Mar 17, 2026
dd0c148
fix dataset record alignment
sachintu47 Mar 17, 2026
50c873b
refactor: replace DEBUG_PRINT macros with conditional DSIO_LOG_* macr…
sachintu47 Mar 25, 2026
8663b08
refactor: remove ISPF implementation (deferred to future phase)
sachintu47 Mar 25, 2026
a7e990b
cleanup dataset I/O logging and remove incomplete features
sachintu47 Mar 25, 2026
6e58f6c
complete error handling API with DSIO-to-errno mapping
sachintu47 Mar 25, 2026
2c600ab
fix: resolve dataset I/O hang by clearing EOF on lseek and refactorin…
sachintu47 Mar 30, 2026
770bfb6
clean up unused
sachintu47 Mar 31, 2026
1175ca2
feat: add dynamic and compile-time toggles for dataset support
sachintu47 Mar 31, 2026
03edcb0
build: add ZOSLIB_ENABLE_DATASETIO configuration option
sachintu47 Mar 31, 2026
1b19b80
fix(datasetio): avoid fseek(SEEK_END) on VB/U record-mode files in fs…
sachintu47 Mar 31, 2026
2764606
augment review fixes
sachintu47 Apr 20, 2026
df5d89a
Resolved Potential Data Loss on Seek
sachintu47 Apr 27, 2026
a5e5cfe
fix: add thread safety and prevent memory leaks in dataset I/O
sachintu47 Apr 28, 2026
d1bab12
feat: enable dataset I/O support by default
sachintu47 Apr 28, 2026
4a29b17
Add documentation for ZOSLIB_DATASET_SUPPORT environment variable
sachintu47 Apr 28, 2026
6667c6a
refactor: simplify dataset I/O implementation
sachintu47 Apr 28, 2026
6bff782
refactor: remove ZOSLIB_ENABLE_DATASETIO build-time conditional
sachintu47 Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ if(ZOSLIB_QUICK_STARTUP)
ZOSLIB_QUICK_STARTUP)
endif()

# Dataset I/O is always compiled in, controlled by ZOSLIB_DATASET_SUPPORT env var at runtime
list(APPEND zoslib_defines
ZOSLIB_ENABLE_DATASETIO=1)

if(DEFINED ENV{BUILD_VERSION})
list(APPEND zoslib_defines BUILD_VERSION="$ENV{BUILD_VERSION}")
endif()
Expand Down
9 changes: 7 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $0
Builds zoslib, uses xlclang/xlclang++ by default, unless CC is set.
Options:
-c Clean build
-d Enable dataset I/O support (default is Disabled)
-h Display this message
-r Release build (default is Debug)
-t Build and run tests
Expand All @@ -26,18 +27,22 @@ BLD_TYPE="Debug"
IS_CLEAN=0
RUN_TESTS="OFF"
BLD_TESTS=
BLD_DSIO=

if test -z "$CC"; then
export CC=xlclang && export CXX=xlclang++ && export LINK=xlclang++
IS_CLEAN=1
fi

nargs=0
while getopts "chrt" o; do
while getopts "cdhrt" o; do
case "${o}" in
c) IS_CLEAN=1
((nargs++))
;;
d) BLD_DSIO="-DZOSLIB_ENABLE_DATASETIO=ON"
((nargs++))
;;
r) BLD_TYPE="Release"
((nargs++))
;;
Expand Down Expand Up @@ -65,7 +70,7 @@ pushd build
export MAKEFLAGS='-j4'

if((IS_CLEAN==1)) || ! test -s CMakeCache.txt; then
cmake .. -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_ASM_COMPILER=${CC} ${BLD_TESTS} -DCMAKE_BUILD_TYPE=${BLD_TYPE} -DCMAKE_INSTALL_PREFIX=${SCRIPT_DIR}/install
cmake .. -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_ASM_COMPILER=${CC} ${BLD_TESTS} ${BLD_DSIO} -DCMAKE_BUILD_TYPE=${BLD_TYPE} -DCMAKE_INSTALL_PREFIX=${SCRIPT_DIR}/install
fi
cmake --build . --target install

Expand Down
3 changes: 2 additions & 1 deletion include/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
/**
* Same as C open but tags new files as ASCII (819)
*/
__Z_EXPORT extern int __open_ds_file(const char *filename, int opts, ...);
__Z_EXPORT extern int __open_ascii(const char *filename, int opts, ...);
__Z_EXPORT extern int __creat_ascii(const char *filename, mode_t mode);
#if defined(__cplusplus)
Expand All @@ -38,7 +39,7 @@ __Z_EXPORT extern int __creat_ascii(const char *filename, mode_t mode);
extern "C" {
#endif

__Z_EXPORT extern int open(const char *filename, int opts, ...) __asm("__open_ascii");
__Z_EXPORT extern int open(const char *filename, int opts, ...) __asm("__open_ds_file");
__Z_EXPORT extern int creat(const char *filename, mode_t mode) __asm("__creat_ascii");

#if defined(__cplusplus)
Expand Down
3 changes: 2 additions & 1 deletion include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern "C" {
* Same as C open but tags new files as ASCII (819)
*/
__Z_EXPORT extern FILE *__fopen_ascii(const char *filename, const char *mode);
__Z_EXPORT extern FILE *__fopen_ds_file(const char *filename, const char *mode);

#if defined(__cplusplus)
}
Expand All @@ -37,7 +38,7 @@ __Z_EXPORT extern FILE *__fopen_ascii(const char *filename, const char *mode);
extern "C" {
#endif

__Z_EXPORT extern FILE *fopen(const char *filename, const char *mode) __asm("__fopen_ascii");
__Z_EXPORT extern FILE *fopen(const char *filename, const char *mode) __asm("__fopen_ds_file");
__Z_EXPORT ssize_t getline(char **lineptr, size_t *n, FILE *stream);
__Z_EXPORT ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream);
__Z_EXPORT int vasprintf(char **strp, const char *fmt, va_list ap);
Expand Down
3 changes: 2 additions & 1 deletion include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C" {
__Z_EXPORT char *__realpath_extended(const char * __restrict__, char * __restrict__);
#ifdef __NATIVE_ASCII_F
__Z_EXPORT int __mkstemp_ascii(char*);
__Z_EXPORT int __mkstemp_ds_file(char*);
#endif
#if defined(__cplusplus)
}
Expand Down Expand Up @@ -82,7 +83,7 @@ __Z_EXPORT void free(void* ptr) __THROW __asm("__zoslib_free") ;
* Same as C mkstemp but tags fd as ASCII (819)
*/
#undef mkstemp
__Z_EXPORT int mkstemp(char*) __asm("__mkstemp_ascii");
__Z_EXPORT int mkstemp(char*) __asm("__mkstemp_ds_file");
#endif /* __NATIVE_ASCII_F */

#if defined(__cplusplus)
Expand Down
10 changes: 10 additions & 0 deletions include/sys/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern "C" {
* Same as C mkfifo but tags FIFO special files as ASCII (819)
*/
__Z_EXPORT extern int __mkfifo_ascii(const char *pathname, mode_t mode);
__Z_EXPORT extern int __stat_ds_file(const char *path, struct stat *buf);
__Z_EXPORT extern int __fstat_ds_file(int fd, struct stat *buf);

#if defined(__cplusplus)
}
Expand All @@ -29,14 +31,22 @@ __Z_EXPORT extern int __mkfifo_ascii(const char *pathname, mode_t mode);

#undef mkfifo
#define mkfifo __mkfifo_replaced
#undef stat
#define stat(x,y) __stat_replaced(x,y)
#undef fstat
#define fstat(x,y) __fstat_replaced(x,y)
#include_next <sys/stat.h>
#undef mkfifo
#undef stat
#undef fstat

#if defined(__cplusplus)
extern "C" {
#endif

__Z_EXPORT extern int mkfifo(const char *pathname, mode_t mode) __asm("__mkfifo_ascii");
__Z_EXPORT extern int stat(const char *path, struct stat *buf) __asm("__stat_ds_file");
__Z_EXPORT extern int fstat(int fd, struct stat *buf) __asm("__fstat_ds_file");

#if defined(__cplusplus)
}
Expand Down
18 changes: 16 additions & 2 deletions include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
#define ZOS_UNISTD_H_

#include "zos-macros.h"
#include <sys/types.h>

#if defined(__cplusplus)
extern "C" {
#endif
__Z_EXPORT int __pipe_ascii(int [2]);
__Z_EXPORT int __close(int);
__Z_EXPORT int __sysconf(int name);
__Z_EXPORT ssize_t __write_ds_file(int fd, const void *buf, size_t count);
__Z_EXPORT ssize_t __read_ds_file(int fd, void *buf, size_t count);
__Z_EXPORT off_t __lseek_ds_file(int fd, off_t offset, int whence);

#if defined(__cplusplus)
}
Expand All @@ -32,11 +36,20 @@ __Z_EXPORT int __sysconf(int name);
#define sysconf __sysconf_replaced
#undef readlink
#define readlink __readlink_replaced
#undef write
#define write __write_replaced
#undef read
#define read __read_replaced
#undef lseek
#define lseek __lseek_replaced
#include_next <unistd.h>
#undef pipe
#undef close
#undef sysconf
#undef readlink
#undef write
#undef read
#undef lseek

#if defined(__cplusplus)
extern "C" {
Expand All @@ -46,10 +59,11 @@ extern "C" {
*/
__Z_EXPORT int pipe(int [2]) __asm("__pipe_ascii");
__Z_EXPORT int close(int) __asm("__close");
__Z_EXPORT int close(int) __asm("__close");
__Z_EXPORT int sysconf(int name) __asm("__sysconf");
__Z_EXPORT ssize_t readlink(const char *path, char *buf, size_t bufsiz) __asm("__readlink");

__Z_EXPORT ssize_t write(int fd, const void *buf, size_t count) __asm("__write_ds_file");
__Z_EXPORT ssize_t read(int fd, void *buf, size_t count) __asm("__read_ds_file");
__Z_EXPORT off_t lseek(int fd, off_t offset, int whence) __asm("__lseek_ds_file");
Comment thread
sachintu47 marked this conversation as resolved.

#if defined(__cplusplus)
}
Expand Down
21 changes: 21 additions & 0 deletions include/zos-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern "builtin" void *_gdsa();
#define MEMORY_USAGE_LOG_FILE_ENVAR_DEFAULT "__MEMORY_USAGE_LOG_FILE"
#define MEMORY_USAGE_LOG_LEVEL_ENVAR_DEFAULT "__MEMORY_USAGE_LOG_LEVEL"
#define MEMORY_USAGE_LOG_INC_ENVAR_DEFAULT "__MEMORY_USAGE_LOG_INC"
#define DATASET_SUPPORT_ENVAR_DEFAULT "ZOSLIB_DATASET_SUPPORT"

typedef enum {
__NO_TAG_READ_DEFAULT = 0,
Expand All @@ -74,6 +75,11 @@ typedef enum {
__NO_TAG_READ_STRICT = 3
} notagread_t;

typedef enum {
DS_SUPPORT_YES = 0,
DS_SUPPORT_NO = 1
} ds_support_mode_t;

struct timespec;

extern const char *__zoslib_version;
Expand Down Expand Up @@ -506,6 +512,10 @@ typedef struct __Z_EXPORT zoslib_config {
* allocated, in bytes, after which logging occurs.
*/
const char *MEMORY_USAGE_LOG_INC_ENVAR = MEMORY_USAGE_LOG_INC_ENVAR_DEFAULT;
/**
* String to indicate the envar to be used to toggle the dataset support mode.
*/
const char *DATASET_SUPPORT_ENVAR = DATASET_SUPPORT_ENVAR_DEFAULT;

} zoslib_config_t;

Expand Down Expand Up @@ -553,6 +563,15 @@ typedef struct __Z_EXPORT zoslib_config {
* to display when memory is allocated or freed.
*/
const char *MEMORY_USAGE_LOG_LEVEL_ENVAR;
/**
* String to indicate the envar to be used to specify the increase in memory
* allocated, in bytes, after which logging occurs.
*/
const char *MEMORY_USAGE_LOG_INC_ENVAR;
/**
* String to indicate the envar to be used to toggle the dataset support mode.
*/
const char *DATASET_SUPPORT_ENVAR;
} zoslib_config_t;

/**
Expand Down Expand Up @@ -667,6 +686,7 @@ struct zoslibEnvar {
class __zinit {
int mode;
int cvstate;
ds_support_mode_t ds_support_mode;
std::terminate_handler _th;

public:
Expand All @@ -678,6 +698,7 @@ class __zinit {
~__zinit();

int initialize(const zoslib_config_t &config);
ds_support_mode_t get_ds_support_mode(void) const { return ds_support_mode; }
bool isValidZOSLIBEnvar(std::string envar);
int setEnvarHelpMap(void);
void populateLEFunctionPointers(void);
Expand Down
Loading
Loading