Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news-was.dfn.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.he.net!pacifier!139.121.16.104.MISMATCH!mvb.saic.com!info-vax
From: Gotfryd Smolik <gotfryd@stanpol.com.pl>
Newsgroups: comp.os.vms
Subject: DEFINE/KERNEL (no confirmation with example)
Message-ID: <Pine.LNX.3.95.980113185855.16288I-100000@irys.stanpol.com.pl>
Date: Tue, 13 Jan 1998 19:22:13 +0100 (MET)
Organization: Info-Vax<==>Comp.Os.Vms Gateway
X-Gateway-Source-Info: Mailing List
Lines: 178

 About defining logical name in KERNEL mode :)
 Was in the "Re: Spawn priveleged processes":

On 9 Jan Robert Koehler <rkoehler@csc.com> wrote:
+Jan Vorbrueggen (jan@mailhost.neuroinformatik.ruhr-uni-bochum.de) wrote:
+: rkoehler@csc.com (Robert Koehler) writes:
+
+: > The last time I tried to assign a kernel mode logical name, it resulted in
+: > a fatal bugcheck.  Noting that only names which are "built in" to the exec
+: > seem to be in kernel mode, I decided never to try it again.
+
+: Did you call the SYS$ or the EXE$ routine?
+
+I just $CMKRNL'ed a little routine which I called the SYS$ routine.  Since
+it's not an RMS service, I didn't think it would mind being called from
+kernel mode (at IPL 0).  I didn't bother analyzing the crash to see why 
+VMS didn't like it, I didn't really need a kernel mode name.
+
+I did try RMS from kernel mode one day just to see what would happen.  That
+was a fatal bugcheck back in VMS 2 days, but it's been a nonfatal bugcheck
+(just blows away the process) since VMS 3.0.

 Ok.
1. Calling RMS or CLI routine from more privileges mode *may* cause
 problem because the protection scheme (std. not allowed call to
 lower mode, must be mapped as "compatibility" (event doesn't know
 how do it) then all CLI$ and EXE$ routine are out.
2. Doesn't know why a normal SYS$ may have problem ! And you may
 not will use it for some reason, but b.ex. setting up a group
 table on system startup may be easier with DEFINE/EXEC :)

 Then having some free time have test a example: definitely works
(VAX VMS 6.2, our Alpha is out for some reason).
 Excuse all poor programing practice: all correction appreciates
without offend: I haven't really programm for long !

 And have end the example looking for the examples (:))
 of
Fred Kleinsorge <kleinsorge@star.enet.dec_nospam.com>
and Carl J.Lydick.

 Code at end. Run example here:
(be aware about the lowercese in C !! Then name in quotas.)

STAN::GS> krnlog:==$sys$disk:[]krnlog
STAN::GS> krnlog "LNM$JOB" "NAME" "VALUE" U
Status of TRLNM=1=%X1
STAN::GS> krnlog "LNM$JOB" "NAME" "VALUE" S
Status of TRLNM=1=%X1
STAN::GS> krnlog "LNM$JOB" "NAME" "VALUE" E
Status of TRLNM=1=%X1
STAN::GS> sho log/job NAME*/full

(LNM$JOB_83CC3780)      [kernel]  [shareable]  [Quota=(2880,4096)]
                        [Protection=(RWCD,RWCD,,)]  [Owner=[GS]]

  "NAME" [user] = "VALUE"
  "NAME" [super] = "VALUE"
  "NAME" [exec] = "VALUE"

******* and the best: **********

STAN::GS> krnlog "LNM$JOB" "NAME" "VALUE" K
Status of TRLNM=1=%X1
STAN::GS> sho log/job NAME*/full

(LNM$JOB_83CC3780)      [kernel]  [shareable]  [Quota=(2832,4096)]
                        [Protection=(RWCD,RWCD,,)]  [Owner=[GS]]

  "NAME" [user] = "VALUE"
  "NAME" [super] = "VALUE"
  "NAME" [exec] = "VALUE"
  "NAME" [kernel] = "VALUE"

+Bob Koehler                     | Computer Sciences Corporation

 Regards - Gotfryd

--
=====================================================================
$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
		THEN EXCUSE/OBJECT=ME
$!                        GS@stanpol.zabrze.pl
=====================================================================



/* Example for test a KERNEL mode logical name */
/* Gotfryd Smolik, gs@stanpol.com.pl I.1997.   */
#include    stdlib
#include    stdio
#include    descrip
#include    lnmdef
#include    string
#include    ctype

int sys$crelnm(unsigned int *attr,
 void *tabnam, void *lognam,
 unsigned char *acmode, void *itmlst);
int sys$cmkrnl(int subfn(),volatile void *arglist);
/* I am not sure, then according to HELP ("on Alpha must exist")
   use the "volatile" to prevent optimization for inner mode
   parameters. */


/* --------------- */

int krnldo(void *tabname,void *logname,void *valuename,int mode)
{
unsigned char lmode=mode ; /*I will not fiddle with the casts...*/
int stan ;
struct dsc$descriptor_s tabnam,lognam ;
struct  /* itemlist ! */
{
 unsigned short buflen, itmcod;
 char   *bufadr;
 int            end1,end2;
} values={
 0,0,0,;
tabnam.dsc$w_length=strlen(tabname) ;
tabnam.dsc$a_pointer=tabname ;
tabnam.dsc$b_dtype=DSC$K_DTYPE_T ;
tabnam.dsc$b_class=DSC$K_CLASS_S;

lognam.dsc$w_length=strlen(logname) ;
lognam.dsc$a_pointer=logname ;
lognam.dsc$b_dtype=DSC$K_DTYPE_T ;
lognam.dsc$b_class=DSC$K_CLASS_S;

values.buflen=strlen(valuename);
values.itmcod=LNM$_STRING;
values.bufadr=valuename;
stan=sys$crelnm(0, &tabnam, &lognam,&lmode, &values) ;
return stan ;
 }


/* --------------- */

main(int ile, char *inp[])
{
int stan; char mode ;
volatile char *arglist[6] ; /* I am to lazy writing all the (char) :) */
if(ile<3)
 { printf(" Usage: KRNLOG table name translation\n"),
   printf("Allows only one translation as example ;), require CMKRNL\n");
   return ; }
arglist[0]=(char *)3; /* The lenght */
arglist[1]=inp[1]; /*Table */
arglist[2]=inp[2]; /*Name itself*/
arglist[3]=inp[3]; /*Value*/
mode='U';/*User mode as default*/
if(inp[4] != NULL)
 if (inp[4][0] != 0) mode=inp[4][0] ;
switch(toupper((char)mode))
{
case '0':
case '1':
case '2':
case '3':
 mode=mode & 3;break ;
case 'U': mode=3;break;
case 'S': mode=2;break;
case 'E': mode=1;break;
case 'K': mode=0;break;
default:
  printf("A wrong mode !!\n");return ;
 } ;
arglist[4]=(char *)mode; /*Ok :)*/
stan=sys$cmkrnl(krnldo,&arglist) ;
printf("Status of TRLNM=%d=%%X%X\n",stan,stan) ;
/* printf("Ok, you have subprocess to do b.ex. SHO LOG/JOB/FULL\n"),
   printf("You may check for user mode logical !\n"),
   system("@TT:") ; /* Have have for testing b.ex. user mode only :) */
return ;
 }


