Thomas Gleixner | a1d312d | 2019-05-22 09:51:42 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Anton Altaparmakov | ce1bafa | 2014-10-16 12:28:03 +0100 | [diff] [blame] | 3 | * ntfs.h - Defines for NTFS Linux kernel driver. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Anton Altaparmakov | ce1bafa | 2014-10-16 12:28:03 +0100 | [diff] [blame] | 5 | * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (C) 2002 Richard Russon |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _LINUX_NTFS_H |
| 10 | #define _LINUX_NTFS_H |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/compiler.h> |
| 16 | #include <linux/fs.h> |
| 17 | #include <linux/nls.h> |
| 18 | #include <linux/smp.h> |
Anton Altaparmakov | 7fafb8b | 2005-04-06 16:09:21 +0100 | [diff] [blame] | 19 | #include <linux/pagemap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | #include "types.h" |
| 22 | #include "volume.h" |
| 23 | #include "layout.h" |
| 24 | |
| 25 | typedef enum { |
| 26 | NTFS_BLOCK_SIZE = 512, |
| 27 | NTFS_BLOCK_SIZE_BITS = 9, |
| 28 | NTFS_SB_MAGIC = 0x5346544e, /* 'NTFS' */ |
| 29 | NTFS_MAX_NAME_LEN = 255, |
Anton Altaparmakov | bb3cf33 | 2005-04-06 13:34:31 +0100 | [diff] [blame] | 30 | NTFS_MAX_ATTR_NAME_LEN = 255, |
Anton Altaparmakov | 7fafb8b | 2005-04-06 16:09:21 +0100 | [diff] [blame] | 31 | NTFS_MAX_CLUSTER_SIZE = 64 * 1024, /* 64kiB */ |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 32 | NTFS_MAX_PAGES_PER_CLUSTER = NTFS_MAX_CLUSTER_SIZE / PAGE_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } NTFS_CONSTANTS; |
| 34 | |
| 35 | /* Global variables. */ |
| 36 | |
| 37 | /* Slab caches (from super.c). */ |
Pekka Enberg | 64419d9 | 2006-02-05 21:43:57 +0000 | [diff] [blame] | 38 | extern struct kmem_cache *ntfs_name_cache; |
| 39 | extern struct kmem_cache *ntfs_inode_cache; |
| 40 | extern struct kmem_cache *ntfs_big_inode_cache; |
| 41 | extern struct kmem_cache *ntfs_attr_ctx_cache; |
| 42 | extern struct kmem_cache *ntfs_index_ctx_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | /* The various operations structs defined throughout the driver files. */ |
Anton Altaparmakov | ce1bafa | 2014-10-16 12:28:03 +0100 | [diff] [blame] | 45 | extern const struct address_space_operations ntfs_normal_aops; |
| 46 | extern const struct address_space_operations ntfs_compressed_aops; |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 47 | extern const struct address_space_operations ntfs_mst_aops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 49 | extern const struct file_operations ntfs_file_ops; |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 50 | extern const struct inode_operations ntfs_file_inode_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 52 | extern const struct file_operations ntfs_dir_ops; |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 53 | extern const struct inode_operations ntfs_dir_inode_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 55 | extern const struct file_operations ntfs_empty_file_ops; |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 56 | extern const struct inode_operations ntfs_empty_inode_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Christoph Hellwig | 3965516 | 2007-10-21 16:42:17 -0700 | [diff] [blame] | 58 | extern const struct export_operations ntfs_export_ops; |
Anton Altaparmakov | 4138268 | 2005-03-03 13:44:15 +0000 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | /** |
| 61 | * NTFS_SB - return the ntfs volume given a vfs super block |
| 62 | * @sb: VFS super block |
| 63 | * |
| 64 | * NTFS_SB() returns the ntfs volume associated with the VFS super block @sb. |
| 65 | */ |
| 66 | static inline ntfs_volume *NTFS_SB(struct super_block *sb) |
| 67 | { |
| 68 | return sb->s_fs_info; |
| 69 | } |
| 70 | |
| 71 | /* Declarations of functions and global variables. */ |
| 72 | |
| 73 | /* From fs/ntfs/compress.c */ |
| 74 | extern int ntfs_read_compressed_block(struct page *page); |
| 75 | extern int allocate_compression_buffers(void); |
| 76 | extern void free_compression_buffers(void); |
| 77 | |
| 78 | /* From fs/ntfs/super.c */ |
| 79 | #define default_upcase_len 0x10000 |
Ingo Molnar | 4e5e529 | 2006-03-23 16:57:48 +0000 | [diff] [blame] | 80 | extern struct mutex ntfs_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | typedef struct { |
| 83 | int val; |
| 84 | char *str; |
| 85 | } option_t; |
| 86 | extern const option_t on_errors_arr[]; |
| 87 | |
| 88 | /* From fs/ntfs/mst.c */ |
| 89 | extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size); |
| 90 | extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size); |
| 91 | extern void post_write_mst_fixup(NTFS_RECORD *b); |
| 92 | |
| 93 | /* From fs/ntfs/unistr.c */ |
Richard Knutsson | c49c311 | 2006-09-30 23:27:12 -0700 | [diff] [blame] | 94 | extern bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | const ntfschar *s2, size_t s2_len, |
| 96 | const IGNORE_CASE_BOOL ic, |
| 97 | const ntfschar *upcase, const u32 upcase_size); |
| 98 | extern int ntfs_collate_names(const ntfschar *name1, const u32 name1_len, |
| 99 | const ntfschar *name2, const u32 name2_len, |
| 100 | const int err_val, const IGNORE_CASE_BOOL ic, |
| 101 | const ntfschar *upcase, const u32 upcase_len); |
| 102 | extern int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n); |
| 103 | extern int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n, |
| 104 | const ntfschar *upcase, const u32 upcase_size); |
| 105 | extern void ntfs_upcase_name(ntfschar *name, u32 name_len, |
| 106 | const ntfschar *upcase, const u32 upcase_len); |
| 107 | extern void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr, |
| 108 | const ntfschar *upcase, const u32 upcase_len); |
| 109 | extern int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1, |
| 110 | FILE_NAME_ATTR *file_name_attr2, |
| 111 | const int err_val, const IGNORE_CASE_BOOL ic, |
| 112 | const ntfschar *upcase, const u32 upcase_len); |
| 113 | extern int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins, |
| 114 | const int ins_len, ntfschar **outs); |
| 115 | extern int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins, |
| 116 | const int ins_len, unsigned char **outs, int outs_len); |
| 117 | |
| 118 | /* From fs/ntfs/upcase.c */ |
| 119 | extern ntfschar *generate_default_upcase(void); |
| 120 | |
Akinobu Mita | b9a2838 | 2006-03-26 01:39:53 -0800 | [diff] [blame] | 121 | static inline int ntfs_ffs(int x) |
| 122 | { |
| 123 | int r = 1; |
| 124 | |
| 125 | if (!x) |
| 126 | return 0; |
| 127 | if (!(x & 0xffff)) { |
| 128 | x >>= 16; |
| 129 | r += 16; |
| 130 | } |
| 131 | if (!(x & 0xff)) { |
| 132 | x >>= 8; |
| 133 | r += 8; |
| 134 | } |
| 135 | if (!(x & 0xf)) { |
| 136 | x >>= 4; |
| 137 | r += 4; |
| 138 | } |
| 139 | if (!(x & 3)) { |
| 140 | x >>= 2; |
| 141 | r += 2; |
| 142 | } |
| 143 | if (!(x & 1)) { |
| 144 | x >>= 1; |
| 145 | r += 1; |
| 146 | } |
| 147 | return r; |
| 148 | } |
| 149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | #endif /* _LINUX_NTFS_H */ |