2008-02-19 02:38:49 +05:30
|
|
|
/*
|
|
|
|
* volume_id - reads filesystem label and uuid
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2013-07-31 19:15:20 +05:30
|
|
|
//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
|
|
|
|
|
2013-07-31 19:27:59 +05:30
|
|
|
//config:
|
|
|
|
//config:config FEATURE_VOLUMEID_ISO9660
|
|
|
|
//config: bool "iso9660 filesystem"
|
|
|
|
//config: default y
|
|
|
|
//config: depends on VOLUMEID
|
|
|
|
//config: help
|
|
|
|
//config: TODO
|
|
|
|
//config:
|
|
|
|
|
2008-02-19 02:38:49 +05:30
|
|
|
#include "volume_id_internal.h"
|
|
|
|
|
|
|
|
#define ISO_SUPERBLOCK_OFFSET 0x8000
|
|
|
|
#define ISO_SECTOR_SIZE 0x800
|
|
|
|
#define ISO_VD_OFFSET (ISO_SUPERBLOCK_OFFSET + ISO_SECTOR_SIZE)
|
|
|
|
#define ISO_VD_PRIMARY 0x1
|
|
|
|
#define ISO_VD_SUPPLEMENTARY 0x2
|
|
|
|
#define ISO_VD_END 0xff
|
|
|
|
#define ISO_VD_MAX 16
|
|
|
|
|
|
|
|
struct iso_volume_descriptor {
|
|
|
|
uint8_t vd_type;
|
|
|
|
uint8_t vd_id[5];
|
|
|
|
uint8_t vd_version;
|
|
|
|
uint8_t flags;
|
|
|
|
uint8_t system_id[32];
|
|
|
|
uint8_t volume_id[32];
|
|
|
|
uint8_t unused[8];
|
|
|
|
uint8_t space_size[8];
|
|
|
|
uint8_t escape_sequences[8];
|
2009-09-16 04:28:11 +05:30
|
|
|
} PACKED;
|
2008-02-19 02:38:49 +05:30
|
|
|
|
|
|
|
struct high_sierra_volume_descriptor {
|
|
|
|
uint8_t foo[8];
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t id[4];
|
|
|
|
uint8_t version;
|
2009-09-16 04:28:11 +05:30
|
|
|
} PACKED;
|
2008-02-19 02:38:49 +05:30
|
|
|
|
2009-11-02 03:37:18 +05:30
|
|
|
int FAST_FUNC volume_id_probe_iso9660(struct volume_id *id /*,uint64_t off*/)
|
2008-02-19 02:38:49 +05:30
|
|
|
{
|
2009-02-15 11:21:19 +05:30
|
|
|
#define off ((uint64_t)0)
|
2008-02-19 02:38:49 +05:30
|
|
|
uint8_t *buf;
|
|
|
|
struct iso_volume_descriptor *is;
|
|
|
|
struct high_sierra_volume_descriptor *hs;
|
|
|
|
|
|
|
|
dbg("probing at offset 0x%llx", (unsigned long long) off);
|
|
|
|
|
|
|
|
buf = volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200);
|
|
|
|
if (buf == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
is = (struct iso_volume_descriptor *) buf;
|
|
|
|
|
|
|
|
if (memcmp(is->vd_id, "CD001", 5) == 0) {
|
|
|
|
int vd_offset;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dbg("read label from PVD");
|
2008-03-17 14:51:26 +05:30
|
|
|
// volume_id_set_label_raw(id, is->volume_id, 32);
|
2008-02-19 02:38:49 +05:30
|
|
|
volume_id_set_label_string(id, is->volume_id, 32);
|
|
|
|
|
|
|
|
dbg("looking for SVDs");
|
|
|
|
vd_offset = ISO_VD_OFFSET;
|
|
|
|
for (i = 0; i < ISO_VD_MAX; i++) {
|
|
|
|
uint8_t svd_label[64];
|
|
|
|
|
|
|
|
is = volume_id_get_buffer(id, off + vd_offset, 0x200);
|
|
|
|
if (is == NULL || is->vd_type == ISO_VD_END)
|
|
|
|
break;
|
|
|
|
if (is->vd_type != ISO_VD_SUPPLEMENTARY)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset));
|
2008-03-17 14:51:26 +05:30
|
|
|
if (memcmp(is->escape_sequences, "%/@", 3) == 0
|
|
|
|
|| memcmp(is->escape_sequences, "%/C", 3) == 0
|
|
|
|
|| memcmp(is->escape_sequences, "%/E", 3) == 0
|
|
|
|
) {
|
2008-02-19 02:38:49 +05:30
|
|
|
dbg("Joliet extension found");
|
|
|
|
volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32);
|
|
|
|
if (memcmp(id->label, svd_label, 16) == 0) {
|
|
|
|
dbg("SVD label is identical, use the possibly longer PVD one");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-17 14:51:26 +05:30
|
|
|
// volume_id_set_label_raw(id, is->volume_id, 32);
|
2008-02-19 02:38:49 +05:30
|
|
|
volume_id_set_label_string(id, svd_label, 32);
|
2008-03-17 14:51:26 +05:30
|
|
|
// strcpy(id->type_version, "Joliet Extension");
|
2008-02-19 02:38:49 +05:30
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
vd_offset += ISO_SECTOR_SIZE;
|
|
|
|
}
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
|
|
|
|
hs = (struct high_sierra_volume_descriptor *) buf;
|
|
|
|
|
|
|
|
if (memcmp(hs->id, "CDROM", 5) == 0) {
|
2008-03-17 14:51:26 +05:30
|
|
|
// strcpy(id->type_version, "High Sierra");
|
2008-02-19 02:38:49 +05:30
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
found:
|
2008-03-17 14:51:26 +05:30
|
|
|
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
|
2010-12-30 05:10:11 +05:30
|
|
|
IF_FEATURE_BLKID_TYPE(id->type = "iso9660";)
|
2008-02-19 02:38:49 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|