blob: 12de47b96ca95d219d03e4be0c3c298b05f56789 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Anton Altaparmakovce1bafa2014-10-16 12:28:03 +01002 * ntfs.h - Defines for NTFS Linux kernel driver.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Anton Altaparmakovce1bafa2014-10-16 12:28:03 +01004 * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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
23#ifndef _LINUX_NTFS_H
24#define _LINUX_NTFS_H
25
26#include <linux/stddef.h>
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/compiler.h>
30#include <linux/fs.h>
31#include <linux/nls.h>
32#include <linux/smp.h>
Anton Altaparmakov7fafb8b2005-04-06 16:09:21 +010033#include <linux/pagemap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35#include "types.h"
36#include "volume.h"
37#include "layout.h"
38
39typedef enum {
40 NTFS_BLOCK_SIZE = 512,
41 NTFS_BLOCK_SIZE_BITS = 9,
42 NTFS_SB_MAGIC = 0x5346544e, /* 'NTFS' */
43 NTFS_MAX_NAME_LEN = 255,
Anton Altaparmakovbb3cf332005-04-06 13:34:31 +010044 NTFS_MAX_ATTR_NAME_LEN = 255,
Anton Altaparmakov7fafb8b2005-04-06 16:09:21 +010045 NTFS_MAX_CLUSTER_SIZE = 64 * 1024, /* 64kiB */
Kirill A. Shutemov09cbfea2016-04-01 15:29:47 +030046 NTFS_MAX_PAGES_PER_CLUSTER = NTFS_MAX_CLUSTER_SIZE / PAGE_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047} NTFS_CONSTANTS;
48
49/* Global variables. */
50
51/* Slab caches (from super.c). */
Pekka Enberg64419d92006-02-05 21:43:57 +000052extern struct kmem_cache *ntfs_name_cache;
53extern struct kmem_cache *ntfs_inode_cache;
54extern struct kmem_cache *ntfs_big_inode_cache;
55extern struct kmem_cache *ntfs_attr_ctx_cache;
56extern struct kmem_cache *ntfs_index_ctx_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/* The various operations structs defined throughout the driver files. */
Anton Altaparmakovce1bafa2014-10-16 12:28:03 +010059extern const struct address_space_operations ntfs_normal_aops;
60extern const struct address_space_operations ntfs_compressed_aops;
Christoph Hellwigf5e54d62006-06-28 04:26:44 -070061extern const struct address_space_operations ntfs_mst_aops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -080063extern const struct file_operations ntfs_file_ops;
Arjan van de Ven92e1d5b2007-02-12 00:55:39 -080064extern const struct inode_operations ntfs_file_inode_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -080066extern const struct file_operations ntfs_dir_ops;
Arjan van de Ven92e1d5b2007-02-12 00:55:39 -080067extern const struct inode_operations ntfs_dir_inode_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -080069extern const struct file_operations ntfs_empty_file_ops;
Arjan van de Ven92e1d5b2007-02-12 00:55:39 -080070extern const struct inode_operations ntfs_empty_inode_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Christoph Hellwig39655162007-10-21 16:42:17 -070072extern const struct export_operations ntfs_export_ops;
Anton Altaparmakov41382682005-03-03 13:44:15 +000073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074/**
75 * NTFS_SB - return the ntfs volume given a vfs super block
76 * @sb: VFS super block
77 *
78 * NTFS_SB() returns the ntfs volume associated with the VFS super block @sb.
79 */
80static inline ntfs_volume *NTFS_SB(struct super_block *sb)
81{
82 return sb->s_fs_info;
83}
84
85/* Declarations of functions and global variables. */
86
87/* From fs/ntfs/compress.c */
88extern int ntfs_read_compressed_block(struct page *page);
89extern int allocate_compression_buffers(void);
90extern void free_compression_buffers(void);
91
92/* From fs/ntfs/super.c */
93#define default_upcase_len 0x10000
Ingo Molnar4e5e5292006-03-23 16:57:48 +000094extern struct mutex ntfs_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96typedef struct {
97 int val;
98 char *str;
99} option_t;
100extern const option_t on_errors_arr[];
101
102/* From fs/ntfs/mst.c */
103extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
104extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size);
105extern void post_write_mst_fixup(NTFS_RECORD *b);
106
107/* From fs/ntfs/unistr.c */
Richard Knutssonc49c3112006-09-30 23:27:12 -0700108extern bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 const ntfschar *s2, size_t s2_len,
110 const IGNORE_CASE_BOOL ic,
111 const ntfschar *upcase, const u32 upcase_size);
112extern int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
113 const ntfschar *name2, const u32 name2_len,
114 const int err_val, const IGNORE_CASE_BOOL ic,
115 const ntfschar *upcase, const u32 upcase_len);
116extern int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n);
117extern int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
118 const ntfschar *upcase, const u32 upcase_size);
119extern void ntfs_upcase_name(ntfschar *name, u32 name_len,
120 const ntfschar *upcase, const u32 upcase_len);
121extern void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
122 const ntfschar *upcase, const u32 upcase_len);
123extern int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
124 FILE_NAME_ATTR *file_name_attr2,
125 const int err_val, const IGNORE_CASE_BOOL ic,
126 const ntfschar *upcase, const u32 upcase_len);
127extern int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
128 const int ins_len, ntfschar **outs);
129extern int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
130 const int ins_len, unsigned char **outs, int outs_len);
131
132/* From fs/ntfs/upcase.c */
133extern ntfschar *generate_default_upcase(void);
134
Akinobu Mitab9a28382006-03-26 01:39:53 -0800135static inline int ntfs_ffs(int x)
136{
137 int r = 1;
138
139 if (!x)
140 return 0;
141 if (!(x & 0xffff)) {
142 x >>= 16;
143 r += 16;
144 }
145 if (!(x & 0xff)) {
146 x >>= 8;
147 r += 8;
148 }
149 if (!(x & 0xf)) {
150 x >>= 4;
151 r += 4;
152 }
153 if (!(x & 3)) {
154 x >>= 2;
155 r += 2;
156 }
157 if (!(x & 1)) {
158 x >>= 1;
159 r += 1;
160 }
161 return r;
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164#endif /* _LINUX_NTFS_H */