udf_readwrite.c revision 1.8.4.1 1 /* $NetBSD: udf_readwrite.c,v 1.8.4.1 2009/02/18 00:51:27 snj Exp $ */
2
3 /*
4 * Copyright (c) 2007, 2008 Reinoud Zandijk
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29 #include <sys/cdefs.h>
30 #ifndef lint
31 __KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.8.4.1 2009/02/18 00:51:27 snj Exp $");
32 #endif /* not lint */
33
34
35 #if defined(_KERNEL_OPT)
36 #include "opt_quota.h"
37 #include "opt_compat_netbsd.h"
38 #endif
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/sysctl.h>
43 #include <sys/namei.h>
44 #include <sys/proc.h>
45 #include <sys/kernel.h>
46 #include <sys/vnode.h>
47 #include <miscfs/genfs/genfs_node.h>
48 #include <sys/mount.h>
49 #include <sys/buf.h>
50 #include <sys/file.h>
51 #include <sys/device.h>
52 #include <sys/disklabel.h>
53 #include <sys/ioctl.h>
54 #include <sys/malloc.h>
55 #include <sys/dirent.h>
56 #include <sys/stat.h>
57 #include <sys/conf.h>
58 #include <sys/kauth.h>
59 #include <sys/kthread.h>
60 #include <dev/clock_subr.h>
61
62 #include <fs/udf/ecma167-udf.h>
63 #include <fs/udf/udf_mount.h>
64
65 #include "udf.h"
66 #include "udf_subr.h"
67 #include "udf_bswap.h"
68
69
70 #define VTOI(vnode) ((struct udf_node *) vnode->v_data)
71
72 /* --------------------------------------------------------------------- */
73
74 void
75 udf_fixup_fid_block(uint8_t *blob, int lb_size,
76 int rfix_pos, int max_rfix_pos, uint32_t lb_num)
77 {
78 struct fileid_desc *fid;
79 uint8_t *fid_pos;
80 int fid_len, found;
81
82 /* needs to be word aligned */
83 KASSERT(rfix_pos % 4 == 0);
84
85 /* first resync with the FID stream !!! */
86 found = 0;
87 while (rfix_pos + sizeof(struct desc_tag) <= max_rfix_pos) {
88 fid_pos = blob + rfix_pos;
89 fid = (struct fileid_desc *) fid_pos;
90 if (udf_rw16(fid->tag.id) == TAGID_FID) {
91 if (udf_check_tag((union dscrptr *) fid) == 0)
92 found = 1;
93 }
94 if (found)
95 break;
96 /* try next location; can only be 4 bytes aligned */
97 rfix_pos += 4;
98 }
99
100 /* walk over the fids */
101 fid_pos = blob + rfix_pos;
102 while (rfix_pos + sizeof(struct desc_tag) <= max_rfix_pos) {
103 fid = (struct fileid_desc *) fid_pos;
104 if (udf_rw16(fid->tag.id) != TAGID_FID) {
105 /* end of FID stream; end of directory or currupted */
106 break;
107 }
108
109 /* update sector number and recalculate checkum */
110 fid->tag.tag_loc = udf_rw32(lb_num);
111 udf_validate_tag_sum((union dscrptr *) fid);
112
113 /* if the FID crosses the memory, we're done! */
114 if (rfix_pos + UDF_FID_SIZE >= max_rfix_pos)
115 break;
116
117 fid_len = udf_fidsize(fid);
118 fid_pos += fid_len;
119 rfix_pos += fid_len;
120 }
121 }
122
123
124 void
125 udf_fixup_internal_extattr(uint8_t *blob, uint32_t lb_num)
126 {
127 struct desc_tag *tag;
128 struct file_entry *fe;
129 struct extfile_entry *efe;
130 struct extattrhdr_desc *eahdr;
131 int l_ea;
132
133 /* get information from fe/efe */
134 tag = (struct desc_tag *) blob;
135 switch (udf_rw16(tag->id)) {
136 case TAGID_FENTRY :
137 fe = (struct file_entry *) blob;
138 l_ea = udf_rw32(fe->l_ea);
139 eahdr = (struct extattrhdr_desc *) fe->data;
140 break;
141 case TAGID_EXTFENTRY :
142 efe = (struct extfile_entry *) blob;
143 l_ea = udf_rw32(efe->l_ea);
144 eahdr = (struct extattrhdr_desc *) efe->data;
145 break;
146 case TAGID_INDIRECTENTRY :
147 case TAGID_ALLOCEXTENT :
148 case TAGID_EXTATTR_HDR :
149 return;
150 default:
151 panic("%s: passed bad tag\n", __func__);
152 }
153
154 /* something recorded here? (why am i called?) */
155 if (l_ea == 0)
156 return;
157
158 #if 0
159 /* check extended attribute tag */
160 /* TODO XXX what to do when we encounter an error here? */
161 error = udf_check_tag(eahdr);
162 if (error)
163 return; /* for now */
164 if (udf_rw16(eahdr->tag.id) != TAGID_EXTATTR_HDR)
165 return; /* for now */
166 error = udf_check_tag_payload(eahdr, sizeof(struct extattrhdr_desc));
167 if (error)
168 return; /* for now */
169 #endif
170
171 DPRINTF(EXTATTR, ("node fixup: found %d bytes of extended attributes\n",
172 l_ea));
173
174 /* fixup eahdr tag */
175 eahdr->tag.tag_loc = udf_rw32(lb_num);
176 udf_validate_tag_and_crc_sums((union dscrptr *) eahdr);
177 }
178
179
180 void
181 udf_fixup_node_internals(struct udf_mount *ump, uint8_t *blob, int udf_c_type)
182 {
183 struct desc_tag *tag, *sbm_tag;
184 struct file_entry *fe;
185 struct extfile_entry *efe;
186 struct alloc_ext_entry *ext;
187 uint32_t lb_size, lb_num;
188 uint32_t intern_pos, max_intern_pos;
189 int icbflags, addr_type, file_type, intern, has_fids, has_sbm, l_ea;
190
191 lb_size = udf_rw32(ump->logical_vol->lb_size);
192 /* if its not a node we're done */
193 if (udf_c_type != UDF_C_NODE)
194 return;
195
196 /* NOTE this could also be done in write_internal */
197 /* start of a descriptor */
198 l_ea = 0;
199 has_fids = 0;
200 has_sbm = 0;
201 intern = 0;
202 file_type = 0;
203 max_intern_pos = intern_pos = lb_num = 0; /* shut up gcc! */
204
205 tag = (struct desc_tag *) blob;
206 switch (udf_rw16(tag->id)) {
207 case TAGID_FENTRY :
208 fe = (struct file_entry *) tag;
209 l_ea = udf_rw32(fe->l_ea);
210 icbflags = udf_rw16(fe->icbtag.flags);
211 addr_type = (icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK);
212 file_type = fe->icbtag.file_type;
213 intern = (addr_type == UDF_ICB_INTERN_ALLOC);
214 intern_pos = UDF_FENTRY_SIZE + l_ea;
215 max_intern_pos = intern_pos + udf_rw64(fe->inf_len);
216 lb_num = udf_rw32(fe->tag.tag_loc);
217 break;
218 case TAGID_EXTFENTRY :
219 efe = (struct extfile_entry *) tag;
220 l_ea = udf_rw32(efe->l_ea);
221 icbflags = udf_rw16(efe->icbtag.flags);
222 addr_type = (icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK);
223 file_type = efe->icbtag.file_type;
224 intern = (addr_type == UDF_ICB_INTERN_ALLOC);
225 intern_pos = UDF_EXTFENTRY_SIZE + l_ea;
226 max_intern_pos = intern_pos + udf_rw64(efe->inf_len);
227 lb_num = udf_rw32(efe->tag.tag_loc);
228 break;
229 case TAGID_INDIRECTENTRY :
230 case TAGID_EXTATTR_HDR :
231 break;
232 case TAGID_ALLOCEXTENT :
233 /* force crclen to 8 for UDF version < 2.01 */
234 ext = (struct alloc_ext_entry *) tag;
235 if (udf_rw16(ump->logvol_info->min_udf_readver) <= 0x200)
236 ext->tag.desc_crc_len = udf_rw16(8);
237 break;
238 default:
239 panic("%s: passed bad tag\n", __func__);
240 break;
241 }
242
243 /* determine what to fix if its internally recorded */
244 if (intern) {
245 has_fids = (file_type == UDF_ICB_FILETYPE_DIRECTORY) ||
246 (file_type == UDF_ICB_FILETYPE_STREAMDIR);
247 has_sbm = (file_type == UDF_ICB_FILETYPE_META_BITMAP);
248 }
249
250 /* fixup internal extended attributes if present */
251 if (l_ea)
252 udf_fixup_internal_extattr(blob, lb_num);
253
254 /* fixup fids lb numbers */
255 if (has_fids)
256 udf_fixup_fid_block(blob, lb_size, intern_pos,
257 max_intern_pos, lb_num);
258
259 /* fixup space bitmap descriptor */
260 if (has_sbm) {
261 sbm_tag = (struct desc_tag *) (blob + intern_pos);
262 sbm_tag->tag_loc = tag->tag_loc;
263 udf_validate_tag_and_crc_sums((uint8_t *) sbm_tag);
264 }
265
266 udf_validate_tag_and_crc_sums(blob);
267 }
268
269 /* --------------------------------------------------------------------- */
270
271 /*
272 * Set of generic descriptor readers and writers and their helper functions.
273 * Descriptors inside `logical space' i.e. inside logically mapped partitions
274 * can never be longer than one logical sector.
275 *
276 * NOTE that these functions *can* be used by the sheduler backends to read
277 * node descriptors too.
278 *
279 * For reading, the size of allocated piece is returned in multiple of sector
280 * size due to udf_calc_udf_malloc_size().
281 */
282
283
284 /* SYNC reading of n blocks from specified sector */
285 int
286 udf_read_phys_sectors(struct udf_mount *ump, int what, void *blob,
287 uint32_t start, uint32_t sectors)
288 {
289 struct buf *buf, *nestbuf;
290 uint32_t buf_offset;
291 off_t lblkno, rblkno;
292 int sector_size = ump->discinfo.sector_size;
293 int blks = sector_size / DEV_BSIZE;
294 int piece;
295 int error;
296
297 DPRINTF(READ, ("udf_intbreadn() : sectors = %d, sector_size = %d\n",
298 sectors, sector_size));
299 buf = getiobuf(ump->devvp, true);
300 buf->b_flags = B_READ;
301 buf->b_cflags = BC_BUSY; /* needed? */
302 buf->b_iodone = NULL;
303 buf->b_data = blob;
304 buf->b_bcount = sectors * sector_size;
305 buf->b_resid = buf->b_bcount;
306 buf->b_bufsize = buf->b_bcount;
307 buf->b_private = NULL; /* not needed yet */
308 BIO_SETPRIO(buf, BPRIO_DEFAULT);
309 buf->b_lblkno = buf->b_blkno = buf->b_rawblkno = start * blks;
310 buf->b_proc = NULL;
311
312 error = 0;
313 buf_offset = 0;
314 rblkno = start;
315 lblkno = 0;
316 while ((sectors > 0) && (error == 0)) {
317 piece = MIN(MAXPHYS/sector_size, sectors);
318 DPRINTF(READ, ("read in %d + %d\n", (uint32_t) rblkno, piece));
319
320 nestbuf = getiobuf(NULL, true);
321 nestiobuf_setup(buf, nestbuf, buf_offset, piece * sector_size);
322 /* nestbuf is B_ASYNC */
323
324 /* identify this nestbuf */
325 nestbuf->b_lblkno = lblkno;
326
327 /* CD shedules on raw blkno */
328 nestbuf->b_blkno = rblkno * blks;
329 nestbuf->b_proc = NULL;
330 nestbuf->b_rawblkno = rblkno * blks;
331 nestbuf->b_udf_c_type = what;
332
333 udf_discstrat_queuebuf(ump, nestbuf);
334
335 lblkno += piece;
336 rblkno += piece;
337 buf_offset += piece * sector_size;
338 sectors -= piece;
339 }
340 error = biowait(buf);
341 putiobuf(buf);
342
343 return error;
344 }
345
346
347 /* synchronous generic descriptor read */
348 int
349 udf_read_phys_dscr(struct udf_mount *ump, uint32_t sector,
350 struct malloc_type *mtype, union dscrptr **dstp)
351 {
352 union dscrptr *dst, *new_dst;
353 uint8_t *pos;
354 int sectors, dscrlen;
355 int i, error, sector_size;
356
357 sector_size = ump->discinfo.sector_size;
358
359 *dstp = dst = NULL;
360 dscrlen = sector_size;
361
362 /* read initial piece */
363 dst = malloc(sector_size, mtype, M_WAITOK);
364 error = udf_read_phys_sectors(ump, UDF_C_DSCR, dst, sector, 1);
365 DPRINTFIF(DESCRIPTOR, error, ("read error (%d)\n", error));
366
367 if (!error) {
368 /* check if its a valid tag */
369 error = udf_check_tag(dst);
370 if (error) {
371 /* check if its an empty block */
372 pos = (uint8_t *) dst;
373 for (i = 0; i < sector_size; i++, pos++) {
374 if (*pos) break;
375 }
376 if (i == sector_size) {
377 /* return no error but with no dscrptr */
378 /* dispose first block */
379 free(dst, mtype);
380 return 0;
381 }
382 }
383 /* calculate descriptor size */
384 dscrlen = udf_tagsize(dst, sector_size);
385 }
386 DPRINTFIF(DESCRIPTOR, error, ("bad tag checksum\n"));
387
388 if (!error && (dscrlen > sector_size)) {
389 DPRINTF(DESCRIPTOR, ("multi block descriptor read\n"));
390 /*
391 * Read the rest of descriptor. Since it is only used at mount
392 * time its overdone to define and use a specific udf_intbreadn
393 * for this alone.
394 */
395
396 new_dst = realloc(dst, dscrlen, mtype, M_WAITOK);
397 if (new_dst == NULL) {
398 free(dst, mtype);
399 return ENOMEM;
400 }
401 dst = new_dst;
402
403 sectors = (dscrlen + sector_size -1) / sector_size;
404 DPRINTF(DESCRIPTOR, ("dscrlen = %d (%d blk)\n", dscrlen, sectors));
405
406 pos = (uint8_t *) dst + sector_size;
407 error = udf_read_phys_sectors(ump, UDF_C_DSCR, pos,
408 sector + 1, sectors-1);
409
410 DPRINTFIF(DESCRIPTOR, error, ("read error on multi (%d)\n",
411 error));
412 }
413 if (!error) {
414 error = udf_check_tag_payload(dst, dscrlen);
415 DPRINTFIF(DESCRIPTOR, error, ("bad payload check sum\n"));
416 }
417 if (error && dst) {
418 free(dst, mtype);
419 dst = NULL;
420 }
421 *dstp = dst;
422
423 return error;
424 }
425
426
427 static void
428 udf_write_phys_buf(struct udf_mount *ump, int what, struct buf *buf)
429 {
430 struct buf *nestbuf;
431 uint32_t buf_offset;
432 off_t lblkno, rblkno;
433 int sector_size = ump->discinfo.sector_size;
434 int blks = sector_size / DEV_BSIZE;
435 uint32_t sectors;
436 int piece;
437 int error;
438
439 sectors = buf->b_bcount / sector_size;
440 DPRINTF(WRITE, ("udf_intbwriten() : sectors = %d, sector_size = %d\n",
441 sectors, sector_size));
442
443 /* don't forget to increase pending count for the bwrite itself */
444 /* panic("NO WRITING\n"); */
445 if (buf->b_vp) {
446 mutex_enter(&buf->b_vp->v_interlock);
447 buf->b_vp->v_numoutput++;
448 mutex_exit(&buf->b_vp->v_interlock);
449 }
450
451 error = 0;
452 buf_offset = 0;
453 rblkno = buf->b_blkno / blks;
454 lblkno = 0;
455 while ((sectors > 0) && (error == 0)) {
456 piece = MIN(MAXPHYS/sector_size, sectors);
457 DPRINTF(WRITE, ("write out %d + %d\n",
458 (uint32_t) rblkno, piece));
459
460 nestbuf = getiobuf(NULL, true);
461 nestiobuf_setup(buf, nestbuf, buf_offset, piece * sector_size);
462 /* nestbuf is B_ASYNC */
463
464 /* identify this nestbuf */
465 nestbuf->b_lblkno = lblkno;
466
467 /* CD shedules on raw blkno */
468 nestbuf->b_blkno = rblkno * blks;
469 nestbuf->b_proc = NULL;
470 nestbuf->b_rawblkno = rblkno * blks;
471 nestbuf->b_udf_c_type = what;
472
473 udf_discstrat_queuebuf(ump, nestbuf);
474
475 lblkno += piece;
476 rblkno += piece;
477 buf_offset += piece * sector_size;
478 sectors -= piece;
479 }
480 }
481
482
483 /* SYNC writing of n blocks from specified sector */
484 int
485 udf_write_phys_sectors(struct udf_mount *ump, int what, void *blob,
486 uint32_t start, uint32_t sectors)
487 {
488 struct vnode *vp;
489 struct buf *buf;
490 int sector_size = ump->discinfo.sector_size;
491 int blks = sector_size / DEV_BSIZE;
492 int error;
493
494 /* get transfer buffer */
495 vp = ump->devvp;
496 buf = getiobuf(vp, true);
497 buf->b_flags = B_WRITE;
498 buf->b_cflags = BC_BUSY; /* needed? */
499 buf->b_iodone = NULL;
500 buf->b_data = blob;
501 buf->b_bcount = sectors * sector_size;
502 buf->b_resid = buf->b_bcount;
503 buf->b_bufsize = buf->b_bcount;
504 buf->b_private = NULL; /* not needed yet */
505 BIO_SETPRIO(buf, BPRIO_DEFAULT);
506 buf->b_lblkno = buf->b_blkno = buf->b_rawblkno = start * blks;
507 buf->b_proc = NULL;
508
509 /* do the write, wait and return error */
510 udf_write_phys_buf(ump, what, buf);
511 error = biowait(buf);
512 putiobuf(buf);
513
514 return error;
515 }
516
517
518 /* synchronous generic descriptor write */
519 int
520 udf_write_phys_dscr_sync(struct udf_mount *ump, struct udf_node *udf_node, int what,
521 union dscrptr *dscr, uint32_t sector, uint32_t logsector)
522 {
523 struct vnode *vp;
524 struct buf *buf;
525 int sector_size = ump->discinfo.sector_size;
526 int blks = sector_size / DEV_BSIZE;
527 int dscrlen;
528 int error;
529
530 /* set sector number in the descriptor and validate */
531 dscr->tag.tag_loc = udf_rw32(logsector);
532 udf_validate_tag_and_crc_sums(dscr);
533
534 /* calculate descriptor size */
535 dscrlen = udf_tagsize(dscr, sector_size);
536
537 /* get transfer buffer */
538 vp = udf_node ? udf_node->vnode : ump->devvp;
539 buf = getiobuf(vp, true);
540 buf->b_flags = B_WRITE;
541 buf->b_cflags = BC_BUSY; /* needed? */
542 buf->b_iodone = NULL;
543 buf->b_data = (void *) dscr;
544 buf->b_bcount = dscrlen;
545 buf->b_resid = buf->b_bcount;
546 buf->b_bufsize = buf->b_bcount;
547 buf->b_private = NULL; /* not needed yet */
548 BIO_SETPRIO(buf, BPRIO_DEFAULT);
549 buf->b_lblkno = buf->b_blkno = buf->b_rawblkno = sector * blks;
550 buf->b_proc = NULL;
551
552 /* do the write, wait and return error */
553 udf_write_phys_buf(ump, what, buf);
554 error = biowait(buf);
555 putiobuf(buf);
556
557 return error;
558 }
559
560
561 /* asynchronous generic descriptor write */
562 int
563 udf_write_phys_dscr_async(struct udf_mount *ump, struct udf_node *udf_node,
564 int what, union dscrptr *dscr,
565 uint32_t sector, uint32_t logsector,
566 void (*dscrwr_callback)(struct buf *))
567 {
568 struct vnode *vp;
569 struct buf *buf;
570 int dscrlen;
571 int sector_size = ump->discinfo.sector_size;
572 int blks = sector_size / DEV_BSIZE;
573
574 KASSERT(dscrwr_callback);
575 DPRINTF(NODE, ("udf_write_phys_dscr_async() called\n"));
576
577 /* set sector number in the descriptor and validate */
578 dscr->tag.tag_loc = udf_rw32(logsector);
579 udf_validate_tag_and_crc_sums(dscr);
580
581 /* calculate descriptor size */
582 dscrlen = udf_tagsize(dscr, sector_size);
583
584 /* get transfer buffer */
585 vp = udf_node ? udf_node->vnode : ump->devvp;
586 buf = getiobuf(vp, true);
587 buf->b_flags = B_WRITE; // | B_ASYNC;
588 buf->b_cflags = BC_BUSY;
589 buf->b_iodone = dscrwr_callback;
590 buf->b_data = dscr;
591 buf->b_bcount = dscrlen;
592 buf->b_resid = buf->b_bcount;
593 buf->b_bufsize = buf->b_bcount;
594 buf->b_private = NULL; /* not needed yet */
595 BIO_SETPRIO(buf, BPRIO_DEFAULT);
596 buf->b_lblkno = buf->b_blkno = buf->b_rawblkno = sector * blks;
597 buf->b_proc = NULL;
598
599 /* do the write and return no error */
600 udf_write_phys_buf(ump, what, buf);
601 return 0;
602 }
603
604 /* --------------------------------------------------------------------- */
605
606 /* disc strategy dispatchers */
607
608 int
609 udf_create_logvol_dscr(struct udf_mount *ump, struct udf_node *udf_node, struct long_ad *icb,
610 union dscrptr **dscrptr)
611 {
612 struct udf_strategy *strategy = ump->strategy;
613 struct udf_strat_args args;
614 int error;
615
616 KASSERT(strategy);
617 args.ump = ump;
618 args.udf_node = udf_node;
619 args.icb = icb;
620 args.dscr = NULL;
621
622 error = (strategy->create_logvol_dscr)(&args);
623 *dscrptr = args.dscr;
624
625 return error;
626 }
627
628
629 void
630 udf_free_logvol_dscr(struct udf_mount *ump, struct long_ad *icb,
631 void *dscr)
632 {
633 struct udf_strategy *strategy = ump->strategy;
634 struct udf_strat_args args;
635
636 KASSERT(strategy);
637 args.ump = ump;
638 args.icb = icb;
639 args.dscr = dscr;
640
641 (strategy->free_logvol_dscr)(&args);
642 }
643
644
645 int
646 udf_read_logvol_dscr(struct udf_mount *ump, struct long_ad *icb,
647 union dscrptr **dscrptr)
648 {
649 struct udf_strategy *strategy = ump->strategy;
650 struct udf_strat_args args;
651 int error;
652
653 KASSERT(strategy);
654 args.ump = ump;
655 args.icb = icb;
656 args.dscr = NULL;
657
658 error = (strategy->read_logvol_dscr)(&args);
659 *dscrptr = args.dscr;
660
661 return error;
662 }
663
664
665 int
666 udf_write_logvol_dscr(struct udf_node *udf_node, union dscrptr *dscr,
667 struct long_ad *icb, int waitfor)
668 {
669 struct udf_strategy *strategy = udf_node->ump->strategy;
670 struct udf_strat_args args;
671 int error;
672
673 KASSERT(strategy);
674 args.ump = udf_node->ump;
675 args.udf_node = udf_node;
676 args.icb = icb;
677 args.dscr = dscr;
678 args.waitfor = waitfor;
679
680 error = (strategy->write_logvol_dscr)(&args);
681 return error;
682 }
683
684
685 void
686 udf_discstrat_queuebuf(struct udf_mount *ump, struct buf *nestbuf)
687 {
688 struct udf_strategy *strategy = ump->strategy;
689 struct udf_strat_args args;
690
691 KASSERT(strategy);
692 args.ump = ump;
693 args.nestbuf = nestbuf;
694
695 (strategy->queuebuf)(&args);
696 }
697
698
699 void
700 udf_discstrat_init(struct udf_mount *ump)
701 {
702 struct udf_strategy *strategy = ump->strategy;
703 struct udf_strat_args args;
704
705 KASSERT(strategy);
706 args.ump = ump;
707 (strategy->discstrat_init)(&args);
708 }
709
710
711 void udf_discstrat_finish(struct udf_mount *ump)
712 {
713 struct udf_strategy *strategy = ump->strategy;
714 struct udf_strat_args args;
715
716 /* strategy might not have been set, so ignore if not set */
717 if (strategy) {
718 args.ump = ump;
719 (strategy->discstrat_finish)(&args);
720 }
721 }
722
723 /* --------------------------------------------------------------------- */
724
725