Added iso9660 driver (not yet working).
[planlOS.git] / system / modules / iso9660 / rockridge.h
blob56ac259675e98750232c4b1532ee8a5c7e00ed9c
1 /*
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)
9 * any later version.
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
14 * more details.
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/>.
20 #ifndef _ISO9660_ROCKRIDGE_H_
21 #define _ISO9660_ROCKRIDGE_H_
23 #include <sys/types.h>
24 #include <stdint.h>
26 #include "directory_record.h"
28 #define ISO9660_ROCKRIDGE_VERSION 1
30 #define ISO9660_ROCKRIDGE_SL_FLAG_LAST 1
32 #define ISO9660_ROCKRIDGE_NAMEFLAG_CONTINUE 1
33 #define ISO9660_ROCKRIDGE_NAMEFLAG_CURRENT 2
34 #define ISO9660_ROCKRIDGE_NAMEFLAG_PARENT 4
35 #define ISO9660_ROCKRIDGE_NAMEFLAG_ROOT 8
37 #define ISO9660_ROCKRIDGE_TFFLAG_CREATION 1
38 #define ISO9660_ROCKRIDGE_TFFLAG_MODIFY 2
39 #define ISO9660_ROCKRIDGE_TFFLAG_ACCESS 4
40 #define ISO9660_ROCKRIDGE_TFFLAG_ATTRIBUTES 8
41 #define ISO9660_ROCKRIDGE_TFFLAG_BACKUP 16
42 #define ISO9660_ROCKRIDGE_TFFLAG_EXPIRATION 32
43 #define ISO9660_ROCKRIDGE_TFFLAG_EFFECTIVE 64
44 #define ISO9660_ROCKRIDGE_TFFLAG_LONGFORM 128
46 #define ISO9660_ROCKRIDGE_SIG_SP ('S'|('P'<<8))
47 #define ISO9660_ROCKRIDGE_SIG_ST ('S'|('T'<<8))
48 #define ISO9660_ROCKRIDGE_SIG_RR ('R'|('R'<<8)) ///< @todo Actually the SUE must start with SP and not with RR
49 #define ISO9660_ROCKRIDGE_SIG_PX ('P'|('X'<<8))
50 #define ISO9660_ROCKRIDGE_SIG_PN ('P'|('N'<<8))
51 #define ISO9660_ROCKRIDGE_SIG_SL ('S'|('L'<<8))
52 #define ISO9660_ROCKRIDGE_SIG_NM ('N'|('M'<<8))
53 #define ISO9660_ROCKRIDGE_SIG_CL ('C'|('L'<<8))
54 #define ISO9660_ROCKRIDGE_SIG_PL ('P'|('L'<<8))
55 #define ISO9660_ROCKRIDGE_SIG_RE ('R'|('E'<<8))
56 #define ISO9660_ROCKRIDGE_SIG_RF ('R'|('F'<<8))
57 #define ISO9660_ROCKRIDGE_SIG_SF ('S'|('F'<<8))
59 // Some POSIX stat stuff
61 #define RS_IFMT 00170000
62 #define RS_IFSOCK 00140000
63 #define RS_IFLNK 00120000
64 #define RS_IFREG 00100000
65 #define RS_IFBLK 00060000
66 #define RS_IFDIR 00040000
67 #define RS_IFCHR 00020000
68 #define RS_IFIFO 00010000
70 #define RS_ISLNK(m) (((m)&RS_IFMT)==RS_IFLNK)
71 #define RS_ISREG(m) (((m)&RS_IFMT)==RS_IFREG)
72 #define RS_ISDIR(m) (((m)&RS_IFMT)==RS_IFDIR)
73 #define RS_ISCHR(m) (((m)&RS_IFMT)==RS_IFCHR)
74 #define RS_ISBLK(m) (((m)&RS_IFMT)==RS_IFBLK)
75 #define RS_ISFIFO(m) (((m)&RS_IFMT)==RS_IFIFO)
76 #define RS_ISSOCK(m) (((m)&RS_IFMT)==RS_IFSOCK)
78 typedef unsigned int rmode_t;
80 // Rockridge System Use Entry
81 struct iso9660_rockridge {
82 // Field signature
83 uint16_t sig;
85 // Size of field
86 uint8_t size;
88 // Version
89 uint8_t version;
90 } __attribute__ ((packed));
92 /// @todo Actually the SUE must start with SP and not with RR
93 struct iso9660_rockridge_rr {
94 // Size: 5
95 struct iso9660_rockridge header;
96 uint8_t unknown;
97 } __attribute__ ((packed));
99 // Rockridge System Use Entry for file permissions
100 struct iso9660_rockridge_px {
101 // Size: 44
102 struct iso9660_rockridge header;
104 // File mode (like in sys/stat.h)
105 uint32_t mode;
106 uint32_t mode_be;
108 // Number of links (like in sys/stat.h)
109 uint32_t nlink;
110 uint32_t nlink_be;
112 // Owner UID
113 uint32_t uid;
114 uint32_t uid_be;
116 // Owner GID
117 uint32_t gid;
118 uint32_t gid_be;
120 // File serial number
121 uint32_t serial;
122 uint32_t serial_be;
123 } __attribute__ ((packed));
125 // Rockridge System Use Entry for device nodes
126 struct iso9660_rockridge_pn {
127 // Size: 20
128 struct iso9660_rockridge header;
130 // Device number
131 uint32_t devhi;
132 uint32_t devhi_be;
133 uint32_t devlo;
134 uint32_t devlo_be;
135 } __attribute__ ((packed));
137 // Rockridge SL Component
138 struct iso9660_rockridge_sl_component {
139 uint8_t flags;
140 uint8_t len;
141 uint8_t content[0];
142 } __attribute__ ((packed));
144 // Rockridge System Use Entry for symbolic links
145 struct iso9660_rockridge_sl {
146 // Size:
147 struct iso9660_rockridge header;
149 // Flags
150 uint8_t flags;
152 // Component Area
153 struct iso9660_rockridge_sl_component component_area[0];
154 } __attribute__ ((packed));
156 // Rockridge System Use Entry for POSIX names
157 struct iso9660_rockridge_nm {
158 // Size:
159 struct iso9660_rockridge header;
161 // Flags
162 uint8_t flags;
164 // Name content
165 uint8_t name[1];
166 } __attribute__ ((packed));
168 // Rockridge System Use Entry for timestamps
169 struct iso9660_rockridge_tf {
170 // Size:
171 struct iso9660_rockridge header;
173 // Flags (Type of timestamp
174 uint8_t flags;
176 uint32_t timestamps[0];
177 } __attribute__ ((packed));
179 int iso9660_rockridge_scan(struct iso9660_dirrec *dirrec,char **_name,mode_t *mode,uid_t *uid,gid_t *gid,nlink_t *nlink,uint64_t *atime,uint64_t *ctime,uint64_t *mtime);
181 #endif