A question about OPEN

Anything QL Software or Programming Related.
Martin_Head
Gold Card
Posts: 418
Joined: Tue Dec 17, 2013 1:17 pm

A question about OPEN

Postby Martin_Head » Sun Apr 14, 2019 10:29 am

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?


User avatar
pjw
Super Gold Card
Posts: 526
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Postby pjw » Sun Apr 14, 2019 12:09 pm

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..


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
Peter
Aurora
Posts: 846
Joined: Sat Jan 22, 2011 8:47 am

Re: A question about OPEN

Postby Peter » Sun Apr 14, 2019 5:44 pm

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


Martin_Head
Gold Card
Posts: 418
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Postby Martin_Head » Mon Apr 15, 2019 11:25 am

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.


User avatar
pjw
Super Gold Card
Posts: 526
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Postby pjw » Mon Apr 15, 2019 12:53 pm

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.


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
janbredenbeek
Gold Card
Posts: 332
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: A question about OPEN

Postby janbredenbeek » Mon Apr 15, 2019 1:54 pm

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.


User avatar
NormanDunbar
Super Gold Card
Posts: 730
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: A question about OPEN

Postby NormanDunbar » Mon Apr 15, 2019 8:36 pm

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.


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
Martin_Head
Gold Card
Posts: 418
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Postby Martin_Head » Tue Apr 16, 2019 10:33 am

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.


Martin_Head
Gold Card
Posts: 418
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Postby Martin_Head » Tue Apr 16, 2019 10:48 am

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.


User avatar
pjw
Super Gold Card
Posts: 526
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Postby pjw » Tue Apr 16, 2019 4:12 pm

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.


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb

Who is online

Users browsing this forum: No registered users and 7 guests