This REXX program uses mount to mount
a file system, an action that requires superuser authority. The name
of this program is mountx and it is in /samples.
The syntax is:
mountx pathname fsn options
where
pathname is
the name of the directory where the file system is to be mounted,
and
fsn is the name of the HFS data set.
The
options are:
- -p parm
- Parameter data, in the form of a single string.
- -r
- Mount file system as read-only.
- -t type
- File system type. The default file system type to HFS. If the
file system type is HFS, the program changes the file system name
to uppercase.
The path name and the file system name can be specified
in any order.
stat is used to determine
which name is the path name.
For the getopts function called in this
program, see Parse arguments passed to a REXX program: the getopts function.
/* rexx */
/**********************************************************************/
/* Determine which options were specified. */
/**********************************************************************/
lcp='p'
lcr='r'
lct='t'
ix=getopts('r','pt')
/**********************************************************************/
/* If -r specified, mount file system read-only. */
/**********************************************************************/
if opt.lcr<>' then
mtm=mtm_rdonly
else
mtm=mtm_rdwr
/**********************************************************************/
/* If -t 'name' specified, direct mount request to file system 'name'.*/
/* Otherwise, direct mount request to file system named HFS. */
/**********************************************************************/
if opt.lct<>' then
type=translate(opt.lct)
else
type='HFS'
/**********************************************************************/
/* Complain if required parameters are missing. */
/**********************************************************************/
if __argv.0<>ix+1 then
do
say 'Pathname and file system name are required, and '
say 'they must follow the options: MOUNT <options> <pathname> <fsn>'
return 1
end
/**********************************************************************/
/* Direct function calls to REXX z/OS UNIX services. */
/**********************************************************************/
address syscall
/**********************************************************************/
/* Determine which of the parameters is the mount point name */
/* (it must be a pathname), and which is the file system to be */
/* mounted. */
/**********************************************************************/
'stat (__argv.ix) st.'
if st.st_type<>s_isdir then
do
fsn=__argv.ix
ix=ix+1
path=__argv.ix
end
else
do
path=__argv.ix
ix=ix+1
fsn=__argv.ix
end
'stat (path) st.'
if st.st_type<>s_isdir then
do
say "Can't figure out pathname, neither name is a directory:"
say path
say fsn
return 1
end
/**********************************************************************/
/* HFS file system requires mounted file systems to be data sets, */
/* so translate the file system name to upper case. */
/**********************************************************************/
if type='HFS' then
fsn=translate(fsn)
/**********************************************************************/
/* Mount the file system. */
/* Return code Return code Meaning */
/* from system to caller */
/* 0 0 Success, file system now mounted */
/* 1 2 Success, file system mount in progress */
/* -1 1 Error, explained by ERRNO and reason code*/
/**********************************************************************/
"mount (path) (fsn) (type) (mtm) (opt.lcp)"
select
when retval= 0 then
do
say fsn 'is now mounted at'
say path
return 0
end
when retval= 1 then
do
say fsn 'will be mounted asynchronously at'
say path
return 2
end
otherwise
do
say 'Mount failed:'
say ' Error number was' errno'x('x2d(errno)')'
say ' Reason code was ' right(errnojr,8,0)
return 1
end
end