Aucbvax.6907
fa.info-vax
utzoo!decvax!ucbvax!info-vax
Sun Apr 25 08:38:57 1982
Lecture/Demonstration on VMS 2.4 logical name tables
>From EPS@MIT-AI Sun Apr 25 08:27:41 1982
We were wondering some time back whether it was possible for a
subprocess to inherit its creator's process-wide logical names.
If the two processes are "cooperating" in nature, the top one
need only read its table and pass the information down.  The
problem was how to read the table.
                             * * *
       .TITLE  SHOWGROUP       Display Group Logical Name Tables

;         BACKGROUND INFORMATION
;         ----------------------
;
; For each logical name assignment, VMS    31                            0
; dynamically allocates a "logical name   +-------------------------------+
; block" (LOG) and links it into one of   |  logical table forward link   |  0
; three chains depending on whether the   +-------------------------------+
; assignment is to be system-wide, group- |  logical table backward link  |  4
; wide, or process-wide.  Pointers exist  +-------+-------+---------------+
; in the Job Information Block (JIB) for  | table | type  | size of block |  8
; a fourth "job-wide" chain, but VMS 2.4  +-------+-------+---------------+
; doesn't make use of them.  The system   |       | amod  | creator group | 12
; location LOG$AL_LOGTBL (%X800024E8) is  +-------+-------+---------------+
; the base of an array of pointers        |      mailbox ucb address      | 16
; indexed by table number (0=system;      +-----------------------+-------+
; 1=group; 2=process) to double links     |      <-- LOGICAL - 1 : ; NAME V FIG. | TABLES. LOG$GL_SLTFL THE +----------------------+ BLOCK TO +------. LOG$AL_LOGTBL COUNT +- +---------------+>+>| head of chain |-->+-->|next LOG block |---->| next
; +---------------+  |  ^ +---------------+       +---------------+  |  +------.
; |system pointer |--+  | | tail of chain |--+ +--|               |  +--| prev
; +---------------+     | +---------------+  | |  +---------------+     +------.
; | group pointer |---+ |                    | v  :               :     :
; +---------------+   | +--------------------|-+<--------------------+ <--+ ; V | |PROCESS POINTER|-+ CTL$GL_PLTFL +-- +<----------------------|---------. +---------------+> similar chain for +--->|            |--+   +-----.
; similar chain for        group logicals         +---------------+      |
; process logicals                                |prev LOG block |------+
;                                                 +---------------+
; (Refer to the description of the INSQUE and     :               :
;  REMQUE instructions in chapter 12 of the VAX
;  Architecture Handbook if this looks confusing)
;                                                Fig. 2   Finding the chains
;
;
       .PAGE
