This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / ntfs / ntfs.h
index 720ffb7..c3fda17 100644 (file)
 #include <linux/module.h>
 #include <linux/compiler.h>
 #include <linux/fs.h>
+#include <linux/buffer_head.h>
 #include <linux/nls.h>
+#include <linux/pagemap.h>
 #include <linux/smp.h>
+#include <asm/atomic.h>
 
 #include "types.h"
+#include "debug.h"
+#include "malloc.h"
+#include "endian.h"
 #include "volume.h"
+#include "inode.h"
 #include "layout.h"
+#include "attrib.h"
+#include "mft.h"
 
 typedef enum {
        NTFS_BLOCK_SIZE         = 512,
@@ -53,8 +62,10 @@ extern kmem_cache_t *ntfs_attr_ctx_cache;
 extern kmem_cache_t *ntfs_index_ctx_cache;
 
 /* The various operations structs defined throughout the driver files. */
+extern struct super_operations ntfs_sops;
 extern struct address_space_operations ntfs_aops;
 extern struct address_space_operations ntfs_mst_aops;
+extern struct address_space_operations ntfs_mft_aops;
 
 extern struct  file_operations ntfs_file_ops;
 extern struct inode_operations ntfs_file_inode_ops;
@@ -76,15 +87,77 @@ static inline ntfs_volume *NTFS_SB(struct super_block *sb)
        return sb->s_fs_info;
 }
 
+/**
+ * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
+ * @page:      the page to release
+ *
+ * Unpin, unmap and release a page that was obtained from ntfs_map_page().
+ */
+static inline void ntfs_unmap_page(struct page *page)
+{
+       kunmap(page);
+       page_cache_release(page);
+}
+
+/**
+ * ntfs_map_page - map a page into accessible memory, reading it if necessary
+ * @mapping:   address space for which to obtain the page
+ * @index:     index into the page cache for @mapping of the page to map
+ *
+ * Read a page from the page cache of the address space @mapping at position
+ * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes.
+ *
+ * If the page is not in memory it is loaded from disk first using the readpage
+ * method defined in the address space operations of @mapping and the page is
+ * added to the page cache of @mapping in the process.
+ *
+ * If the page is in high memory it is mapped into memory directly addressible
+ * by the kernel.
+ *
+ * Finally the page count is incremented, thus pinning the page into place.
+ *
+ * The above means that page_address(page) can be used on all pages obtained
+ * with ntfs_map_page() to get the kernel virtual address of the page.
+ *
+ * When finished with the page, the caller has to call ntfs_unmap_page() to
+ * unpin, unmap and release the page.
+ *
+ * Note this does not grant exclusive access. If such is desired, the caller
+ * must provide it independently of the ntfs_{un}map_page() calls by using
+ * a {rw_}semaphore or other means of serialization. A spin lock cannot be
+ * used as ntfs_map_page() can block.
+ *
+ * The unlocked and uptodate page is returned on success or an encoded error
+ * on failure. Caller has to test for error using the IS_ERR() macro on the
+ * return value. If that evaluates to TRUE, the negative error code can be
+ * obtained using PTR_ERR() on the return value of ntfs_map_page().
+ */
+static inline struct page *ntfs_map_page(struct address_space *mapping,
+               unsigned long index)
+{
+       struct page *page = read_cache_page(mapping, index,
+                       (filler_t*)mapping->a_ops->readpage, NULL);
+
+       if (!IS_ERR(page)) {
+               wait_on_page_locked(page);
+               kmap(page);
+               if (PageUptodate(page) && !PageError(page))
+                       return page;
+               ntfs_unmap_page(page);
+               return ERR_PTR(-EIO);
+       }
+       return page;
+}
+
 /* Declarations of functions and global variables. */
 
 /* From fs/ntfs/compress.c */
 extern int ntfs_read_compressed_block(struct page *page);
-extern int allocate_compression_buffers(void);
-extern void free_compression_buffers(void);
 
 /* From fs/ntfs/super.c */
 #define default_upcase_len 0x10000
+extern ntfschar *default_upcase;
+extern unsigned long ntfs_nr_upcase_users;
 extern struct semaphore ntfs_lock;
 
 typedef struct {
@@ -93,6 +166,10 @@ typedef struct {
 } option_t;
 extern const option_t on_errors_arr[];
 
+/* From fs/ntfs/compress.c */
+extern int allocate_compression_buffers(void);
+extern void free_compression_buffers(void);
+
 /* From fs/ntfs/mst.c */
 extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
 extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size);