From: mckinneyj@cpva.saic.com Sent: Thursday, October 16, 2003 10:16 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: Convert C file descriptor to VMS channel number In article , mckinneyj@cpva.saic.com writes: > In article <3f86c4a8$1@cpns1.saic.com>, > Mark Berryman writes: >> I am in the process of making a program written for Unix available on >> VMS. As part of this, I need to write the VMS version of some IOCTL >> calls. I'm not allowed to touch what the Unix code hands me (which is >> an Integer File Descriptor from an open call), nor would modifying the >> open call be practical since it is all the calls to IOCTL that would >> need to change, not the result of the open. >> >> On Unix, all IOCTL functions use a file descriptor. On VMS, the >> functions I need to issue are QIO based and need a channel number. How >> can I find the channel associcated with the FD? >> >> Mark Berryman >> >> P.S. DECC$GET_SDC is not a viable answer. That only works on sockets >> and I am working with other types of devices (e.g., CDROM, DVD, etc.). >> > > I haven't tested any of this but it may work for you Mark... > > From the FD you can get the FAB, check out the following URL (it's > wrapped so you'll have to paste the lines together) where David Murphy > provides an example of how to locate all the RMS blocks given a C FD. > > http://groups.google.com/groups? > hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=dpm.867095187%40access4 > > Then, given the FAB you can check the value stored in FAB$L_STV. A > successful $CREATE or a $OPEN will store the IO channel number here. So, > if the CRTL is using these RMS services and the values haven't been > disturbed you should find the channel number there. Hope this helps. > I was curious about this and so did a bit of testing. The fab$l_stv does contain the channel; however, the fab$m_ufo bit is not set in the fab$l_fop field so the channel is assigned in RMS' exec mode and is unavailable for use by any user mode code. -- - Jim