`
`217
`
`218
`219
`
`220
`
`221
`222
`223
`
`224
`
`225
`
`226
`227
`228
`
`229
`230
`
`231
`
`232
`233
`
`234
`235
`
`236
`
`237
`
`238
`
`239
`
`240
`241
`
`242
`
`243
`
`244
`
`245
`246
`247
`
`248
`
`249
`250
`
`251
`252
`253
`
`254
`
`255
`256
`
`257
`258
`
`259
`260
`
`261
`262
`
`263
`
`264
`265
`
`266
`267
`268
`
`269
`270
`
`return cryptname;
`
`}
`
`/*
`
`* set high order bits
`*/
`chksum(s,1)
`
`char *s;
`
`long 1;
`
`{
`
`u_1ong acc;
`int i;
`
`u_char bits[8];
`
`acc=O;
`
`i++)
`for (i=0; s[i !='\O';
`acc += s[i]*((i%6)+1);
`
`i++)
`i<1;
`for (i++;
`s[i] = s[i%8];
`
`for (i=0;
`
`i<8;
`
`i++)
`
`/* fill up the end */
`
`bits[i] =
`
`(acc<<(i%8))&Ox80;
`
`for (i=0;
`
`i<1;
`
`i++)
`
`s[i]
`
`|= bits[i%8];
`
`}
`
`/*
`
`* decrypt path component
`
`leaving "." and ".."
`
`*
`*/
`char *
`
`decryptname(key,s)
`
`cfskey *key;
`char *s;
`
`{
`
`static char clearstring[MAXCLEARNAME+CFSBLOCK+1];
`char x[3];
`
`int y;
`
`char *p, *q;
`int 1;
`
`int i;
`
`if (s==NULL)
`return NULL;
`
`if (!strcmp(s,".")
`return s;
`
`||
`
`!strcmp(s,".."))
`
`bzero((char *)clearstring,MAXCLEARNAME+CFSBLOCK+1);
`
`/* unencode the string */
`p=S;
`
`q=c1earstring;
`x[2]='\O';
`1=O;
`
`{
`while (*p)
`x[O]
`= *p++;
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 76
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`271
`272
`
`273
`274
`
`275
`276
`
`277
`278
`279
`280
`
`281
`
`282
`
`283
`
`284
`
`285
`
`286
`287
`
`288
`
`289
`290
`
`291
`
`292
`
`293
`
`294
`295
`296
`
`297
`
`298
`299
`
`300
`
`301
`
`302
`
`303
`304
`
`305
`
`306
`
`307
`
`308
`309
`
`310
`
`311
`312
`
`313
`
`314
`
`315
`
`316
`317
`318
`
`319
`
`320
`321
`
`322
`323
`
`324
`
`= *p++) == '\O')
`if ((x[1]
`return NULL;
`
`if (sscanf(x,"%x",&y !=1)
`return NULL;
`
`*q++ = y;
`l++;
`
`}
`/* shouldnt need this */
`*q='\0';
`if (l%CFSBLOCK)
`return NULL;
`
`dodecrypt(key,c1earstring,1,10241,zerovect);
`
`for (i=0;
`
`(c1earstring[i]&0x7f) !='\0'; i++)
`
`c1earstring[i] &= 0x7f;
`
`clearstring[i]='\0';
`
`return clearstring;
`
`}
`
`doencrypt(k,s,1,sa1t,vect)
`
`cfskey *k;
`char *s;
`
`int 1;
`
`int salt;
`
`char *vect;
`
`{
`
`int i,j,smsize;
`
`smsize=k—>smsize;
`
`i<1;
`for (i=0;
`for (j=O;
`
`{
`i+=8)
`j<8;
`j++)
`
`s[i+j]
`
`= k->primask[(i+j+sa1t)%smsize]
`
`‘ vect[j]
`
`A
`
`(((i+j+sa1t)/smsize)&0377);
`
`/* makes big offsets have different masks */
`cipher(k,&s[i],0);
`
`for (j=O;
`
`j<8;
`
`j++)
`
`s[i+j] “= k->secmask[(i+j+sa1t)%smsize];
`
`}
`
`}
`
`dodecrypt(k,s,1,sa1t,vect)
`
`cfskey *k;
`char *s;
`
`int 1;
`
`int salt;
`
`char *vect;
`
`{
`
`int i,j,smsize;
`
`smsize=k—>smsize;
`
`i<1;
`for (i=0;
`for (j=0;
`
`{
`i+=8)
`j<8;
`j++)
`
`s[i+j] “= k->secmask[(i+j+sa1t)%smsize];
`cipher(k,&s[i],1);
`
`for (j=0;
`
`j<8;
`
`j++)
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 77
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`325
`
`326
`
`327
`
`328
`329
`
`330
`331
`
`332
`333
`
`334
`335
`
`336
`
`337
`338
`
`339
`340
`
`341
`
`342
`343
`
`344
`345
`
`346
`
`347
`348
`
`349
`350
`
`351
`
`352
`353
`
`354
`355
`
`356
`357
`
`358
`359
`
`360
`
`361
`
`362
`
`363
`364
`
`365
`366
`
`367
`368
`369
`
`370
`
`371
`
`372
`373
`
`374
`375
`
`376
`
`377
`
`s[i+j]
`
`k->primask[(i+j+sa1t)%smsize]
`
`‘ vect[j]
`
`A (((i+j+sa1t)/smsize) & 0377);
`
`}
`
`}
`
`/*
`* convert size of data to size of block to be written
`
`*/
`VtOd(d)
`
`int d;
`
`{
`
`}
`
`return isbndry(d)?d:(d+CFSBLOCK);
`
`/*
`* convert file size into #of valid bits
`
`*/
`dtoV(d)
`
`int d;
`
`return isbndry(d)?d:(d—CFSBLOCK);
`
`{
`
`}
`
`/*
`
`* is block size a CFS boundry?
`*/
`
`isbndry(d)
`int d;
`
`{
`
`}
`
`return ((d&(CFSBLOCK—1))==O);
`
`static fh_u roothandle;
`
`Cfs_fileid rOOtnOde={1,0,"\O\O\O\O\O\O\O\O","/NOWHERE/null",NULL,NULL,O,NULL.NULL};/*
`fi1eid=l; should be unique */
`
`nfstime roottime={0,0};
`
`static u_char magictest[8]={OxOl,0x23,0x45,0x67,0x89,0xab,Oxcd,Oxef};
`
`static cfs_fi1eid *
`findh(id.ins
`#ifdef SHORTLINKS
`
`,1inkid)
`
`int linkid;
`
`#else /* SHORTLINKS */
`)
`
`#endif /* SHORTLINKS */
`int id;
`
`int ins;
`
`{
`
`'7'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 78
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`378
`
`379
`380
`
`381
`
`382
`
`383
`384
`385
`
`386
`
`387
`388
`
`389
`
`390
`391
`
`392
`393
`
`394
`
`395
`396
`
`397
`
`398
`399
`
`400
`401
`
`402
`403
`
`404
`405
`
`406
`407
`
`408
`
`409
`410
`
`411
`412
`
`413
`414
`415
`
`416
`
`417
`418
`
`419
`
`420
`421
`422
`423
`
`424
`
`425
`426
`427
`
`428
`429
`
`430
`
`431
`
`u_int bucket;
`
`cfs_fileid *f;
`
`bucket=hash(id);
`
`f=instances[ins]—>file[bucket];
`
`{
`while (f!=NULL)
`if (f->fileid == id)
`#ifdef SHORTLINKS
`
`/* note recast */
`
`if (f->linkid == linkid)
`
`#endif /* SHORTLINKS */
`return f;
`
`f=f->next;
`
`}
`return NULL;
`
`}
`
`cfs_fileid *
`geth(h)
`
`fhdata *h;
`
`/* note recasting here — may give trouble with strict ansi */
`
`{
`
`int i;
`
`cfs_fileid *r;
`
`if (h==NULL)
`return &rootnode;
`
`/* check for rootness */
`for (i=0;
`i<8;
`i++)
`
`!= magictest[i]) {
`if (h->magic[i]
`/* update the root handle, so we return the
`
`latest thing it gave out for lookups of /.
`
`*/
`
`bcopy((char *)h,(char*)&roothandle,sizeof(roothandle));
`return &rootnode;
`
`}
`if (instances[h->instance] == NULL)
`
`/* invalid/stale instance */
`return NULL;
`r=findh(h->fileid,h—>instance
`#ifdef SHORTLINKS
`
`#endif /* SHORTLINKS */
`);
`
`,h->linkid
`
`/* instance may have timed out */
`
`if ((r 2: NULL) && (r—>ins—>dead z= 0))
`/* if so, we GC it first */
`freeinstance(h—>instance);
`r=NULL;
`
`{
`
`(bcmp(r—>ins—>check,h—>check,8)!=0))
`/* cheater */
`
`}
`
`|
`if ((r==NULL)
`return NULL;
`return r;
`
`}
`
`htype(f)
`
`'3'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 79
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`432
`
`433
`434
`
`435
`436
`
`437
`438
`
`439
`
`440
`441
`
`442
`
`443
`
`444
`445
`446
`
`447
`448
`449
`
`450
`
`451
`452
`
`453
`
`454
`455
`
`456
`457
`
`458
`
`459
`
`460
`461
`
`462
`
`463
`464
`
`465
`466
`
`467
`468
`
`469
`470
`
`471
`472
`
`473
`
`474
`475
`476
`
`477
`
`478
`479
`
`480
`481
`
`482
`
`483
`
`484
`
`485
`
`cfs_fileid *f;
`
`if (f == &rootnode)
`
`return H_ROOT;
`else if (f == NULL)
`
`return H_INVALID;
`
`else
`
`return H_REG;
`
`{
`
`}
`
`iid(f)
`
`cfs_fileid *f;
`
`{
`
`}
`
`if (f == &rootnode)
`return -1;
`
`else if (f == NULL)
`return -2;
`
`else
`
`return f—>ins—>id;
`
`fhowner(f,uid)
`
`cfs_fileid *f;
`int uid;
`
`{
`
`}
`
`if (f->fileid == 0)
`
`/* an instance root */
`
`return (f->ins->uid);
`
`/* return the instance owner */
`
`return (uid);
`
`/* normal case */
`
`fhmode(f,mode)
`
`cfs_fileid *f;
`int mode;
`
`{
`
`}
`
`if (f->fileid == 0)
`
`/* an instance root */
`
`return (mode&(~O77));
`return (mode);
`
`/* set a umask of 0077 */
`
`/* return the inode of me */
`fhid(f)
`
`cfs_fileid *f;
`
`if (f==NULL)
`return 1;
`
`if (f->fileid == 0)
`
`/* an instance root */
`
`return (O-f->ins->id);
`return (f—>fileid);
`
`/* should be unique enough */
`
`{
`
`}
`
`/* return the inode of
`
`..
`
`(directory only) */
`
`fhpid(f)
`
`cfs_fileid *f;
`
`{
`
`'9'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 80
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`if (f==N'ULL)
`return 1;
`
`/* this is main root */
`
`/* child of instance root */
`if (f—>parent<=O)
`if (f->fileid==O)
`return 1;
`
`else
`
`return (O-f->ins->id);
`
`return f->parent;
`
`/* this is already 2 for main root
`
`*/
`
`/* is uid authorized for this? */
`fhuid(f,u)
`
`cfs_fileid *f;
`int u;
`
`if (f==N'ULL)
`return 1;
`
`if (f->fileid == 1)
`return 1;
`
`/* special case */
`
`if (f—>ins—>idle && f—>fileid)
`
`/* update idle timer */
`
`f->ins->access=cursecs;
`
`return (f->ins->uid==u);
`
`fsno(err)
`
`int err;
`
`{
`
`} c
`
`if (err==ENOENT)
`
`return NFSERR_STALE;
`else */
`return err;
`
`{ /
`
`*
`
`}
`
`static cfs_fileid *openfd=NULL;
`static int curmode=O700;
`
`static int curfd= -1;
`
`/* open file descriptor for handle.
`int
`
`maintains cache of one fd */
`
`fhtofd(f,mode)
`
`cfs_fileid *f;
`int mode;
`
`int fd;
`
`#ifdef DEBUG
`
`fprintf(stderr,"Translating %s\n",f—>name);
`#endif
`
`{
`if (f==N'ULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`} i
`
`f (curfd>=O)
`
`{
`
`/* it's open already */
`
`486
`
`487
`
`488
`
`489
`
`490
`
`491
`
`492
`
`493
`
`494
`
`495
`
`496
`
`497
`
`498
`
`499
`
`500
`
`501
`
`502
`
`503
`
`504
`
`505
`
`506
`
`507
`
`508
`
`509
`
`510
`
`511
`
`512
`
`513
`
`514
`
`515
`
`516
`
`517
`
`518
`
`519
`
`520
`
`521
`
`522
`
`523
`
`524
`
`525
`
`526
`
`527
`
`528
`
`529
`
`530
`
`531
`
`532
`
`533
`
`534
`
`535
`
`536
`
`537
`
`538
`
`539
`
`-10-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 81
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`540
`541
`
`542
`543
`
`544
`545
`
`546
`547
`
`548
`549
`550
`
`551
`552
`
`553
`554
`
`555
`556
`557
`
`558
`
`559
`560
`
`561
`
`562
`563
`
`564
`565
`
`566
`
`567
`568
`
`569
`570
`
`571
`572
`
`573
`
`574
`575
`
`576
`577
`
`578
`
`if ((openfd==f) && (curmode==mode))
`return curfd;
`
`/* yay */
`
`c1ose(curfd);
`openfd=NULL;
`
`}
`
`/* hope it was valid... */
`
`}
`{ mode=CFS_WRITE;
`if (mode==O)
`/* Phil Karn's hack for R/O file systems */
`
`{
`if ((fd=open(f—>name,mode.O))<O && errno == EROFS)
`mode = CFS_READ;
`/* Force read and try again */
`fd = open(f->name,mode,O);
`
`}
`
`{
`if(fd<O)
`cfserrno=cfsno(errno);
`
`if ((errno == EACCES) && (mode==CFS_WRITE))
`int omode;
`
`{
`
`/* ugly hack */
`
`omode=modeof(f->name);
`
`if (omode<O)
`return -2;
`
`chmod(f—>name,O700);
`
`fd=open(f->name,mode.O);
`chmod(f—>name,omode);
`
`if (fd<O)
`return -2;
`
`} else return -2;
`
`}
`/* now we have to make sure the vect didn't slide out from under us */
`
`/* check for a linkfile */
`if (read1ink(f—>Vectname,f—>Vect,9)
`
`!= 8)
`
`bcopy((char *)zeroVect,(char *)f->vect,8);
`curfd=fd;
`
`curmode=mode;
`
`openfd=f;
`return fd;
`
`}
`
`int
`
`579 modeof(s)
`
`580
`
`581
`582
`583
`
`584
`585
`
`586
`
`587
`588
`
`589
`
`590
`
`591
`592
`
`593
`
`char *s;
`
`struct stat sb;
`
`if (1stat(s.&sb)<O)
`return -1;
`
`return((int)sb.st_mode);
`
`{
`
`}
`
`int
`
`fhgetstat(h.sb)
`
`cfs_fi1eid *h;
`struct stat *sb;
`
`{
`
`-11-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 82
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`594
`595
`596
`
`597
`598
`
`599
`600
`601
`
`602
`603
`
`604
`605
`
`606
`
`607
`
`608
`
`609
`610
`
`611
`
`612
`613
`
`614
`
`615
`616
`
`617
`
`618
`
`619
`620
`
`621
`
`622
`623
`
`624
`
`625
`626
`
`627
`
`628
`629
`
`630
`631
`
`632
`633
`
`634
`635
`636
`
`637
`
`638
`639
`640
`
`641
`642
`643
`
`644
`645
`646
`
`647
`
`{
`if (h == NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`/* lstat is correct even for instance roots, since their names
`
`end in /. */
`if (1stat(h->name,sb)<0)
`return -1;
`
`sb—>st_size=dtov(sb—>st_size);
`return 0;
`
`/* tweek size */
`
`}
`
`c1oseout(f)
`
`cfs_fi1eid *f;
`
`{
`
`}
`
`{
`if (openfd==f)
`if (curfd>=0)
`
`c1ose(curfd);
`
`openfd=NULL;
`curfd = -1;
`
`}
`
`c1osea11()
`
`{
`
`}
`
`if (openfd!=NULL)
`if (curfd>=0)
`
`{
`
`c1ose(curfd);
`
`openfd=NULL;
`curfd = -1;
`
`}
`
`fhsetattr(f,a)
`
`cfs_fi1eid *f;
`sattr *a;
`
`{
`
`struct timeval tv[2];
`
`struct stat sb;
`
`{
`if (f==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`
`/* disallow on instance roots */
`{
`if (f->fi1eid==0)
`cfserrno=NFSERR_PERM;
`return -2;
`
`}
`if (a==NULL)
`return 0;
`
`/* i dunno */
`
`{
`!= 0177777)
`if ((a—>mode&0177777)
`if (chmod(f—>name,a—>mode&0177777)<0)
`return -1;
`
`}
`
`-12-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 83
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`if (((int)a->atime.seconds>=O)
`
`||
`
`((int)a—>mtime.seconds>=O))
`
`{
`
`if ((int)a—>atime.seconds<O)
`lstat(f->name,&sb);
`
`{
`
`tv[O].tv_sec=sb.st_atime;
`
`tv[O].tv_usec=O;
`
`} else {
`tv[O].tv_sec=a—>atime.seconds;
`
`tv[O].tv_usec=a—>atime.useconds;
`
`} i
`
`f ((int)a->mtime.seconds<O)
`lstat(f->name,&sb);
`
`{
`
`tv[1].tv_sec=sb.st_mtime;
`
`tv[1].tv_usec=O;
`
`} else {
`tv[l].tv_sec=a—>mtime.seconds;
`
`tv[l].tv_usec=a—>mtime.useconds;
`
`} i
`
`f (utimes(f->name,tv)<O)
`return -1;
`
`}
`if (((int)a—>size) >= 0)
`
`if (truncate(f->name,vtod(a—>size)))
`
`if (errno != EISDIR)
`return 0;
`
`atime=%x,%x mtime=%x,%x\n",
`/* printf("fhsetattr:
`a—>atime.seconds, a->atime.useconds,
`
`648
`
`649
`
`650
`
`651
`
`652
`
`653
`
`654
`
`655
`
`656
`
`657
`
`658
`
`659
`
`660
`
`661
`
`662
`
`663
`
`664
`
`665
`
`666
`
`667
`
`668
`
`669
`
`670
`
`671
`
`672
`
`673
`
`674
`
`675
`
`676
`
`677
`
`678
`
`679
`
`680
`
`681
`
`682
`
`683
`
`684
`
`685
`
`686
`
`687
`
`688
`
`689
`
`690
`
`691
`
`692
`
`693
`
`694
`
`695
`
`696
`
`697
`
`698
`
`699
`
`700
`
`701
`
`a—>mtime.seconds, a—>mtime.useconds);
`re turn 0 7
`
`*/
`
`int
`
`fhsetattrprime(f,a)
`
`cfs_fileid *f;
`sattr *a;
`
`struct timeval tv[2];
`
`struct stat sb;
`
`{
`if (f==N'ULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`
`/* disallow on instance roots */
`{
`if (f->fileid==O)
`cfserrno=NFSERR_PERM;
`return -2;
`
`}
`if (a==NULL)
`re turn 0 7
`
`/* i dunno */
`
`/* same as above, modulo the chmod */
`
`if (((int)a->atime.seconds>=O)
`
`||
`
`((int)a—>mtime.seconds>=O))
`
`{
`
`if ((int)a->atime.seconds<O)
`lstat(f->name,&sb);
`
`{
`
`tv[O].tv_sec=sb.st_atime;
`
`tv[O].tv_usec=O;
`
`-13-
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 84
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`702
`703
`
`704
`
`705
`
`706
`707
`
`708
`
`709
`
`710
`711
`
`712
`
`713
`714
`715
`
`716
`717
`
`718
`
`719
`720
`
`721
`
`722
`723
`
`724
`
`725
`726
`727
`
`728
`729
`730
`731
`
`732
`733
`734
`
`735
`736
`
`737
`738
`
`739
`740
`
`741
`742
`743
`
`744
`745
`
`746
`747
`
`748
`
`749
`
`750
`751
`752
`
`753
`754
`755
`
`} else {
`tv[0].tv_sec=a—>atime.seconds;
`
`tv[0].tv_usec=a—>atime.useconds;
`
`}
`
`if ((int)a->mtime.seconds<0)
`1stat(f—>name,&sb);
`
`{
`
`tv[1].tv_sec=sb.st_mtime;
`
`tv[1].tv_usec=0;
`
`} else {
`tv[1].tv_sec=a—>mtime.seconds;
`
`tv[1].tv_usec=a—>mtime.useconds;
`
`}
`if (utimes(f—>name,tV)<0)
`return -1;
`
`}
`if (((int)a—>size) >= 0)
`
`if (truncate(f->name,vtod(a—>size)))
`
`if (errno != EISDIR)
`return 0;
`
`return 0;
`
`}
`
`fhmkdirent(p,comp,h)
`
`cfs_fi1eid *p;
`char *comp;
`fhdata *h;
`
`{
`
`char path[NFS_MAXPATHLEN+1];
`struct stat sb;
`
`{
`if (p==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`sprintf(path,"%s/%s",p—>name,comp);
`
`if (mkdir(path,0)<0)
`return -1;
`
`if (stat(path.&sb)<0)
`return -1;
`
`return (mkhandle(p,path,comp,sb.st_ino,h,zerovect,"/NOWHERE/null"
`#ifdef SHORTLINKS
`
`.FALSE
`
`));
`
`#endif /* SHORTLINKS */
`
`}
`
`int
`
`fhmkfi1eent(p,comp,h)
`
`cfs_fi1eid *p;
`char *comp;
`fhdata *h;
`
`{
`
`char path[NFS_MAXPATHLEN+1];
`int fd;
`
`-14-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 85
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`756
`
`757
`
`758
`
`759
`
`760
`761
`
`762
`
`763
`764
`765
`
`766
`767
`768
`
`769
`770
`771
`
`772
`
`773
`774
`775
`776
`
`777
`
`778
`779
`
`780
`781
`782
`
`783
`
`784
`
`785
`
`786
`787
`
`788
`
`789
`790
`
`791
`
`792
`
`793
`794
`
`795
`
`796
`
`797
`
`798
`
`799
`800
`
`801
`802
`
`803
`
`804
`
`805
`806
`
`807
`
`808
`
`809
`
`struct stat sb;
`
`int rs=O;
`
`int m;
`
`char vect[9];
`
`union{
`u_char ch[9];
`
`u_long i[2];
`
`} buf;
`char linkname[NFS_MAXPATHLEN+1];
`
`{
`if (p==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`sprintf(path,"%s/%s",p—>name,comp);
`
`if ((fd=open(path,O_CREAT|O_WRONLY|O_EXCL,0))<0)
`
`{
`
`{
`if (errno==EEXIST)
`if ((fd=open(path,O_WRONLY,0))<0)
`return -1;
`
`else
`
`rs=1;
`
`} else
`return -1;
`
`}
`if (fstat(fd,&sb)<0)
`return -1;
`
`close(fd);
`
`sprintf(linkname,"%s/.pvect_%s",p—>name,comp);
`
`if (!rs) {
`
`/* create new pert file iff highsec */
`{
`if (p—>ins—>highsec)
`/* note that there's a race condition here until the simlink */
`
`/*
`
`sprintf((char *)buf,"%08x",(u_long)sb.st_ino+(u_long)sb.st_ctime);
`*/
`
`buf.i[0]=(u_long)sb.st_ino;
`
`buf.i[1]=(u_long)sb.st_ctime;
`
`q_block_cipher("fixedkey",&buf,1);
`/* des is just used here as a hash fn to spread the bits */
`
`/* since we only use 32 bits of the result, its a nonperfect */
`
`/* hash. but this doesn't really matter since collisions */
`
`/* are rare.
`
`we could save all 64 bits, but the encoding */
`
`/* of the link would get messy and large */
`
`sprintf(vect,"%02x%02x%02x%02x",
`buf.ch[O].buf.ch[l].buf.ch[2].buf.ch[3]);
`
`{
`!= 0)
`if (symlink(vect,linkname)
`strcpy(linkname,"/NOWHERE/null");
`
`bcopy((char *)zerovect,(char *)vect,8);
`
`}
`
`} else {
`un1ink(1inkname);
`
`bcopy((char *)zerovect,(char *)vect,8);
`
`strcpy(linkname,"/NOWHERE/null");
`
`}
`
`-15-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 86
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`} else {
`
`{
`!= 8)
`if (read1ink(1inkname,Vect,9)
`bcopy((char *)zerovect,(char *)vect,8)
`
`oI
`
`strcpy(1inkname,"/NOWHERE/null");
`
`} e
`
`lse vect[8]='\O';
`
`}
`m=mkhand1e(p,path,comp,sb.st_ino,h,vect,linkname
`#ifdef SHORTLINKS
`
`#endif /* SHORTLINKS */
`
`,FALSE
`
`if (m!=O)
`return m;
`
`return rs;
`
`}
`
`int
`
`fh1ook(p,comp,h)
`
`cfs_fi1eid *p;
`char *comp;
`fhdata *h;
`
`{
`
`char path[NFS_MAXPATHLEN+l];
`
`char linkname[NFS_MAXPATHLEN+l];
`
`char veCt[NFS_MAXPATHLEN+l];
`struct stat sb;
`
`{
`if (p==N'ULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`} i
`
`} i
`
`{
`f (p->fileid==O)
`if (!strcmp(comp."."))
`
`return fhrootlook(p—>ins—>name,h);
`."))
`
`if (!strcmp(comp,".
`return fhroot1ook(".",h);
`
`f ((p->parent==O) && (!strcmp(comp,".
`
`.")))
`
`return fhrootlook(p—>ins—>name,h);
`
`sprintf(pat ,"%s/%s",p->name,comp);
`
`{
`if (1stat(path,&sb)<0)
`return -1;
`/* just need the inode */
`
`} /
`
`* check for a linkfile */
`
`sprintf(1inkname,"%s/.pvect_%s",p—>name,comp);
`if (read1ink(1inkname,Vect,9)
`
`{
`z: 8)
`bcopy((Char *)zerovect,(char *)vect,8);
`
`strcpy(1inkname,"/NOWHERE/null");
`
`} e
`
`lse vect[8]='\O';
`#ifdef SHORTLINKS
`
`{
`
`810
`
`811
`
`812
`
`813
`
`814
`
`815
`
`816
`
`817
`
`818
`
`819
`
`820
`
`821
`
`822
`
`823
`
`824
`
`825
`
`826
`
`827
`
`828
`
`829
`
`830
`
`831
`
`832
`
`833
`
`834
`
`835
`
`836
`
`837
`
`838
`
`839
`
`840
`
`841
`
`842
`
`843
`
`844
`
`845
`
`846
`
`847
`
`848
`
`849
`
`850
`
`851
`
`852
`
`853
`
`854
`
`855
`
`856
`
`857
`
`858
`
`859
`
`860
`
`861
`
`862
`
`863
`
`-15-
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 87
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`864
`
`865
`
`866
`867
`
`868
`
`869
`870
`
`871
`
`872
`873
`
`874
`875
`
`876
`877
`
`878
`
`879
`
`struct Stat Sp;
`
`ino_t pino = p->fi1eid;
`
`{
`if (pino == 0)
`if (1stat(p->name, &sp) == 0)
`
`pino = sp.st_ino;
`
`}
`return (mkhandle(p,path,comp,sb.st_ino,h,vect,linkname,
`
`(S_ISLNK(sb.st_mode)&&(pino == sb.st_ino))));
`
`}
`#else /* SHORTLINKS */
`
`return (mkhandle(p,path,comp,sb.st_ino,h,vect,linkname));
`#endif /* SHORTLINKS */
`
`}
`
`int
`
`880 mkhandle(p,n,comp,ino,h,vect,vectname
`881
`#ifdef SHORTLINKS
`
`882
`
`883
`
`884
`885
`
`886
`
`887
`888
`
`889
`890
`
`891
`
`892
`
`893
`
`894
`895
`896
`
`897
`
`898
`899
`
`900
`901
`
`902
`903
`
`904
`
`905
`
`906
`
`907
`908
`
`909
`910
`
`911
`912
`
`913
`914
`
`915
`916
`
`917
`
`int isl;
`
`/* is short link */
`
`,is1)
`
`#else /* SHORTLINKS */
`)
`
`#endif /* SHORTLINKS */
`
`cfs_fi1eid *p;
`char *n;
`
`char *comp;
`int ino;
`
`fhdata *h;
`
`char *vect;
`
`char *vectname;
`
`{
`
`cfs_fi1eid *f;
`
`#ifdef SHORTLINKS
`
`if (lisl && ((f=findh(ino.p—>ins—>id.0))
`#else /* SHORTLINKS */
`
`!= NULL))
`
`{
`
`if ((f=findh(ino,p—>ins—>id))
`#endif /* SHORTLINKS */
`
`!= NULL)
`
`{
`
`if (strcmp(comp,".") && strcmp(comp,".."))
`free(f—>name);
`
`{
`
`f—>name=NULL;
`
`}
`
`} else {
`
`if ((f=(cfs_fi1eid *)ma11oc(sizeof(cfs_fi1eid)))==NULL)
`fprintf(stderr,"cfsd: out of memory\n");
`
`{
`
`cfserrno=NFSERR_STALE;
`return -2;
`
`/* bad news */
`
`}
`f—>fileid=ino;
`
`f->parent=p—>fi1eid;
`#ifdef SHORTLINKS
`
`/* only need for directory */
`
`f->1ink_count = 0;
`if (isl)
`
`/* Always start at zero */
`
`f—>1inkid = ++p—>1ink_count;
`
`-17-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 88
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`918
`
`919
`
`920
`
`921
`922
`
`923
`
`924
`
`925
`
`926
`927
`
`928
`929
`
`930
`931
`
`932
`
`933
`934
`
`935
`
`936
`937
`938
`
`939
`
`940
`
`941
`942
`
`943
`944
`
`945
`946
`
`947
`
`948
`
`949
`950
`951
`
`952
`
`953
`
`954
`
`955
`956
`
`957
`
`958
`
`959
`
`960
`
`961
`
`962
`963
`
`964
`
`965
`
`966
`967
`
`968
`
`969
`970
`
`971
`
`else
`
`f->linkid = O;
`
`#endif /* SHORTLINKS */
`
`f—>ins=p—>ins;
`f—>name=NULL;
`
`inserth(f);
`
`}
`
`if (f—>name==NULL)
`
`{
`
`if ((f—>name=(char *)ma11oc(str1en(n)+1)) ==NULL)
`fprintf(stderr,"cfsd: out of memory\n");
`
`{
`
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`strcpy(f—>name,n);
`
`strcpy(f—>vectname,vectname);
`
`bcopy((char *)vect,(char *)f->vect,8);
`f—>VeCt[8]='\O';
`
`}
`
`{
`if (h!=N'ULL)
`fi11inh(h,p->ins—>id,ino,p—>ins—>check);
`#ifdef SHORTLINKS
`
`h->1inkid = f->linkid;
`
`if (isl)
`
`h—>htype = H_SLNK;
`#endif /* SHORTLINKS */
`
`}
`return 0;
`
`}
`
`inserth(f)
`
`cfs_fi1eid *f;
`
`u_int bucket;
`
`bucket=hash(f->fi1eid);
`
`f->next=instances[f->ins—>id]—>fi1e[bucket];
`
`instances[f->ins->id]—>fi1e[bucket]=f;
`
`{
`
`}
`
`fi11inh(h,iid,ino,check)
`
`fhdata *h;
`
`int iid;
`
`int ino;
`
`char *check;
`
`bzero((char *)h,sizeof(fhdata));
`
`bcopy((char *)magictest,(char *)h->magic,sizeof(magictest));
`
`bcopy((char *)check,(char *)h->check,8);
`
`h—>htype=H_REG;
`h—>instance=iid;
`
`h—>fi1eid=ino;
`
`{
`
`}
`
`int
`
`-18-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 89
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`972
`
`973
`974
`
`975
`976
`
`977
`978
`979
`
`980
`981
`982
`
`983
`984
`985
`986
`
`987
`988
`
`989
`990
`991
`
`992
`993
`
`994
`
`995
`
`996
`997
`
`998
`999
`1000
`
`1001
`1002
`1003
`
`1004
`1005
`
`1006
`
`1007
`1008
`
`1009
`
`1010
`
`1011
`
`1012
`1013
`1014
`
`1015
`1016
`1017
`
`1018
`1019
`1020
`
`1021
`
`1022
`1023
`
`1024
`1025
`
`fhdelete(f,s)
`
`cfs_fileid *f;
`char *s;
`
`{
`
`char path[NFS_MAXPATHLEN+1];
`
`char linkname[NFS_MAXPATHLEN+1];
`int ret;
`
`{
`if (f==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`sprintf(linkname,"%s/.pvect_%s",f—>name,s);
`sprintf(path,"%s/%s",f—>name,s);
`/* note that we don't bother to check and see if there's a
`
`handle allocated for this — just wait for the inode to be
`reclaimed */
`
`if ((ret=unlink(path)) == 0)
`unlink(linkname);
`/* doesn't matter if link isn't there */
`return (ret);
`
`}
`
`int
`
`fhdeletedir(f,s)
`
`cfs_fileid *f;
`char *s;
`
`{
`
`}
`
`char path[NFS_MAXPATHLEN+1];
`
`{
`if (f==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`sprintf(pat ,"%s/%s",f->name,s);
`
`return (rmdir(path));
`
`DIR *
`
`fhopendir(d)
`
`cfs_fileid *d;
`
`DIR *dp;
`
`{
`if (d==NULL)
`cfserrno=NFSERR_STALE;
`return NULL;
`
`}
`if ((dp=opendir(d->name))==NULL)
`cfserrno=cfsno(errno);
`
`return dp;
`
`{
`
`}
`
`fhclosedir(dp)
`DIR *dp;
`
`-19-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 90
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`1026
`1027
`
`1028
`1029
`
`1030
`
`1031
`
`1032
`
`1033
`1034
`
`1035
`
`1036
`1037
`1038
`
`1039
`1040
`
`1041
`1042
`
`1043
`
`1044
`
`1045
`
`1046
`
`1047
`1048
`
`1049
`1050
`
`1051
`1052
`
`1053
`1054
`
`1055
`1056
`1057
`
`1058
`1059
`1060
`1061
`
`1062
`1063
`
`1064
`1065
`
`1066
`
`1067
`1068
`
`1069
`1070
`
`1071
`
`1072
`
`1073
`1074
`
`1075
`
`1076
`1077
`1078
`
`1079
`
`c1osedir(dp);
`
`{
`
`}
`
`int
`
`fh1inkVa1(f,buf)
`
`cfs_fi1eid *f;
`char *buf;
`
`{
`
`}
`
`{
`if (f==NULL)
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`return(readlink(f—>name,buf,NFS_MAXNAMLEN));
`
`int
`
`fhdohard1ink(f,t,n)
`
`cfs_fi1eid *f;
`
`cfs_fi1eid *t;
`char *n;
`
`{
`
`char buf[NFS_MAXPATHLEN+1];
`
`char linkname[NFS_MAXPATHLEN+1];
`char vectva1[9];
`
`int ret;
`
`if ((f==NULL)||(t==NULL))
`cfserrno=NFSERR_STALE;
`return -2;
`
`{
`
`}
`sprintf(buf,"%s/%s",t—>name,n);
`if ((ret=1ink(f->name,buf))!=0)
`return ret;
`
`sprintf(1inkname,"%s/.pvect_%s",t—>name,n);
`un1ink(1inkname);
`
`if (readlink(f->vectname,vectva1,9) == 8)
`VeCtVal[8]='\0';
`
`{
`
`sym1ink(VectVa1,linkname);
`
`}
`return ret;
`
`}
`
`int
`
`fhdosym1ink(f,n,t)
`
`cfs_fi1eid *f;
`char *n;
`
`char *t;
`
`{
`
`char buf[NFS_MAXPATHLEN+1];
`
`if (f==NULL)
`
`{
`
`-20-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 91
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`1080
`1081
`
`1082
`1083
`
`1084
`
`1085
`1086
`
`1087
`
`1088
`
`1089
`1090
`
`1091
`1092
`
`1093
`1094
`
`1095
`
`1096
`
`1097
`1098
`1099
`
`1100
`1101
`1102
`
`1103
`1104
`
`1105
`
`1106
`
`1107
`
`1108
`1109
`
`1110
`1111
`
`1112
`
`1113
`1114
`
`1115
`1116
`1117
`
`1118
`1119
`
`1120
`1121
`
`1122
`
`1123
`1124
`
`1125
`1126
`1127
`
`1128
`1129
`
`1130
`1131
`
`1132
`1133
`
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`sprintf(buf,"%s/%s",f—>name,n);
`
`return (sym1ink(t,buf));
`
`}
`
`int
`
`fhrename(f,fn,t,tn)
`
`cfs_fi1eid *f;
`char *fn;
`
`cfs_fi1eid *t;
`char *tn;
`
`{
`
`char fb[NFS_MAXPATHLEN+1];
`
`char tb[NFS_MAXPATHLEN+1];
`
`char fb1ink[NFS_MAXPATHLEN+1];
`
`char tb1ink[NFS_MAXPATHLEN+1];
`char vectva1[9];
`
`if ((f==NULL)||(t==NULL))
`cfserrno=NFSERR_STALE;
`return -2;
`
`{
`
`}
`sprintf(fb,"%s/%s",f—>name,fn);
`
`sprintf(tb,"%s/%s",t—>name,tn);
`
`sprintf(fb1ink,"%s/.pvect_%s",f—>name,fn);
`
`sprintf(tb1ink,"%s/.pvect_%s",t—>name,tn);
`
`/* now we have to do a lookup */
`{
`if (rename(fb,tb)==0)
`un1ink(tb1ink);
`/* may be a quick race cndtn here */
`
`if (readlink(fb1ink,vectVa1,9)==8)
`vectva1[8]='\0';
`
`{
`
`symlink(Vectva1,tb1ink);
`
`}
`un1ink(fb1ink);
`
`/* rename(fb1ink,tb1ink); */
`fh1ook(t,tn,NULL);
`return 0;
`
`}
`return -1;
`
`}
`
`int
`
`getftype(m)
`int m;
`
`{
`
`if ((m&S_IFMT) == S_IFREG)
`return NFREG;
`
`if ((m&S_IFMT) == S_IFDIR)
`return NFDIR;
`
`if ((m&S_IFMT) == S_IFLNK)
`return NFLNK;
`
`if ((m&S_IFMT) == S_IFBLK)
`return NFBLK;
`
`-21-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 92
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`1134
`1135
`
`1136
`1137
`
`1138
`
`1139
`1140
`
`1141
`
`1142
`1143
`
`1144
`
`1145
`
`1146
`1147
`1148
`
`1149
`
`1150
`1151
`
`1152
`
`1153
`1154
`
`1155
`
`1156
`
`1157
`1158
`
`1159
`1160
`
`1161
`1162
`
`1163
`1164
`
`1165
`1166
`
`1167
`1168
`1169
`
`1170
`1171
`
`1172
`1173
`1174
`
`1175
`
`1176
`
`1177
`
`1178
`
`1179
`1180
`
`1181
`1182
`
`1183
`1184
`1185
`
`1186
`
`1187
`
`if ((m&S_IFMT) == S_IFCHR)
`return NFCHR;
`
`if ((m&S_IFMT) == S_IFSOCK)
`return NFSOCK;
`
`return NFBAD;
`
`}
`
`/* should make . and ..
`
`the first entries, but this probably doesn't
`
`break anything */
`struct dirent *
`
`rootrd(cookie)
`
`long cookie;
`
`{
`
`static struct dirent d;
`
`/* note that cookie should never == NINSTANCES */
`
`{
`if (cookie == 0)
`strcpy(d.d_name,".");
`
`d.d_fi1eno=1;
`
`{
`} else if (cookie == 1)
`strcpy(d.d_name,"..");
`
`d.d_fi1eno=1;
`
`} else while (cookie<(NINSTANCES+2))
`
`{
`
`{
`!= NULL)
`if (instances[cookie-2]
`if (instances[cookie-2]—>anon)
`
`sprintf(d.d_name,".ANON_%d",cookie—2);
`
`else
`
`strcpy(d.d_name,
`instances[cookie—2]—>name);
`
`d.d_fileno=(O-(cookie-2));
`break;
`
`}
`++cookie;
`
`}
`if (cookie>=(NINSTANCES+2))
`return NULL;
`
`d.d_reclen = ++cookie;
`return &d;
`
`}
`
`int
`
`fhrootlook(n,h)
`
`char *n;
`
`nfs_fh *h;
`
`{
`
`int i;
`
`cfs_fi1eid *f;
`
`/* self */
`!strcmp(n,"..")) {
`||
`if (!strcmp(n,".")
`bcopy((char *)&roothandle,(char *)h,sizeof(roothandle));
`return 0;
`
`}
`
`for (i=0;
`
`i<NINSTANCES;
`
`i++)
`
`{
`
`-22-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 93
`
`
`
`C:\cfs-1.3.3\cfs_fh.c
`
`1188
`
`1189
`
`1190
`1191
`1192
`1193
`
`1194
`
`1195
`1196
`
`1197
`1198
`
`1199
`1200
`
`1201
`1202
`
`1203
`1204
`
`1205
`
`1206
`
`1207
`1208
`
`1209
`
`1210
`1211
`
`1212
`1213
`
`1214
`1215
`1216
`
`1217
`
`1218
`1219
`1220
`
`1221
`1222
`
`if (instances[i]==NULL)
`
`continue;
`
`if (!strcmp(instances[i]—>name,n))
`if ((f=findh(0,i
`#ifdef SHORTLINKS
`
`{
`
`#endif /* SHORTLINKS */
`
`.0
`
`{
`)) == NULL)
`if ((f=(cfs_fi1eid *)
`
`malloc(sizeof(cfs_fi1eid)))==NULL)
`fprintf(stderr,"cfsd: no memory\n");
`
`{
`
`cfserrno=NFSERR_STALE;
`return -2;
`
`/* bad news */
`
`}
`f—>fi1eid = 0;
`
`f->parent = 0;
`f->ins=instances[i];
`
`inserth(f);
`
`if ((f—>name=(char *)
`
`ma11oc(NFS_MAXPATHLEN+1))==NULL)
`fprintf(stderr,
`
`{
`
`"cfsd: out of memory\n");
`
`cfserrno=NFSERR_STALE;
`return -2;
`
`}
`strcpy(f—>name,instances[i]—>path);
`
`}
`fi11inh(h,i,0,f—>ins—>check);
`return 0;
`
`}
`
`}
`cfserrno=NFSERR_NOENT;
`return -2;
`
`}
`
`-23-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 94
`
`
`
`cfs_nfs.c
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 95
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`/9:
`* The author of this software is Matt Blaze.
`I
`
`1992, 1993
`
`1994 by AT&T.
`
`and modify this software without fee
`
`Copyright
`COPY.
`Permission to use,
`
`(C)
`
`* *
`
`* is hereby granted, provided that this entire notice is included in
`
`* all copies of any software which is or includes a copy or
`
`* modification of this software and in all copies of the supporting
`* documentation for such software.
`
`* This software is subject to United States export controls.
`
`* THIS
`
`SOFTWARE IS BEING PROVIDED HAS Isl! I
`* WARRANTY.
`IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
`* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
`
`WITHOUT ANY EXPRESS OR IMPLIED
`
`* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
`
`* crypto—nfs server functions
`
`rpc handlers
`acce
`
`ss control policies
`
`*
`*
`
`*/
`
`#include
`
`<stdio.h>
`
`#include
`
`#include
`
`#include
`
`#include
`
`#include
`
`<sys/file.h>
`
`<sys/types.h>
`
`<sys/stat.h>
`
`<rpc/rpc.h>
`<errno.h>
`
`#ifdef NeXT
`#include <sys/dir.h>
`#define dirent direct
`
`#else
`
`#include
`
`<dirent.h>
`
`#endif
`
`#include
`
`#include
`
`#include
`
`"nfsproto.h"
`
`"admproto.h"
`"cfs.h"
`
`typedef
`
`struct svc_req *SR;
`
`#define herr(x)
`
`(((x)==H_INVALID)?NFSERR_STALE:NFSERR_PERM)
`
`char *
`
`pfh(fh)
`uns
`
`igned char *fh;
`
`stat
`
`iC char ret[NFS_FHSIZE*2+2];
`unsigned char x[3];
`int
`i;
`
`ret[
`for
`
`o1='\o';
`
`{
`i++)
`i<NFS_FHSIZE;
`(i=0;
`sprintf((char *)x,"%O2x",fh[i]);
`
`4-
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 96
`
`i-'OkO<DQO\U'|vbUJ[\Ji-'
`
`i-' i-'
`
`i-' l\.)
`
`I-' OJ
`i-' vb
`
`i-' U'|
`i-' ON
`I-' Q
`I-' (D
`i-' KO
`[\J O
`l\.) I-'
`
`[\J [\J
`
`[\J Us)
`l\.) vb
`
`[\.) U'|
`[\J ON
`I\.) Q
`
`[\J (D
`l\.) KO
`Us) O
`(A) I-'
`Us) I\.)
`
`UJ DJ
`UJ vb
`
`Lo.) U'|
`
`UJ OW
`UJ Q
`Us) (D
`
`(A) KO
`vb O
`vb i-'
`
`vb [\.)
`
`vb UJ
`vb vb
`
`vb U'|
`vb OW
`vb Q
`
`vb (D
`vb KO
`U'| 0
`L11 i-'
`U'| [\.)
`
`U'| (L3
`L11 vb
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`55
`
`56
`57
`
`58
`59
`
`60
`
`61
`62
`63
`
`64
`65
`
`66
`
`67
`68
`
`69
`70
`
`71
`72
`73
`
`74
`
`75
`76
`77
`
`78
`79
`
`80
`
`81
`
`82
`83
`
`84
`
`85
`86
`
`87
`88
`89
`
`90
`91
`
`92
`93
`
`94
`95
`96
`
`97
`98
`
`99
`100
`101
`
`102
`103
`
`104
`105
`
`106
`107
`
`108
`
`strcat(ret,x);
`
`}
`return ret;
`
`}
`
`Void *
`
`nfsproc_null_2(ap,rp)
`void *ap;
`SR rp;
`
`{
`
`}
`
`static int ret=0;
`
`return ((void*) &ret);
`
`#define as_attr attrstat_u.attributes
`
`diropres *rootlookup();
`readdirres *rootreaddir();
`
`attrstat *
`
`nfsproc_getattr_2(ap,rp)
`nfs_fh *ap;
`SR rp;
`
`{
`
`static attrstat ret;
`
`int uid;
`
`int ht;
`
`cfs_fileid *h;
`
`#ifdef DEBUG
`
`printf("getattr:\n");
`#endif
`
`{
`if ((ht=htype(h=geth(ap)))!=H_REG)
`/* this is an ugly hack to deal w/
`but it will do for now */;
`
`lookups in root,
`
`{
`if (ht==H_ROOT)
`ret.status=NFS_OK;
`
`rootgetattr(&ret.as_attr);
`return &ret;
`
`}
`ret.status=NFSERR_STALE;
`return &ret;
`
`}
`uid=ruid(rp);
`
`if (!fhuid(h,uid)) {
`ret.status = NFSERR_PERM;
`return &ret;
`
`}
`become(rp);
`
`/* become the user */
`
`switch (fhstat(h,&ret.as_attr)) {
`case 0:
`/* ok */
`
`ret.status=NFS_OK;
`break;
`
`case -1:
`
`/* error from syscall */
`
`'2'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 97
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`109
`110
`
`111
`112
`
`113
`
`114
`115
`116
`117
`
`118
`119
`
`120
`
`121
`122
`
`123
`
`124
`125
`
`126
`
`127
`
`128
`129
`
`130
`
`131
`
`132
`133
`
`134
`
`135
`136
`
`137
`138
`139
`
`140
`141
`
`142
`
`143
`144
`
`145
`
`146
`147
`
`148
`149
`150
`
`151
`
`152
`153
`
`154
`
`155
`
`156
`157
`
`158
`
`159
`160
`
`161
`
`162
`
`ret.status=cfsno(errno);
`break;
`
`/* bad handle, probably */
`default:
`ret.status=cfserrno;
`
`break;
`
`}
`c1oseout(h);
`become(NULL);
`return &ret;
`
`}
`
`attrstat *
`
`/* if it was open, close it */
`
`nfsproc_setattr_2(ap,rp)
`sattrargs *ap;
`
`SR rp;
`
`{
`
`static attrstat ret;
`
`int uid;
`
`int ht;
`
`cfs_fileid *h;
`
`/* this is non-atomic, and could leave partial results */
`
`/* also, we vary from std nfs semantics in that failure does
`
`not always leave the file in its previous state */
`
`#ifdef DEBUG
`
`printf("setattr: \n");
`#endif
`
`if ((ht=htype(h=geth(&ap—>fi1e)))!=H_REG)
`ret.status=herr(ht);
`return &ret;
`
`{
`
`}
`uid=ruid(rp);
`
`become(rp);
`
`/* become the user */
`
`switch (fhsetattr(h,&ap—>attributes))
`case 0:
`/* ok */
`
`{
`
`/* now do a getattr */
`
`switch (fhstat(h,&ret.as_attr)) {
`case 0:
`
`ret.status=NFS_OK;
`break;
`case -1:
`
`ret.status=cfsno(errno);
`
`break;
`default:
`
`ret.status=cfserrno;
`
`break;
`
`}
`break;
`
`case -1:
`
`/* error from syscall */
`
`/* but some things may be already set.
`ret.status=cfsno(errno);
`
`break;
`
`default:
`
`/* bad handle, probably */
`
`should fix this */
`
`'3'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 98
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`163
`
`164
`
`165
`166
`167
`
`168
`169
`
`170
`
`171
`172
`173
`
`174
`175
`176
`
`177
`
`178
`179
`
`180
`
`181
`
`182
`183
`184
`
`185
`186
`
`187
`
`188
`189
`
`190
`191
`
`192
`
`193
`194
`
`195
`196
`197
`
`198
`199
`
`200
`
`201
`
`202
`
`203
`204
`205
`
`206
`
`207
`
`208
`209
`
`210
`211
`
`212
`
`213
`214
`215
`
`216
`
`ret.status=cfserrno;
`
`break;
`
`}
`become(NULL);
`return &ret;
`
`}
`
`Void *
`
`nfsproc_root_2(ap,rp)
`Void *ap;
`SR rp;
`
`{
`
`}
`
`static int ret=0;
`
`return ((void*)&ret);
`
`/* fix this to deal w/ fs root
`
`(instance root should be ok) */
`
`diropres *
`
`nfsproc_lookup_2(ap,rp)
`diropargs *ap;
`SR rp;
`
`{
`
`static diropres ret;
`
`diropres *retp;
`
`nfs_fh *handle;
`int uid;
`
`cfskey *key;
`char *s;
`
`int ht;
`
`cfs_fileid *h;
`
`/* this, mkdir, create, and the mount protocol are the only ways
`to create a handle */
`#ifdef DEBUG
`
`printf("lookup:
`#endif
`
`\n");
`
`/* this is where most of the security has to lie, since lookup
`
`returns handles to files.
`
`so we have to make sure we're coming
`
`from the right place and that it's really a priv port, etc */
`
`{
`if (!goodsrc(rp))
`ret.status=NFSERR_PERM;
`return &ret;
`
`}
`
`if ((ht=htype(h=geth(&ap—>dir)))!=H_REG)
`
`{
`
`if (ht==H_ROOT)
`become(rp);
`
`{
`
`retp=root1ookup(ap—>name);
`become(NULL);
`
`return retp;
`
`}
`ret.status=herr(ht);
`return &ret;
`
`}
`
`'4'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 99
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`217
`
`218
`219
`220
`
`221
`222
`
`223
`
`224
`225
`
`226
`227
`
`228
`
`229
`
`230
`231
`232
`
`233
`
`234
`
`235
`
`236
`237
`
`238
`
`239
`240
`
`241
`242
`
`243
`
`244
`245
`
`246
`
`247
`248
`
`249
`250
`
`251
`
`252
`253
`
`254
`
`255
`256
`
`257
`
`258
`259
`
`260
`
`261
`262
`263
`
`264
`265
`
`266
`
`267
`268
`
`269
`270
`
`uid=ruid(rp);
`
`if (!fhuid(h.uid)) {
`ret.status = NFSERR_PERM;
`return &ret;
`
`}
`
`become(rp);
`
`/* become the user */
`
`handle = &ret.diropres_u.diropres.file;
`key=keyof(h);
`
`if (key==N'ULL)
`ret.status=cfsno(errno);
`
`else if ((s=encryptname(key,ap—>name))==NULL)
`
`ret.status=NFSERR_NOENT;
`
`{
`else switch (fhlook(h,s,handle))
`/* fhlook might update the underlying name associated with the
`handle, or delete the handle */
`
`case 0:
`
`/* found it */
`
`/* now do a getattr */
`
`switch (fhstat(geth(handle),
`
`&ret.diropres_u.diropres.attributes)) {
`
`case 0:
`
`ret.status=NFS_OK;
`
`/* stat is already in attributes field */
`break;
`
`/* couldn't open file for some reason */
`case -1:
`ret.status=cfsno(errno);
`
`break;
`
`/* shouldn't happen */
`default:
`ret.status=cfserrno;
`
`break;
`
`}
`break;
`
`/* some parent dir went away, probably */
`case -1:
`ret.status=cfsno(errno);
`
`break;
`
`/* bad parent handle or notfound, probably */
`default:
`ret.status=cfserrno;
`
`break;
`
`}
`become(NULL);
`
`return (&ret);
`
`}
`
`readlinkres *
`
`nfsproc_readlink_2(ap,rp)
`nfs_fh *ap;
`SR rp;
`
`{
`
`static readlinkres ret;
`
`int uid;
`
`char buf[NFS_MAXPATHLEN+l];
`char *s;
`
`cfskey *key;
`int ht;
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 100
`
`
`
`C:\cfs-1.3.3\cfs_nfs.c
`
`271
`272
`273
`
`274
`
`275
`276
`
`277
`278
`279
`
`280
`281
`
`282
`283
`
`284
`285
`
`286
`
`287
`288
`
`289
`
`290
`291
`
`292
`
`293
`294
`
`295
`
`296
`
`297
`298
`299
`
`300
`301
`302
`303
`
`304
`305
`
`306
`
`307
`
`308
`309
`
`310
`
`311
`
`312
`313
`314
`
`315
`316
`
`317
`
`318
`
`319
`
`320
`
`321
`322
`
`323
`324
`
`cfs_fi1eid *h;
`int 1;
`
`#ifdef DEBUG
`
`printf("read1ink:\n");
`#endif
`
`if ((ht=htype(h=geth(ap))
`ret.status=herr(ht);
`return &ret;
`
`!=H_REG)
`
`{
`
`}
`uid=ruid(rp);
`
`become(rp);
`
`switch (1=fh1inkVa1(h,buf))
`case -1:
`
`{
`
`ret.status=cfsno(errno);
`
`break;
`case -2:
`
`ret.status=cfserrno;
`
`break;
`default:
`
`buf[1]='\0';
`
`if ((key=keyof(h))==NULL)
`ret.status=cfserrno;
`
`{
`
`break;
`
`}
`
`{
`if ((s=decryptname(key,buf)) == NULL)
`ret.status=NFSERR_NOENT;
`/* close enough */
`break;
`
`}
`ret.read1inkres_u.data = s;
`ret.status=NFS_OK;
`break;
`
`}
`
`become(NULL);
`
`return (&ret);
`
`}
`
`readres *
`
`nfsproc_read_2(ap,rp)
`readargs *ap;
`SR rp;
`
`{
`
`static readres ret;
`
`static char buffer[8192];
`
`int fd;
`
`int uid;
`
`int len;
`
`cfskey *key;
`int ht;
`
`cfs_f