1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
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
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
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
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
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
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
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
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
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
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
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
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
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
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
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
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
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
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
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
|
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
* Support code is derived from software contributed to Berkeley
* by Atsushi Murai (amurai@spec.co.jp).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)cd9660_vnops.c 8.3 (Berkeley) 1/23/94
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/namei.h>
#include <sys/resourcevar.h>
#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <miscfs/specfs/specdev.h>
#include <miscfs/fifofs/fifo.h>
#include <sys/malloc.h>
#include <sys/dir.h>
#include <isofs/cd9660/iso.h>
#include <isofs/cd9660/cd9660_node.h>
#include <isofs/cd9660/iso_rrip.h>
#if 0
/*
* Mknod vnode call
* Actually remap the device number
*/
cd9660_mknod(ndp, vap, cred, p)
struct nameidata *ndp;
struct ucred *cred;
struct vattr *vap;
struct proc *p;
{
#ifndef ISODEVMAP
free(ndp->ni_pnbuf, M_NAMEI);
vput(ndp->ni_dvp);
vput(ndp->ni_vp);
return EINVAL;
#else
register struct vnode *vp;
struct iso_node *ip;
struct iso_dnode *dp;
int error;
vp = ndp->ni_vp;
ip = VTOI(vp);
if (ip->i_mnt->iso_ftype != ISO_FTYPE_RRIP
|| vap->va_type != vp->v_type
|| (vap->va_type != VCHR && vap->va_type != VBLK)) {
free(ndp->ni_pnbuf, M_NAMEI);
vput(ndp->ni_dvp);
vput(ndp->ni_vp);
return EINVAL;
}
dp = iso_dmap(ip->i_dev,ip->i_number,1);
if (ip->inode.iso_rdev == vap->va_rdev || vap->va_rdev == VNOVAL) {
/* same as the unmapped one, delete the mapping */
remque(dp);
FREE(dp,M_CACHE);
} else
/* enter new mapping */
dp->d_dev = vap->va_rdev;
/*
* Remove inode so that it will be reloaded by iget and
* checked to see if it is an alias of an existing entry
* in the inode cache.
*/
vput(vp);
vp->v_type = VNON;
vgone(vp);
return (0);
#endif
}
#endif
/*
* Open called.
*
* Nothing to do.
*/
/* ARGSUSED */
int
cd9660_open(ap)
struct vop_open_args /* {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
return (0);
}
/*
* Close called
*
* Update the times on the inode on writeable file systems.
*/
/* ARGSUSED */
int
cd9660_close(ap)
struct vop_close_args /* {
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
return (0);
}
/*
* Check mode permission on inode pointer. Mode is READ, WRITE or EXEC.
* The mode is shifted to select the owner/group/other fields. The
* super user is granted all permissions.
*/
/* ARGSUSED */
cd9660_access(ap)
struct vop_access_args /* {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
return (0);
}
cd9660_getattr(ap)
struct vop_getattr_args /* {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
struct vnode *vp = ap->a_vp;
register struct vattr *vap = ap->a_vap;
register struct iso_node *ip = VTOI(vp);
int i;
vap->va_fsid = ip->i_dev;
vap->va_fileid = ip->i_number;
vap->va_mode = ip->inode.iso_mode;
vap->va_nlink = ip->inode.iso_links;
vap->va_uid = ip->inode.iso_uid;
vap->va_gid = ip->inode.iso_gid;
vap->va_atime = ip->inode.iso_atime;
vap->va_mtime = ip->inode.iso_mtime;
vap->va_ctime = ip->inode.iso_ctime;
vap->va_rdev = ip->inode.iso_rdev;
vap->va_size = (u_quad_t) ip->i_size;
vap->va_flags = 0;
vap->va_gen = 1;
vap->va_blocksize = ip->i_mnt->logical_block_size;
vap->va_bytes = (u_quad_t) ip->i_size;
vap->va_type = vp->v_type;
return (0);
}
#if ISO_DEFAULT_BLOCK_SIZE >= NBPG
#ifdef DEBUG
extern int doclusterread;
#else
#define doclusterread 1
#endif
#else
/* XXX until cluster routines can handle block sizes less than one page */
#define doclusterread 0
#endif
/*
* Vnode op for reading.
*/
cd9660_read(ap)
struct vop_read_args /* {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
} */ *ap;
{
struct vnode *vp = ap->a_vp;
register struct uio *uio = ap->a_uio;
register struct iso_node *ip = VTOI(vp);
register struct iso_mnt *imp;
struct buf *bp;
daddr_t lbn, bn, rablock;
off_t diff;
int rasize, error = 0;
long size, n, on;
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset < 0)
return (EINVAL);
ip->i_flag |= IACC;
imp = ip->i_mnt;
do {
lbn = iso_lblkno(imp, uio->uio_offset);
on = iso_blkoff(imp, uio->uio_offset);
n = min((unsigned)(imp->logical_block_size - on),
uio->uio_resid);
diff = (off_t)ip->i_size - uio->uio_offset;
if (diff <= 0)
return (0);
if (diff < n)
n = diff;
size = iso_blksize(imp, ip, lbn);
rablock = lbn + 1;
if (doclusterread) {
if (iso_lblktosize(imp, rablock) <= ip->i_size)
error = cluster_read(vp, (off_t)ip->i_size,
lbn, size, NOCRED, &bp);
else
error = bread(vp, lbn, size, NOCRED, &bp);
} else {
if (vp->v_lastr + 1 == lbn &&
iso_lblktosize(imp, rablock) < ip->i_size) {
rasize = iso_blksize(imp, ip, rablock);
error = breadn(vp, lbn, size, &rablock,
&rasize, 1, NOCRED, &bp);
} else
error = bread(vp, lbn, size, NOCRED, &bp);
}
vp->v_lastr = lbn;
n = min(n, size - bp->b_resid);
if (error) {
brelse(bp);
return (error);
}
error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
if (n + on == imp->logical_block_size ||
uio->uio_offset == (off_t)ip->i_size)
bp->b_flags |= B_AGE;
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
return (error);
}
/* ARGSUSED */
int
cd9660_ioctl(ap)
struct vop_ioctl_args /* {
struct vnode *a_vp;
int a_command;
caddr_t a_data;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
printf("You did ioctl for isofs !!\n");
return (ENOTTY);
}
/* ARGSUSED */
int
cd9660_select(ap)
struct vop_select_args /* {
struct vnode *a_vp;
int a_which;
int a_fflags;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
/*
* We should really check to see if I/O is possible.
*/
return (1);
}
/*
* Mmap a file
*
* NB Currently unsupported.
*/
/* ARGSUSED */
int
cd9660_mmap(ap)
struct vop_mmap_args /* {
struct vnode *a_vp;
int a_fflags;
struct ucred *a_cred;
struct proc *a_p;
} */ *ap;
{
return (EINVAL);
}
/*
* Seek on a file
*
* Nothing to do, so just return.
*/
/* ARGSUSED */
int
cd9660_seek(ap)
struct vop_seek_args /* {
struct vnode *a_vp;
off_t a_oldoff;
off_t a_newoff;
struct ucred *a_cred;
} */ *ap;
{
return (0);
}
/*
* Structure for reading directories
*/
struct isoreaddir {
struct dirent saveent;
struct dirent assocent;
struct dirent current;
off_t saveoff;
off_t assocoff;
off_t curroff;
struct uio *uio;
off_t uio_off;
u_int *cookiep;
int ncookies;
int eof;
};
static int
iso_uiodir(idp,dp,off)
struct isoreaddir *idp;
struct dirent *dp;
off_t off;
{
int error;
dp->d_name[dp->d_namlen] = 0;
dp->d_reclen = DIRSIZ(dp);
if (idp->uio->uio_resid < dp->d_reclen) {
idp->eof = 0;
return -1;
}
if (idp->cookiep) {
if (idp->ncookies <= 0) {
idp->eof = 0;
return -1;
}
*idp->cookiep++ = off;
--idp->ncookies;
}
if (error = uiomove(dp,dp->d_reclen,idp->uio))
return error;
idp->uio_off = off;
return 0;
}
static int
iso_shipdir(idp)
struct isoreaddir *idp;
{
struct dirent *dp;
int cl, sl, assoc;
int error;
char *cname, *sname;
cl = idp->current.d_namlen;
cname = idp->current.d_name;
if (assoc = cl > 1 && *cname == ASSOCCHAR) {
cl--;
cname++;
}
dp = &idp->saveent;
sname = dp->d_name;
if (!(sl = dp->d_namlen)) {
dp = &idp->assocent;
sname = dp->d_name + 1;
sl = dp->d_namlen - 1;
}
if (sl > 0) {
if (sl != cl
|| bcmp(sname,cname,sl)) {
if (idp->assocent.d_namlen) {
if (error = iso_uiodir(idp,&idp->assocent,idp->assocoff))
return error;
idp->assocent.d_namlen = 0;
}
if (idp->saveent.d_namlen) {
if (error = iso_uiodir(idp,&idp->saveent,idp->saveoff))
return error;
idp->saveent.d_namlen = 0;
}
}
}
idp->current.d_reclen = DIRSIZ(&idp->current);
if (assoc) {
idp->assocoff = idp->curroff;
bcopy(&idp->current,&idp->assocent,idp->current.d_reclen);
} else {
idp->saveoff = idp->curroff;
bcopy(&idp->current,&idp->saveent,idp->current.d_reclen);
}
return 0;
}
/*
* Vnode op for readdir
* XXX make sure everything still works now that eofflagp and cookiep
* are no longer args.
*/
int
cd9660_readdir(ap)
struct vop_readdir_args /* {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
} */ *ap;
{
register struct uio *uio = ap->a_uio;
struct isoreaddir *idp;
int entryoffsetinblock;
int error = 0;
int endsearch;
struct iso_directory_record *ep;
u_short elen;
int reclen;
struct iso_mnt *imp;
struct iso_node *ip;
struct buf *bp = NULL;
ip = VTOI(ap->a_vp);
imp = ip->i_mnt;
MALLOC(idp,struct isoreaddir *,sizeof(*idp),M_TEMP,M_WAITOK);
idp->saveent.d_namlen = 0;
idp->assocent.d_namlen = 0;
idp->uio = uio;
#if 0
idp->cookiep = cookies;
idp->ncookies = ncookies;
idp->eof = 1;
#else
idp->cookiep = 0;
#endif
idp->curroff = uio->uio_offset;
entryoffsetinblock = iso_blkoff(imp, idp->curroff);
if (entryoffsetinblock != 0) {
if (error = iso_blkatoff(ip, idp->curroff, &bp)) {
FREE(idp,M_TEMP);
return (error);
}
}
endsearch = ip->i_size;
while (idp->curroff < endsearch) {
/*
* If offset is on a block boundary,
* read the next directory block.
* Release previous if it exists.
*/
if (iso_blkoff(imp, idp->curroff) == 0) {
if (bp != NULL)
brelse(bp);
if (error = iso_blkatoff(ip, idp->curroff, &bp))
break;
entryoffsetinblock = 0;
}
/*
* Get pointer to next entry.
*/
ep = (struct iso_directory_record *)
(bp->b_un.b_addr + entryoffsetinblock);
reclen = isonum_711 (ep->length);
if (reclen == 0) {
/* skip to next block, if any */
idp->curroff = roundup (idp->curroff,
imp->logical_block_size);
continue;
}
if (reclen < ISO_DIRECTORY_RECORD_SIZE) {
error = EINVAL;
/* illegal entry, stop */
break;
}
if (entryoffsetinblock + reclen > imp->logical_block_size) {
error = EINVAL;
/* illegal directory, so stop looking */
break;
}
idp->current.d_namlen = isonum_711 (ep->name_len);
if (isonum_711(ep->flags)&2)
isodirino(&idp->current.d_fileno,ep,imp);
else
idp->current.d_fileno = dbtob(bp->b_blkno) +
idp->curroff;
if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) {
error = EINVAL;
/* illegal entry, stop */
break;
}
idp->curroff += reclen;
/*
*
*/
switch (imp->iso_ftype) {
case ISO_FTYPE_RRIP:
cd9660_rrip_getname(ep,idp->current.d_name,
(u_short *)&idp->current.d_namlen,
&idp->current.d_fileno,imp);
if (idp->current.d_namlen)
error = iso_uiodir(idp,&idp->current,idp->curroff);
break;
default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */
strcpy(idp->current.d_name,"..");
switch (ep->name[0]) {
case 0:
idp->current.d_namlen = 1;
error = iso_uiodir(idp,&idp->current,idp->curroff);
break;
case 1:
idp->current.d_namlen = 2;
error = iso_uiodir(idp,&idp->current,idp->curroff);
break;
default:
isofntrans(ep->name,idp->current.d_namlen,
idp->current.d_name, &elen,
imp->iso_ftype == ISO_FTYPE_9660,
isonum_711(ep->flags)&4);
idp->current.d_namlen = (u_char)elen;
if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
error = iso_shipdir(idp);
else
error = iso_uiodir(idp,&idp->current,idp->curroff);
break;
}
}
if (error)
break;
entryoffsetinblock += reclen;
}
if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) {
idp->current.d_namlen = 0;
error = iso_shipdir(idp);
}
if (error < 0)
error = 0;
if (bp)
brelse (bp);
uio->uio_offset = idp->uio_off;
#if 0
*eofflagp = idp->eof;
#endif
FREE(idp,M_TEMP);
return (error);
}
/*
* Return target name of a symbolic link
* Shouldn't we get the parent vnode and read the data from there?
* This could eventually result in deadlocks in cd9660_lookup.
* But otherwise the block read here is in the block buffer two times.
*/
typedef struct iso_directory_record ISODIR;
typedef struct iso_node ISONODE;
typedef struct iso_mnt ISOMNT;
int
cd9660_readlink(ap)
struct vop_readlink_args /* {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
} */ *ap;
{
ISONODE *ip;
ISODIR *dirp;
ISOMNT *imp;
struct buf *bp;
u_short symlen;
int error;
char *symname;
ino_t ino;
ip = VTOI(ap->a_vp);
imp = ip->i_mnt;
if (imp->iso_ftype != ISO_FTYPE_RRIP)
return EINVAL;
/*
* Get parents directory record block that this inode included.
*/
error = bread(imp->im_devvp,
(daddr_t)(ip->i_number / DEV_BSIZE),
imp->logical_block_size,
NOCRED,
&bp);
if (error) {
brelse(bp);
return EINVAL;
}
/*
* Setup the directory pointer for this inode
*/
dirp = (ISODIR *)(bp->b_un.b_addr + (ip->i_number & imp->im_bmask));
#ifdef DEBUG
printf("lbn=%d,off=%d,bsize=%d,DEV_BSIZE=%d, dirp= %08x, b_addr=%08x, offset=%08x(%08x)\n",
(daddr_t)(ip->i_number >> imp->im_bshift),
ip->i_number & imp->im_bmask,
imp->logical_block_size,
DEV_BSIZE,
dirp,
bp->b_un.b_addr,
ip->i_number,
ip->i_number & imp->im_bmask );
#endif
/*
* Just make sure, we have a right one....
* 1: Check not cross boundary on block
*/
if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length)
> imp->logical_block_size) {
brelse(bp);
return EINVAL;
}
/*
* Now get a buffer
* Abuse a namei buffer for now.
*/
MALLOC(symname,char *,MAXPATHLEN,M_NAMEI,M_WAITOK);
/*
* Ok, we just gathering a symbolic name in SL record.
*/
if (cd9660_rrip_getsymname(dirp,symname,&symlen,imp) == 0) {
FREE(symname,M_NAMEI);
brelse(bp);
return EINVAL;
}
/*
* Don't forget before you leave from home ;-)
*/
brelse(bp);
/*
* return with the symbolic name to caller's.
*/
error = uiomove(symname,symlen,ap->a_uio);
FREE(symname,M_NAMEI);
return error;
}
/*
* Ufs abort op, called after namei() when a CREATE/DELETE isn't actually
* done. If a buffer has been saved in anticipation of a CREATE, delete it.
*/
int
cd9660_abortop(ap)
struct vop_abortop_args /* {
struct vnode *a_dvp;
struct componentname *a_cnp;
} */ *ap;
{
if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
FREE(ap->a_cnp->cn_pnbuf, M_NAMEI);
return 0;
}
/*
* Lock an inode.
*/
int
cd9660_lock(ap)
struct vop_lock_args /* {
struct vnode *a_vp;
} */ *ap;
{
register struct iso_node *ip = VTOI(ap->a_vp);
ISO_ILOCK(ip);
return 0;
}
/*
* Unlock an inode.
*/
int
cd9660_unlock(ap)
struct vop_unlock_args /* {
struct vnode *a_vp;
} */ *ap;
{
register struct iso_node *ip = VTOI(ap->a_vp);
if (!(ip->i_flag & ILOCKED))
panic("cd9660_unlock NOT LOCKED");
ISO_IUNLOCK(ip);
return 0;
}
/*
* Check for a locked inode.
*/
int
cd9660_islocked(ap)
struct vop_islocked_args /* {
struct vnode *a_vp;
} */ *ap;
{
if (VTOI(ap->a_vp)->i_flag & ILOCKED)
return 1;
return 0;
}
/*
* Calculate the logical to physical mapping if not done already,
* then call the device strategy routine.
*/
int
cd9660_strategy(ap)
struct vop_strategy_args /* {
struct buf *a_bp;
} */ *ap;
{
register struct buf *bp = ap->a_bp;
register struct vnode *vp = bp->b_vp;
register struct iso_node *ip;
int error;
ip = VTOI(vp);
if (vp->v_type == VBLK || vp->v_type == VCHR)
panic("cd9660_strategy: spec");
if (bp->b_blkno == bp->b_lblkno) {
if (error =
VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL)) {
bp->b_error = error;
bp->b_flags |= B_ERROR;
biodone(bp);
return (error);
}
if ((long)bp->b_blkno == -1)
clrbuf(bp);
}
if ((long)bp->b_blkno == -1) {
biodone(bp);
return (0);
}
vp = ip->i_devvp;
bp->b_dev = vp->v_rdev;
VOCALL (vp->v_op, VOFFSET(vop_strategy), ap);
return (0);
}
/*
* Print out the contents of an inode.
*/
int
cd9660_print(ap)
struct vop_print_args /* {
struct vnode *a_vp;
} */ *ap;
{
printf("tag VT_ISOFS, isofs vnode\n");
return 0;
}
/*
* Unsupported operation
*/
int
cd9660_enotsupp()
{
return (EOPNOTSUPP);
}
/*
* Global vfs data structures for isofs
*/
#define cd9660_create \
((int (*) __P((struct vop_create_args *)))cd9660_enotsupp)
#define cd9660_mknod ((int (*) __P((struct vop_mknod_args *)))cd9660_enotsupp)
#define cd9660_setattr \
((int (*) __P((struct vop_setattr_args *)))cd9660_enotsupp)
#define cd9660_write ((int (*) __P((struct vop_write_args *)))cd9660_enotsupp)
#define cd9660_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
#define cd9660_remove \
((int (*) __P((struct vop_remove_args *)))cd9660_enotsupp)
#define cd9660_link ((int (*) __P((struct vop_link_args *)))cd9660_enotsupp)
#define cd9660_rename \
((int (*) __P((struct vop_rename_args *)))cd9660_enotsupp)
#define cd9660_mkdir ((int (*) __P((struct vop_mkdir_args *)))cd9660_enotsupp)
#define cd9660_rmdir ((int (*) __P((struct vop_rmdir_args *)))cd9660_enotsupp)
#define cd9660_symlink \
((int (*) __P((struct vop_symlink_args *)))cd9660_enotsupp)
#define cd9660_pathconf \
((int (*) __P((struct vop_pathconf_args *)))cd9660_enotsupp)
#define cd9660_advlock \
((int (*) __P((struct vop_advlock_args *)))cd9660_enotsupp)
#define cd9660_blkatoff \
((int (*) __P((struct vop_blkatoff_args *)))cd9660_enotsupp)
#define cd9660_valloc ((int(*) __P(( \
struct vnode *pvp, \
int mode, \
struct ucred *cred, \
struct vnode **vpp))) cd9660_enotsupp)
#define cd9660_vfree ((int (*) __P((struct vop_vfree_args *)))cd9660_enotsupp)
#define cd9660_truncate \
((int (*) __P((struct vop_truncate_args *)))cd9660_enotsupp)
#define cd9660_update \
((int (*) __P((struct vop_update_args *)))cd9660_enotsupp)
#define cd9660_bwrite \
((int (*) __P((struct vop_bwrite_args *)))cd9660_enotsupp)
/*
* Global vfs data structures for nfs
*/
int (**cd9660_vnodeop_p)();
struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, cd9660_lookup }, /* lookup */
{ &vop_create_desc, cd9660_create }, /* create */
{ &vop_mknod_desc, cd9660_mknod }, /* mknod */
{ &vop_open_desc, cd9660_open }, /* open */
{ &vop_close_desc, cd9660_close }, /* close */
{ &vop_access_desc, cd9660_access }, /* access */
{ &vop_getattr_desc, cd9660_getattr }, /* getattr */
{ &vop_setattr_desc, cd9660_setattr }, /* setattr */
{ &vop_read_desc, cd9660_read }, /* read */
{ &vop_write_desc, cd9660_write }, /* write */
{ &vop_ioctl_desc, cd9660_ioctl }, /* ioctl */
{ &vop_select_desc, cd9660_select }, /* select */
{ &vop_mmap_desc, cd9660_mmap }, /* mmap */
{ &vop_fsync_desc, cd9660_fsync }, /* fsync */
{ &vop_seek_desc, cd9660_seek }, /* seek */
{ &vop_remove_desc, cd9660_remove }, /* remove */
{ &vop_link_desc, cd9660_link }, /* link */
{ &vop_rename_desc, cd9660_rename }, /* rename */
{ &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */
{ &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */
{ &vop_symlink_desc, cd9660_symlink }, /* symlink */
{ &vop_readdir_desc, cd9660_readdir }, /* readdir */
{ &vop_readlink_desc, cd9660_readlink },/* readlink */
{ &vop_abortop_desc, cd9660_abortop }, /* abortop */
{ &vop_inactive_desc, cd9660_inactive },/* inactive */
{ &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */
{ &vop_lock_desc, cd9660_lock }, /* lock */
{ &vop_unlock_desc, cd9660_unlock }, /* unlock */
{ &vop_bmap_desc, cd9660_bmap }, /* bmap */
{ &vop_strategy_desc, cd9660_strategy },/* strategy */
{ &vop_print_desc, cd9660_print }, /* print */
{ &vop_islocked_desc, cd9660_islocked },/* islocked */
{ &vop_pathconf_desc, cd9660_pathconf },/* pathconf */
{ &vop_advlock_desc, cd9660_advlock }, /* advlock */
{ &vop_blkatoff_desc, cd9660_blkatoff },/* blkatoff */
{ &vop_valloc_desc, cd9660_valloc }, /* valloc */
{ &vop_vfree_desc, cd9660_vfree }, /* vfree */
{ &vop_truncate_desc, cd9660_truncate },/* truncate */
{ &vop_update_desc, cd9660_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
};
struct vnodeopv_desc cd9660_vnodeop_opv_desc =
{ &cd9660_vnodeop_p, cd9660_vnodeop_entries };
/*
* Special device vnode ops
*/
int (**cd9660_specop_p)();
struct vnodeopv_entry_desc cd9660_specop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, spec_lookup }, /* lookup */
{ &vop_create_desc, cd9660_create }, /* create */
{ &vop_mknod_desc, cd9660_mknod }, /* mknod */
{ &vop_open_desc, spec_open }, /* open */
{ &vop_close_desc, spec_close }, /* close */
{ &vop_access_desc, cd9660_access }, /* access */
{ &vop_getattr_desc, cd9660_getattr }, /* getattr */
{ &vop_setattr_desc, cd9660_setattr }, /* setattr */
{ &vop_read_desc, spec_read }, /* read */
{ &vop_write_desc, spec_write }, /* write */
{ &vop_ioctl_desc, spec_ioctl }, /* ioctl */
{ &vop_select_desc, spec_select }, /* select */
{ &vop_mmap_desc, spec_mmap }, /* mmap */
{ &vop_fsync_desc, spec_fsync }, /* fsync */
{ &vop_seek_desc, spec_seek }, /* seek */
{ &vop_remove_desc, cd9660_remove }, /* remove */
{ &vop_link_desc, cd9660_link }, /* link */
{ &vop_rename_desc, cd9660_rename }, /* rename */
{ &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */
{ &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */
{ &vop_symlink_desc, cd9660_symlink }, /* symlink */
{ &vop_readdir_desc, spec_readdir }, /* readdir */
{ &vop_readlink_desc, spec_readlink }, /* readlink */
{ &vop_abortop_desc, spec_abortop }, /* abortop */
{ &vop_inactive_desc, cd9660_inactive },/* inactive */
{ &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */
{ &vop_lock_desc, cd9660_lock }, /* lock */
{ &vop_unlock_desc, cd9660_unlock }, /* unlock */
{ &vop_bmap_desc, spec_bmap }, /* bmap */
/* XXX strategy: panics, should be notsupp instead? */
{ &vop_strategy_desc, cd9660_strategy },/* strategy */
{ &vop_print_desc, cd9660_print }, /* print */
{ &vop_islocked_desc, cd9660_islocked },/* islocked */
{ &vop_pathconf_desc, spec_pathconf }, /* pathconf */
{ &vop_advlock_desc, spec_advlock }, /* advlock */
{ &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */
{ &vop_valloc_desc, spec_valloc }, /* valloc */
{ &vop_vfree_desc, spec_vfree }, /* vfree */
{ &vop_truncate_desc, spec_truncate }, /* truncate */
{ &vop_update_desc, cd9660_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
};
struct vnodeopv_desc cd9660_specop_opv_desc =
{ &cd9660_specop_p, cd9660_specop_entries };
#ifdef FIFO
int (**cd9660_fifoop_p)();
struct vnodeopv_entry_desc cd9660_fifoop_entries[] = {
{ &vop_default_desc, vn_default_error },
{ &vop_lookup_desc, fifo_lookup }, /* lookup */
{ &vop_create_desc, cd9660_create }, /* create */
{ &vop_mknod_desc, cd9660_mknod }, /* mknod */
{ &vop_open_desc, fifo_open }, /* open */
{ &vop_close_desc, fifo_close }, /* close */
{ &vop_access_desc, cd9660_access }, /* access */
{ &vop_getattr_desc, cd9660_getattr }, /* getattr */
{ &vop_setattr_desc, cd9660_setattr }, /* setattr */
{ &vop_read_desc, fifo_read }, /* read */
{ &vop_write_desc, fifo_write }, /* write */
{ &vop_ioctl_desc, fifo_ioctl }, /* ioctl */
{ &vop_select_desc, fifo_select }, /* select */
{ &vop_mmap_desc, fifo_mmap }, /* mmap */
{ &vop_fsync_desc, fifo_fsync }, /* fsync */
{ &vop_seek_desc, fifo_seek }, /* seek */
{ &vop_remove_desc, cd9660_remove }, /* remove */
{ &vop_link_desc, cd9660_link }, /* link */
{ &vop_rename_desc, cd9660_rename }, /* rename */
{ &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */
{ &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */
{ &vop_symlink_desc, cd9660_symlink }, /* symlink */
{ &vop_readdir_desc, fifo_readdir }, /* readdir */
{ &vop_readlink_desc, fifo_readlink }, /* readlink */
{ &vop_abortop_desc, fifo_abortop }, /* abortop */
{ &vop_inactive_desc, cd9660_inactive },/* inactive */
{ &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */
{ &vop_lock_desc, cd9660_lock }, /* lock */
{ &vop_unlock_desc, cd9660_unlock }, /* unlock */
{ &vop_bmap_desc, fifo_bmap }, /* bmap */
{ &vop_strategy_desc, fifo_badop }, /* strategy */
{ &vop_print_desc, cd9660_print }, /* print */
{ &vop_islocked_desc, cd9660_islocked },/* islocked */
{ &vop_pathconf_desc, fifo_pathconf }, /* pathconf */
{ &vop_advlock_desc, fifo_advlock }, /* advlock */
{ &vop_blkatoff_desc, fifo_blkatoff }, /* blkatoff */
{ &vop_valloc_desc, fifo_valloc }, /* valloc */
{ &vop_vfree_desc, fifo_vfree }, /* vfree */
{ &vop_truncate_desc, fifo_truncate }, /* truncate */
{ &vop_update_desc, cd9660_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite },
{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
};
struct vnodeopv_desc cd9660_fifoop_opv_desc =
{ &cd9660_fifoop_p, cd9660_fifoop_entries };
#endif /* FIFO */
|