Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news-was.dfn.de!news-fra1.dfn.de!Cabal.CESspool!bofh.vszbr.cz!wuff.mayn.de!cosy.sbg.ac.at!newsfeed.Austria.EU.net!nntp.magwien.gv.at!usenet From: Ferry Bolhar-Nordenkampf Newsgroups: comp.os.vms Subject: Re: DEFINE/KERNEL (no confirmation with example) Date: Wed, 14 Jan 1998 09:41:48 +0100 Organization: Magistrat der Stadt Wien MA-14 Lines: 211 Message-ID: <34BC7A4C.6956@adv.magwien.gv.at> References: NNTP-Posting-Host: marmeladinger.adv.magwien.gv.at Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 3.0 (X11; I; OSF1 V4.0 alpha) To: Gotfryd Smolik Gotfryd Smolik wrote: > > About defining logical name in KERNEL mode :) > Was in the "Re: Spawn priveleged processes": > > On 9 Jan Robert Koehler 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 > 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 ; > } Why do you switch to kernel mode to create a kernel-mode logical name? There is no need to do so - only SYSNAM privilege is required. From the "System Service Reference" maunal, description of SYS$CRELNM: acmode OpenVMS usage: access_mode type: byte (unsigned) access: read only mechanism: by 32- or 64-bit reference (Alpha) by 32-bit reference (VAX) Access mode to be associated with the logical name. The ac- mode argument is the 32-bit address (on VAX systems) or the 32- or 64-bit address (on Alpha systems) of a byte that specifies the access mode. The access mode associated with the logical name is deter- mined by maximizing the access mode of the caller with the access mode specified by the acmode argument, which means that the less privileged of the two is used. Symbols for the four access modes are defined by the $PSLDEF macro. You cannot specify an access mode more privileged than that ! of the containing table. However, if the caller has SYSNAM ! privilege, then the specified access mode is associated with the ! logical name regardless of the access mode of the caller. Greetings, Ferry -- Ing. Ferry Bolhár-Nordenkampf Magistrat der Stadt Wien (MA-14) A - 1010 Vienna (Austria) Phone: +43 1 4000 98632 E-Mail: bol@adv.magwien.gv.at "Wenn hier einer schuld ist, dann immer nur der Computer."