4 #define UDF_VERSION_NOTICE "v0.8.9.3"
8 #include <linux/types.h>
9 #include <linux/udf_udf.h>
10 #include <linux/udf_fs.h>
11 #include <linux/config.h>
13 #ifndef LINUX_VERSION_CODE
14 #include <linux/version.h>
17 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,7)
18 #error "The UDF Module Current Requires Kernel Version 2.3.7 or greater"
21 /* if we're not defined, we must be compiling outside of the kernel tree */
22 #if !defined(CONFIG_UDF_FS) && !defined(CONFIG_UDF_FS_MODULE)
23 /* ... so override config */
24 #define CONFIG_UDF_FS_MODULE
26 /* explicitly include udf_fs_sb.h and udf_fs_i.h */
27 #include <linux/udf_fs_sb.h>
28 #include <linux/udf_fs_i.h>
30 #include <linux/fs.h> /* also gets udf_fs_i.h and udf_fs_sb.h */
39 extern struct inode_operations udf_dir_inode_operations
;
40 extern struct inode_operations udf_file_inode_operations
;
41 extern struct inode_operations udf_file_inode_operations_adinicb
;
42 extern struct inode_operations udf_symlink_inode_operations
;
44 struct udf_fileident_bh
46 struct buffer_head
*sbh
;
47 struct buffer_head
*ebh
;
52 extern void udf_error(struct super_block
*, const char *, const char *, ...);
53 extern void udf_warning(struct super_block
*, const char *, const char *, ...);
54 extern int udf_write_fi(struct FileIdentDesc
*, struct FileIdentDesc
*, struct udf_fileident_bh
*, Uint8
*, Uint8
*);
55 extern struct dentry
* udf_lookup(struct inode
*, struct dentry
*);
56 extern int udf_create(struct inode
*, struct dentry
*, int);
57 extern int udf_mknod(struct inode
*, struct dentry
*, int, int);
58 extern int udf_mkdir(struct inode
*, struct dentry
*, int);
59 extern int udf_rmdir(struct inode
*, struct dentry
*);
60 extern int udf_unlink(struct inode
*, struct dentry
*);
61 extern int udf_symlink(struct inode
*, struct dentry
*, const char *);
62 extern int udf_link(struct dentry
*, struct inode
*, struct dentry
*);
63 extern int udf_rename(struct inode
*, struct dentry
*, struct inode
*, struct dentry
*);
64 extern int udf_ioctl(struct inode
*, struct file
*, unsigned int, unsigned long);
65 extern struct inode
*udf_iget(struct super_block
*, lb_addr
);
66 extern int udf_sync_inode(struct inode
*);
67 extern struct buffer_head
* udf_expand_adinicb(struct inode
*, int *, int, int *);
68 extern struct buffer_head
* udf_getblk(struct inode
*, long, int, int *);
69 extern int udf_get_block(struct inode
*, long, struct buffer_head
*, int);
70 extern struct buffer_head
* udf_bread(struct inode
*, int, int, int *);
71 extern void udf_read_inode(struct inode
*);
72 extern void udf_put_inode(struct inode
*);
73 extern void udf_delete_inode(struct inode
*);
74 extern void udf_write_inode(struct inode
*);
75 extern long udf_locked_block_map(struct inode
*, long);
76 extern long udf_block_map(struct inode
*, long);
77 extern int inode_bmap(struct inode
*, int, lb_addr
*, Uint32
*, lb_addr
*, Uint32
*, Uint32
*, struct buffer_head
**);
78 extern int udf_add_aext(struct inode
*, lb_addr
*, int *, lb_addr
, Uint32
, struct buffer_head
**, int);
79 extern int udf_write_aext(struct inode
*, lb_addr
, int *, lb_addr
, Uint32
, struct buffer_head
**, int);
80 extern int udf_insert_aext(struct inode
*, lb_addr
, int, lb_addr
, Uint32
, struct buffer_head
*);
81 extern int udf_delete_aext(struct inode
*, lb_addr
, int, lb_addr
, Uint32
, struct buffer_head
*);
82 extern int udf_next_aext(struct inode
*, lb_addr
*, int *, lb_addr
*, Uint32
*, struct buffer_head
**, int);
83 extern int udf_current_aext(struct inode
*, lb_addr
*, int *, lb_addr
*, Uint32
*, struct buffer_head
**, int);
85 extern int udf_read_tagged_data(char *, int size
, int fd
, int block
, int partref
);
87 extern struct buffer_head
*udf_tread(struct super_block
*, int, int);
88 extern struct GenericAttrFormat
*udf_add_extendedattr(struct inode
*, Uint32
, Uint32
, Uint8
, struct buffer_head
**);
89 extern struct GenericAttrFormat
*udf_get_extendedattr(struct inode
*, Uint32
, Uint8
, struct buffer_head
**);
90 extern struct buffer_head
*udf_read_tagged(struct super_block
*, Uint32
, Uint32
, Uint16
*);
91 extern struct buffer_head
*udf_read_ptagged(struct super_block
*, lb_addr
, Uint32
, Uint16
*);
92 extern struct buffer_head
*udf_read_untagged(struct super_block
*, Uint32
, Uint32
);
93 extern void udf_release_data(struct buffer_head
*);
95 extern unsigned int udf_get_last_session(kdev_t
);
96 extern unsigned int udf_get_last_block(kdev_t
, int *);
98 extern Uint32
udf_get_pblock(struct super_block
*, Uint32
, Uint16
, Uint32
);
99 extern Uint32
udf_get_lb_pblock(struct super_block
*, lb_addr
, Uint32
);
101 extern int udf_get_filename(Uint8
*, Uint8
*, int);
103 extern void udf_free_inode(struct inode
*);
104 extern struct inode
* udf_new_inode (const struct inode
*, int, int *);
105 extern void udf_discard_prealloc(struct inode
*);
106 extern void udf_truncate(struct inode
*);
107 extern void udf_truncate_adinicb(struct inode
*);
108 extern void udf_free_blocks(const struct inode
*, lb_addr
, Uint32
, Uint32
);
109 extern int udf_alloc_blocks(const struct inode
*, Uint16
, Uint32
, Uint32
);
110 extern int udf_new_block(const struct inode
*, Uint16
, Uint32
, int *);
111 extern int udf_sync_file(struct file
*, struct dentry
*);
115 #include <sys/types.h>
116 #include <linux/udf_udf.h>
118 #endif /* __KERNEL__ */
123 struct udf_directory_record
130 #define VDS_POS_PRIMARY_VOL_DESC 0
131 #define VDS_POS_UNALLOC_SPACE_DESC 1
132 #define VDS_POS_LOGICAL_VOL_DESC 2
133 #define VDS_POS_PARTITION_DESC 3
134 #define VDS_POS_IMP_USE_VOL_DESC 4
135 #define VDS_POS_VOL_DESC_PTR 5
136 #define VDS_POS_TERMINATING_DESC 6
137 #define VDS_POS_LENGTH 7
139 struct udf_vds_record
142 Uint32 volDescSeqNum
;
159 Uint8 u_name
[UDF_NAME_LEN
-1];
162 unsigned long u_hash
;
166 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
167 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
171 #define CURRENT_UTIME (xtime.tv_usec)
173 #define udf_file_entry_alloc_offset(inode)\
174 ((UDF_I_EXTENDED_FE(inode) ?\
175 sizeof(struct ExtendedFileEntry) :\
176 sizeof(struct FileEntry)) + UDF_I_LENEATTR(inode))
178 #define udf_clear_bit(nr,addr) ext2_clear_bit(nr,addr)
179 #define udf_set_bit(nr,addr) ext2_set_bit(nr,addr)
180 #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr)
181 #define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size)
182 #define udf_find_next_one_bit(addr, size, offset) find_next_one_bit(addr, size, offset)
184 #define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x)
185 #define leNUM_to_cpup(x,y) xleNUM_to_cpup(x,y)
186 #define xleNUM_to_cpup(x,y) (le ## x ## _to_cpup(y))
188 extern inline int find_next_one_bit (void * addr
, int size
, int offset
)
190 unsigned long * p
= ((unsigned long *) addr
) + (offset
/ BITS_PER_LONG
);
191 unsigned long result
= offset
& ~(BITS_PER_LONG
-1);
197 offset
&= (BITS_PER_LONG
-1);
200 tmp
= leBPL_to_cpup(p
++);
201 tmp
&= ~0UL << offset
;
202 if (size
< BITS_PER_LONG
)
206 size
-= BITS_PER_LONG
;
207 result
+= BITS_PER_LONG
;
209 while (size
& ~(BITS_PER_LONG
-1))
211 if ((tmp
= leBPL_to_cpup(p
++)))
213 result
+= BITS_PER_LONG
;
214 size
-= BITS_PER_LONG
;
218 tmp
= leBPL_to_cpup(p
);
220 tmp
&= ~0UL >> (BITS_PER_LONG
-size
);
222 return result
+ ffz(~tmp
);
225 #define find_first_one_bit(addr, size)\
226 find_next_one_bit((addr), (size), 0)
230 /* Miscellaneous UDF Prototypes */
232 extern int udf_ustr_to_dchars(Uint8
*, const struct ustr
*, int);
233 extern int udf_ustr_to_char(Uint8
*, const struct ustr
*, int);
234 extern int udf_ustr_to_dstring(dstring
*, const struct ustr
*, int);
235 extern int udf_dchars_to_ustr(struct ustr
*, const Uint8
*, int);
236 extern int udf_char_to_ustr(struct ustr
*, const Uint8
*, int);
237 extern int udf_dstring_to_ustr(struct ustr
*, const dstring
*, int);
239 extern Uint16
udf_crc(Uint8
*, Uint32
, Uint16
);
240 extern int udf_translate_to_linux(Uint8
*, Uint8
*, int, Uint8
*, int);
241 extern int udf_build_ustr(struct ustr
*, dstring
*, int);
242 extern int udf_build_ustr_exact(struct ustr
*, dstring
*, int);
243 extern int udf_CS0toUTF8(struct ustr
*, struct ustr
*);
244 extern int udf_UTF8toCS0(dstring
*, struct ustr
*, int);
246 extern uid_t
udf_convert_uid(int);
247 extern gid_t
udf_convert_gid(int);
248 extern Uint32
udf64_low32(Uint64
);
249 extern Uint32
udf64_high32(Uint64
);
252 extern time_t *udf_stamp_to_time(time_t *, long *, timestamp
);
253 extern timestamp
*udf_time_to_stamp(timestamp
*, time_t, long);
254 extern time_t udf_converttime (struct ktm
*);
258 udf_filead_read(struct inode
*, Uint8
*, Uint8
, lb_addr
, int *, int *,
259 struct buffer_head
**, int *);
261 extern struct FileIdentDesc
*
262 udf_fileident_read(struct inode
*, int *,
263 struct udf_fileident_bh
*,
264 struct FileIdentDesc
*,
266 Uint32
*, struct buffer_head
**);
268 extern struct FileIdentDesc
*
269 udf_get_fileident(void * buffer
, int bufsize
, int * offset
);
270 extern extent_ad
* udf_get_fileextent(void * buffer
, int bufsize
, int * offset
);
271 extern long_ad
* udf_get_filelongad(void * buffer
, int bufsize
, int * offset
, int);
272 extern short_ad
* udf_get_fileshortad(void * buffer
, int bufsize
, int * offset
, int);
273 extern Uint8
* udf_get_filead(struct FileEntry
*, Uint8
*, int, int, int, int *);
275 extern void udf_update_tag(char *, int);
276 extern void udf_new_tag(char *, Uint16
, Uint16
, Uint16
, Uint32
, int);