1#ifndef __UDF_DECL_H
2#define __UDF_DECL_H
3
4#include <linux/udf_167.h>
5#include <linux/udf_udf.h>
6#include "udfend.h"
7
8#include <linux/udf_fs.h>
9
10#ifdef __KERNEL__
11
12#include <linux/config.h>
13#include <linux/types.h>
14#include <linux/fs.h>
15
16#if !defined(CONFIG_UDF_FS) && !defined(CONFIG_UDF_FS_MODULE)
17#define CONFIG_UDF_FS_MODULE
18#include <linux/udf_fs_sb.h>
19#include <linux/udf_fs_i.h>
20#endif
21
22#define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
23#define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
24
25#define CURRENT_UTIME (xtime.tv_usec)
26
27#define udf_file_entry_alloc_offset(inode)\
28 ((UDF_I_EXTENDED_FE(inode) ?\
29 sizeof(struct ExtendedFileEntry) :\
30 sizeof(struct FileEntry)) + UDF_I_LENEATTR(inode))
31
32#define udf_ext0_offset(inode)\
33 (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB ?\
34 udf_file_entry_alloc_offset(inode) : 0)
35
36#define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset))
37
38#else
39
40#include <sys/types.h>
41
42#endif
43
44
45
46#ifdef __KERNEL__
47
48struct dentry;
49struct inode;
50struct task_struct;
51struct buffer_head;
52struct super_block;
53
54extern struct inode_operations udf_dir_inode_operations;
55extern struct file_operations udf_dir_operations;
56extern struct inode_operations udf_file_inode_operations;
57extern struct file_operations udf_file_operations;
58extern struct address_space_operations udf_aops;
59extern struct address_space_operations udf_adinicb_aops;
60extern struct address_space_operations udf_symlink_aops;
61
62struct udf_fileident_bh
63{
64 struct buffer_head *sbh;
65 struct buffer_head *ebh;
66 int soffset;
67 int eoffset;
68};
69
70#endif
71
72struct udf_directory_record
73{
74 Uint32 d_parent;
75 Uint32 d_inode;
76 Uint32 d_name[255];
77};
78
79
80struct udf_vds_record
81{
82 Uint32 block;
83 Uint32 volDescSeqNum;
84};
85
86struct ktm
87{
88 int tm_sec;
89 int tm_min;
90 int tm_hour;
91 int tm_mday;
92 int tm_mon;
93 int tm_year;
94 int tm_isdst;
95};
96
97struct ustr
98{
99 Uint8 u_cmpID;
100 Uint8 u_name[UDF_NAME_LEN];
101 Uint8 u_len;
102 Uint8 padding;
103 unsigned long u_hash;
104};
105
106#ifdef __KERNEL__
107
108
109extern void udf_error(struct super_block *, const char *, const char *, ...);
110extern void udf_warning(struct super_block *, const char *, const char *, ...);
111
112
113extern int udf_write_fi(struct inode *inode, struct FileIdentDesc *, struct FileIdentDesc *, struct udf_fileident_bh *, Uint8 *, Uint8 *);
114
115
116extern int udf_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
117
118
119extern struct inode *udf_iget(struct super_block *, lb_addr);
120extern int udf_sync_inode(struct inode *);
121extern void udf_expand_file_adinicb(struct inode *, int, int *);
122extern struct buffer_head * udf_expand_dir_adinicb(struct inode *, int *, int *);
123extern struct buffer_head * udf_getblk(struct inode *, long, int, int *);
124extern struct buffer_head * udf_bread(struct inode *, int, int, int *);
125extern void udf_truncate(struct inode *);
126extern void udf_read_inode(struct inode *);
127extern void udf_put_inode(struct inode *);
128extern void udf_delete_inode(struct inode *);
129extern void udf_write_inode(struct inode *, int);
130extern long udf_block_map(struct inode *, long);
131extern Sint8 inode_bmap(struct inode *, int, lb_addr *, Uint32 *, lb_addr *, Uint32 *, Uint32 *, struct buffer_head **);
132extern Sint8 udf_add_aext(struct inode *, lb_addr *, int *, lb_addr, Uint32, struct buffer_head **, int);
133extern Sint8 udf_write_aext(struct inode *, lb_addr, int *, lb_addr, Uint32, struct buffer_head *, int);
134extern Sint8 udf_insert_aext(struct inode *, lb_addr, int, lb_addr, Uint32, struct buffer_head *);
135extern Sint8 udf_delete_aext(struct inode *, lb_addr, int, lb_addr, Uint32, struct buffer_head *);
136extern Sint8 udf_next_aext(struct inode *, lb_addr *, int *, lb_addr *, Uint32 *, struct buffer_head **, int);
137extern Sint8 udf_current_aext(struct inode *, lb_addr *, int *, lb_addr *, Uint32 *, struct buffer_head **, int);
138extern void udf_discard_prealloc(struct inode *);
139
140
141extern int udf_read_tagged_data(char *, int size, int fd, int block, int partref);
142extern struct buffer_head *udf_tgetblk(struct super_block *, int);
143extern struct buffer_head *udf_tread(struct super_block *, int);
144extern struct GenericAttrFormat *udf_add_extendedattr(struct inode *, Uint32, Uint32, Uint8, struct buffer_head **);
145extern struct GenericAttrFormat *udf_get_extendedattr(struct inode *, Uint32, Uint8, struct buffer_head **);
146extern struct buffer_head *udf_read_tagged(struct super_block *, Uint32, Uint32, Uint16 *);
147extern struct buffer_head *udf_read_ptagged(struct super_block *, lb_addr, Uint32, Uint16 *);
148extern struct buffer_head *udf_read_untagged(struct super_block *, Uint32, Uint32);
149extern void udf_release_data(struct buffer_head *);
150
151
152extern unsigned int udf_get_last_session(struct super_block *);
153extern unsigned long udf_get_last_block(struct super_block *);
154
155
156extern Uint32 udf_get_pblock(struct super_block *, Uint32, Uint16, Uint32);
157extern Uint32 udf_get_pblock_virt15(struct super_block *, Uint32, Uint16, Uint32);
158extern Uint32 udf_get_pblock_virt20(struct super_block *, Uint32, Uint16, Uint32);
159extern Uint32 udf_get_pblock_spar15(struct super_block *, Uint32, Uint16, Uint32);
160extern int udf_relocate_blocks(struct super_block *, long, long *);
161
162
163extern int udf_get_filename(struct super_block *, Uint8 *, Uint8 *, int);
164
165
166extern void udf_free_inode(struct inode *);
167extern struct inode * udf_new_inode (struct inode *, int, int *);
168
169
170extern void udf_truncate_extents(struct inode *);
171
172
173extern void udf_free_blocks(struct super_block *, struct inode *, lb_addr, Uint32, Uint32);
174extern int udf_prealloc_blocks(struct super_block *, struct inode *, Uint16, Uint32, Uint32);
175extern int udf_new_block(struct super_block *, struct inode *, Uint16, Uint32, int *);
176
177
178extern int udf_fsync_file(struct file *, struct dentry *, int);
179extern int udf_fsync_inode(struct inode *, int);
180
181
182extern Uint8 * udf_filead_read(struct inode *, Uint8 *, Uint8, lb_addr, int *, int *, struct buffer_head **, int *);
183extern struct FileIdentDesc * udf_fileident_read(struct inode *, loff_t *, struct udf_fileident_bh *, struct FileIdentDesc *, lb_addr *, Uint32 *, lb_addr *, Uint32 *, Uint32 *, struct buffer_head **);
184
185#endif
186
187
188
189
190extern int udf_ustr_to_dchars(Uint8 *, const struct ustr *, int);
191extern int udf_ustr_to_char(Uint8 *, const struct ustr *, int);
192extern int udf_ustr_to_dstring(dstring *, const struct ustr *, int);
193extern int udf_dchars_to_ustr(struct ustr *, const Uint8 *, int);
194extern int udf_char_to_ustr(struct ustr *, const Uint8 *, int);
195extern int udf_dstring_to_ustr(struct ustr *, const dstring *, int);
196extern int udf_translate_to_linux(Uint8 *, Uint8 *, int, Uint8 *, int);
197extern int udf_build_ustr(struct ustr *, dstring *, int);
198extern int udf_build_ustr_exact(struct ustr *, dstring *, int);
199extern int udf_CS0toUTF8(struct ustr *, struct ustr *);
200extern int udf_UTF8toCS0(dstring *, struct ustr *, int);
201#ifdef __KERNEL__
202extern int udf_CS0toNLS(struct nls_table *, struct ustr *, struct ustr *);
203extern int udf_NLStoCS0(struct nls_table *, dstring *, struct ustr *, int);
204#endif
205
206
207extern Uint16 udf_crc(Uint8 *, Uint32, Uint16);
208
209
210extern Uint32 udf64_low32(Uint64);
211extern Uint32 udf64_high32(Uint64);
212extern void udf_update_tag(char *, int);
213extern void udf_new_tag(char *, Uint16, Uint16, Uint16, Uint32, int);
214
215
216extern time_t *udf_stamp_to_time(time_t *, long *, timestamp);
217extern timestamp *udf_time_to_stamp(timestamp *, time_t, long);
218extern time_t udf_converttime (struct ktm *);
219
220
221extern struct FileIdentDesc * udf_get_fileident(void * buffer, int bufsize, int * offset);
222extern extent_ad * udf_get_fileextent(void * buffer, int bufsize, int * offset);
223extern long_ad * udf_get_filelongad(void * buffer, int bufsize, int * offset, int);
224extern short_ad * udf_get_fileshortad(void * buffer, int bufsize, int * offset, int);
225extern Uint8 * udf_get_filead(struct FileEntry *, Uint8 *, int, int, int, int *);
226
227#endif
228