Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Attn RT-11 gurus: file protect detection?
@ 1992-02-06 15:44 cepek
  1992-02-07  1:02 ` cepek
  1992-02-07 20:24 ` Attn RT-11 gurus: file protect detection? Jerry Weiss
  0 siblings, 2 replies; 5+ messages in thread
From: cepek @ 1992-02-06 15:44 UTC (permalink / raw)


On RT-11, is there a way to find out if a file is protected (without
having to muddle through the directory itself)?

There don't seem to be any system requests for such a seemingly
simple task; none of these seem to help:  .CSTAT, .DSTATUS, .ENTER,
.LOOKUP, .PURGE, .RENAME, etc.

Note that I don't want to _change_ the protection (that's easy with
.FPROT), I want to find out what it currently is for a file.

In fact, the documentation says that you can do a .LOOKUP on a
file that is protected and then write to it (honest! look up .FPROT).
So how the heck am I supposed to know that I _shouldn't_ change
the file because it is protected?  KEX does it:
   ?KEX-W-Output file or device protected- Inspect (Y,N) ? _

(At this point, I'd even be willing to entertain something undocumented.)

Thanks in advance.

 ,--------------------------------,___________________________
/  Mike Cepek, Sr. Software Eng. / Internet: CEPEK@MGI.COM   /
\  Management Graphics, Inc.     \    Voice: +1 612/851-6112 \ "Engage."
/  1401 East 79th Street         / Operator: +1 612/854-1220 /
\  Minneapolis, MN  55425  USA   \      Fax: +1 612/854-6913 \
 `-------------------------------/___________________________/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Attn RT-11 gurus: file protect detection?
  1992-02-06 15:44 Attn RT-11 gurus: file protect detection? cepek
@ 1992-02-07  1:02 ` cepek
  1992-02-07 18:16   ` Soln: Attn RT-11 gurus: file protect detection cepek
  1992-02-07 20:24 ` Attn RT-11 gurus: file protect detection? Jerry Weiss
  1 sibling, 1 reply; 5+ messages in thread
From: cepek @ 1992-02-07  1:02 UTC (permalink / raw)


In article <1992Feb6.104432.1599@vixvax.mgi.com>, I wrote:
> On RT-11, is there a way to find out if a file is protected (without
> having to muddle through the directory itself)?
:

A few additional notes:

- I have tried opening the file and reading the first block, and then
  writing that block back out.  This *succeeds*, *even*if*the*file*is*
  protected.  Recall that I wrote in my original post:

> In fact, the documentation says that you can do a .LOOKUP on a
> file that is protected and then write to it (honest! look up .FPROT).

- I've worked with this system for 6 years; this is not a novice 
  question (hence my Subject line).  However, I certainly don't claim
  to know everything about the system (just lots and lots :-).

- We are using the DECUS-C run-time library, circa 1985 (with local 
  mods, of course; mostly bug fixes and ANSI-C-ization).

- A valid solution to the problem should not affect the file I am 
  checking the protection on - contents or date stamp.

Thanks again, in advance.

 ,--------------------------------,___________________________
/  Mike Cepek, Sr. Software Eng. / Internet: CEPEK@MGI.COM   /
\  Management Graphics, Inc.     \    Voice: +1 612/851-6112 \ "Engage."
/  1401 East 79th Street         / Operator: +1 612/854-1220 /
\  Minneapolis, MN  55425  USA   \      Fax: +1 612/854-6913 \
 `-------------------------------/___________________________/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Soln: Attn RT-11 gurus: file protect detection
  1992-02-07  1:02 ` cepek
@ 1992-02-07 18:16   ` cepek
  1992-02-13 16:51     ` John M. Crowell
  0 siblings, 1 reply; 5+ messages in thread
From: cepek @ 1992-02-07 18:16 UTC (permalink / raw)


> In article <1992Feb6.104432.1599@vixvax.mgi.com>, I wrote:
> On RT-11, is there a way to find out if a file is protected (without
> having to muddle through the directory itself)?
> :

I've found something that works.  First do a .ENTER for the file.  This
attempts to create a tentative entry in the directory for the (new)
file.  It will fail if a protected file by that name already exists. 
So far so good.

If the file doesn't exist already, or does exist but is not protected,
the .ENTER will succeed (barring other errors).  If this file (channel)
is then closed, the original file will be replaced with the new, empty
one - this would be bad.  So instead free up the channel with a .PURGE
request.  This abandons the tentative directory entry, leaving
everything else alone.  Viola. 

And best of all I can do it from C, by using a recent creation of mine -
a C-callable EMT utility routine for EMT 374 and EMT 375 calls.  Most 
RTLs have them, I know, but they also have a bug which zaps the high-bit 
of the return value for error indication, which screws up quite a few 
I/O requests expecting to be able to return unsigned ints.  (Mine also 
returns the error byte as well as R0).

Fare thee well.

 ,--------------------------------,___________________________
/  Mike Cepek, Sr. Software Eng. / Internet: CEPEK@MGI.COM   /
\  Management Graphics, Inc.     \    Voice: +1 612/851-6112 \ "Make
/  1401 East 79th Street         / Operator: +1 612/854-1220 /  it so."
\  Minneapolis, MN  55425  USA   \      Fax: +1 612/854-6913 \
 `-------------------------------/___________________________/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Attn RT-11 gurus: file protect detection?
  1992-02-06 15:44 Attn RT-11 gurus: file protect detection? cepek
  1992-02-07  1:02 ` cepek
@ 1992-02-07 20:24 ` Jerry Weiss
  1 sibling, 0 replies; 5+ messages in thread
From: Jerry Weiss @ 1992-02-07 20:24 UTC (permalink / raw)


In article <1992Feb6.104432.1599@vixvax.mgi.com> cepek@vixvax.mgi.com writes:
>On RT-11, is there a way to find out if a file is protected (without
>having to muddle through the directory itself)?
>
>There don't seem to be any system requests for such a seemingly
>simple task; none of these seem to help:  .CSTAT, .DSTATUS, .ENTER,
>.LOOKUP, .PURGE, .RENAME, etc.
>
>Note that I don't want to _change_ the protection (that's easy with
>.FPROT), I want to find out what it currently is for a file.
>
>In fact, the documentation says that you can do a .LOOKUP on a
>file that is protected and then write to it (honest! look up .FPROT).
>So how the heck am I supposed to know that I _shouldn't_ change
>the file because it is protected?  KEX does it:
>   ?KEX-W-Output file or device protected- Inspect (Y,N) ? _
>
>(At this point, I'd even be willing to entertain something undocumented.)

RT-11 file protection is intended only to ensure that a file is not
deleted accidently.  You can overwrite the file at will.   I don't believe
you can just test the file protection status.  I suspect KED/KEX does
something unethical like look directly at the directory.  You can
get the directory segment from .CSTAT and look yourself w/o searching the
entire directory.   I'm not aware of any other method.

  Of course if you do a .ENTER first it will report failure if protected.
Then you can .Purge I suppose if you really wanted to keep the unprotected
file.  I have not tried this however.





-- 
Jerry S. Weiss	  "If you can't stand the heat, stay out of the antimatter!"
j-weiss@nwu.edu    Dept. Medicine, Northwestern Univ. Medical School


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Soln: Attn RT-11 gurus: file protect detection
  1992-02-07 18:16   ` Soln: Attn RT-11 gurus: file protect detection cepek
@ 1992-02-13 16:51     ` John M. Crowell
  0 siblings, 0 replies; 5+ messages in thread
From: John M. Crowell @ 1992-02-13 16:51 UTC (permalink / raw)


In article <1992Feb7.131645.1612@vixvax.mgi.com> cepek@vixvax.mgi.com writes:
>
> On RT-11, is there a way to find out if a file is protected (without
> having to muddle through the directory itself)?
> :
>

Well the obvious (to me at least) way to determine whether
a file is protected is to look at its status word with the
.GFSTA programmed request, which returns the status word
in R0.

e.g.

	.GFSTA	#area,#chan,#dblk
	bcs	error
	tst	r0	; bit 15 =1 => protected
	bmi	aprot	; branch if file protected
	.
	.
	.
dblk:	.word		; .RAD50 of device goes here
	.word		; .RAD50 of file name goes
	.word		;      in these two words
	.word		; .RAD50 of extension goes here


Of course you can accomplish the same thing with
.GFINF using an offset of zero to point to the
status word:

	.GFINF	#area,#chan,#dblk,#0
	bcs	error
	tst	r0
	bmi	aprot



If you're using an antiquated version of RT-11 that
doesn't have .GFSTA and .GFINF, you can use the
USR callback on a .LOOKUP (triggered by an odd
address for the dblk entry.

e.g.
	; directory entry offsets

	e.stat	=  0	; offset to status word
	e.date	= 14	; offset to date word

	.lookup	#farea,#chan
	bcs	error
	tst	status	; look at status word
	bmi	aprot	; branch if file protected
	.
	.
	.close	#chan
	.
	.
	.
; Check file status
;  This routine is entered after file is found
;  with R1 pointing to the date word in the
;  directory entry in the USR buffer.

chksta:	mov	<e.stat-e.date>(r1),status
	rts	pc
	.
	.
	.
status:	.word	0	; file status goes here

farea:	.byte	chan,1	; these will be filled in by .LOOKUP
	.word	dblk+1	; odd address triggers callback
	.word	0	; no sequence number
	.word	0	; this word is ignored
	.word	chkstq	; address of callback routine


For more information and more examples of USR callback
routines, see the February, 1990 issue of the DECUS
Newsletter.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1992-02-13 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1992-02-06 15:44 Attn RT-11 gurus: file protect detection? cepek
1992-02-07  1:02 ` cepek
1992-02-07 18:16   ` Soln: Attn RT-11 gurus: file protect detection cepek
1992-02-13 16:51     ` John M. Crowell
1992-02-07 20:24 ` Attn RT-11 gurus: file protect detection? Jerry Weiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox