Introduction
Among all the developments we are currently witnessing in z/OS, dsfs stands out as my favorite. The reasons are straightforward. dsfs provides a simple and transparent interface between traditional MVS files and Unix processes.
In recent days, I’ve been experimenting with the Advent of Code 2023. During this time, I’ve performed some interesting tasks using dsfs, which I’d like to describe here:
(Note: Not every use case might make perfect sense, but I aim to demonstrate the power of dsfs when combined with other standard tools.)
Notation of dsfs Calls
The dsfs call typically looks like this:
/dsfs/[bin or txt]/[HLQ of the Data Sets]/[ALL].[OTHER].[QUALIFIERS]/[MEMBERNAME]
For the examples, I will use the Userid: LMMB
Detailed information about dsfs can be found here: Data Set File System (DSFS) – IBM Documentation.
Use Cases
Viewing a Mainframe File Over SSH
A common use case is to view a Mainframe Data set. This has never been easier:
ssh LMMB@HOST-IP 'cat /dsfs/txt/LMMB/test.cobol/hellouss'
Just one line to display a member from a PDS/E from my distributed system or workstation.
Search for a String in all members of a PDS:
find /dsfs/txt/LMMB/test.cobol | xargs grep "TEST"
*At the time of writing, I did not have access to a grep -r in Unix System Services.
Editing a Mainframe File
In the same way, these files can be edited:
Appending “things”:
echo "append this" >> /dsfs/txt/LMMB/test.cobol/hellouss
Editing files using vi (or better):
vi /dsfs/txt/LMMB/test.cobol/hellouss
Compiling a USS File:
Compiling a cobol file located in the USS so that it lands in a load library:
cob2 hellouss.cbl -o /dsfs/bin/LMMB/test.load/hellouss
Executing a Load Module
To execute the file:
/dsfs/bin/LMMB/test.load/hellouss
And it runs.
Including a Debugger:
If we want to debug the file and it requires input through ACCEPT:
_CEE_RUNOPTS="TEST(ERROR,'',PROMPT,'DBMDT%LMMB:')" /dsfs/bin/LMMB/test.load/hellouss < ~/input.txt
Bonus Round: DD Allocation in USS
If the cobol file reads its input through FILE-CONTROL:
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO 'INPUT01'
ORGANIZATION IS LINE SEQUENTIAL.
…and you want to run this program under USS, you can declare INPUT01 like this:
export INPUT01='PATH(/u/lmmb/input.txt)'
…and then run the program.
Summary
The scenarios described above are merely a glimpse of what dsfs in z/OS is capable of. The true strength of dsfs lies in its ability to bridge the gap between Unix programs and traditional MVS Data Sets. With dsfs, we are now able to seamlessly employ Unix-based applications and tools to directly and transparently access MVS Data Sets. This integration unlocks a myriad of possibilities that extend far beyond the use cases presented here. Whether it’s complex data processing, automated workflows, or innovative solutions to traditional challenges, dsfs expands the realm of what’s possible in mainframe data management.