Summary
Uploading binary data to a DSORG=DA (Direct Access) dataset via PUT causes an SD37 ABEND because mvsMF writes sequentially via QSAM/PUT. DSORG=DA datasets require BDAM I/O (WRITE with relative block address), not sequential access.
How to reproduce
//ALCROOT JOB (1),'ALLOC ROOT',CLASS=A,MSGCLASS=H
//ALLOC EXEC PGM=IEFBR14
//DISK DD DSN=IBMUSER.UFSD.ROOT,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(4096,(256)),
// DCB=(DSORG=DA,BLKSIZE=4096)
zowe files upload file-to-data-set root.img "IBMUSER.UFSD.ROOT" --binary
Result: SD37 ABEND in @@AWRITE → IFG0554T (DADSM extent routine)
ABEND trace
IEC031I D37-04,IFG0554T,HTTPD,HTTPD,SYS00014,252,WORK01,
IEC031I IBMUSER.UFSD.ROOT
datasetPutHandler → write_record → fwrite → __fwrite → __fputc
→ __fflush → varflush → @@AWRITE → @@ATROUT → SD37 ABEND
Root cause
datasetPutHandler uses fopen(dsname, "wb") which sets up QSAM sequential access. For DSORG=DA, MVS requires BDAM I/O with relative block addressing. When QSAM tries to extend past the primary allocation on a DA dataset, the EOV routine (IFG0554T) issues D37-04.
What needs to be done
datasetPutHandler should detect DSORG=DA from the DSCB (already available via is_pds() pattern) and switch to BDAM I/O for writing:
- Detect DSORG=DA: Read
dscb1.dsorg1 & DSGDA (already done in dataset list handler)
- Use BDAM API: crent370 provides the full BDAM API in
<osio.h>:
osddcb(ddname) — allocate DCB for BDAM access by relative block number
osdopen(dcb, typej) — open for UPDATE (read+write)
osdwrite(decb, dcb, buf, length, block) — write one block by relative block number
osdclose(dcb, freedcb) — close BDAM DCB
- Write logic: Split incoming binary data into
blksize-sized blocks and write each at sequential block numbers (0, 1, 2, ...)
Affected handlers
datasetPutHandler — primary target
datasetGetHandler — should also use BDAM for reading DSORG=DA datasets (with osdread)
Context
This is needed for ufsd (UFS370 filesystem daemon) which stores its root filesystem image in a DSORG=DA dataset.
Summary
Uploading binary data to a DSORG=DA (Direct Access) dataset via PUT causes an SD37 ABEND because mvsMF writes sequentially via QSAM/PUT. DSORG=DA datasets require BDAM I/O (WRITE with relative block address), not sequential access.
How to reproduce
zowe files upload file-to-data-set root.img "IBMUSER.UFSD.ROOT" --binaryResult: SD37 ABEND in
@@AWRITE→IFG0554T(DADSM extent routine)ABEND trace
Root cause
datasetPutHandlerusesfopen(dsname, "wb")which sets up QSAM sequential access. For DSORG=DA, MVS requires BDAM I/O with relative block addressing. When QSAM tries to extend past the primary allocation on a DA dataset, the EOV routine (IFG0554T) issues D37-04.What needs to be done
datasetPutHandlershould detect DSORG=DA from the DSCB (already available viais_pds()pattern) and switch to BDAM I/O for writing:dscb1.dsorg1 & DSGDA(already done in dataset list handler)<osio.h>:osddcb(ddname)— allocate DCB for BDAM access by relative block numberosdopen(dcb, typej)— open for UPDATE (read+write)osdwrite(decb, dcb, buf, length, block)— write one block by relative block numberosdclose(dcb, freedcb)— close BDAM DCBblksize-sized blocks and write each at sequential block numbers (0, 1, 2, ...)Affected handlers
datasetPutHandler— primary targetdatasetGetHandler— should also use BDAM for reading DSORG=DA datasets (withosdread)Context
This is needed for ufsd (UFS370 filesystem daemon) which stores its root filesystem image in a DSORG=DA dataset.