To make building easier an automated script autobuild.py was developed.
It relies on the python automvs library. A docker build file has been created
which automates all the steps below.
To use it you can run the following commands from the root folder of this repo:
- First build the FTPD XMI and install files:
docker build --tag ftpd:builder . - Then mount the local folder inside the docker container:
docker run -it --entrypoint /bin/bash -v $(pwd):/project ftpd:builder - Once inside the container copy the files to
/project:cp * /project
FTPD/source/build/ folder.
Make sure you're running the latest SDL Hyperion and have enabled HERC_TCPIP_EXTENSION and HERC_TCPIP_PROB_STATE before you IPL
Place the following at the top of an RC file and launch hercules with: hercules -r tcpip.rc
facility enable HERC_TCPIP_EXTENSION
facility enable HERC_TCPIP_PROB_STATE
Note: You do not need to do this if you are running MVS/CE.
If you are using MVS/CE building requires the MACLIBS package. Install with the TSO command RX MVP INSTALL MACLIBS.
- Get JCC:
git clone https://github.com/mvslovers/jcc.git - Get rdrprep:
git clone https://github.com/mvslovers/rdrprep.git- Install rdrprep with
makeandsudo make install
- Install rdrprep with
- Generate new JCL to assemble the FTP hlasm programs:
python3 generate_ftpdrakf.py ../hlasm- This will generate the file
assemble_ftprakf.jclwhich assembles all asm programs in hlasm - When we submit this job we it will output to the punch card writer
- This step also assembles FTPDXCTL and places it in
SYS2.LINKLIB
- This will generate the file
- Change the punch output file and folder by typing the following on the hercules console
detach dand enter followed byattach d 3525 /path/to/FTPD/source/build/ftpdrakf.punch ebcdic - Then submit
assemble_ftprakf.jclto the socket readercat assemble_ftprakf.jcl | ncat --send-only -w1 127.0.0.1 3505- Each step should complete with
00000. - When you see
/ $HASP150 MAKEFTPD ON PUNCH1 34 CARDSin the hercules console type:/$s punch1, this will place the assembled binary in/path/to/FTPD/source/build/ftpdrakf.punch
- Each step should complete with
- Detach the punch card now in the hercules console:
detach d - The punch writter as configured adds a seperator to the beginning and ends of files. To remove the
ftpdrakf.punchheader and footer you can use either of the following linux commands:dd if=ftpdrakf.punch bs=1 skip=160 count=2720 of=ftpdrac.pch(wherecount=is the size offtpdrakf.punchin bytes minus 240)tail -c +161 ftpdrakf.punch |head -c -80 > ftpdrac.pch
- Use
objscanfrom jcc to replace HLASM names:./jcc/objscan ftpdrakf.punch objscan_input.nam ftpdrac.obj- This command replaced the labels/names in ASM like
FTPLOGINwithrac_user_loginwhich is used inftpd.c - This step creates
ftpdrac.obj
- This command replaced the labels/names in ASM like
- Compile
ftpd.cwith jcc:./jcc/jcc -I./jcc/include -I../c -D__MVS_ -o -list=list.out ../c/ftpd.c- It should complete with
JCC-RC:0 - This will create the file
ftpd.obj - ❗ To enable debug output (which prints to SYSTOUT) add
-D__DEBUG__to the command above after-D__MVS_
- It should complete with
- Use
prelinkto link the object:./jcc/prelink -r jcc/objs ftpd.load ftpd.obj ftpdrac.obj- It should completed with
PLK-RC:0 - This creates
ftpd.loadwhich is our assembled program ready to link in MVS
- It should completed with
- Generate an EBCDIC JCL file with the
ftpd.loadinside:rdrprep link_ftpd.template- This will create the file
reader.jcl
- This will create the file
- Submit this job which will link and place
FTPDinSYS2.LINKLIB:cat reader.jcl | ncat --send-only -w1 localhost 3506- The
LINKFTPDstep should complete with00000.
- The
- Generate and submit the install JCL which finalizes the install:
python3 generate_install.py ../../FTPD.conf && cat install.jcl | ncat --send-only -w1 127.0.0.1 3505- You should only do this last step once, you wont need to do it again
Congratulations, you compiled FTPD from scratch!
Going forward if you only edit ftpd.c/mvsdirs.h you only need to do the bottom 4 steps!
Place the following JCL in SYS2.PROCLIB(FTDDEV) and run from the hercules console with /s ftpddev (it can be stopped with /p ftpddev):
//FTPDDEV PROC
//********************************************************************
//*
//* MVS3.8j RAKF Enabled FTP server PROC
//* To use: in Hercules console issue /s FTPDDEV to start FTP server
//* on the port configure in SYS1.PARMLIB(FTPDPM00)
//*
//********************************************************************
//FTPD EXEC PGM=FTPDXCTL,TIME=1440,REGION=8192K,
// PARM='DD=AAINTRDR'
//AAINTRDR DD SYSOUT=(A,INTRDR),DCB=(RECFM=FB,LRECL=80,BLKSIZE=80)
//STDOUT DD SYSOUT=*