;
;
; LOG structures are allocated in P1 space for process-wide assignments, or
; system dynamic memory for group or system assignments.  Insofar as $CRELOGs
; are concerned, the only difference between system and group assignments
; is which chain they hook on to.  In both cases LOG$W_GROUP is set to the
; group number of the creating process.  When the group table is searched,
; only entries for your group are considered.  VMS does not maintain a
; separate table for each group.
;
; The logical name and equivalence are stored as counted ASCII strings, so
; the structure is of variable size.  The "size" word in the LOG block is
; the number of bytes in the structure rounded up to the next multiple of
; 16.  "Type" is always DYN$C_LOG (11 decimal).  "Table" is 0, 1, or 2
; for System, Group, or Process table.  "Amod" is access mode in which
; the assignment was made (0=Kernel 1=Exec 2=Super 3=User).  If the logical
; name was created by $CREMBX then mbxucb will contain the address of the
; mailbox's unit control block, otherwise it will be NULL.
;
; Everything I have described above is readable to user-mode software with
; ONE exception.  The definition of SYS$SYSDISK (the second definition in
; the system table) resides in a read-protected page!  Only DEC knows why
; this is (I sure don't--it seems really stupid to me).  SHOW LOGICAL/S
; can get it because it's INSTALLed with CMKRNL and CMEXEC and doesn't
; mind living dangerously.
;
;
;                                       Eric P. Scott
;                            California Institute of Technology
;                                        April, 1982
;
;
;       to compile:
;       $ MACRO SHOWGROUP
;       $ LINK/NOTRACE SHOWGROUP,SYS$SYSTEM:SYS.STB
;
       .PAGE

       $DSCDEF
       $RMSDEF
       $SSDEF
       $TPADEF
       .LIBRARY        /SYS$LIBRARY:LIB/
       $LOGDEF

       .EXTRN  LOG$AL_LOGTBL

       .PSECT  MAIN,NOWRT,SHR,PIC,LONG

       .ENTRY  MAIN,^M

       CLRL    -(SP)           ; Descriptor for input line
       PUSHL   #<DSC$K_DTYPE_T@16>!<DSC$K_CLASS_D@24>

       PUSHAQ  PROMPT          ; Get foreign command line
       PUSHAQ  4(SP)
       CALLS   #2,G^LIB$GET_FOREIGN
       CMPL    R0,#RMS$_EOF
       BEQL    11$
       BLBC    R0,10$

       PUSHAQ  (SP)
       PUSHAQ  4(SP)
       CALLS   #2,STR$UPCASE
       BLBC    R0,10$

       SUBL2   #TPA$K_LENGTH0-16,SP    ; Push TPARSE parameter block
       PUSHL   TPA$K_LENGTH0-16+DSC$A_POINTER(SP)
       MOVZWL  TPA$K_LENGTH0-12+DSC$W_LENGTH(SP),-(SP)
       PUSHL   #TPA$M_ABBREV
       PUSHL   #TPA$K_COUNT0

       PUSHAL  SKT             ; Validate syntax
       PUSHAL  SST
       PUSHAL  8(SP)
       CALLS   #3,G^LIB$TPARSE
       BLBC    R0,10$          ; Really should die more gracefully

       MOVZWL  TPA$K_LENGTH0+DSC$W_LENGTH(SP),TPA$L_STRINGCNT(SP)
       MOVL    TPA$K_LENGTH0+DSC$A_POINTER(SP),TPA$L_STRINGPTR(SP)

       PUSHAL  XKT             ; Display requested group(s)
       PUSHAL  XST
       PUSHAL  8(SP)
       CALLS   #3,G^LIB$TPARSE

10$:    RET
11$:    MOVZWL  #SS$_NORMAL,R0
       RET

       .PSECT  HELP,NOWRT,SHR,PIC,LONG

       .ENTRY  HELP,^M

       PUSHAQ  HLPTXT          ; Display one-line help message
       CALLS   #1,LIB$PUT_OUTPUT
       $EXIT_S R0

       .PSECT  DISPLAY,NOWRT,SHR,PIC,LONG

       .ENTRY  DISPLAY,^M<R2,R3,R4,R5,R6>

       CLRL    -(SP)
       PUSHL   #<DSC$K_DTYPE_T@16>!<DSC$K_CLASS_D@24>

       PUSHAQ  (SP)            ; Output blank line
       CALLS   #1,G^LIB$PUT_OUTPUT
       BLBC    R0,DIE1

       TSTW    TPA$L_TOKENCNT(AP)
       BNEQ    DSPN

       PUSHAQ  GRPA            ; Output header for all groups
       CALLS   #1,G^LIB$PUT_OUTPUT
       BLBS    R0,DSPB

DIE1:   PUSHL   R0              ; Die horribly
       CALLS   #1,G^LIB$STOP
DSPX:   RET

DSPN:   PUSHL   TPA$L_NUMBER(AP)
       PUSHAQ  4(SP)
       CLRL    -(SP)
       PUSHAQ  GRPN
       CALLS   #4,G^LIB$SYS_FAO
       BLBC    R0,DIE1

       PUSHAQ  (SP)            ; Output header for specific group
       CALLS   #1,G^LIB$PUT_OUTPUT
       BLBC    R0,DIE1

       MOVAQ   (SP),R0
       JSB     G^LIB$SFREE1_DD6
       BLBC    R0,DIE1

DSPB:   PUSHAQ  (SP)            ; Output blank line
       CALLS   #1,G^LIB$PUT_OUTPUT
       BLBC    R0,DIE1

       MOVL    @#LOG$AL_LOGTBL+<LOG$C_GROUP*4>,R2
       CMPL    (R2),R2
       BEQL    DSPX            ; Table empty
       MOVL    (R2),R3

DSPE:   TSTW    TPA$L_TOKENCNT(AP)
       BNEQ    DSPM            ; Specific group

       MOVZBL  LOG$B_AMOD(R3),R0
       PUSHAB  ACMODE(R0)
       PUSHL   #1
       MOVAB   LOG$T_NAME(R3),R1
       MOVZBL  (R1),R0
       INCL    R0
       ADDL3   R1,R0,-(SP)
       PUSHL   R1
       MOVZWL  LOG$W_GROUP(R3),-(SP)
       PUSHAQ  20(SP)
       CLRL    -(SP)
       PUSHAQ  ALINE
       CALLS   #8,G^LIB$SYS_FAO
       BLBS    R0,DSPP

DIE2:   BRW     DIE1

DSPM:   CMPW    TPA$L_NUMBER(AP),LOG$W_GROUP(R3)
       BNEQ    DSPC

       MOVZBL  LOG$B_AMOD(R3),R0
       PUSHAB  ACMODE(R0)
       PUSHL   #1
       MOVAB   LOG$T_NAME(R3),R1
       MOVZBL  (R1),R0
       INCL    R0
       ADDL3   R1,R0,-(SP)
       PUSHL   R1
       PUSHAQ  16(SP)
       CLRL    -(SP)
       PUSHAQ  NLINE
       CALLS   #7,G^LIB$SYS_FAO
       BLBC    R0,DIE2

DSPP:   PUSHAQ  (SP)
       CALLS   #1,G^LIB$PUT_OUTPUT
       BLBC    R0,DIE2

DSPC:   MOVL    LOG$L_LTFL(R3),R3
       CMPL    R3,R2
       BEQL    DSPX2
       BRW     DSPE
DSPX2:  MOVAQ   (SP),R0
       JSB     G^LIB$SFREE1_DD6
       BLBC    R0,DIE2

       RET

       .PSECT  CONSTANTS,NOWRT,NOEXE,SHR,LONG
PROMPT: .ASCID  /SHOWGROUP> /
       .ALIGN  LONG
HLPTXT: .ASCID  /  Give list of groups or ALL/
       .ALIGN  LONG
GRPA:   .ASCID  /  Contents of group logical name tables :/
       .ALIGN  LONG
GRPN:   .ASCID  /  Contents of group !OW logical name table:/
       .ALIGN  LONG
ALINE:  .WORD   ETEXT-ATEXT
       .BYTE   DSC$K_DTYPE_T
       .BYTE   DSC$K_CLASS_S
       .ADDRESS        ATEXT
NLINE:  .WORD   ETEXT-NTEXT
       .BYTE   DSC$K_DTYPE_T
       .BYTE   DSC$K_CLASS_S
       .ADDRESS        NTEXT
ATEXT:  .ASCII  /  !OW/
NTEXT:  .ASCII  /  !AC  =  !AC  (!AD)/
ETEXT:
ACMODE: .ASCII  /KESU/

COMMA=^A','
       $INIT_STATE     SST,SKT
       $STATE
       $TRAN   !SAS,TPA$_EXIT
       $TRAN   !SHS,TPA$_EXIT,HELP
       $TRAN   TPA$_EOS,TPA$_EXIT
       $TRAN   TPA$_OCTAL,,VGRP
       $STATE  SBS
       $TRAN   COMMA
       $TRAN   TPA$_EOS,TPA$_EXIT
       $STATE
       $TRAN   TPA$_OCTAL,SBS
       $STATE  SAS
       $TRAN   'ALL'
       $STATE
       $TRAN   TPA$_EOS,TPA$_EXIT
       $STATE  SHS
       $TRAN   '?'
       $STATE
       $TRAN   TPA$_EOS,TPA$_EXIT
       $END_STATE

       $INIT_STATE     XST,XKT
       $STATE
       $TRAN   'ALL',XAS
       $TRAN   TPA$_EOS,TPA$_EXIT,DISPLAY
       $TRAN   TPA$_OCTAL,,DISPLAY
       $STATE  XBS
       $TRAN   COMMA
       $TRAN   TPA$_EOS,TPA$_EXIT
       $STATE
       $TRAN   TPA$_OCTAL,XBS,DISPLAY
       $STATE  XAS
       $TRAN   TPA$_EOS,TPA$_EXIT,DISPLAY
       $END_STATE

       .PSECT  VGRP,NOWRT,SHR,PIC,LONG

       .ENTRY  VGRP,^M
       TSTW    TPA$L_NUMBER+2(AP)
       BEQL    1$
       CLRL    R0
1$:     RET

       .END    MAIN
                                     * * *
Exercise for the reader: modify this program to correspond more
closely to the DCL SHOW LOGICAL command, e.g. I should be able
to type SHOWGROUP/GROUP=(1,10,20,77) FOO_BAR
Don't bother turning in the homework; this is a pass/pass course.
Next: How to read your DCL symbol table

                                       Enjoy!

                                       --Eric

Face it.  You can learn everything there is to know about Unix
in a matter of weeks.  VMS can keep you entertained for years.
If we could get the United States Congress to design and implement
an operating system, the documentation alone...

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.