00001
00002
00003
00004
00005
00006 #ifdef USERLAND
00007 #define __LINUX_VMALLOC_H
00008 #define _LINUX_VMALLOC_H
00009 #define LINUX_VMALLOC_H
00010 struct lnmhshs lnmhshs;
00011 struct lnmhshp lnmhshp;
00012 #endif
00013
00014 #include<linux/linkage.h>
00015
00016 #ifdef USERLAND
00017 #include<starlet.h>
00018 #include<lnmdef.h>
00019 #include<ssdef.h>
00020 #include<misc.h>
00021 #include<descrip.h>
00022 #include<lnmstrdef.h>
00023 #include<orbdef.h>
00024 #include<ipldef.h>
00025 #include<dyndef.h>
00026 #include<system_service_setup.h>
00027 #include<lnmsub.h>
00028 #include<sysgen.h>
00029 #include<system_data_cells.h>
00030 #else
00031 #include<linux/mm.h>
00032 #include<starlet.h>
00033 #include<lnmdef.h>
00034 #include<ssdef.h>
00035 #include<misc.h>
00036 #include<descrip.h>
00037 #include<lnmstrdef.h>
00038 #include<orbdef.h>
00039 #include<ipldef.h>
00040 #include<dyndef.h>
00041 #include<system_service_setup.h>
00042 #include<lnmsub.h>
00043 #include<sysgen.h>
00044 #include<system_data_cells.h>
00045 #include<ipl.h>
00046 #include<internals.h>
00047 #include <exe_routines.h>
00048 #include <misc_routines.h>
00049 #include <linux/slab.h>
00050 #endif
00051
00052
00053
00054 #ifndef USERLAND
00055 #if 0
00056 #define __KERNEL__
00057 #define MODULE
00058 #endif
00059 #endif
00060
00061 #if 0
00062
00063 #include <linux/modversions.h>
00064 #include <linux/module.h>
00065
00066 #define _LOOSE_KERNEL_NAMES
00067
00068
00069
00070 #include <linux/tty.h>
00071 #endif
00072
00073 int isp1(void * a) { return 0; }
00074
00075 int isshar(void * a) { return 1; }
00076
00077
00078 #ifdef MODULE
00079 int init_module()
00080 {
00081
00082
00083
00084
00085 console_print("Hello, world - this is the kernel speaking\n");
00086
00087
00088
00089
00090
00091
00092
00093 return 0;
00094 }
00095
00096
00097
00098 void cleanup_module()
00099 {
00100 console_print("Short is the life of an LKM\n");
00101 }
00102 #endif
00103
00104 asmlinkage sys__CRELNM();
00105 asmlinkage exe_crelnm (unsigned int *attr, void *tabnam, void *lognam, unsigned char *acmode, void *itmlst)
00106 {
00107 int status;
00108 struct struct_lnm_ret ret= {0,0};
00109 struct _lnmb * mylnmb;
00110 struct _lnmth * mylnmth;
00111 struct _lnmx * mylnmx = 0;
00112 struct dsc_descriptor * mytabnam=tabnam;
00113 struct dsc_descriptor * mylognam=lognam;
00114 struct item_list_3 * i,j;
00115 struct struct_rt * RT;
00116
00117 if (mytabnam && mytabnam->dsc_a_pointer)
00118 exe_prober_simple(mytabnam->dsc$a_pointer);
00119 if (mylognam && mylognam->dsc_a_pointer)
00120 exe_prober_simple(mylognam->dsc$a_pointer);
00121
00122 setipl(IPL__ASTDEL);
00123
00124 mylnmb=lnmmalloc(sizeof(struct _lnmb));
00125 memset(mylnmb,0,sizeof(struct _lnmb));
00126 mylnmth=lnmmalloc(sizeof(struct _lnmth));
00127 memset(mylnmth,0,sizeof(struct _lnmth));
00128
00129 RT=(struct struct_rt *) lnmmalloc(sizeof(struct struct_rt));
00130 memset(RT,0,sizeof(struct struct_rt));
00131
00132 lnm_lockw();
00133
00134 status=lnm_firsttab(&ret,mytabnam->dsc$w_length,mytabnam->dsc$a_pointer);
00135
00136 mylnmb=lnmmalloc(sizeof(struct _lnmb));
00137 memset(mylnmb,0,sizeof(struct _lnmb));
00138 mylnmb->lnmb_l_flink=0;
00139 mylnmb->lnmb_l_blink=0;
00140 mylnmb->lnmb_w_size=sizeof(struct _lnmb);
00141 mylnmb->lnmb_b_type=DYN$C_LNM;
00142 mylnmb->lnmb_b_acmode=0;
00143 mylnmb->lnmb_l_table=ret.mylnmb->lnmb$l_table;
00144 mylnmb->lnmb_b_flags=0;
00145 mylnmb->lnmb_b_count=mylognam->dsc$w_length;
00146 mylnmb->lnmb_l_lnmx=0;
00147 struct _lnmx ** next_lnmx = &mylnmb->lnmb_l_lnmx;
00148 strncpy( &(mylnmb->lnmb_t_name[0]),mylognam->dsc$a_pointer,mylognam->dsc$w_length);
00149
00150 for(i=itmlst;i->item_code!=0;i++) {
00151 switch (i->item_code) {
00152 case LNM__INDEX:
00153 memcpy(&mylnmx->lnmx_l_index,i->bufaddr,4);
00154 break;
00155 case LNM__STRING:
00156 mylnmx=lnmmalloc(sizeof(struct _lnmx));
00157 memset(mylnmx,0,sizeof(struct _lnmx));
00158
00159 *next_lnmx=mylnmx;
00160 next_lnmx=&mylnmx->lnmx_l_next;
00161
00162 mylnmx->lnmx_l_xlen=i->buflen;
00163 strncpy( &(mylnmx->lnmx_t_xlation[0]),i->bufaddr,i->buflen);
00164 mylnmx->lnmx_l_flags=LNMX$M_TERMINAL;
00165 mylnmx->lnmx_l_flags|=LNMX$M_XEND;
00166
00167 break;
00168 case LNM__LNMB_ADDR:
00169 memcpy(i->bufaddr,&mylnmb,i->buflen);
00170 break;
00171 default:
00172 printk("yet unknown LNM param %x\n",i->item_code);
00173 }
00174 }
00175
00176 status=lnm_inslogtab(&ret,mylnmb);
00177
00178 lnm_unlock();
00179 setipl(0);
00180 return status;
00181 }
00182
00183 asmlinkage sys__CRELNT();
00184
00185
00186
00187
00188
00189
00190 asmlinkage int exe_crelnt (unsigned int *attr, void *resnam, unsigned int *reslen, unsigned int *quota, unsigned short *promsk, void *tabnam, void *partab, unsigned char *acmode) {
00191 int status;
00192
00193
00194 struct struct_lnm_ret ret ={0,0};
00195 struct _lnmb * mylnmb;
00196 struct _lnmx * mylnmx;
00197 struct _lnmth * mylnmth;
00198 struct _orb * myorb;
00199 long * trailer;
00200 struct struct_rt * RT;
00201 struct dsc_descriptor_s * mytabnam = 0, * mypartab;
00202 if (!(partab)) return 0;
00203 mypartab=partab;
00204 #ifdef LNM_DEBUG
00205 lnmprintf("partab %s\n",mypartab->dsc_a_pointer);
00206 #endif
00207 if (tabnam) mytabnam=tabnam;
00208 else {
00209
00210 }
00211
00212 if (mytabnam && mytabnam->dsc_a_pointer)
00213 exe_prober_simple(mytabnam->dsc$a_pointer);
00214 if (mypartab && mypartab->dsc_a_pointer)
00215 exe_prober_simple(mypartab->dsc$a_pointer);
00216
00217 setipl(IPL__ASTDEL);
00218 mylnmb=lnmmalloc(sizeof(struct _lnmb));
00219 memset(mylnmb,0,sizeof(struct _lnmb));
00220 mylnmx=lnmmalloc(sizeof(struct _lnmx));
00221 memset(mylnmx,0,sizeof(struct _lnmx));
00222 mylnmth=lnmmalloc(sizeof(struct _lnmth));
00223 memset(mylnmth,0,sizeof(struct _lnmth));
00224 myorb=lnmmalloc(sizeof(struct _orb));
00225 memset(myorb,0,sizeof(struct _orb));
00226 trailer=lnmmalloc(sizeof(long));
00227
00228
00229 lnm_lockw();
00230 RT=(struct struct_rt *) lnmmalloc(sizeof(struct struct_rt));
00231 memset(RT,0,sizeof(struct struct_rt));
00232 #ifdef LNM_DEBUG
00233
00234
00235
00236 lnmprintf("fir %x\n",ret.mylnmth);
00237 #endif
00238 status=lnm_firsttab(&ret,mypartab->dsc$w_length,mypartab->dsc$a_pointer);
00239 #ifdef LNM_DEBUG
00240 lnmprintf("fir %x\n",ret.mylnmth);
00241 #endif
00242 if (status==SS__NOLOGTAB) {
00243 lnmfree(mylnmb);
00244 lnmfree(mylnmx);
00245 lnmfree(mylnmth);
00246 lnmfree(myorb);
00247 lnmfree(trailer);
00248
00249 lnm_unlock();
00250 setipl(0);
00251 return status;
00252 }
00253
00254 if (isp1(mylnmth)){
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 }
00265 if (isshar(mylnmth)){
00266 status=lnm_check_prot();
00267 if (status!=SS__NORMAL) {
00268 lnmfree(mylnmb);
00269 lnmfree(mylnmx);
00270 lnmfree(mylnmth);
00271 lnmfree(myorb);
00272 lnmfree(trailer);
00273
00274 lnm_unlock();
00275 setipl(0);
00276 return SS__NOPRIV;
00277 }
00278 }
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 mylnmb->lnmb_l_flink=0;
00294 mylnmb->lnmb_l_blink=0;
00295 mylnmb->lnmb_w_size=sizeof(struct _lnmb);
00296 mylnmb->lnmb_b_type=DYN$C_LNM;
00297 mylnmb->lnmb_b_acmode=0;
00298 mylnmb->lnmb_l_lnmx=mylnmx;
00299 mylnmth=&mylnmx->lnmx_l_xlen;
00300 mylnmb->lnmb_l_table=mylnmth;
00301 mylnmb->lnmb_b_flags=LNM$M_TABLE;
00302 mylnmb->lnmb_b_count=mytabnam->dsc$w_length;
00303 strncpy( &(mylnmb->lnmb_t_name[0]),mytabnam->dsc$a_pointer,mytabnam->dsc$w_length);
00304
00305 mylnmx->lnmx_l_flags=LNMX$M_TERMINAL;
00306 mylnmx->lnmx_l_index=LNMX$C_TABLE;
00307
00308 mylnmth->lnmth_l_flags=LNMTH$M_SHAREABLE|LNMTH$M_DIRECTORY;
00309 mylnmth->lnmth_l_name=mylnmb;
00310 mylnmth->lnmth_l_parent=ret.mylnmb;
00311 mylnmth->lnmth_l_hash=ret.mylnmb->lnmb$l_table->lnmth$l_hash;
00312 mylnmth->lnmth_l_sibling=0;
00313 mylnmth->lnmth_l_child=0;
00314 mylnmth->lnmth_l_qtable=0;
00315 mylnmth->lnmth_l_hash=0;
00316 mylnmth->lnmth_l_orb=0;
00317 mylnmth->lnmth_l_byteslm=0;
00318 mylnmth->lnmth_l_bytes=0;
00319
00320 #ifdef LNM_DEBUG
00321 lnmprintf("bef inslogtab %x %s\n",mylnmb->lnmb_b_count,mytabnam->dsc$a_pointer);
00322 #endif
00323 status=lnm_inslogtab(&ret,mylnmb);
00324
00325
00326 #ifdef LNM_DEBUG
00327 lnmprintf("so far %x\n",status);
00328 #endif
00329
00330
00331 lnm_unlock();
00332
00333 setipl(0);
00334 return status;
00335 }
00336
00337 asmlinkage sys__DELLNM() {;}
00338 asmlinkage exe_dellnm (void *tabnam, void *lognam, unsigned char *acmode) {
00339
00340 #if 0
00341 needs these
00342
00343 setipl(IPL__ASTDEL);
00344 lnm_lockw();
00345
00346 #endif
00347
00348
00349 }
00350
00351 asmlinkage sys__TRNLNM() {;}
00352 asmlinkage exe_trnlnm (unsigned int *attr, void *tabnam, void
00353 *lognam, unsigned char *acmode, void *itmlst) {
00354 int status;
00355 struct dsc_descriptor *mytabnam, *mylognam;
00356 struct struct_lnm_ret ret={0,0};
00357 struct item_list_3 * i=itmlst;
00358
00359 mylognam=lognam;
00360 mytabnam=tabnam;
00361 if (!(tabnam && itmlst)) return 0;
00362
00363 if (mytabnam && mytabnam->dsc_a_pointer)
00364 exe_prober_simple(mytabnam->dsc$a_pointer);
00365 if (mylognam && mylognam->dsc_a_pointer)
00366 exe_prober_simple(mylognam->dsc$a_pointer);
00367
00368
00369 setipl(IPL__ASTDEL);
00370 lnm_lockr();
00371
00372 status=lnm_searchlog(&ret,mylognam->dsc$w_length,mylognam->dsc$a_pointer,mytabnam->dsc$w_length,mytabnam->dsc$a_pointer);
00373 if (status==SS__NOLOGNAM || status!=SS$_NORMAL) {
00374
00375 lnm_unlock();
00376 setipl(0);
00377 return status;
00378 }
00379 for(i=itmlst;i->item_code!=0;i++) {
00380 switch(i->item_code) {
00381 case LNM__INDEX:
00382
00383
00384 memcpy(i->bufaddr,&(ret.mylnmb)->lnmb_l_lnmx->lnmx$l_index,4);
00385 #if 0
00386 if (*(long*)i->bufaddr!=LNMX_C_BACKPTR)
00387 return SS__BADPARAM;
00388 #endif
00389 break;
00390 case LNM__STRING:
00391 i->buflen=(ret.mylnmb)->lnmb_l_lnmx->lnmx$l_xlen;
00392 if (i->retlenaddr) {
00393 long * l=i->retlenaddr;
00394 *l=i->buflen;
00395 }
00396 memcpy(i->bufaddr,(ret.mylnmb)->lnmb_l_lnmx->lnmx$t_xlation,i->buflen);
00397 #ifdef LNM_DEBUG
00398 lnmprintf("found lnm %x %s\n",i->bufaddr,i->bufaddr);
00399 #endif
00400 break;
00401 default:
00402 printk("another unsupport LNM %x\n",i->item_code);
00403 }
00404 }
00405 lnm_unlock();
00406 setipl(0);
00407 return status;
00408 }
00409
00410 asmlinkage int exe_crelnt_wrap (struct struct_crelnt *s) {
00411 return exe_crelnt (s->attr, s->resnam, s->reslen, s->quota, s->promsk, s->tabnam, s->partab, s->acmode);
00412 }
00413
00414 #ifdef USERLAND
00415 main(){
00416 struct item_list_3 i[2];
00417 int c;
00418 unsigned long * myhash;
00419 int status;
00420 struct _lnmb * lnm_system_directory;
00421 struct _lnmth * lnm_system_directory_b;
00422 struct struct_crelnt * s;
00423 _DESCRIPTOR(mynam,"BIBI");
00424 _DESCRIPTOR(mynam2,"BOBO");
00425 _DESCRIPTOR(mytabnam3,"MYTEST3");
00426 _DESCRIPTOR(mytabnam2,"MYTEST2");
00427 _DESCRIPTOR(mytabnam,"MYTEST");
00428 _DESCRIPTOR(mypartab,"LNM$SYSTEM_DIRECTORY");
00429 char resstring[LNM_C_NAMLENGTH];
00430
00431
00432 lnm_system_directory=lnmmalloc(sizeof(struct _lnmb));
00433 memset(lnm_system_directory,0,sizeof(struct _lnmb));
00434 lnm_system_directory->lnmb$l_flink=lnm$system_directory;
00435 lnm_system_directory->lnmb$l_blink=lnm$system_directory;
00436 lnm_system_directory->lnmb$b_type=DYN$C_LNM;
00437 lnm_system_directory->lnmb$b_acmode=MODE_K_KERNEL;
00438 lnm_system_directory_b=(struct _lnmth *)&lnm$system_directory->lnmxs[0].lnmx$l_xlen;
00439 lnm_system_directory->lnmb$l_table=lnm$system_directory_b;
00440 lnm_system_directory->lnmb$b_flags=LNM$M_NO_ALIAS|LNM$M_TABLE|LNM$M_NO_DELETE;
00441 lnm_system_directory->lnmb$b_count=mypartab.dsc$w_length;
00442 strncpy(lnm_system_directory->lnmb$t_name,mypartab.dsc$a_pointer,lnm$system_directory->lnmb$b_count);
00443 lnm_system_directory->lnmxs[0].lnmx$b_flags=LNMX$M_TERMINAL;
00444 lnm_system_directory->lnmxs[0].lnmx$b_index=LNMX$C_TABLE;
00445 lnm_system_directory->lnmxs[1].lnmx$b_flags=LNMXH$M_XEND;
00446
00447 lnm_system_directory_b->lnmth$b_flags=LNMTH$M_SHAREABLE|LNMTH$M_DIRECTORY;
00448 lnm_system_directory_b->lnmth$l_name=lnm$system_directory;
00449 lnm_system_directory_b->lnmth$l_parent=0;
00450 lnm_system_directory_b->lnmth$l_sibling=0;
00451 lnm_system_directory_b->lnmth$l_child=0;
00452 lnm_system_directory_b->lnmth$l_qtable=0;
00453 lnm_system_directory_b->lnmth$l_hash=0;
00454 lnm_system_directory_b->lnmth$l_orb=0;
00455 lnm_system_directory_b->lnmth$l_byteslm=0;
00456 lnm_system_directory_b->lnmth$l_bytes=0;
00457
00458
00459
00460
00461 myhash=lnmmalloc(sizeof(unsigned long));
00462 status=lnm_hash(mypartab.dsc$w_length,mypartab.dsc$a_pointer,0xffff,myhash);
00463 #ifdef LNM_DEBUG
00464 lnmprintf("here %x %x\n",myhash,*myhash);
00465 #endif
00466 lnmhshs.entry[2*(*myhash)]=lnm_system_directory;
00467 lnmhshs.entry[2*(*myhash)+1]=lnm_system_directory;
00468 s=lnmmalloc(sizeof(struct struct_crelnt));
00469 s->partab=&mypartab;
00470 s->tabnam=&mytabnam;
00471 status=exe_crelnt_wrap(s);
00472 s=lnmmalloc(sizeof(struct struct_crelnt));
00473 s->partab=&mypartab;
00474 s->tabnam=&mytabnam2;
00475 status=exe_crelnt_wrap(s);
00476 s=lnmmalloc(sizeof(struct struct_crelnt));
00477 s->partab=&mytabnam2;
00478 s->tabnam=&mytabnam3;
00479 status=exe_crelnt_wrap(s);
00480 i[0].item_code=LNM__STRING;
00481 i[0].buflen=5;
00482 i[0].bufaddr="mylog";
00483 memset(&i[1],0,sizeof(struct item_list_3));
00484 status=exe_crelnm(0,&mytabnam2,&mynam,0,i);
00485 i[0].item_code=LNM__STRING;
00486 i[0].buflen=6;
00487 i[0].bufaddr="mylog3";
00488 memset(&i[1],0,sizeof(struct item_list_3));
00489 status=exe_crelnm(0,&mytabnam2,&mynam2,0,i);
00490 i[0].item_code=LNM__STRING;
00491 i[0].buflen=6;
00492 i[0].bufaddr=resstring;
00493 memset(&i[1],0,sizeof(struct item_list_3));
00494 status=exe_trnlnm(0,&mytabnam2,&mynam,0,i);
00495 #ifdef LNM_DEBUG
00496 lnmprintf("end status %x\n",status);
00497 #endif
00498 for (c=0;c<LNMSHASHTBL;c++) {
00499 if (lnmhshs.entry[2*c]) {
00500 struct _lnmth * l;
00501 struct _lnmb *head, *tmp;
00502 head=lnmhshs.entry[2*c];
00503 tmp=head;
00504 do {
00505 #ifdef LNM_DEBUG
00506 lnmprintf("lnmhshs entry %x %x %s\n",c,tmp,tmp->lnmb_t_name);
00507 #endif
00508 l=&(tmp->lnmxs[0].lnmx_l_xlen);
00509 #ifdef LNM_DEBUG
00510 lnmprintf(" parent %x\n",l->lnmth_l_parent);
00511 lnmprintf(" table %x\n",tmp->lnmb_l_table);
00512 #endif
00513 tmp=tmp->lnmb_l_flink;
00514 } while (tmp!=head);
00515 }
00516 }
00517 }
00518 #else
00519
00520 #endif
00521
00522
00523 void cre_syscommon(char * name) {
00524 int sts;
00525 char * myname = "DKA200:[vms_common.]";
00526 char * myname2 = "DKA200:[vms_common.sysexe]";
00527 char * myname3 = "DKA200:[vms_common.syslib]";
00528 char * myname4 = "DKA200:[vms_common.sys$ldr]";
00529 _DESCRIPTOR(mytabnam_, "LNM$SYSTEM_TABLE");
00530 struct dsc_descriptor * mytabnam = &mytabnam_;
00531 _DESCRIPTOR(dev_, "SYS$COMMON");
00532 struct dsc_descriptor * dev = &dev_;
00533 _DESCRIPTOR(dev2_, "SYS$SYSTEM");
00534 struct dsc_descriptor * dev2 = &dev2_;
00535 _DESCRIPTOR(dev3_, "SYS$LIBRARY");
00536 struct dsc_descriptor * dev3 = &dev3_;
00537 _DESCRIPTOR(dev4_, "SYS$LOADABLE_IMAGES");
00538 struct dsc_descriptor * dev4 = &dev4_;
00539 struct item_list_3 itm[2];
00540
00541 memcpy(myname,name,strlen(name));
00542 memcpy(myname2,name,strlen(name));
00543 memcpy(myname3,name,strlen(name));
00544
00545 itm[0].item_code=LNM__STRING;
00546 itm[0].buflen=strlen(myname);
00547 itm[0].bufaddr=myname;
00548 memset(&itm[1],0,sizeof(struct item_list_3));
00549 sts=exe_crelnm(0,mytabnam,dev,0,itm);
00550
00551 itm[0].item_code=LNM__STRING;
00552 itm[0].buflen=strlen(myname2);
00553 itm[0].bufaddr=myname2;
00554 memset(&itm[1],0,sizeof(struct item_list_3));
00555 sts=exe_crelnm(0,mytabnam,dev2,0,itm);
00556
00557 itm[0].item_code=LNM__STRING;
00558 itm[0].buflen=strlen(myname3);
00559 itm[0].bufaddr=myname3;
00560 memset(&itm[1],0,sizeof(struct item_list_3));
00561 sts=exe_crelnm(0,mytabnam,dev3,0,itm);
00562
00563 itm[0].item_code=LNM__STRING;
00564 itm[0].buflen=strlen(myname4);
00565 itm[0].bufaddr=myname4;
00566 memset(&itm[1],0,sizeof(struct item_list_3));
00567 sts=exe_crelnm(0,mytabnam,dev4,0,itm);
00568 }
00569