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