Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / fs / grubfs / iso9660.h
1 /*
2  *  ISO 9660 filesystem backend for GRUB (GRand Unified Bootloader)
3  *  including Rock Ridge Extensions support
4  *
5  *  Copyright (C) 1998, 1999  Kousuke Takai  <tak@kmc.kyoto-u.ac.jp>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20  *  MA 02110-1301, USA.
21  */
22 /*
23  *  References:
24  *      linux/fs/isofs/rock.[ch]
25  *      mkisofs-1.11.1/diag/isoinfo.c
26  *      mkisofs-1.11.1/iso9660.h
27  *              (all are written by Eric Youngdale)
28  */
29
30 /*
31  * Modified by SONE Takeshi to work with FILO
32  */
33
34 #ifndef _ISO9660_H_
35 #define _ISO9660_H_
36
37 #define ISO_SECTOR_BITS              (11)
38 #define ISO_SECTOR_SIZE              (1<<ISO_SECTOR_BITS)
39
40 #define ISO_REGULAR     1       /* regular file */
41 #define ISO_DIRECTORY   2       /* directory    */
42 #define ISO_OTHER       0       /* other file (with Rock Ridge) */
43
44 #define RR_FLAG_PX      0x01    /* have POSIX file attributes */
45 #define RR_FLAG_NM      0x08    /* have alternate file name   */
46
47 /* POSIX file attributes for Rock Ridge extensions */
48 #define POSIX_S_IFMT    0xF000
49 #define POSIX_S_IFREG   0x8000
50 #define POSIX_S_IFDIR   0x4000
51
52 /* volume descriptor types */
53 #define ISO_VD_PRIMARY 1
54 #define ISO_VD_END 255
55
56 #define ISO_STANDARD_ID "CD001"
57
58 #ifndef ASM_FILE
59
60 typedef union {
61         uint8_t l,b;
62 }       iso_8bit_t;
63
64 typedef struct __iso_16bit {
65         uint16_t l, b;
66 } iso_16bit_t;
67
68 typedef struct __iso_32bit {
69         uint32_t l, b;
70 } iso_32bit_t;
71
72 typedef uint8_t         iso_date_t[7];
73
74 struct iso_directory_record {
75         iso_8bit_t      length;
76         iso_8bit_t      ext_attr_length;
77         iso_32bit_t     extent;
78         iso_32bit_t     size;
79         iso_date_t      date;
80         iso_8bit_t      flags;
81         iso_8bit_t      file_unit_size;
82         iso_8bit_t      interleave;
83         iso_16bit_t     volume_seq_number;
84         iso_8bit_t      name_len;
85         uint8_t name[1];
86 } __attribute__ ((packed));
87
88 struct iso_primary_descriptor {
89         iso_8bit_t      type;
90         uint8_t         id[5];
91         iso_8bit_t      version;
92         uint8_t         _unused1[1];
93         uint8_t         system_id[32];
94         uint8_t         volume_id[32];
95         uint8_t         _unused2[8];
96         iso_32bit_t     volume_space_size;
97         uint8_t         _unused3[32];
98         iso_16bit_t     volume_set_size;
99         iso_16bit_t     volume_seq_number;
100         iso_16bit_t     logical_block_size;
101         iso_32bit_t     path_table_size;
102         uint8_t         type_l_path_table[4];
103         uint8_t         opt_type_l_path_table[4];
104         uint8_t         type_m_path_table[4];
105         uint8_t         opt_type_m_path_table[4];
106         struct iso_directory_record root_directory_record;
107         uint8_t         volume_set_id[128];
108         uint8_t         publisher_id[128];
109         uint8_t         preparer_id[128];
110         uint8_t         application_id[128];
111         uint8_t         copyright_file_id[37];
112         uint8_t         abstract_file_id[37];
113         uint8_t         bibliographic_file_id[37];
114         uint8_t         creation_date[17];
115         uint8_t         modification_date[17];
116         uint8_t         expiration_date[17];
117         uint8_t         effective_date[17];
118         iso_8bit_t      file_structure_version;
119         uint8_t         _unused4[1];
120         uint8_t         application_data[512];
121         uint8_t         _unused5[653];
122 } __attribute__ ((packed));
123
124 struct rock_ridge {
125         uint16_t        signature;
126         uint8_t         len;
127         uint8_t         version;
128         union {
129           struct CE {
130             iso_32bit_t extent;
131             iso_32bit_t offset;
132             iso_32bit_t size;
133           } ce;
134           struct NM {
135             iso_8bit_t  flags;
136             uint8_t     name[0];
137           } nm;
138           struct PX {
139             iso_32bit_t mode;
140             iso_32bit_t nlink;
141             iso_32bit_t uid;
142             iso_32bit_t gid;
143           } px;
144           struct RR {
145             iso_8bit_t  flags;
146           } rr;
147         } u;
148 } __attribute__ ((packed));
149
150 typedef union RR_ptr {
151         struct rock_ridge *rr;
152         char              *ptr;
153         int                i;
154 } RR_ptr_t;
155
156 #define CHECK2(ptr, c1, c2)                                             \
157     (*(unsigned char *)(ptr) == (c1) &&                                 \
158      *((unsigned char *)(ptr) + 1) == (c2))
159 #define CHECK4(ptr, c1, c2, c3, c4)                                     \
160     (*(unsigned char *)(ptr) == (c1) &&                                 \
161      *((unsigned char *)(ptr) + 1) == (c2) &&                           \
162      *((unsigned char *)(ptr) + 2) == (c3) &&                           \
163      *((unsigned char *)(ptr) + 3) == (c4))
164
165 #endif /* !ASM_FILE */
166
167 #endif /* _ISO9660_H_ */