ntfs.h 4.2 KB

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