2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <asm/types.h>
37 #include "volume_id.h"
42 #define ISO_SUPERBLOCK_OFFSET 0x8000
43 #define ISO_SECTOR_SIZE 0x800
44 #define ISO_VD_OFFSET (ISO_SUPERBLOCK_OFFSET + ISO_SECTOR_SIZE)
45 #define ISO_VD_PRIMARY 0x1
46 #define ISO_VD_SUPPLEMENTARY 0x2
47 #define ISO_VD_END 0xff
50 union iso_super_block {
58 } __attribute__((__packed__)) iso;
64 } __attribute__((__packed__)) hs;
65 } __attribute__((__packed__));
67 int volume_id_probe_iso9660(struct volume_id *id, __u64 off)
69 union iso_super_block *is;
71 dbg("probing at offset %llu", off);
73 is = (union iso_super_block *) volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200);
77 if (memcmp(is->iso.id, "CD001", 5) == 0) {
78 char root_label[VOLUME_ID_LABEL_SIZE+1];
83 memset(root_label, 0, sizeof(root_label));
84 strncpy(root_label, is->iso.volume_id, sizeof(root_label)-1);
87 vd_offset = ISO_VD_OFFSET;
88 for (i = 0; i < ISO_VD_MAX; i++) {
89 is = (union iso_super_block *) volume_id_get_buffer(id, off + vd_offset, 0x200);
90 if (is == NULL || is->iso.type == ISO_VD_END)
92 if (is->iso.type == ISO_VD_SUPPLEMENTARY) {
93 dbg("found ISO supplementary VD at offset 0x%llx", off + vd_offset);
94 volume_id_set_label_raw(id, is->iso.volume_id, 32);
95 volume_id_set_label_unicode16(id, is->iso.volume_id, BE, 32);
99 vd_offset += ISO_SECTOR_SIZE;
103 (found_svd && !memcmp(root_label, id->label, 16)))
105 volume_id_set_label_raw(id, root_label, 32);
106 volume_id_set_label_string(id, root_label, 32);
110 if (memcmp(is->hs.id, "CDROM", 5) == 0)
115 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
116 id->type = "iso9660";