2 * ntfs.h - Defines for NTFS Linux kernel driver. Part of the Linux-NTFS
5 * Copyright (c) 2001,2002 Anton Altaparmakov.
6 * Copyright (C) 2002 Richard Russon.
8 * This program/include file is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program/include file is distributed in the hope that it will be
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program (in the main directory of the Linux-NTFS
20 * distribution in the file COPYING); if not, write to the Free Software
21 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/compiler.h>
31 #include <linux/buffer_head.h>
32 #include <linux/nls.h>
33 #include <linux/pagemap.h>
34 #include <linux/smp.h>
35 #include <asm/atomic.h>
48 NTFS_BLOCK_SIZE
= 512,
49 NTFS_BLOCK_SIZE_BITS
= 9,
50 NTFS_SB_MAGIC
= 0x5346544e, /* 'NTFS' */
51 NTFS_MAX_NAME_LEN
= 255,
54 /* Global variables. */
56 /* Slab caches (from super.c). */
57 extern kmem_cache_t
*ntfs_name_cache
;
58 extern kmem_cache_t
*ntfs_inode_cache
;
59 extern kmem_cache_t
*ntfs_big_inode_cache
;
60 extern kmem_cache_t
*ntfs_attr_ctx_cache
;
62 /* The various operations structs defined throughout the driver files. */
63 extern struct super_operations ntfs_sops
;
64 extern struct super_operations ntfs_mount_sops
;
66 extern struct address_space_operations ntfs_aops
;
67 extern struct address_space_operations ntfs_mft_aops
;
69 extern struct file_operations ntfs_file_ops
;
70 extern struct inode_operations ntfs_file_inode_ops
;
72 extern struct file_operations ntfs_dir_ops
;
73 extern struct inode_operations ntfs_dir_inode_ops
;
75 extern struct file_operations ntfs_empty_file_ops
;
76 extern struct inode_operations ntfs_empty_inode_ops
;
78 /* Generic macro to convert pointers to values for comparison purposes. */
80 #define p2n(p) ((ptrdiff_t)((ptrdiff_t*)(p)))
84 * NTFS_SB - return the ntfs volume given a vfs super block
85 * @sb: VFS super block
87 * NTFS_SB() returns the ntfs volume associated with the VFS super block @sb.
89 static inline ntfs_volume
*NTFS_SB(struct super_block
*sb
)
95 * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
96 * @page: the page to release
98 * Unpin, unmap and release a page that was obtained from ntfs_map_page().
100 static inline void ntfs_unmap_page(struct page
*page
)
103 page_cache_release(page
);
107 * ntfs_map_page - map a page into accessible memory, reading it if necessary
108 * @mapping: address space for which to obtain the page
109 * @index: index into the page cache for @mapping of the page to map
111 * Read a page from the page cache of the address space @mapping at position
112 * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes.
114 * If the page is not in memory it is loaded from disk first using the readpage
115 * method defined in the address space operations of @mapping and the page is
116 * added to the page cache of @mapping in the process.
118 * If the page is in high memory it is mapped into memory directly addressible
121 * Finally the page count is incremented, thus pinning the page into place.
123 * The above means that page_address(page) can be used on all pages obtained
124 * with ntfs_map_page() to get the kernel virtual address of the page.
126 * When finished with the page, the caller has to call ntfs_unmap_page() to
127 * unpin, unmap and release the page.
129 * Note this does not grant exclusive access. If such is desired, the caller
130 * must provide it independently of the ntfs_{un}map_page() calls by using
131 * a {rw_}semaphore or other means of serialization. A spin lock cannot be
132 * used as ntfs_map_page() can block.
134 * The unlocked and uptodate page is returned on success or an encoded error
135 * on failure. Caller has to test for error using the IS_ERR() macro on the
136 * return value. If that evaluates to TRUE, the negative error code can be
137 * obtained using PTR_ERR() on the return value of ntfs_map_page().
139 static inline struct page
*ntfs_map_page(struct address_space
*mapping
,
142 struct page
*page
= read_cache_page(mapping
, index
,
143 (filler_t
*)mapping
->a_ops
->readpage
, NULL
);
146 wait_on_page_locked(page
);
148 if (PageUptodate(page
) && !PageError(page
))
150 ntfs_unmap_page(page
);
151 return ERR_PTR(-EIO
);
156 /* Declarations of functions and global variables. */
158 /* From fs/ntfs/compress.c */
159 extern int ntfs_read_compressed_block(struct page
*page
);
161 /* From fs/ntfs/super.c */
162 #define default_upcase_len 0x10000
163 extern wchar_t *default_upcase
;
164 extern unsigned long ntfs_nr_upcase_users
;
165 extern unsigned long ntfs_nr_mounts
;
166 extern struct semaphore ntfs_lock
;
172 extern const option_t on_errors_arr
[];
174 /* From fs/ntfs/compress.c */
175 extern int allocate_compression_buffers(void);
176 extern void free_compression_buffers(void);
178 /* From fs/ntfs/mst.c */
179 extern int post_read_mst_fixup(NTFS_RECORD
*b
, const u32 size
);
180 extern int pre_write_mst_fixup(NTFS_RECORD
*b
, const u32 size
);
181 extern void post_write_mst_fixup(NTFS_RECORD
*b
);
183 /* From fs/ntfs/time.c */
184 extern inline s64
utc2ntfs(const time_t time
);
185 extern inline s64
get_current_ntfs_time(void);
186 extern inline time_t ntfs2utc(const s64 time
);
188 /* From fs/ntfs/unistr.c */
189 extern BOOL
ntfs_are_names_equal(const uchar_t
*s1
, size_t s1_len
,
190 const uchar_t
*s2
, size_t s2_len
,
191 const IGNORE_CASE_BOOL ic
,
192 const uchar_t
*upcase
, const u32 upcase_size
);
193 extern int ntfs_collate_names(const uchar_t
*name1
, const u32 name1_len
,
194 const uchar_t
*name2
, const u32 name2_len
,
195 const int err_val
, const IGNORE_CASE_BOOL ic
,
196 const uchar_t
*upcase
, const u32 upcase_len
);
197 extern int ntfs_ucsncmp(const uchar_t
*s1
, const uchar_t
*s2
, size_t n
);
198 extern int ntfs_ucsncasecmp(const uchar_t
*s1
, const uchar_t
*s2
, size_t n
,
199 const uchar_t
*upcase
, const u32 upcase_size
);
200 extern void ntfs_upcase_name(uchar_t
*name
, u32 name_len
,
201 const uchar_t
*upcase
, const u32 upcase_len
);
202 extern void ntfs_file_upcase_value(FILE_NAME_ATTR
*file_name_attr
,
203 const uchar_t
*upcase
, const u32 upcase_len
);
204 extern int ntfs_file_compare_values(FILE_NAME_ATTR
*file_name_attr1
,
205 FILE_NAME_ATTR
*file_name_attr2
,
206 const int err_val
, const IGNORE_CASE_BOOL ic
,
207 const uchar_t
*upcase
, const u32 upcase_len
);
208 extern int ntfs_nlstoucs(const ntfs_volume
*vol
, const char *ins
,
209 const int ins_len
, uchar_t
**outs
);
210 extern int ntfs_ucstonls(const ntfs_volume
*vol
, const uchar_t
*ins
,
211 const int ins_len
, unsigned char **outs
, int outs_len
);
213 /* From fs/ntfs/upcase.c */
214 extern uchar_t
*generate_default_upcase(void);
216 #endif /* _LINUX_NTFS_H */