Page 1 of 2

A question about OPEN

Posted: Sun Apr 14, 2019 10:29 am
by Martin_Head
I'm working on a directory device driver project that needs to know the job ID of of the caller when the the drivers OPEN routine is called.

When the open routine is entered, the channel definition block does not yet have CH_OWNER at $08 set. I assume this gets done by the operating system after the open routine has finished.

Does anyone know of a way of finding out the callers job ID while you are in the open routine?

Re: A question about OPEN

Posted: Sun Apr 14, 2019 12:09 pm
by pjw
On entry to the ioa.open call the job ID could very well be in d1. I know it doesnt say so in the documentation, but that could just be an omission..

Re: A question about OPEN

Posted: Sun Apr 14, 2019 5:44 pm
by Peter
Hi Martin,
I use the "get system information" trap for that.
Peter

Code: Select all

MT.INF      equ     0
            moveq   #MT.INF,d0
            trap    #1              ; Get current job ID in d1

Re: A question about OPEN

Posted: Mon Apr 15, 2019 11:25 am
by Martin_Head
pjw wrote:On entry to the ioa.open call the job ID could very well be in d1. I know it doesnt say so in the documentation, but that could just be an omission..

I had a look in the SMSQ/E sources and it looks like D1 should be the job ID. A quick look in Minerva and JS, also looks like D1 should be the job ID. But I have not had a chance to actually try it yet.

Re: A question about OPEN

Posted: Mon Apr 15, 2019 12:53 pm
by pjw
It would seem like a lost opportunity otherwise, as the job ID is required to call the open routine.. Either way, it would be good to get confirmation as, if correct, this should be nailed into the documentation.

Re: A question about OPEN

Posted: Mon Apr 15, 2019 1:54 pm
by janbredenbeek
Martin_Head wrote:I had a look in the SMSQ/E sources and it looks like D1 should be the job ID. A quick look in Minerva and JS, also looks like D1 should be the job ID. But I have not had a chance to actually try it yet.

I don't know why you need a job id for a system-level I/O open, but if you need the id of the current job (which may not be the same as the one given in D1), you can find it by picking up SV_JBPNT(A6), subtracting SV_JBBAS(A6) from it and dividing this by 4 which gives the low word of the job id. The high word (job tag) can be found by picking up JB_TAG from the current job's header. Something like:

Code: Select all

   move.l    $64(a6),a0   ; current job's header
   move.w    $10(a0),d1   ; job tag
   swap    d1         ; goes to high word in D1
   sub.l      $68(a6),a0   ; offset of table entry
   move.w   a0,d1      ; goes to low word in D1
   lsr.w      #2,d1      ; divide by 4


Jan.

Re: A question about OPEN

Posted: Mon Apr 15, 2019 8:36 pm
by NormanDunbar
Am I missing something here? I wouldn't be surprised, it happens. ;)

Over at http://qdosmsq.dunbar-it.co.uk/doku.php ... rap_2:open I see that D1 has to be the job id for the owner of the file being opened. You can pass -1 to have the current job own the file.

I assume, always a bad idea, that the owning job id is needed to allow tidying up if the job dies, or is killed, or simply finishes, without closing its open files.

Now, what am I missing, I wonder....

Cheers,
Norm.

Re: A question about OPEN

Posted: Tue Apr 16, 2019 10:33 am
by Martin_Head
pjw wrote:It would seem like a lost opportunity otherwise, as the job ID is required to call the open routine.. Either way, it would be good to get confirmation as, if correct, this should be nailed into the documentation.
I tried it in QPC2, and D1 is not the job ID.

I expected that 'smsq\ioa\open_asm' was the open routine. But I think 'smsq\ioa\opfl_asm' may be. Not too sure as the code in QPC2 does not exactly match my (rather old) copy of the SMSQ/E sources, but it was the closest I could find.

I forgot to consider in my question that the calling job may be opening the channel for another job.

But I think for the moment that I may use the MT_INF method. It's not ideal but will do for testing.

Re: A question about OPEN

Posted: Tue Apr 16, 2019 10:48 am
by Martin_Head
janbredenbeek wrote:I don't know why you need a job id for a system-level I/O open,


The job contains a pointer to a string, which I want the open routine to add to the supplied file name.

I am tinkering with a file system that supports long file names, but maintains compatibility with the operating system and existing software by adding a path to the start of the file name that is 'invisible' to the system and programs.

Re: A question about OPEN

Posted: Tue Apr 16, 2019 4:12 pm
by pjw
Do you mean sort of "anchoring" a virtual device off some point in the file system, like QPC's DOS device? In theory, I think something like that could work.

Are you aware of QVFS by HPR? His device driver doesnt use the directory device driver system (at least not directly). Its years since I played with it, so cant really remember what the issues are - ie why I dont use it today.