SCSI Pass-Through Programmer's Guide

device file name is made up using the prefix “/dev/tm_diag” followed by the device path. As
paths almost always include a forward slash “/” which has special meaning for the file
system, all the “/” are first converted to “_” (under bar) to produce a more “usable” name.
For example a path of “10/4/4.12.0” becomes “10_4_4.12.0” and so the device file will be
named “/dev/tm_diag10_4_4.12.0. The device file is then created via the following call:
mknod (file_name, S_IFCHR, makedev (0, query_minor_num));
The constant S_IFCHR specifies a character device file type; The Major number is set to
zero. Query_minor_num should contain the value returned by io_query; this is a 24bit
version of the DM port number; see ‘Deriving the mknod() “minor number” using io_query ‘
below for further discussion.
This mknod can be done against any path/ldev configured with one of the following SCSI
DMs: scsi_disc_dm, scsi_disk_and_and_array_dm, scsi_tape_dm, scsi_tape2_dm,
mo_scsi_pthru_dm. Device configuration is discussed in detail in later in this document in
the section titled: ”Device Configuration using SYSGEN” .
Deriving the mknod() “minor number” using io_query
As mentioned above, the physical path of a device must be known in order to supply
information for the call to mknod(). An enhancement to MPE/iX provides a new user callable
interface that returns the physical path of a device given its logical device number (LDEV).
This routine is described in detail in the section of this document titled: “LDEV number to
I/O path Conversion.”
To call mknod(), the physical path (in the form of a character array) should first be verified
by io_str_to_hw_path(). This routine scans the MPE/iX “io tree” structure for the path
specified, checks that it exists and then encodes the path to an internal type. This encoded
path value is referenced by the device_ptr which is next used by io_search to return a
“token” for accessing the device path.
(void) io_str_to_hw_path (path_ptr, device_ptr);
io_search is then called to get the “token” for our path using the device_ptr returned from
io_str_to_hw_path:
token = 0; /* start at "root" of io tree */
token = io_search ( token, S_IOTREE, 0, "hw_path", device_ptr);
Finally, given this token, we can get the information needed to actually create the device file,
the “minor number”, from io_query.
(void) io_query (token, S_IOTREE, "minor_num", &query_minor_num);
- 7 -