ntfs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * ntfs.h - Defines for NTFS Linux kernel driver.
  3. *
  4. * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
  5. * Copyright (C) 2002 Richard Russon
  6. *
  7. * This program/include file is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as published
  9. * by the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program/include file is distributed in the hope that it will be
  13. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program (in the main directory of the Linux-NTFS
  19. * distribution in the file COPYING); if not, write to the Free Software
  20. * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef _LINUX_NTFS_H
  23. #define _LINUX_NTFS_H
  24. #include <linux/stddef.h>
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/compiler.h>
  28. #include <linux/fs.h>
  29. #include <linux/nls.h>
  30. #include <linux/smp.h>
  31. #include <linux/pagemap.h>
  32. #include "types.h"
  33. #include "volume.h"
  34. #include "layout.h"
  35. typedef enum {
  36. NTFS_BLOCK_SIZE = 512,
  37. NTFS_BLOCK_SIZE_BITS = 9,
  38. NTFS_SB_MAGIC = 0x5346544e, /* 'NTFS' */
  39. NTFS_MAX_NAME_LEN = 255,
  40. NTFS_MAX_ATTR_NAME_LEN = 255,
  41. NTFS_MAX_CLUSTER_SIZE = 64 * 1024, /* 64kiB */
  42. NTFS_MAX_PAGES_PER_CLUSTER = NTFS_MAX_CLUSTER_SIZE / PAGE_CACHE_SIZE,
  43. } NTFS_CONSTANTS;
  44. /* Global variables. */
  45. /* Slab caches (from super.c). */
  46. extern struct kmem_cache *ntfs_name_cache;
  47. extern struct kmem_cache *ntfs_inode_cache;
  48. extern struct kmem_cache *ntfs_big_inode_cache;
  49. extern struct kmem_cache *ntfs_attr_ctx_cache;
  50. extern struct kmem_cache *ntfs_index_ctx_cache;
  51. /* The various operations structs defined throughout the driver files. */
  52. extern const struct address_space_operations ntfs_normal_aops;
  53. extern const struct address_space_operations ntfs_compressed_aops;
  54. extern const struct address_space_operations ntfs_mst_aops;
  55. extern const struct file_operations ntfs_file_ops;
  56. extern const struct inode_operations ntfs_file_inode_ops;
  57. extern const struct file_operations ntfs_dir_ops;
  58. extern const struct inode_operations ntfs_dir_inode_ops;
  59. extern const struct file_operations ntfs_empty_file_ops;
  60. extern const struct inode_operations ntfs_empty_inode_ops;
  61. extern const struct export_operations ntfs_export_ops;
  62. /**
  63. * NTFS_SB - return the ntfs volume given a vfs super block
  64. * @sb: VFS super block
  65. *
  66. * NTFS_SB() returns the ntfs volume associated with the VFS super block @sb.
  67. */
  68. static inline ntfs_volume *NTFS_SB(struct super_block *sb)
  69. {
  70. return sb->s_fs_info;
  71. }
  72. /* Declarations of functions and global variables. */
  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. /* From fs/ntfs/super.c */
  78. #define default_upcase_len 0x10000
  79. extern struct mutex ntfs_lock;
  80. typedef struct {
  81. int val;
  82. char *str;
  83. } option_t;
  84. extern const option_t on_errors_arr[];
  85. /* From fs/ntfs/mst.c */
  86. extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
  87. extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size);
  88. extern void post_write_mst_fixup(NTFS_RECORD *b);
  89. /* From fs/ntfs/unistr.c */
  90. extern bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len,
  91. const ntfschar *s2, size_t s2_len,
  92. const IGNORE_CASE_BOOL ic,
  93. const ntfschar *upcase, const u32 upcase_size);
  94. extern int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
  95. const ntfschar *name2, const u32 name2_len,
  96. const int err_val, const IGNORE_CASE_BOOL ic,
  97. const ntfschar *upcase, const u32 upcase_len);
  98. extern int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n);
  99. extern int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
  100. const ntfschar *upcase, const u32 upcase_size);
  101. extern void ntfs_upcase_name(ntfschar *name, u32 name_len,
  102. const ntfschar *upcase, const u32 upcase_len);
  103. extern void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
  104. const ntfschar *upcase, const u32 upcase_len);
  105. extern int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
  106. FILE_NAME_ATTR *file_name_attr2,
  107. const int err_val, const IGNORE_CASE_BOOL ic,
  108. const ntfschar *upcase, const u32 upcase_len);
  109. extern int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
  110. const int ins_len, ntfschar **outs);
  111. extern int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
  112. const int ins_len, unsigned char **outs, int outs_len);
  113. /* From fs/ntfs/upcase.c */
  114. extern ntfschar *generate_default_upcase(void);
  115. static inline int ntfs_ffs(int x)
  116. {
  117. int r = 1;
  118. if (!x)
  119. return 0;
  120. if (!(x & 0xffff)) {
  121. x >>= 16;
  122. r += 16;
  123. }
  124. if (!(x & 0xff)) {
  125. x >>= 8;
  126. r += 8;
  127. }
  128. if (!(x & 0xf)) {
  129. x >>= 4;
  130. r += 4;
  131. }
  132. if (!(x & 3)) {
  133. x >>= 2;
  134. r += 2;
  135. }
  136. if (!(x & 1)) {
  137. x >>= 1;
  138. r += 1;
  139. }
  140. return r;
  141. }
  142. #endif /* _LINUX_NTFS_H */