2 * This code is based on dvdudf by:
3 * Christian Wolff <scarabaeus@convergence.de>.
6 * Billy Biggs <vektor@dumbterm.net>.
7 * Björn Englund <d4bjorn@dtek.chalmers.se>.
9 * dvdudf: parse and read the UDF volume information of a DVD Video
10 * Copyright (C) 1999 Christian Wolff for convergence integrated media
11 * GmbH The author can be reached at scarabaeus@convergence.de, the
12 * project's page is at http://linuxtv.org/dvd/
14 * This file is part of libdvdread.
16 * libdvdread is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * libdvdread is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with libdvdread; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include <sys/types.h>
40 #include "dvdread/dvd_reader.h"
41 #include "dvdread/dvd_udf.h"
43 /* Private but located in/shared with dvd_reader.c */
44 extern int UDFReadBlocksRaw( dvd_reader_t
*device
, uint32_t lb_number
,
45 size_t block_count
, unsigned char *data
,
48 /* It's required to either fail or deliver all the blocks asked for. */
49 static int DVDReadLBUDF( dvd_reader_t
*device
, uint32_t lb_number
,
50 size_t block_count
, unsigned char *data
,
54 size_t count
= block_count
;
58 ret
= UDFReadBlocksRaw(device
, lb_number
, count
, data
, encrypted
);
61 /* One of the reads failed or nothing more to read, too bad.
62 * We won't even bother returning the reads that went ok. */
67 lb_number
+= (uint32_t)ret
;
75 #define NULL ((void *)0)
102 struct extent_ad mvds
;
103 struct extent_ad rvds
;
107 uint8_t VolumeIdentifier
[32];
108 uint8_t VolumeSetIdentifier
[128];
114 /* needed for proper freeing */
130 struct Partition partition
;
140 PartitionCache
, RootICBCache
, LBUDFCache
, MapCache
, AVDPCache
, PVDCache
143 void FreeUDFCache(void *cache
)
145 struct udf_cache
*c
= (struct udf_cache
*)cache
;
151 for(n
= 0; n
< c
->lb_num
; n
++)
152 free(c
->lbs
[n
].data_base
);
161 static int GetUDFCache(dvd_reader_t
*device
, UDFCacheType type
,
162 uint32_t nr
, void *data
)
167 if(DVDUDFCacheLevel(device
, -1) <= 0)
170 c
= (struct udf_cache
*)GetUDFCacheHandle(device
);
178 *(struct avdp_t
*)data
= c
->avdp
;
184 *(struct pvd_t
*)data
= c
->pvd
;
189 if(c
->partition_valid
) {
190 *(struct Partition
*)data
= c
->partition
;
195 if(c
->rooticb_valid
) {
196 *(struct AD
*)data
= c
->rooticb
;
201 for(n
= 0; n
< c
->lb_num
; n
++) {
202 if(c
->lbs
[n
].lb
== nr
) {
203 *(uint8_t **)data
= c
->lbs
[n
].data
;
209 for(n
= 0; n
< c
->map_num
; n
++) {
210 if(c
->maps
[n
].lbn
== nr
) {
211 *(struct icbmap
*)data
= c
->maps
[n
];
223 static int SetUDFCache(dvd_reader_t
*device
, UDFCacheType type
,
224 uint32_t nr
, void *data
)
230 if(DVDUDFCacheLevel(device
, -1) <= 0)
233 c
= (struct udf_cache
*)GetUDFCacheHandle(device
);
236 c
= calloc(1, sizeof(struct udf_cache
));
237 /* fprintf(stderr, "calloc: %d\n", sizeof(struct udf_cache)); */
240 SetUDFCacheHandle(device
, c
);
246 c
->avdp
= *(struct avdp_t
*)data
;
250 c
->pvd
= *(struct pvd_t
*)data
;
254 c
->partition
= *(struct Partition
*)data
;
255 c
->partition_valid
= 1;
258 c
->rooticb
= *(struct AD
*)data
;
259 c
->rooticb_valid
= 1;
262 for(n
= 0; n
< c
->lb_num
; n
++) {
263 if(c
->lbs
[n
].lb
== nr
) {
264 /* replace with new data */
265 c
->lbs
[n
].data_base
= ((uint8_t **)data
)[0];
266 c
->lbs
[n
].data
= ((uint8_t **)data
)[1];
272 tmp
= realloc(c
->lbs
, c
->lb_num
* sizeof(struct lbudf
));
274 fprintf(stderr, "realloc lb: %d * %d = %d\n",
275 c->lb_num, sizeof(struct lbudf),
276 c->lb_num * sizeof(struct lbudf));
279 if(c
->lbs
) free(c
->lbs
);
284 c
->lbs
[n
].data_base
= ((uint8_t **)data
)[0];
285 c
->lbs
[n
].data
= ((uint8_t **)data
)[1];
289 for(n
= 0; n
< c
->map_num
; n
++) {
290 if(c
->maps
[n
].lbn
== nr
) {
291 /* replace with new data */
292 c
->maps
[n
] = *(struct icbmap
*)data
;
298 tmp
= realloc(c
->maps
, c
->map_num
* sizeof(struct icbmap
));
300 fprintf(stderr, "realloc maps: %d * %d = %d\n",
301 c->map_num, sizeof(struct icbmap),
302 c->map_num * sizeof(struct icbmap));
305 if(c
->maps
) free(c
->maps
);
310 c
->maps
[n
] = *(struct icbmap
*)data
;
321 /* For direct data access, LSB first */
322 #define GETN1(p) ((uint8_t)data[p])
323 #define GETN2(p) ((uint16_t)data[p] | ((uint16_t)data[(p) + 1] << 8))
324 #define GETN3(p) ((uint32_t)data[p] | ((uint32_t)data[(p) + 1] << 8) \
325 | ((uint32_t)data[(p) + 2] << 16))
326 #define GETN4(p) ((uint32_t)data[p] \
327 | ((uint32_t)data[(p) + 1] << 8) \
328 | ((uint32_t)data[(p) + 2] << 16) \
329 | ((uint32_t)data[(p) + 3] << 24))
330 /* This is wrong with regard to endianess */
331 #define GETN(p, n, target) memcpy(target, &data[p], n)
333 static int Unicodedecode( uint8_t *data
, int len
, char *target
)
337 if( ( data
[ 0 ] == 8 ) || ( data
[ 0 ] == 16 ) ) do {
338 if( data
[ 0 ] == 16 ) p
++; /* Ignore MSB of unicode16 */
340 target
[ i
++ ] = data
[ p
++ ];
348 static int UDFDescriptor( uint8_t *data
, uint16_t *TagID
)
351 /* TODO: check CRC 'n stuff */
355 static int UDFExtentAD( uint8_t *data
, uint32_t *Length
, uint32_t *Location
)
358 *Location
= GETN4(4);
362 static int UDFShortAD( uint8_t *data
, struct AD
*ad
,
363 struct Partition
*partition
)
365 ad
->Length
= GETN4(0);
366 ad
->Flags
= ad
->Length
>> 30;
367 ad
->Length
&= 0x3FFFFFFF;
368 ad
->Location
= GETN4(4);
369 ad
->Partition
= partition
->Number
; /* use number of current partition */
373 static int UDFLongAD( uint8_t *data
, struct AD
*ad
)
375 ad
->Length
= GETN4(0);
376 ad
->Flags
= ad
->Length
>> 30;
377 ad
->Length
&= 0x3FFFFFFF;
378 ad
->Location
= GETN4(4);
379 ad
->Partition
= GETN2(8);
380 /* GETN(10, 6, Use); */
384 static int UDFExtAD( uint8_t *data
, struct AD
*ad
)
386 ad
->Length
= GETN4(0);
387 ad
->Flags
= ad
->Length
>> 30;
388 ad
->Length
&= 0x3FFFFFFF;
389 ad
->Location
= GETN4(12);
390 ad
->Partition
= GETN2(16);
391 /* GETN(10, 6, Use); */
395 static int UDFICB( uint8_t *data
, uint8_t *FileType
, uint16_t *Flags
)
397 *FileType
= GETN1(11);
403 static int UDFPartition( uint8_t *data
, uint16_t *Flags
, uint16_t *Number
,
404 char *Contents
, uint32_t *Start
, uint32_t *Length
)
408 GETN(24, 32, Contents
);
410 *Length
= GETN4(192);
415 * Reads the volume descriptor and checks the parameters. Returns 0 on OK, 1
418 static int UDFLogVolume( uint8_t *data
, char *VolumeDescriptor
)
420 uint32_t lbsize
, MT_L
, N_PM
;
421 Unicodedecode(&data
[84], 128, VolumeDescriptor
);
422 lbsize
= GETN4(212); /* should be 2048 */
423 MT_L
= GETN4(264); /* should be 6 */
424 N_PM
= GETN4(268); /* should be 1 */
425 if (lbsize
!= DVD_VIDEO_LB_LEN
) return 1;
429 static int UDFFileEntry( uint8_t *data
, uint8_t *FileType
,
430 struct Partition
*partition
, struct AD
*ad
)
436 UDFICB( &data
[ 16 ], FileType
, &flags
);
438 /* Init ad for an empty file (i.e. there isn't a AD, L_AD == 0 ) */
439 ad
->Length
= GETN4( 60 ); /* Really 8 bytes a 56 */
441 ad
->Location
= 0; /* what should we put here? */
442 ad
->Partition
= partition
->Number
; /* use number of current partition */
447 while( p
< 176 + L_EA
+ L_AD
) {
448 switch( flags
& 0x0007 ) {
450 UDFShortAD( &data
[ p
], ad
, partition
);
454 UDFLongAD( &data
[ p
], ad
);
458 UDFExtAD( &data
[ p
], ad
);
464 UDFShortAD( &data
[ p
], ad
, partition
);
467 UDFLongAD( &data
[ p
], ad
);
470 UDFExtAD( &data
[ p
], ad
);
483 static int UDFFileIdentifier( uint8_t *data
, uint8_t *FileCharacteristics
,
484 char *FileName
, struct AD
*FileICB
)
489 *FileCharacteristics
= GETN1(18);
491 UDFLongAD(&data
[20], FileICB
);
493 if (L_FI
) Unicodedecode(&data
[38 + L_IU
], L_FI
, FileName
);
494 else FileName
[0] = '\0';
495 return 4 * ((38 + L_FI
+ L_IU
+ 3) / 4);
500 * ICB: Location of ICB of directory to scan
501 * FileType: Type of the file
502 * File: Location of file the ICB is pointing to
503 * return 1 on success, 0 on error;
505 static int UDFMapICB( dvd_reader_t
*device
, struct AD ICB
, uint8_t *FileType
,
506 struct Partition
*partition
, struct AD
*File
)
508 uint8_t LogBlock_base
[DVD_VIDEO_LB_LEN
+ 2048];
509 uint8_t *LogBlock
= (uint8_t *)(((uintptr_t)LogBlock_base
& ~((uintptr_t)2047)) + 2048);
512 struct icbmap tmpmap
;
514 lbnum
= partition
->Start
+ ICB
.Location
;
516 if(GetUDFCache(device
, MapCache
, lbnum
, &tmpmap
)) {
517 *FileType
= tmpmap
.filetype
;
518 memcpy(File
, &tmpmap
.file
, sizeof(tmpmap
.file
));
523 if( DVDReadLBUDF( device
, lbnum
++, 1, LogBlock
, 0 ) <= 0 )
526 UDFDescriptor( LogBlock
, &TagID
);
529 UDFFileEntry( LogBlock
, FileType
, partition
, File
);
530 memcpy(&tmpmap
.file
, File
, sizeof(tmpmap
.file
));
531 tmpmap
.filetype
= *FileType
;
532 SetUDFCache(device
, MapCache
, tmpmap
.lbn
, &tmpmap
);
535 } while( ( lbnum
<= partition
->Start
+ ICB
.Location
+ ( ICB
.Length
- 1 )
536 / DVD_VIDEO_LB_LEN
) && ( TagID
!= 261 ) );
542 * Dir: Location of directory to scan
543 * FileName: Name of file to look for
544 * FileICB: Location of ICB of the found file
545 * return 1 on success, 0 on error;
547 static int UDFScanDir( dvd_reader_t
*device
, struct AD Dir
, char *FileName
,
548 struct Partition
*partition
, struct AD
*FileICB
,
551 char filename
[ MAX_UDF_FILE_NAME_LEN
];
552 uint8_t directory_base
[ 2 * DVD_VIDEO_LB_LEN
+ 2048];
553 uint8_t *directory
= (uint8_t *)(((uintptr_t)directory_base
& ~((uintptr_t)2047)) + 2048);
558 uint8_t *cached_dir_base
= NULL
, *cached_dir
;
564 /* Scan dir for ICB of file */
565 lbnum
= partition
->Start
+ Dir
.Location
;
567 if(DVDUDFCacheLevel(device
, -1) > 0) {
570 if(!GetUDFCache(device
, LBUDFCache
, lbnum
, &cached_dir
)) {
571 dir_lba
= (Dir
.Length
+ DVD_VIDEO_LB_LEN
) / DVD_VIDEO_LB_LEN
;
572 if((cached_dir_base
= malloc(dir_lba
* DVD_VIDEO_LB_LEN
+ 2048)) == NULL
)
574 cached_dir
= (uint8_t *)(((uintptr_t)cached_dir_base
& ~((uintptr_t)2047)) + 2048);
575 if( DVDReadLBUDF( device
, lbnum
, dir_lba
, cached_dir
, 0) <= 0 ) {
576 free(cached_dir_base
);
577 cached_dir_base
= NULL
;
582 fprintf(stderr, "malloc dir: %d\n", dir_lba * DVD_VIDEO_LB_LEN);
587 data
[0] = cached_dir_base
;
588 data
[1] = cached_dir
;
589 SetUDFCache(device
, LBUDFCache
, lbnum
, data
);
594 if(cached_dir
== NULL
)
599 while( p
< Dir
.Length
) {
600 UDFDescriptor( &cached_dir
[ p
], &TagID
);
602 p
+= UDFFileIdentifier( &cached_dir
[ p
], &filechar
,
604 if(cache_file_info
&& !in_cache
) {
608 if( !strcasecmp( FileName
, filename
) ) {
609 memcpy(FileICB
, &tmpICB
, sizeof(tmpICB
));
612 UDFMapICB(device
, tmpICB
, &tmpFiletype
, partition
, &tmpFile
);
614 if( !strcasecmp( FileName
, filename
) ) {
615 memcpy(FileICB
, &tmpICB
, sizeof(tmpICB
));
620 if(cache_file_info
&& (!in_cache
) && found
)
625 if(cache_file_info
&& (!in_cache
) && found
)
630 if( DVDReadLBUDF( device
, lbnum
, 2, directory
, 0 ) <= 0 )
634 while( p
< Dir
.Length
) {
635 if( p
> DVD_VIDEO_LB_LEN
) {
637 p
-= DVD_VIDEO_LB_LEN
;
638 Dir
.Length
-= DVD_VIDEO_LB_LEN
;
639 if( DVDReadLBUDF( device
, lbnum
, 2, directory
, 0 ) <= 0 ) {
643 UDFDescriptor( &directory
[ p
], &TagID
);
645 p
+= UDFFileIdentifier( &directory
[ p
], &filechar
,
647 if( !strcasecmp( FileName
, filename
) ) {
658 static int UDFGetAVDP( dvd_reader_t
*device
,
661 uint8_t Anchor_base
[ DVD_VIDEO_LB_LEN
+ 2048 ];
662 uint8_t *Anchor
= (uint8_t *)(((uintptr_t)Anchor_base
& ~((uintptr_t)2047)) + 2048);
663 uint32_t lbnum
, MVDS_location
, MVDS_length
;
669 if(GetUDFCache(device
, AVDPCache
, 0, avdp
))
674 lbnum
= 256; /* Try #1, prime anchor */
678 if( DVDReadLBUDF( device
, lbnum
, 1, Anchor
, 0 ) > 0 ) {
679 UDFDescriptor( Anchor
, &TagID
);
685 if( terminate
) return 0; /* Final try failed */
688 /* We already found the last sector. Try #3, alternative
689 * backup anchor. If that fails, don't try again.
694 /* TODO: Find last sector of the disc (this is optional). */
696 /* Try #2, backup anchor */
697 lbnum
= lastsector
- 256;
699 /* Unable to find last sector */
703 /* It's an anchor! We can leave */
706 /* Main volume descriptor */
707 UDFExtentAD( &Anchor
[ 16 ], &MVDS_length
, &MVDS_location
);
708 avdp
->mvds
.location
= MVDS_location
;
709 avdp
->mvds
.length
= MVDS_length
;
711 /* Backup volume descriptor */
712 UDFExtentAD( &Anchor
[ 24 ], &MVDS_length
, &MVDS_location
);
713 avdp
->rvds
.location
= MVDS_location
;
714 avdp
->rvds
.length
= MVDS_length
;
716 SetUDFCache(device
, AVDPCache
, 0, avdp
);
722 * Looks for partition on the disc. Returns 1 if partition found, 0 on error.
723 * partnum: Number of the partition, starting at 0.
724 * part: structure to fill with the partition information
726 static int UDFFindPartition( dvd_reader_t
*device
, int partnum
,
727 struct Partition
*part
)
729 uint8_t LogBlock_base
[ DVD_VIDEO_LB_LEN
+ 2048 ];
730 uint8_t *LogBlock
= (uint8_t *)(((uintptr_t)LogBlock_base
& ~((uintptr_t)2047)) + 2048);
731 uint32_t lbnum
, MVDS_location
, MVDS_length
;
736 if(!UDFGetAVDP(device
, &avdp
))
739 /* Main volume descriptor */
740 MVDS_location
= avdp
.mvds
.location
;
741 MVDS_length
= avdp
.mvds
.length
;
745 part
->VolumeDesc
[ 0 ] = '\0';
748 /* Find Volume Descriptor */
749 lbnum
= MVDS_location
;
752 if( DVDReadLBUDF( device
, lbnum
++, 1, LogBlock
, 0 ) <= 0 )
755 UDFDescriptor( LogBlock
, &TagID
);
757 if( ( TagID
== 5 ) && ( !part
->valid
) ) {
758 /* Partition Descriptor */
759 UDFPartition( LogBlock
, &part
->Flags
, &part
->Number
,
760 part
->Contents
, &part
->Start
, &part
->Length
);
761 part
->valid
= ( partnum
== part
->Number
);
762 } else if( ( TagID
== 6 ) && ( !volvalid
) ) {
763 /* Logical Volume Descriptor */
764 if( UDFLogVolume( LogBlock
, part
->VolumeDesc
) ) {
765 /* TODO: sector size wrong! */
770 } while( ( lbnum
<= MVDS_location
+ ( MVDS_length
- 1 )
771 / DVD_VIDEO_LB_LEN
) && ( TagID
!= 8 )
772 && ( ( !part
->valid
) || ( !volvalid
) ) );
774 if( ( !part
->valid
) || ( !volvalid
) ) {
775 /* Backup volume descriptor */
776 MVDS_location
= avdp
.mvds
.location
;
777 MVDS_length
= avdp
.mvds
.length
;
779 } while( i
-- && ( ( !part
->valid
) || ( !volvalid
) ) );
781 /* We only care for the partition, not the volume */
785 uint32_t UDFFindFile( dvd_reader_t
*device
, char *filename
,
788 uint8_t LogBlock_base
[ DVD_VIDEO_LB_LEN
+ 2048 ];
789 uint8_t *LogBlock
= (uint8_t *)(((uintptr_t)LogBlock_base
& ~((uintptr_t)2047)) + 2048);
792 struct Partition partition
;
793 struct AD RootICB
, File
, ICB
;
794 char tokenline
[ MAX_UDF_FILE_NAME_LEN
];
800 strncat(tokenline
, filename
, MAX_UDF_FILE_NAME_LEN
- 1);
801 memset(&ICB
, 0, sizeof(ICB
));
803 if(!(GetUDFCache(device
, PartitionCache
, 0, &partition
) &&
804 GetUDFCache(device
, RootICBCache
, 0, &RootICB
))) {
805 /* Find partition, 0 is the standard location for DVD Video.*/
806 if( !UDFFindPartition( device
, 0, &partition
) ) return 0;
807 SetUDFCache(device
, PartitionCache
, 0, &partition
);
809 /* Find root dir ICB */
810 lbnum
= partition
.Start
;
812 if( DVDReadLBUDF( device
, lbnum
++, 1, LogBlock
, 0 ) <= 0 )
815 UDFDescriptor( LogBlock
, &TagID
);
817 /* File Set Descriptor */
818 if( TagID
== 256 ) /* File Set Descriptor */
819 UDFLongAD( &LogBlock
[ 400 ], &RootICB
);
820 } while( ( lbnum
< partition
.Start
+ partition
.Length
)
821 && ( TagID
!= 8 ) && ( TagID
!= 256 ) );
826 if( RootICB
.Partition
!= 0 )
828 SetUDFCache(device
, RootICBCache
, 0, &RootICB
);
832 if( !UDFMapICB( device
, RootICB
, &filetype
, &partition
, &File
) )
835 return 0; /* Root dir should be dir */
837 int cache_file_info
= 0;
838 /* Tokenize filepath */
839 token
= strtok(tokenline
, "/");
841 while( token
!= NULL
) {
842 if( !UDFScanDir( device
, File
, token
, &partition
, &ICB
,
845 if( !UDFMapICB( device
, ICB
, &filetype
, &partition
, &File
) )
847 if(!strcmp(token
, "VIDEO_TS"))
849 token
= strtok( NULL
, "/" );
854 if( File
.Partition
!= 0 )
856 *filesize
= File
.Length
;
857 /* Hack to not return partition.Start for empty files. */
861 return partition
.Start
+ File
.Location
;
867 * Gets a Descriptor .
868 * Returns 1 if descriptor found, 0 on error.
869 * id, tagid of descriptor
870 * bufsize, size of BlockBuf (must be >= DVD_VIDEO_LB_LEN).
872 static int UDFGetDescriptor( dvd_reader_t
*device
, int id
,
873 uint8_t *descriptor
, int bufsize
)
875 uint32_t lbnum
, MVDS_location
, MVDS_length
;
883 lbnum
= 256; /* Try #1, prime anchor */
885 if(bufsize
< DVD_VIDEO_LB_LEN
)
888 if(!UDFGetAVDP(device
, &avdp
))
891 /* Main volume descriptor */
892 MVDS_location
= avdp
.mvds
.location
;
893 MVDS_length
= avdp
.mvds
.length
;
897 /* Find Descriptor */
898 lbnum
= MVDS_location
;
900 if( DVDReadLBUDF( device
, lbnum
++, 1, descriptor
, 0 ) <= 0 )
903 UDFDescriptor( descriptor
, &TagID
);
904 if( (TagID
== id
) && ( !desc_found
) )
907 } while( ( lbnum
<= MVDS_location
+ ( MVDS_length
- 1 )
908 / DVD_VIDEO_LB_LEN
) && ( TagID
!= 8 )
912 /* Backup volume descriptor */
913 MVDS_location
= avdp
.rvds
.location
;
914 MVDS_length
= avdp
.rvds
.length
;
916 } while( i
-- && ( !desc_found
) );
922 static int UDFGetPVD(dvd_reader_t
*device
, struct pvd_t
*pvd
)
924 uint8_t pvd_buf_base
[DVD_VIDEO_LB_LEN
+ 2048];
925 uint8_t *pvd_buf
= (uint8_t *)(((uintptr_t)pvd_buf_base
& ~((uintptr_t)2047)) + 2048);
926 if(GetUDFCache(device
, PVDCache
, 0, pvd
))
929 if(!UDFGetDescriptor( device
, 1, pvd_buf
, sizeof(pvd_buf
)))
932 memcpy(pvd
->VolumeIdentifier
, &pvd_buf
[24], 32);
933 memcpy(pvd
->VolumeSetIdentifier
, &pvd_buf
[72], 128);
934 SetUDFCache(device
, PVDCache
, 0, pvd
);
939 * Gets the Volume Identifier string, in 8bit unicode (latin-1)
940 * volid, place to put the string
941 * volid_size, size of the buffer volid points to
942 * returns the size of buffer needed for all data
944 int UDFGetVolumeIdentifier(dvd_reader_t
*device
, char *volid
,
945 unsigned int volid_size
)
948 unsigned int volid_len
;
950 /* get primary volume descriptor */
951 if(!UDFGetPVD(device
, &pvd
))
954 volid_len
= pvd
.VolumeIdentifier
[31];
956 /* this field is only 32 bytes something is wrong */
958 if(volid_size
> volid_len
)
959 volid_size
= volid_len
;
960 Unicodedecode(pvd
.VolumeIdentifier
, volid_size
, volid
);
966 * Gets the Volume Set Identifier, as a 128-byte dstring (not decoded)
967 * WARNING This is not a null terminated string
968 * volsetid, place to put the data
969 * volsetid_size, size of the buffer volsetid points to
970 * the buffer should be >=128 bytes to store the whole volumesetidentifier
971 * returns the size of the available volsetid information (128)
974 int UDFGetVolumeSetIdentifier(dvd_reader_t
*device
, uint8_t *volsetid
,
975 unsigned int volsetid_size
)
979 /* get primary volume descriptor */
980 if(!UDFGetPVD(device
, &pvd
))
984 if(volsetid_size
> 128)
987 memcpy(volsetid
, pvd
.VolumeSetIdentifier
, volsetid_size
);