blob: 8ce0d4f439a1e26b9f12dbdab0fbb946da859adb [file] [log] [blame]
Konstantin Komarov82cae262021-08-13 17:21:29 +03001// SPDX-License-Identifier: GPL-2.0
2/*
3 *
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
5 *
6 *
7 * terminology
8 *
9 * cluster - allocation unit - 512,1K,2K,4K,...,2M
Kari Argillandere8b8e972021-08-03 14:57:09 +030010 * vcn - virtual cluster number - Offset inside the file in clusters.
11 * vbo - virtual byte offset - Offset inside the file in bytes.
12 * lcn - logical cluster number - 0 based cluster in clusters heap.
13 * lbo - logical byte offset - Absolute position inside volume.
14 * run - maps VCN to LCN - Stored in attributes in packed form.
15 * attr - attribute segment - std/name/data etc records inside MFT.
16 * mi - MFT inode - One MFT record(usually 1024 bytes or 4K), consists of attributes.
17 * ni - NTFS inode - Extends linux inode. consists of one or more mft inodes.
18 * index - unit inside directory - 2K, 4K, <=page size, does not depend on cluster size.
Konstantin Komarov82cae262021-08-13 17:21:29 +030019 *
20 * WSL - Windows Subsystem for Linux
21 * https://docs.microsoft.com/en-us/windows/wsl/file-permissions
22 * It stores uid/gid/mode/dev in xattr
23 *
24 */
25
Konstantin Komarov82cae262021-08-13 17:21:29 +030026#include <linux/blkdev.h>
27#include <linux/buffer_head.h>
28#include <linux/exportfs.h>
29#include <linux/fs.h>
Kari Argillander610f8f52021-09-07 18:35:52 +030030#include <linux/fs_context.h>
31#include <linux/fs_parser.h>
Kari Argillander528c9b32021-08-16 13:37:32 +030032#include <linux/log2.h>
Konstantin Komarov82cae262021-08-13 17:21:29 +030033#include <linux/module.h>
34#include <linux/nls.h>
Konstantin Komarov82cae262021-08-13 17:21:29 +030035#include <linux/seq_file.h>
36#include <linux/statfs.h>
37
38#include "debug.h"
39#include "ntfs.h"
40#include "ntfs_fs.h"
41#ifdef CONFIG_NTFS3_LZX_XPRESS
42#include "lib/lib.h"
43#endif
44
45#ifdef CONFIG_PRINTK
46/*
Kari Argillandere8b8e972021-08-03 14:57:09 +030047 * ntfs_printk - Trace warnings/notices/errors.
48 *
Konstantin Komarov82cae262021-08-13 17:21:29 +030049 * Thanks Joe Perches <joe@perches.com> for implementation
50 */
51void ntfs_printk(const struct super_block *sb, const char *fmt, ...)
52{
53 struct va_format vaf;
54 va_list args;
55 int level;
56 struct ntfs_sb_info *sbi = sb->s_fs_info;
57
Kari Argillandere8b8e972021-08-03 14:57:09 +030058 /* Should we use different ratelimits for warnings/notices/errors? */
Konstantin Komarov82cae262021-08-13 17:21:29 +030059 if (!___ratelimit(&sbi->msg_ratelimit, "ntfs3"))
60 return;
61
62 va_start(args, fmt);
63
64 level = printk_get_level(fmt);
65 vaf.fmt = printk_skip_level(fmt);
66 vaf.va = &args;
67 printk("%c%cntfs3: %s: %pV\n", KERN_SOH_ASCII, level, sb->s_id, &vaf);
68
69 va_end(args);
70}
71
72static char s_name_buf[512];
Kari Argillandere8b8e972021-08-03 14:57:09 +030073static atomic_t s_name_buf_cnt = ATOMIC_INIT(1); // 1 means 'free s_name_buf'.
Konstantin Komarov82cae262021-08-13 17:21:29 +030074
Kari Argillandere8b8e972021-08-03 14:57:09 +030075/*
76 * ntfs_inode_printk
77 *
78 * Print warnings/notices/errors about inode using name or inode number.
79 */
Konstantin Komarov82cae262021-08-13 17:21:29 +030080void ntfs_inode_printk(struct inode *inode, const char *fmt, ...)
81{
82 struct super_block *sb = inode->i_sb;
83 struct ntfs_sb_info *sbi = sb->s_fs_info;
84 char *name;
85 va_list args;
86 struct va_format vaf;
87 int level;
88
89 if (!___ratelimit(&sbi->msg_ratelimit, "ntfs3"))
90 return;
91
Kari Argillandere8b8e972021-08-03 14:57:09 +030092 /* Use static allocated buffer, if possible. */
Konstantin Komarov82cae262021-08-13 17:21:29 +030093 name = atomic_dec_and_test(&s_name_buf_cnt)
94 ? s_name_buf
95 : kmalloc(sizeof(s_name_buf), GFP_NOFS);
96
97 if (name) {
98 struct dentry *de = d_find_alias(inode);
99 const u32 name_len = ARRAY_SIZE(s_name_buf) - 1;
100
101 if (de) {
102 spin_lock(&de->d_lock);
103 snprintf(name, name_len, " \"%s\"", de->d_name.name);
104 spin_unlock(&de->d_lock);
Kari Argillandere8b8e972021-08-03 14:57:09 +0300105 name[name_len] = 0; /* To be sure. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300106 } else {
107 name[0] = 0;
108 }
Kari Argillandere8b8e972021-08-03 14:57:09 +0300109 dput(de); /* Cocci warns if placed in branch "if (de)" */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300110 }
111
112 va_start(args, fmt);
113
114 level = printk_get_level(fmt);
115 vaf.fmt = printk_skip_level(fmt);
116 vaf.va = &args;
117
118 printk("%c%cntfs3: %s: ino=%lx,%s %pV\n", KERN_SOH_ASCII, level,
119 sb->s_id, inode->i_ino, name ? name : "", &vaf);
120
121 va_end(args);
122
123 atomic_inc(&s_name_buf_cnt);
124 if (name != s_name_buf)
125 kfree(name);
126}
127#endif
128
129/*
130 * Shared memory struct.
131 *
Kari Argillandere8b8e972021-08-03 14:57:09 +0300132 * On-disk ntfs's upcase table is created by ntfs formatter.
133 * 'upcase' table is 128K bytes of memory.
134 * We should read it into memory when mounting.
135 * Several ntfs volumes likely use the same 'upcase' table.
136 * It is good idea to share in-memory 'upcase' table between different volumes.
137 * Unfortunately winxp/vista/win7 use different upcase tables.
Konstantin Komarov82cae262021-08-13 17:21:29 +0300138 */
139static DEFINE_SPINLOCK(s_shared_lock);
140
141static struct {
142 void *ptr;
143 u32 len;
144 int cnt;
145} s_shared[8];
146
147/*
148 * ntfs_set_shared
149 *
Kari Argillandere8b8e972021-08-03 14:57:09 +0300150 * Return:
151 * * @ptr - If pointer was saved in shared memory.
152 * * NULL - If pointer was not shared.
Konstantin Komarov82cae262021-08-13 17:21:29 +0300153 */
154void *ntfs_set_shared(void *ptr, u32 bytes)
155{
156 void *ret = NULL;
157 int i, j = -1;
158
159 spin_lock(&s_shared_lock);
160 for (i = 0; i < ARRAY_SIZE(s_shared); i++) {
161 if (!s_shared[i].cnt) {
162 j = i;
163 } else if (bytes == s_shared[i].len &&
164 !memcmp(s_shared[i].ptr, ptr, bytes)) {
165 s_shared[i].cnt += 1;
166 ret = s_shared[i].ptr;
167 break;
168 }
169 }
170
171 if (!ret && j != -1) {
172 s_shared[j].ptr = ptr;
173 s_shared[j].len = bytes;
174 s_shared[j].cnt = 1;
175 ret = ptr;
176 }
177 spin_unlock(&s_shared_lock);
178
179 return ret;
180}
181
182/*
183 * ntfs_put_shared
184 *
Kari Argillandere8b8e972021-08-03 14:57:09 +0300185 * Return:
186 * * @ptr - If pointer is not shared anymore.
187 * * NULL - If pointer is still shared.
Konstantin Komarov82cae262021-08-13 17:21:29 +0300188 */
189void *ntfs_put_shared(void *ptr)
190{
191 void *ret = ptr;
192 int i;
193
194 spin_lock(&s_shared_lock);
195 for (i = 0; i < ARRAY_SIZE(s_shared); i++) {
196 if (s_shared[i].cnt && s_shared[i].ptr == ptr) {
197 if (--s_shared[i].cnt)
198 ret = NULL;
199 break;
200 }
201 }
202 spin_unlock(&s_shared_lock);
203
204 return ret;
205}
206
Kari Argillander610f8f52021-09-07 18:35:52 +0300207static inline void put_mount_options(struct ntfs_mount_options *options)
Konstantin Komarov82cae262021-08-13 17:21:29 +0300208{
Kari Argillander610f8f52021-09-07 18:35:52 +0300209 kfree(options->nls_name);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300210 unload_nls(options->nls);
Kari Argillander610f8f52021-09-07 18:35:52 +0300211 kfree(options);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300212}
213
214enum Opt {
215 Opt_uid,
216 Opt_gid,
217 Opt_umask,
218 Opt_dmask,
219 Opt_fmask,
220 Opt_immutable,
221 Opt_discard,
222 Opt_force,
223 Opt_sparse,
224 Opt_nohidden,
225 Opt_showmeta,
226 Opt_acl,
Kari Argillandere274cde2021-09-07 18:35:55 +0300227 Opt_iocharset,
Konstantin Komarov82cae262021-08-13 17:21:29 +0300228 Opt_prealloc,
Kari Argillander28a941f2021-09-07 18:35:56 +0300229 Opt_noacsrules,
Konstantin Komarov82cae262021-08-13 17:21:29 +0300230 Opt_err,
231};
232
Kari Argillander610f8f52021-09-07 18:35:52 +0300233static const struct fs_parameter_spec ntfs_fs_parameters[] = {
234 fsparam_u32("uid", Opt_uid),
235 fsparam_u32("gid", Opt_gid),
236 fsparam_u32oct("umask", Opt_umask),
237 fsparam_u32oct("dmask", Opt_dmask),
238 fsparam_u32oct("fmask", Opt_fmask),
239 fsparam_flag_no("sys_immutable", Opt_immutable),
240 fsparam_flag_no("discard", Opt_discard),
241 fsparam_flag_no("force", Opt_force),
242 fsparam_flag_no("sparse", Opt_sparse),
Kari Argillander9d1939f2021-09-07 18:35:54 +0300243 fsparam_flag_no("hidden", Opt_nohidden),
Kari Argillander610f8f52021-09-07 18:35:52 +0300244 fsparam_flag_no("acl", Opt_acl),
245 fsparam_flag_no("showmeta", Opt_showmeta),
Kari Argillander610f8f52021-09-07 18:35:52 +0300246 fsparam_flag_no("prealloc", Opt_prealloc),
Kari Argillander28a941f2021-09-07 18:35:56 +0300247 fsparam_flag_no("acsrules", Opt_noacsrules),
Kari Argillandere274cde2021-09-07 18:35:55 +0300248 fsparam_string("iocharset", Opt_iocharset),
249
250 __fsparam(fs_param_is_string,
251 "nls", Opt_iocharset,
252 fs_param_deprecated, NULL),
Kari Argillander610f8f52021-09-07 18:35:52 +0300253 {}
Konstantin Komarov82cae262021-08-13 17:21:29 +0300254};
255
Kari Argillander610f8f52021-09-07 18:35:52 +0300256/*
257 * Load nls table or if @nls is utf8 then return NULL.
258 */
259static struct nls_table *ntfs_load_nls(char *nls)
Konstantin Komarov82cae262021-08-13 17:21:29 +0300260{
Kari Argillander610f8f52021-09-07 18:35:52 +0300261 struct nls_table *ret;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300262
Kari Argillander610f8f52021-09-07 18:35:52 +0300263 if (!nls)
264 nls = CONFIG_NLS_DEFAULT;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300265
Kari Argillander610f8f52021-09-07 18:35:52 +0300266 if (strcmp(nls, "utf8") == 0)
267 return NULL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300268
Kari Argillander610f8f52021-09-07 18:35:52 +0300269 if (strcmp(nls, CONFIG_NLS_DEFAULT) == 0)
270 return load_nls_default();
Konstantin Komarov82cae262021-08-13 17:21:29 +0300271
Kari Argillander610f8f52021-09-07 18:35:52 +0300272 ret = load_nls(nls);
273 if (ret)
274 return ret;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300275
Kari Argillander610f8f52021-09-07 18:35:52 +0300276 return ERR_PTR(-EINVAL);
277}
278
279static int ntfs_fs_parse_param(struct fs_context *fc,
280 struct fs_parameter *param)
281{
282 struct ntfs_mount_options *opts = fc->fs_private;
283 struct fs_parse_result result;
284 int opt;
285
286 opt = fs_parse(fc, ntfs_fs_parameters, param, &result);
287 if (opt < 0)
288 return opt;
289
290 switch (opt) {
291 case Opt_uid:
292 opts->fs_uid = make_kuid(current_user_ns(), result.uint_32);
293 if (!uid_valid(opts->fs_uid))
294 return invalf(fc, "ntfs3: Invalid value for uid.");
Kari Argillander610f8f52021-09-07 18:35:52 +0300295 break;
296 case Opt_gid:
297 opts->fs_gid = make_kgid(current_user_ns(), result.uint_32);
298 if (!gid_valid(opts->fs_gid))
299 return invalf(fc, "ntfs3: Invalid value for gid.");
Kari Argillander610f8f52021-09-07 18:35:52 +0300300 break;
301 case Opt_umask:
302 if (result.uint_32 & ~07777)
303 return invalf(fc, "ntfs3: Invalid value for umask.");
304 opts->fs_fmask_inv = ~result.uint_32;
305 opts->fs_dmask_inv = ~result.uint_32;
306 opts->fmask = 1;
307 opts->dmask = 1;
308 break;
309 case Opt_dmask:
310 if (result.uint_32 & ~07777)
311 return invalf(fc, "ntfs3: Invalid value for dmask.");
312 opts->fs_dmask_inv = ~result.uint_32;
313 opts->dmask = 1;
314 break;
315 case Opt_fmask:
316 if (result.uint_32 & ~07777)
317 return invalf(fc, "ntfs3: Invalid value for fmask.");
318 opts->fs_fmask_inv = ~result.uint_32;
319 opts->fmask = 1;
320 break;
321 case Opt_immutable:
322 opts->sys_immutable = result.negated ? 0 : 1;
323 break;
324 case Opt_discard:
325 opts->discard = result.negated ? 0 : 1;
326 break;
327 case Opt_force:
328 opts->force = result.negated ? 0 : 1;
329 break;
330 case Opt_sparse:
331 opts->sparse = result.negated ? 0 : 1;
332 break;
333 case Opt_nohidden:
Kari Argillander9d1939f2021-09-07 18:35:54 +0300334 opts->nohidden = result.negated ? 1 : 0;
Kari Argillander610f8f52021-09-07 18:35:52 +0300335 break;
336 case Opt_acl:
337 if (!result.negated)
Konstantin Komarov82cae262021-08-13 17:21:29 +0300338#ifdef CONFIG_NTFS3_FS_POSIX_ACL
Kari Argillander610f8f52021-09-07 18:35:52 +0300339 fc->sb_flags |= SB_POSIXACL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300340#else
Kari Argillander610f8f52021-09-07 18:35:52 +0300341 return invalf(fc, "ntfs3: Support for ACL not compiled in!");
Konstantin Komarov82cae262021-08-13 17:21:29 +0300342#endif
Kari Argillander610f8f52021-09-07 18:35:52 +0300343 else
344 fc->sb_flags &= ~SB_POSIXACL;
345 break;
346 case Opt_showmeta:
347 opts->showmeta = result.negated ? 0 : 1;
348 break;
Kari Argillandere274cde2021-09-07 18:35:55 +0300349 case Opt_iocharset:
Kari Argillander610f8f52021-09-07 18:35:52 +0300350 kfree(opts->nls_name);
351 opts->nls_name = param->string;
352 param->string = NULL;
353 break;
354 case Opt_prealloc:
355 opts->prealloc = result.negated ? 0 : 1;
356 break;
Kari Argillander28a941f2021-09-07 18:35:56 +0300357 case Opt_noacsrules:
358 opts->noacsrules = result.negated ? 1 : 0;
Kari Argillander610f8f52021-09-07 18:35:52 +0300359 break;
360 default:
361 /* Should not be here unless we forget add case. */
362 return -EINVAL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300363 }
Konstantin Komarov82cae262021-08-13 17:21:29 +0300364 return 0;
365}
366
Kari Argillander610f8f52021-09-07 18:35:52 +0300367static int ntfs_fs_reconfigure(struct fs_context *fc)
Konstantin Komarov82cae262021-08-13 17:21:29 +0300368{
Kari Argillander610f8f52021-09-07 18:35:52 +0300369 struct super_block *sb = fc->root->d_sb;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300370 struct ntfs_sb_info *sbi = sb->s_fs_info;
Kari Argillander610f8f52021-09-07 18:35:52 +0300371 struct ntfs_mount_options *new_opts = fc->fs_private;
372 int ro_rw;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300373
Kari Argillander610f8f52021-09-07 18:35:52 +0300374 ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300375 if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY)) {
Kari Argillander610f8f52021-09-07 18:35:52 +0300376 errorf(fc, "ntfs3: Couldn't remount rw because journal is not replayed. Please umount/remount instead\n");
377 return -EINVAL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300378 }
379
Kari Argillander610f8f52021-09-07 18:35:52 +0300380 new_opts->nls = ntfs_load_nls(new_opts->nls_name);
381 if (IS_ERR(new_opts->nls)) {
382 new_opts->nls = NULL;
Kari Argillandere274cde2021-09-07 18:35:55 +0300383 errorf(fc, "ntfs3: Cannot load iocharset %s", new_opts->nls_name);
Kari Argillander610f8f52021-09-07 18:35:52 +0300384 return -EINVAL;
385 }
386 if (new_opts->nls != sbi->options->nls)
Kari Argillandere274cde2021-09-07 18:35:55 +0300387 return invalf(fc, "ntfs3: Cannot use different iocharset when remounting!");
Kari Argillander610f8f52021-09-07 18:35:52 +0300388
Konstantin Komarov82cae262021-08-13 17:21:29 +0300389 sync_filesystem(sb);
390
391 if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) &&
Kari Argillander610f8f52021-09-07 18:35:52 +0300392 !new_opts->force) {
393 errorf(fc, "ntfs3: Volume is dirty and \"force\" flag is not set!");
394 return -EINVAL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300395 }
396
Kari Argillander610f8f52021-09-07 18:35:52 +0300397 memcpy(sbi->options, new_opts, sizeof(*new_opts));
Konstantin Komarov82cae262021-08-13 17:21:29 +0300398
Kari Argillander610f8f52021-09-07 18:35:52 +0300399 return 0;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300400}
401
402static struct kmem_cache *ntfs_inode_cachep;
403
404static struct inode *ntfs_alloc_inode(struct super_block *sb)
405{
406 struct ntfs_inode *ni = kmem_cache_alloc(ntfs_inode_cachep, GFP_NOFS);
407
408 if (!ni)
409 return NULL;
410
411 memset(ni, 0, offsetof(struct ntfs_inode, vfs_inode));
412
413 mutex_init(&ni->ni_lock);
414
415 return &ni->vfs_inode;
416}
417
418static void ntfs_i_callback(struct rcu_head *head)
419{
420 struct inode *inode = container_of(head, struct inode, i_rcu);
421 struct ntfs_inode *ni = ntfs_i(inode);
422
423 mutex_destroy(&ni->ni_lock);
424
425 kmem_cache_free(ntfs_inode_cachep, ni);
426}
427
428static void ntfs_destroy_inode(struct inode *inode)
429{
430 call_rcu(&inode->i_rcu, ntfs_i_callback);
431}
432
433static void init_once(void *foo)
434{
435 struct ntfs_inode *ni = foo;
436
437 inode_init_once(&ni->vfs_inode);
438}
439
Kari Argillandere8b8e972021-08-03 14:57:09 +0300440/*
441 * put_ntfs - Noinline to reduce binary size.
442 */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300443static noinline void put_ntfs(struct ntfs_sb_info *sbi)
444{
Kari Argillander195c52b2021-08-24 21:37:07 +0300445 kfree(sbi->new_rec);
446 kvfree(ntfs_put_shared(sbi->upcase));
447 kfree(sbi->def_table);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300448
449 wnd_close(&sbi->mft.bitmap);
450 wnd_close(&sbi->used.bitmap);
451
452 if (sbi->mft.ni)
453 iput(&sbi->mft.ni->vfs_inode);
454
455 if (sbi->security.ni)
456 iput(&sbi->security.ni->vfs_inode);
457
458 if (sbi->reparse.ni)
459 iput(&sbi->reparse.ni->vfs_inode);
460
461 if (sbi->objid.ni)
462 iput(&sbi->objid.ni->vfs_inode);
463
464 if (sbi->volume.ni)
465 iput(&sbi->volume.ni->vfs_inode);
466
467 ntfs_update_mftmirr(sbi, 0);
468
469 indx_clear(&sbi->security.index_sii);
470 indx_clear(&sbi->security.index_sdh);
471 indx_clear(&sbi->reparse.index_r);
472 indx_clear(&sbi->objid.index_o);
Kari Argillander195c52b2021-08-24 21:37:07 +0300473 kfree(sbi->compress.lznt);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300474#ifdef CONFIG_NTFS3_LZX_XPRESS
475 xpress_free_decompressor(sbi->compress.xpress);
476 lzx_free_decompressor(sbi->compress.lzx);
477#endif
Kari Argillander195c52b2021-08-24 21:37:07 +0300478 kfree(sbi);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300479}
480
481static void ntfs_put_super(struct super_block *sb)
482{
483 struct ntfs_sb_info *sbi = sb->s_fs_info;
484
Kari Argillandere8b8e972021-08-03 14:57:09 +0300485 /* Mark rw ntfs as clear, if possible. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300486 ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
487
Kari Argillander610f8f52021-09-07 18:35:52 +0300488 put_mount_options(sbi->options);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300489 put_ntfs(sbi);
Kari Argillander610f8f52021-09-07 18:35:52 +0300490 sb->s_fs_info = NULL;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300491
492 sync_blockdev(sb->s_bdev);
493}
494
495static int ntfs_statfs(struct dentry *dentry, struct kstatfs *buf)
496{
497 struct super_block *sb = dentry->d_sb;
498 struct ntfs_sb_info *sbi = sb->s_fs_info;
499 struct wnd_bitmap *wnd = &sbi->used.bitmap;
500
501 buf->f_type = sb->s_magic;
502 buf->f_bsize = sbi->cluster_size;
503 buf->f_blocks = wnd->nbits;
504
505 buf->f_bfree = buf->f_bavail = wnd_zeroes(wnd);
506 buf->f_fsid.val[0] = sbi->volume.ser_num;
507 buf->f_fsid.val[1] = (sbi->volume.ser_num >> 32);
508 buf->f_namelen = NTFS_NAME_LEN;
509
510 return 0;
511}
512
513static int ntfs_show_options(struct seq_file *m, struct dentry *root)
514{
515 struct super_block *sb = root->d_sb;
516 struct ntfs_sb_info *sbi = sb->s_fs_info;
Kari Argillander564c97b2021-09-07 18:35:51 +0300517 struct ntfs_mount_options *opts = sbi->options;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300518 struct user_namespace *user_ns = seq_user_ns(m);
519
Kari Argillander15b2ae72021-09-07 18:35:57 +0300520 seq_printf(m, ",uid=%u",
521 from_kuid_munged(user_ns, opts->fs_uid));
522 seq_printf(m, ",gid=%u",
523 from_kgid_munged(user_ns, opts->fs_gid));
Konstantin Komarov82cae262021-08-13 17:21:29 +0300524 if (opts->fmask)
525 seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv);
526 if (opts->dmask)
527 seq_printf(m, ",dmask=%04o", ~opts->fs_dmask_inv);
528 if (opts->nls)
Kari Argillandere274cde2021-09-07 18:35:55 +0300529 seq_printf(m, ",iocharset=%s", opts->nls->charset);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300530 else
Kari Argillandere274cde2021-09-07 18:35:55 +0300531 seq_puts(m, ",iocharset=utf8");
Konstantin Komarov82cae262021-08-13 17:21:29 +0300532 if (opts->sys_immutable)
533 seq_puts(m, ",sys_immutable");
534 if (opts->discard)
535 seq_puts(m, ",discard");
536 if (opts->sparse)
537 seq_puts(m, ",sparse");
538 if (opts->showmeta)
539 seq_puts(m, ",showmeta");
540 if (opts->nohidden)
541 seq_puts(m, ",nohidden");
542 if (opts->force)
543 seq_puts(m, ",force");
Kari Argillander28a941f2021-09-07 18:35:56 +0300544 if (opts->noacsrules)
545 seq_puts(m, ",noacsrules");
Konstantin Komarov82cae262021-08-13 17:21:29 +0300546 if (opts->prealloc)
547 seq_puts(m, ",prealloc");
548 if (sb->s_flags & SB_POSIXACL)
549 seq_puts(m, ",acl");
Konstantin Komarov82cae262021-08-13 17:21:29 +0300550
551 return 0;
552}
553
Kari Argillandere8b8e972021-08-03 14:57:09 +0300554/*
555 * ntfs_sync_fs - super_operations::sync_fs
556 */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300557static int ntfs_sync_fs(struct super_block *sb, int wait)
558{
559 int err = 0, err2;
560 struct ntfs_sb_info *sbi = sb->s_fs_info;
561 struct ntfs_inode *ni;
562 struct inode *inode;
563
564 ni = sbi->security.ni;
565 if (ni) {
566 inode = &ni->vfs_inode;
567 err2 = _ni_write_inode(inode, wait);
568 if (err2 && !err)
569 err = err2;
570 }
571
572 ni = sbi->objid.ni;
573 if (ni) {
574 inode = &ni->vfs_inode;
575 err2 = _ni_write_inode(inode, wait);
576 if (err2 && !err)
577 err = err2;
578 }
579
580 ni = sbi->reparse.ni;
581 if (ni) {
582 inode = &ni->vfs_inode;
583 err2 = _ni_write_inode(inode, wait);
584 if (err2 && !err)
585 err = err2;
586 }
587
588 if (!err)
589 ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
590
591 ntfs_update_mftmirr(sbi, wait);
592
593 return err;
594}
595
596static const struct super_operations ntfs_sops = {
597 .alloc_inode = ntfs_alloc_inode,
598 .destroy_inode = ntfs_destroy_inode,
599 .evict_inode = ntfs_evict_inode,
600 .put_super = ntfs_put_super,
601 .statfs = ntfs_statfs,
602 .show_options = ntfs_show_options,
603 .sync_fs = ntfs_sync_fs,
Konstantin Komarov82cae262021-08-13 17:21:29 +0300604 .write_inode = ntfs3_write_inode,
605};
606
607static struct inode *ntfs_export_get_inode(struct super_block *sb, u64 ino,
608 u32 generation)
609{
610 struct MFT_REF ref;
611 struct inode *inode;
612
613 ref.low = cpu_to_le32(ino);
614#ifdef CONFIG_NTFS3_64BIT_CLUSTER
615 ref.high = cpu_to_le16(ino >> 32);
616#else
617 ref.high = 0;
618#endif
619 ref.seq = cpu_to_le16(generation);
620
621 inode = ntfs_iget5(sb, &ref, NULL);
622 if (!IS_ERR(inode) && is_bad_inode(inode)) {
623 iput(inode);
624 inode = ERR_PTR(-ESTALE);
625 }
626
627 return inode;
628}
629
630static struct dentry *ntfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
631 int fh_len, int fh_type)
632{
633 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
634 ntfs_export_get_inode);
635}
636
637static struct dentry *ntfs_fh_to_parent(struct super_block *sb, struct fid *fid,
638 int fh_len, int fh_type)
639{
640 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
641 ntfs_export_get_inode);
642}
643
644/* TODO: == ntfs_sync_inode */
645static int ntfs_nfs_commit_metadata(struct inode *inode)
646{
647 return _ni_write_inode(inode, 1);
648}
649
650static const struct export_operations ntfs_export_ops = {
651 .fh_to_dentry = ntfs_fh_to_dentry,
652 .fh_to_parent = ntfs_fh_to_parent,
653 .get_parent = ntfs3_get_parent,
654 .commit_metadata = ntfs_nfs_commit_metadata,
655};
656
Kari Argillandere8b8e972021-08-03 14:57:09 +0300657/*
658 * format_size_gb - Return Gb,Mb to print with "%u.%02u Gb".
659 */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300660static u32 format_size_gb(const u64 bytes, u32 *mb)
661{
Kari Argillandere8b8e972021-08-03 14:57:09 +0300662 /* Do simple right 30 bit shift of 64 bit value. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300663 u64 kbytes = bytes >> 10;
664 u32 kbytes32 = kbytes;
665
666 *mb = (100 * (kbytes32 & 0xfffff) + 0x7ffff) >> 20;
667 if (*mb >= 100)
668 *mb = 99;
669
670 return (kbytes32 >> 20) | (((u32)(kbytes >> 32)) << 12);
671}
672
673static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)
674{
675 return boot->sectors_per_clusters <= 0x80
676 ? boot->sectors_per_clusters
677 : (1u << (0 - boot->sectors_per_clusters));
678}
679
Kari Argillandere8b8e972021-08-03 14:57:09 +0300680/*
681 * ntfs_init_from_boot - Init internal info from on-disk boot sector.
682 */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300683static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
684 u64 dev_size)
685{
686 struct ntfs_sb_info *sbi = sb->s_fs_info;
687 int err;
688 u32 mb, gb, boot_sector_size, sct_per_clst, record_size;
689 u64 sectors, clusters, fs_size, mlcn, mlcn2;
690 struct NTFS_BOOT *boot;
691 struct buffer_head *bh;
692 struct MFT_REC *rec;
693 u16 fn, ao;
694
695 sbi->volume.blocks = dev_size >> PAGE_SHIFT;
696
697 bh = ntfs_bread(sb, 0);
698 if (!bh)
699 return -EIO;
700
701 err = -EINVAL;
702 boot = (struct NTFS_BOOT *)bh->b_data;
703
704 if (memcmp(boot->system_id, "NTFS ", sizeof("NTFS ") - 1))
705 goto out;
706
707 /* 0x55AA is not mandaroty. Thanks Maxim Suhanov*/
708 /*if (0x55 != boot->boot_magic[0] || 0xAA != boot->boot_magic[1])
709 * goto out;
710 */
711
712 boot_sector_size = (u32)boot->bytes_per_sector[1] << 8;
713 if (boot->bytes_per_sector[0] || boot_sector_size < SECTOR_SIZE ||
Kari Argillander528c9b32021-08-16 13:37:32 +0300714 !is_power_of_2(boot_sector_size)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300715 goto out;
716 }
717
718 /* cluster size: 512, 1K, 2K, 4K, ... 2M */
719 sct_per_clst = true_sectors_per_clst(boot);
Kari Argillander528c9b32021-08-16 13:37:32 +0300720 if (!is_power_of_2(sct_per_clst))
Konstantin Komarov82cae262021-08-13 17:21:29 +0300721 goto out;
722
723 mlcn = le64_to_cpu(boot->mft_clst);
724 mlcn2 = le64_to_cpu(boot->mft2_clst);
725 sectors = le64_to_cpu(boot->sectors_per_volume);
726
727 if (mlcn * sct_per_clst >= sectors)
728 goto out;
729
730 if (mlcn2 * sct_per_clst >= sectors)
731 goto out;
732
Kari Argillandere8b8e972021-08-03 14:57:09 +0300733 /* Check MFT record size. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300734 if ((boot->record_size < 0 &&
735 SECTOR_SIZE > (2U << (-boot->record_size))) ||
Kari Argillander528c9b32021-08-16 13:37:32 +0300736 (boot->record_size >= 0 && !is_power_of_2(boot->record_size))) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300737 goto out;
738 }
739
Kari Argillandere8b8e972021-08-03 14:57:09 +0300740 /* Check index record size. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300741 if ((boot->index_size < 0 &&
742 SECTOR_SIZE > (2U << (-boot->index_size))) ||
Kari Argillander528c9b32021-08-16 13:37:32 +0300743 (boot->index_size >= 0 && !is_power_of_2(boot->index_size))) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300744 goto out;
745 }
746
747 sbi->sector_size = boot_sector_size;
748 sbi->sector_bits = blksize_bits(boot_sector_size);
749 fs_size = (sectors + 1) << sbi->sector_bits;
750
751 gb = format_size_gb(fs_size, &mb);
752
753 /*
Kari Argillandere8b8e972021-08-03 14:57:09 +0300754 * - Volume formatted and mounted with the same sector size.
755 * - Volume formatted 4K and mounted as 512.
756 * - Volume formatted 512 and mounted as 4K.
Konstantin Komarov82cae262021-08-13 17:21:29 +0300757 */
758 if (sbi->sector_size != sector_size) {
759 ntfs_warn(sb,
760 "Different NTFS' sector size and media sector size");
761 dev_size += sector_size - 1;
762 }
763
764 sbi->cluster_size = boot_sector_size * sct_per_clst;
765 sbi->cluster_bits = blksize_bits(sbi->cluster_size);
766
767 sbi->mft.lbo = mlcn << sbi->cluster_bits;
768 sbi->mft.lbo2 = mlcn2 << sbi->cluster_bits;
769
770 if (sbi->cluster_size < sbi->sector_size)
771 goto out;
772
773 sbi->cluster_mask = sbi->cluster_size - 1;
774 sbi->cluster_mask_inv = ~(u64)sbi->cluster_mask;
775 sbi->record_size = record_size = boot->record_size < 0
776 ? 1 << (-boot->record_size)
777 : (u32)boot->record_size
778 << sbi->cluster_bits;
779
780 if (record_size > MAXIMUM_BYTES_PER_MFT)
781 goto out;
782
783 sbi->record_bits = blksize_bits(record_size);
784 sbi->attr_size_tr = (5 * record_size >> 4); // ~320 bytes
785
786 sbi->max_bytes_per_attr =
Kari Argillanderfa3cacf2021-08-26 11:56:29 +0300787 record_size - ALIGN(MFTRECORD_FIXUP_OFFSET_1, 8) -
788 ALIGN(((record_size >> SECTOR_SHIFT) * sizeof(short)), 8) -
789 ALIGN(sizeof(enum ATTR_TYPE), 8);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300790
791 sbi->index_size = boot->index_size < 0
792 ? 1u << (-boot->index_size)
793 : (u32)boot->index_size << sbi->cluster_bits;
794
795 sbi->volume.ser_num = le64_to_cpu(boot->serial_num);
796 sbi->volume.size = sectors << sbi->sector_bits;
797
Kari Argillandere8b8e972021-08-03 14:57:09 +0300798 /* Warning if RAW volume. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300799 if (dev_size < fs_size) {
800 u32 mb0, gb0;
801
802 gb0 = format_size_gb(dev_size, &mb0);
803 ntfs_warn(
804 sb,
805 "RAW NTFS volume: Filesystem size %u.%02u Gb > volume size %u.%02u Gb. Mount in read-only",
806 gb, mb, gb0, mb0);
807 sb->s_flags |= SB_RDONLY;
808 }
809
810 clusters = sbi->volume.size >> sbi->cluster_bits;
811#ifndef CONFIG_NTFS3_64BIT_CLUSTER
Kari Argillandere8b8e972021-08-03 14:57:09 +0300812 /* 32 bits per cluster. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300813 if (clusters >> 32) {
814 ntfs_notice(
815 sb,
816 "NTFS %u.%02u Gb is too big to use 32 bits per cluster",
817 gb, mb);
818 goto out;
819 }
820#elif BITS_PER_LONG < 64
821#error "CONFIG_NTFS3_64BIT_CLUSTER incompatible in 32 bit OS"
822#endif
823
824 sbi->used.bitmap.nbits = clusters;
825
Kari Argillander195c52b2021-08-24 21:37:07 +0300826 rec = kzalloc(record_size, GFP_NOFS);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300827 if (!rec) {
828 err = -ENOMEM;
829 goto out;
830 }
831
832 sbi->new_rec = rec;
833 rec->rhdr.sign = NTFS_FILE_SIGNATURE;
834 rec->rhdr.fix_off = cpu_to_le16(MFTRECORD_FIXUP_OFFSET_1);
835 fn = (sbi->record_size >> SECTOR_SHIFT) + 1;
836 rec->rhdr.fix_num = cpu_to_le16(fn);
Kari Argillanderfa3cacf2021-08-26 11:56:29 +0300837 ao = ALIGN(MFTRECORD_FIXUP_OFFSET_1 + sizeof(short) * fn, 8);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300838 rec->attr_off = cpu_to_le16(ao);
Kari Argillanderfa3cacf2021-08-26 11:56:29 +0300839 rec->used = cpu_to_le32(ao + ALIGN(sizeof(enum ATTR_TYPE), 8));
Konstantin Komarov82cae262021-08-13 17:21:29 +0300840 rec->total = cpu_to_le32(sbi->record_size);
841 ((struct ATTRIB *)Add2Ptr(rec, ao))->type = ATTR_END;
842
843 if (sbi->cluster_size < PAGE_SIZE)
844 sb_set_blocksize(sb, sbi->cluster_size);
845
846 sbi->block_mask = sb->s_blocksize - 1;
847 sbi->blocks_per_cluster = sbi->cluster_size >> sb->s_blocksize_bits;
848 sbi->volume.blocks = sbi->volume.size >> sb->s_blocksize_bits;
849
Kari Argillandere8b8e972021-08-03 14:57:09 +0300850 /* Maximum size for normal files. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300851 sbi->maxbytes = (clusters << sbi->cluster_bits) - 1;
852
853#ifdef CONFIG_NTFS3_64BIT_CLUSTER
854 if (clusters >= (1ull << (64 - sbi->cluster_bits)))
855 sbi->maxbytes = -1;
856 sbi->maxbytes_sparse = -1;
857#else
Kari Argillandere8b8e972021-08-03 14:57:09 +0300858 /* Maximum size for sparse file. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300859 sbi->maxbytes_sparse = (1ull << (sbi->cluster_bits + 32)) - 1;
860#endif
861
862 err = 0;
863
864out:
865 brelse(bh);
866
867 return err;
868}
869
Kari Argillandere8b8e972021-08-03 14:57:09 +0300870/*
871 * ntfs_fill_super - Try to mount.
872 */
Kari Argillander610f8f52021-09-07 18:35:52 +0300873static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
Konstantin Komarov82cae262021-08-13 17:21:29 +0300874{
875 int err;
Kari Argillander610f8f52021-09-07 18:35:52 +0300876 struct ntfs_sb_info *sbi = sb->s_fs_info;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300877 struct block_device *bdev = sb->s_bdev;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300878 struct request_queue *rq = bdev_get_queue(bdev);
Kari Argillander10b4f122021-09-09 21:09:36 +0300879 struct inode *inode;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300880 struct ntfs_inode *ni;
881 size_t i, tt;
882 CLST vcn, lcn, len;
883 struct ATTRIB *attr;
884 const struct VOLUME_INFO *info;
885 u32 idx, done, bytes;
886 struct ATTR_DEF_ENTRY *t;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300887 u16 *shared;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300888 struct MFT_REF ref;
889
890 ref.high = 0;
891
Konstantin Komarov82cae262021-08-13 17:21:29 +0300892 sbi->sb = sb;
893 sb->s_flags |= SB_NODIRATIME;
894 sb->s_magic = 0x7366746e; // "ntfs"
895 sb->s_op = &ntfs_sops;
896 sb->s_export_op = &ntfs_export_ops;
897 sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
898 sb->s_xattr = ntfs_xattr_handlers;
899
Kari Argillander610f8f52021-09-07 18:35:52 +0300900 sbi->options->nls = ntfs_load_nls(sbi->options->nls_name);
901 if (IS_ERR(sbi->options->nls)) {
902 sbi->options->nls = NULL;
903 errorf(fc, "Cannot load nls %s", sbi->options->nls_name);
904 return -EINVAL;
905 }
Konstantin Komarov82cae262021-08-13 17:21:29 +0300906
907 if (!rq || !blk_queue_discard(rq) || !rq->limits.discard_granularity) {
908 ;
909 } else {
910 sbi->discard_granularity = rq->limits.discard_granularity;
911 sbi->discard_granularity_mask_inv =
912 ~(u64)(sbi->discard_granularity - 1);
913 }
914
915 sb_set_blocksize(sb, PAGE_SIZE);
916
Kari Argillandere8b8e972021-08-03 14:57:09 +0300917 /* Parse boot. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300918 err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512,
Kari Argillander4ea41b32021-09-09 21:09:39 +0300919 bdev->bd_inode->i_size);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300920 if (err)
Kari Argillanderbce18282021-09-09 21:09:35 +0300921 return err;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300922
923#ifdef CONFIG_NTFS3_64BIT_CLUSTER
924 sb->s_maxbytes = MAX_LFS_FILESIZE;
925#else
926 sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
927#endif
928
Konstantin Komarov82cae262021-08-13 17:21:29 +0300929 /*
Kari Argillandere8b8e972021-08-03 14:57:09 +0300930 * Load $Volume. This should be done before $LogFile
931 * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'.
Konstantin Komarov82cae262021-08-13 17:21:29 +0300932 */
933 ref.low = cpu_to_le32(MFT_REC_VOL);
934 ref.seq = cpu_to_le16(MFT_REC_VOL);
935 inode = ntfs_iget5(sb, &ref, &NAME_VOLUME);
936 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300937 ntfs_err(sb, "Failed to load $Volume.");
Kari Argillanderbce18282021-09-09 21:09:35 +0300938 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300939 }
940
941 ni = ntfs_i(inode);
942
Kari Argillandere8b8e972021-08-03 14:57:09 +0300943 /* Load and save label (not necessary). */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300944 attr = ni_find_attr(ni, NULL, NULL, ATTR_LABEL, NULL, 0, NULL, NULL);
945
946 if (!attr) {
947 /* It is ok if no ATTR_LABEL */
948 } else if (!attr->non_res && !is_attr_ext(attr)) {
Kari Argillandere8b8e972021-08-03 14:57:09 +0300949 /* $AttrDef allows labels to be up to 128 symbols. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300950 err = utf16s_to_utf8s(resident_data(attr),
951 le32_to_cpu(attr->res.data_size) >> 1,
952 UTF16_LITTLE_ENDIAN, sbi->volume.label,
953 sizeof(sbi->volume.label));
954 if (err < 0)
955 sbi->volume.label[0] = 0;
956 } else {
Kari Argillandere8b8e972021-08-03 14:57:09 +0300957 /* Should we break mounting here? */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300958 //err = -EINVAL;
959 //goto out;
960 }
961
962 attr = ni_find_attr(ni, attr, NULL, ATTR_VOL_INFO, NULL, 0, NULL, NULL);
963 if (!attr || is_attr_ext(attr)) {
964 err = -EINVAL;
965 goto out;
966 }
967
968 info = resident_data_ex(attr, SIZEOF_ATTRIBUTE_VOLUME_INFO);
969 if (!info) {
970 err = -EINVAL;
971 goto out;
972 }
973
974 sbi->volume.major_ver = info->major_ver;
975 sbi->volume.minor_ver = info->minor_ver;
976 sbi->volume.flags = info->flags;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300977 sbi->volume.ni = ni;
Konstantin Komarov82cae262021-08-13 17:21:29 +0300978
Kari Argillandere8b8e972021-08-03 14:57:09 +0300979 /* Load $MFTMirr to estimate recs_mirr. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300980 ref.low = cpu_to_le32(MFT_REC_MIRR);
981 ref.seq = cpu_to_le16(MFT_REC_MIRR);
982 inode = ntfs_iget5(sb, &ref, &NAME_MIRROR);
983 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300984 ntfs_err(sb, "Failed to load $MFTMirr.");
Kari Argillanderbce18282021-09-09 21:09:35 +0300985 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +0300986 }
987
988 sbi->mft.recs_mirr =
989 ntfs_up_cluster(sbi, inode->i_size) >> sbi->record_bits;
990
991 iput(inode);
992
Konstantin Komarovd3624462021-08-31 16:57:40 +0300993 /* Load LogFile to replay. */
Konstantin Komarov82cae262021-08-13 17:21:29 +0300994 ref.low = cpu_to_le32(MFT_REC_LOG);
995 ref.seq = cpu_to_le16(MFT_REC_LOG);
996 inode = ntfs_iget5(sb, &ref, &NAME_LOGFILE);
997 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +0300998 ntfs_err(sb, "Failed to load \x24LogFile.");
Kari Argillanderbce18282021-09-09 21:09:35 +0300999 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001000 }
1001
1002 ni = ntfs_i(inode);
1003
1004 err = ntfs_loadlog_and_replay(ni, sbi);
1005 if (err)
1006 goto out;
1007
1008 iput(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001009
Konstantin Komarov82cae262021-08-13 17:21:29 +03001010 if (sbi->flags & NTFS_FLAGS_NEED_REPLAY) {
Kari Argillander0cde7e812021-09-09 21:09:38 +03001011 if (!sb_rdonly(sb)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001012 ntfs_warn(sb,
1013 "failed to replay log file. Can't mount rw!");
Kari Argillanderbce18282021-09-09 21:09:35 +03001014 return -EINVAL;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001015 }
1016 } else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) {
Kari Argillander0cde7e812021-09-09 21:09:38 +03001017 if (!sb_rdonly(sb) && !sbi->options->force) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001018 ntfs_warn(
1019 sb,
1020 "volume is dirty and \"force\" flag is not set!");
Kari Argillanderbce18282021-09-09 21:09:35 +03001021 return -EINVAL;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001022 }
1023 }
1024
Kari Argillandere8b8e972021-08-03 14:57:09 +03001025 /* Load $MFT. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001026 ref.low = cpu_to_le32(MFT_REC_MFT);
1027 ref.seq = cpu_to_le16(1);
1028
1029 inode = ntfs_iget5(sb, &ref, &NAME_MFT);
1030 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001031 ntfs_err(sb, "Failed to load $MFT.");
Kari Argillanderbce18282021-09-09 21:09:35 +03001032 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001033 }
1034
1035 ni = ntfs_i(inode);
1036
1037 sbi->mft.used = ni->i_valid >> sbi->record_bits;
1038 tt = inode->i_size >> sbi->record_bits;
1039 sbi->mft.next_free = MFT_REC_USER;
1040
1041 err = wnd_init(&sbi->mft.bitmap, sb, tt);
1042 if (err)
1043 goto out;
1044
1045 err = ni_load_all_mi(ni);
1046 if (err)
1047 goto out;
1048
1049 sbi->mft.ni = ni;
1050
Kari Argillandere8b8e972021-08-03 14:57:09 +03001051 /* Load $BadClus. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001052 ref.low = cpu_to_le32(MFT_REC_BADCLUST);
1053 ref.seq = cpu_to_le16(MFT_REC_BADCLUST);
1054 inode = ntfs_iget5(sb, &ref, &NAME_BADCLUS);
1055 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001056 ntfs_err(sb, "Failed to load $BadClus.");
Kari Argillanderbce18282021-09-09 21:09:35 +03001057 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001058 }
1059
1060 ni = ntfs_i(inode);
1061
1062 for (i = 0; run_get_entry(&ni->file.run, i, &vcn, &lcn, &len); i++) {
1063 if (lcn == SPARSE_LCN)
1064 continue;
1065
1066 if (!sbi->bad_clusters)
1067 ntfs_notice(sb, "Volume contains bad blocks");
1068
1069 sbi->bad_clusters += len;
1070 }
1071
1072 iput(inode);
1073
Kari Argillandere8b8e972021-08-03 14:57:09 +03001074 /* Load $Bitmap. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001075 ref.low = cpu_to_le32(MFT_REC_BITMAP);
1076 ref.seq = cpu_to_le16(MFT_REC_BITMAP);
1077 inode = ntfs_iget5(sb, &ref, &NAME_BITMAP);
1078 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001079 ntfs_err(sb, "Failed to load $Bitmap.");
Kari Argillanderbce18282021-09-09 21:09:35 +03001080 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001081 }
1082
Konstantin Komarov82cae262021-08-13 17:21:29 +03001083#ifndef CONFIG_NTFS3_64BIT_CLUSTER
1084 if (inode->i_size >> 32) {
1085 err = -EINVAL;
1086 goto out;
1087 }
1088#endif
1089
Kari Argillandere8b8e972021-08-03 14:57:09 +03001090 /* Check bitmap boundary. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001091 tt = sbi->used.bitmap.nbits;
1092 if (inode->i_size < bitmap_size(tt)) {
1093 err = -EINVAL;
1094 goto out;
1095 }
1096
Kari Argillandere8b8e972021-08-03 14:57:09 +03001097 /* Not necessary. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001098 sbi->used.bitmap.set_tail = true;
Kari Argillanderb4f110d2021-09-09 21:09:37 +03001099 err = wnd_init(&sbi->used.bitmap, sb, tt);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001100 if (err)
1101 goto out;
1102
1103 iput(inode);
1104
Kari Argillandere8b8e972021-08-03 14:57:09 +03001105 /* Compute the MFT zone. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001106 err = ntfs_refresh_zone(sbi);
1107 if (err)
Kari Argillanderbce18282021-09-09 21:09:35 +03001108 return err;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001109
Kari Argillandere8b8e972021-08-03 14:57:09 +03001110 /* Load $AttrDef. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001111 ref.low = cpu_to_le32(MFT_REC_ATTR);
1112 ref.seq = cpu_to_le16(MFT_REC_ATTR);
Kari Argillanderb4f110d2021-09-09 21:09:37 +03001113 inode = ntfs_iget5(sb, &ref, &NAME_ATTRDEF);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001114 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001115 ntfs_err(sb, "Failed to load $AttrDef -> %d", err);
Kari Argillanderbce18282021-09-09 21:09:35 +03001116 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001117 }
1118
1119 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
1120 err = -EINVAL;
1121 goto out;
1122 }
1123 bytes = inode->i_size;
Kari Argillander195c52b2021-08-24 21:37:07 +03001124 sbi->def_table = t = kmalloc(bytes, GFP_NOFS);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001125 if (!t) {
1126 err = -ENOMEM;
1127 goto out;
1128 }
1129
1130 for (done = idx = 0; done < bytes; done += PAGE_SIZE, idx++) {
1131 unsigned long tail = bytes - done;
1132 struct page *page = ntfs_map_page(inode->i_mapping, idx);
1133
1134 if (IS_ERR(page)) {
1135 err = PTR_ERR(page);
1136 goto out;
1137 }
1138 memcpy(Add2Ptr(t, done), page_address(page),
1139 min(PAGE_SIZE, tail));
1140 ntfs_unmap_page(page);
1141
1142 if (!idx && ATTR_STD != t->type) {
1143 err = -EINVAL;
1144 goto out;
1145 }
1146 }
1147
1148 t += 1;
1149 sbi->def_entries = 1;
1150 done = sizeof(struct ATTR_DEF_ENTRY);
1151 sbi->reparse.max_size = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
Colin Ian Kingf8d87ed2021-08-16 11:13:08 +01001152 sbi->ea_max_size = 0x10000; /* default formatter value */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001153
1154 while (done + sizeof(struct ATTR_DEF_ENTRY) <= bytes) {
1155 u32 t32 = le32_to_cpu(t->type);
1156 u64 sz = le64_to_cpu(t->max_sz);
1157
1158 if ((t32 & 0xF) || le32_to_cpu(t[-1].type) >= t32)
1159 break;
1160
1161 if (t->type == ATTR_REPARSE)
1162 sbi->reparse.max_size = sz;
1163 else if (t->type == ATTR_EA)
1164 sbi->ea_max_size = sz;
1165
1166 done += sizeof(struct ATTR_DEF_ENTRY);
1167 t += 1;
1168 sbi->def_entries += 1;
1169 }
1170 iput(inode);
1171
Kari Argillandere8b8e972021-08-03 14:57:09 +03001172 /* Load $UpCase. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001173 ref.low = cpu_to_le32(MFT_REC_UPCASE);
1174 ref.seq = cpu_to_le16(MFT_REC_UPCASE);
1175 inode = ntfs_iget5(sb, &ref, &NAME_UPCASE);
1176 if (IS_ERR(inode)) {
Kari Argillander04120162021-09-09 21:09:32 +03001177 ntfs_err(sb, "Failed to load $UpCase.");
Kari Argillanderbce18282021-09-09 21:09:35 +03001178 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001179 }
1180
Konstantin Komarov82cae262021-08-13 17:21:29 +03001181 if (inode->i_size != 0x10000 * sizeof(short)) {
1182 err = -EINVAL;
1183 goto out;
1184 }
1185
Konstantin Komarov82cae262021-08-13 17:21:29 +03001186 for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
1187 const __le16 *src;
Kari Argillander0056b272021-09-09 21:09:40 +03001188 u16 *dst = Add2Ptr(sbi->upcase, idx << PAGE_SHIFT);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001189 struct page *page = ntfs_map_page(inode->i_mapping, idx);
1190
1191 if (IS_ERR(page)) {
1192 err = PTR_ERR(page);
1193 goto out;
1194 }
1195
1196 src = page_address(page);
1197
1198#ifdef __BIG_ENDIAN
1199 for (i = 0; i < PAGE_SIZE / sizeof(u16); i++)
1200 *dst++ = le16_to_cpu(*src++);
1201#else
1202 memcpy(dst, src, PAGE_SIZE);
1203#endif
1204 ntfs_unmap_page(page);
1205 }
1206
Kari Argillander0056b272021-09-09 21:09:40 +03001207 shared = ntfs_set_shared(sbi->upcase, 0x10000 * sizeof(short));
1208 if (shared && sbi->upcase != shared) {
1209 kvfree(sbi->upcase);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001210 sbi->upcase = shared;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001211 }
1212
1213 iput(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001214
1215 if (is_ntfs3(sbi)) {
Kari Argillandere8b8e972021-08-03 14:57:09 +03001216 /* Load $Secure. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001217 err = ntfs_security_init(sbi);
1218 if (err)
Kari Argillanderbce18282021-09-09 21:09:35 +03001219 return err;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001220
Kari Argillandere8b8e972021-08-03 14:57:09 +03001221 /* Load $Extend. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001222 err = ntfs_extend_init(sbi);
1223 if (err)
1224 goto load_root;
1225
Kari Argillandere8b8e972021-08-03 14:57:09 +03001226 /* Load $Extend\$Reparse. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001227 err = ntfs_reparse_init(sbi);
1228 if (err)
1229 goto load_root;
1230
Kari Argillandere8b8e972021-08-03 14:57:09 +03001231 /* Load $Extend\$ObjId. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001232 err = ntfs_objid_init(sbi);
1233 if (err)
1234 goto load_root;
1235 }
1236
1237load_root:
Kari Argillandere8b8e972021-08-03 14:57:09 +03001238 /* Load root. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001239 ref.low = cpu_to_le32(MFT_REC_ROOT);
1240 ref.seq = cpu_to_le16(MFT_REC_ROOT);
1241 inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
1242 if (IS_ERR(inode)) {
Konstantin Komarov82cae262021-08-13 17:21:29 +03001243 ntfs_err(sb, "Failed to load root.");
Kari Argillanderbce18282021-09-09 21:09:35 +03001244 return PTR_ERR(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001245 }
1246
Konstantin Komarov82cae262021-08-13 17:21:29 +03001247 sb->s_root = d_make_root(inode);
Kari Argillanderbce18282021-09-09 21:09:35 +03001248 if (!sb->s_root)
1249 return -ENOMEM;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001250
Kari Argillander610f8f52021-09-07 18:35:52 +03001251 fc->fs_private = NULL;
1252 fc->s_fs_info = NULL;
1253
Konstantin Komarov82cae262021-08-13 17:21:29 +03001254 return 0;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001255out:
1256 iput(inode);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001257 return err;
1258}
1259
1260void ntfs_unmap_meta(struct super_block *sb, CLST lcn, CLST len)
1261{
1262 struct ntfs_sb_info *sbi = sb->s_fs_info;
1263 struct block_device *bdev = sb->s_bdev;
1264 sector_t devblock = (u64)lcn * sbi->blocks_per_cluster;
1265 unsigned long blocks = (u64)len * sbi->blocks_per_cluster;
1266 unsigned long cnt = 0;
1267 unsigned long limit = global_zone_page_state(NR_FREE_PAGES)
1268 << (PAGE_SHIFT - sb->s_blocksize_bits);
1269
1270 if (limit >= 0x2000)
1271 limit -= 0x1000;
1272 else if (limit < 32)
1273 limit = 32;
1274 else
1275 limit >>= 1;
1276
1277 while (blocks--) {
1278 clean_bdev_aliases(bdev, devblock++, 1);
1279 if (cnt++ >= limit) {
1280 sync_blockdev(bdev);
1281 cnt = 0;
1282 }
1283 }
1284}
1285
1286/*
Kari Argillandere8b8e972021-08-03 14:57:09 +03001287 * ntfs_discard - Issue a discard request (trim for SSD).
Konstantin Komarov82cae262021-08-13 17:21:29 +03001288 */
1289int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len)
1290{
1291 int err;
1292 u64 lbo, bytes, start, end;
1293 struct super_block *sb;
1294
1295 if (sbi->used.next_free_lcn == lcn + len)
1296 sbi->used.next_free_lcn = lcn;
1297
1298 if (sbi->flags & NTFS_FLAGS_NODISCARD)
1299 return -EOPNOTSUPP;
1300
Kari Argillander564c97b2021-09-07 18:35:51 +03001301 if (!sbi->options->discard)
Konstantin Komarov82cae262021-08-13 17:21:29 +03001302 return -EOPNOTSUPP;
1303
1304 lbo = (u64)lcn << sbi->cluster_bits;
1305 bytes = (u64)len << sbi->cluster_bits;
1306
Kari Argillandere8b8e972021-08-03 14:57:09 +03001307 /* Align up 'start' on discard_granularity. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001308 start = (lbo + sbi->discard_granularity - 1) &
1309 sbi->discard_granularity_mask_inv;
Kari Argillandere8b8e972021-08-03 14:57:09 +03001310 /* Align down 'end' on discard_granularity. */
Konstantin Komarov82cae262021-08-13 17:21:29 +03001311 end = (lbo + bytes) & sbi->discard_granularity_mask_inv;
1312
1313 sb = sbi->sb;
1314 if (start >= end)
1315 return 0;
1316
1317 err = blkdev_issue_discard(sb->s_bdev, start >> 9, (end - start) >> 9,
1318 GFP_NOFS, 0);
1319
1320 if (err == -EOPNOTSUPP)
1321 sbi->flags |= NTFS_FLAGS_NODISCARD;
1322
1323 return err;
1324}
1325
Kari Argillander610f8f52021-09-07 18:35:52 +03001326static int ntfs_fs_get_tree(struct fs_context *fc)
Konstantin Komarov82cae262021-08-13 17:21:29 +03001327{
Kari Argillander610f8f52021-09-07 18:35:52 +03001328 return get_tree_bdev(fc, ntfs_fill_super);
1329}
1330
1331/*
1332 * ntfs_fs_free - Free fs_context.
1333 *
1334 * Note that this will be called after fill_super and reconfigure
1335 * even when they pass. So they have to take pointers if they pass.
1336 */
1337static void ntfs_fs_free(struct fs_context *fc)
1338{
1339 struct ntfs_mount_options *opts = fc->fs_private;
1340 struct ntfs_sb_info *sbi = fc->s_fs_info;
1341
1342 if (sbi)
1343 put_ntfs(sbi);
1344
1345 if (opts)
1346 put_mount_options(opts);
1347}
1348
1349static const struct fs_context_operations ntfs_context_ops = {
1350 .parse_param = ntfs_fs_parse_param,
1351 .get_tree = ntfs_fs_get_tree,
1352 .reconfigure = ntfs_fs_reconfigure,
1353 .free = ntfs_fs_free,
1354};
1355
1356/*
1357 * ntfs_init_fs_context - Initialize spi and opts
1358 *
1359 * This will called when mount/remount. We will first initiliaze
1360 * options so that if remount we can use just that.
1361 */
1362static int ntfs_init_fs_context(struct fs_context *fc)
1363{
1364 struct ntfs_mount_options *opts;
1365 struct ntfs_sb_info *sbi;
1366
1367 opts = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS);
1368 if (!opts)
1369 return -ENOMEM;
1370
1371 /* Default options. */
1372 opts->fs_uid = current_uid();
1373 opts->fs_gid = current_gid();
1374 opts->fs_fmask_inv = ~current_umask();
1375 opts->fs_dmask_inv = ~current_umask();
1376
1377 if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
1378 goto ok;
1379
1380 sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
Kari Argillander27fac772021-09-07 18:35:53 +03001381 if (!sbi)
1382 goto free_opts;
1383
1384 sbi->upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
1385 if (!sbi->upcase)
1386 goto free_sbi;
1387
1388 ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
1389 DEFAULT_RATELIMIT_BURST);
1390
1391 mutex_init(&sbi->compress.mtx_lznt);
1392#ifdef CONFIG_NTFS3_LZX_XPRESS
1393 mutex_init(&sbi->compress.mtx_xpress);
1394 mutex_init(&sbi->compress.mtx_lzx);
1395#endif
Kari Argillander610f8f52021-09-07 18:35:52 +03001396
1397 sbi->options = opts;
1398 fc->s_fs_info = sbi;
1399ok:
1400 fc->fs_private = opts;
1401 fc->ops = &ntfs_context_ops;
1402
1403 return 0;
Kari Argillander27fac772021-09-07 18:35:53 +03001404free_opts:
1405 kfree(opts);
1406free_sbi:
1407 kfree(sbi);
1408 return -ENOMEM;
Konstantin Komarov82cae262021-08-13 17:21:29 +03001409}
1410
1411// clang-format off
1412static struct file_system_type ntfs_fs_type = {
Kari Argillander610f8f52021-09-07 18:35:52 +03001413 .owner = THIS_MODULE,
1414 .name = "ntfs3",
1415 .init_fs_context = ntfs_init_fs_context,
1416 .parameters = ntfs_fs_parameters,
1417 .kill_sb = kill_block_super,
1418 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
Konstantin Komarov82cae262021-08-13 17:21:29 +03001419};
1420// clang-format on
1421
1422static int __init init_ntfs_fs(void)
1423{
1424 int err;
1425
Kari Argillander2e3a51b2021-08-29 17:42:39 +03001426 pr_info("ntfs3: Max link count %u\n", NTFS_LINK_MAX);
Konstantin Komarov82cae262021-08-13 17:21:29 +03001427
Kari Argillander2e3a51b2021-08-29 17:42:39 +03001428 if (IS_ENABLED(CONFIG_NTFS3_FS_POSIX_ACL))
1429 pr_info("ntfs3: Enabled Linux POSIX ACLs support\n");
1430 if (IS_ENABLED(CONFIG_NTFS3_64BIT_CLUSTER))
1431 pr_notice("ntfs3: Warning: Activated 64 bits per cluster. Windows does not support this\n");
1432 if (IS_ENABLED(CONFIG_NTFS3_LZX_XPRESS))
1433 pr_info("ntfs3: Read-only LZX/Xpress compression included\n");
Konstantin Komarov82cae262021-08-13 17:21:29 +03001434
1435 err = ntfs3_init_bitmap();
1436 if (err)
1437 return err;
1438
1439 ntfs_inode_cachep = kmem_cache_create(
1440 "ntfs_inode_cache", sizeof(struct ntfs_inode), 0,
1441 (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT),
1442 init_once);
1443 if (!ntfs_inode_cachep) {
1444 err = -ENOMEM;
1445 goto out1;
1446 }
1447
1448 err = register_filesystem(&ntfs_fs_type);
1449 if (err)
1450 goto out;
1451
1452 return 0;
1453out:
1454 kmem_cache_destroy(ntfs_inode_cachep);
1455out1:
1456 ntfs3_exit_bitmap();
1457 return err;
1458}
1459
1460static void __exit exit_ntfs_fs(void)
1461{
1462 if (ntfs_inode_cachep) {
1463 rcu_barrier();
1464 kmem_cache_destroy(ntfs_inode_cachep);
1465 }
1466
1467 unregister_filesystem(&ntfs_fs_type);
1468 ntfs3_exit_bitmap();
1469}
1470
1471MODULE_LICENSE("GPL");
1472MODULE_DESCRIPTION("ntfs3 read/write filesystem");
Konstantin Komarov82cae262021-08-13 17:21:29 +03001473#ifdef CONFIG_NTFS3_FS_POSIX_ACL
1474MODULE_INFO(behaviour, "Enabled Linux POSIX ACLs support");
1475#endif
1476#ifdef CONFIG_NTFS3_64BIT_CLUSTER
Kari Argillander2e3a51b2021-08-29 17:42:39 +03001477MODULE_INFO(cluster, "Warning: Activated 64 bits per cluster. Windows does not support this");
Konstantin Komarov82cae262021-08-13 17:21:29 +03001478#endif
1479#ifdef CONFIG_NTFS3_LZX_XPRESS
1480MODULE_INFO(compression, "Read-only lzx/xpress compression included");
1481#endif
1482
1483MODULE_AUTHOR("Konstantin Komarov");
1484MODULE_ALIAS_FS("ntfs3");
1485
1486module_init(init_ntfs_fs);
1487module_exit(exit_ntfs_fs);