2 iso9660 - An iso9660 CDI driver with Rockridge support
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "iso9660_cdi.h"
26 #include "iso9660def.h"
27 #include "volume_descriptor.h"
30 * Checks signature of volume descriptor
31 * @param sig Signature
32 * @return If signature is right
34 static int iso9660_voldesc_checksig(uint8_t sig
[6]) {
35 char right
[6] = {'C','D','0','0','1',1};
36 return memcmp(right
,sig
,6)==0;
40 * Loads a volume descriptor
41 * @param fs Filesystem
42 * @param type Type of volume descriptor
43 * @param buf Buffer for volume descriptor
44 * @return 0=success; -1=failure
46 int iso9660_voldesc_load(struct cdi_fs_filesystem
*fs
,iso9660_voldesc_type_t type
,void *buf
) {
47 debug("iso9660_voldesc_load(0x%x,%d,0x%x)\n",fs
,type
,buf
);
48 struct iso9660_voldesc header
;
51 for (i
=ISO9660_FIRST_SECTOR
;header
.type
!=type
&& header
.type
!=ISO9660_VOLDESC_TERM
;i
++) {
52 if (iso9660_sector_read(fs
,i
*ISO9660_DEFAULT_SECTOR_SIZE
,sizeof(header
),&header
)!=sizeof(header
)) return -1;
53 if (!iso9660_voldesc_checksig(header
.signature
)) return -1;
57 if (header
.type
==type
) {
58 iso9660_sector_read(fs
,i
*ISO9660_DEFAULT_SECTOR_SIZE
,sizeof(struct iso9660_voldesc_prim
),buf
);
62 debug("Volume Descriptor: Wrong type: %d\n",header
.type
);