1 /* Some of the source code in this file came from "linux/fs/fat/file.c","linux/fs/fat/inode.c" and "linux/fs/fat/misc.c". */
5 * Written 1992,1993 by Werner Almesberger
7 * regular file handling primitives for fat-based filesystems
11 * linux/fs/fat/inode.c
13 * Written 1992,1993 by Werner Almesberger
14 * VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
15 * Rewritten for the constant inumbers support by Al Viro
19 * Max Cohan: Fixed invalid FSINFO offset when info_sector is 0
25 * Written 1992,1993 by Werner Almesberger
26 * 22/11/2000 - Fixed fat_date_unix2dos for dates earlier than 01/01/1980
27 * and date_dos2unix for date==0 by Igor Zhbanov(bsg@uniyar.ac.ru)
31 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
33 * This program is free software; you can redistribute it and/or
34 * modify it under the terms of the GNU General Public License
35 * as published by the Free Software Foundation; either version 2
36 * of the License, or (at your option) any later version.
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
48 #include <linux/version.h>
49 #include <linux/module.h>
50 #include <linux/init.h>
51 #include <linux/time.h>
52 #include <linux/slab.h>
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
54 #include <linux/smp_lock.h>
56 #include <linux/seq_file.h>
57 #include <linux/pagemap.h>
58 #include <linux/mpage.h>
59 #include <linux/buffer_head.h>
60 #include <linux/exportfs.h>
61 #include <linux/mount.h>
62 #include <linux/vfs.h>
63 #include <linux/parser.h>
64 #include <linux/uio.h>
65 #include <linux/writeback.h>
66 #include <linux/log2.h>
67 #include <linux/hash.h>
68 #include <linux/backing-dev.h>
69 #include <linux/sched.h>
70 #include <linux/fs_struct.h>
71 #include <linux/namei.h>
72 #include <asm/current.h>
73 #include <asm/unaligned.h>
74 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
75 #include <linux/aio.h>
78 #include "exfat_version.h"
79 #include "exfat_config.h"
80 #include "exfat_global.h"
81 #include "exfat_data.h"
82 #include "exfat_oal.h"
84 #include "exfat_blkdev.h"
85 #include "exfat_cache.h"
86 #include "exfat_part.h"
87 #include "exfat_nls.h"
88 #include "exfat_api.h"
91 #include "exfat_super.h"
93 static struct kmem_cache
*exfat_inode_cachep
;
95 static int exfat_default_codepage
= CONFIG_EXFAT_DEFAULT_CODEPAGE
;
96 static char exfat_default_iocharset
[] = CONFIG_EXFAT_DEFAULT_IOCHARSET
;
98 extern struct timezone sys_tz
;
100 #define CHECK_ERR(x) BUG_ON(x)
101 #define ELAPSED_TIME 0
103 #if (ELAPSED_TIME == 1)
104 #include <linux/time.h>
106 static UINT32 __t1
, __t2
;
107 static UINT32
get_current_msec(void)
110 do_gettimeofday(&tm
);
111 return((UINT32
)(tm
.tv_sec
*1000000 + tm
.tv_usec
));
113 #define TIME_START() do {__t1 = get_current_msec();} while (0)
114 #define TIME_END() do {__t2 = get_current_msec();} while (0)
115 #define PRINT_TIME(n) do {printk("[EXFAT] Elapsed time %d = %d (usec)\n", n, (__t2 - __t1));} while (0)
119 #define PRINT_TIME(n)
122 #define UNIX_SECS_1980 315532800L
124 #if BITS_PER_LONG == 64
125 #define UNIX_SECS_2108 4354819200L
127 /* days between 1.1.70 and 1.1.80 (2 leap days) */
128 #define DAYS_DELTA_DECADE (365 * 10 + 2)
129 /* 120 (2100 - 1980) isn't leap year */
130 #define NO_LEAP_YEAR_2100 (120)
131 #define IS_LEAP_YEAR(y) (!((y) & 0x3) && (y) != NO_LEAP_YEAR_2100)
133 #define SECS_PER_MIN (60)
134 #define SECS_PER_HOUR (60 * SECS_PER_MIN)
135 #define SECS_PER_DAY (24 * SECS_PER_HOUR)
137 #define MAKE_LEAP_YEAR(leap_year, year) \
139 if (unlikely(year > NO_LEAP_YEAR_2100)) \
140 leap_year = ((year + 3) / 4) - 1; \
142 leap_year = ((year + 3) / 4); \
145 /* Linear day numbers of the respective 1sts in non-leap years. */
146 static time_t accum_days_in_year
[] = {
147 /* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
148 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
151 static void _exfat_truncate(struct inode
*inode
, loff_t old_size
);
153 /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
154 void exfat_time_fat2unix(struct exfat_sb_info
*sbi
, struct timespec
*ts
,
157 time_t year
= tp
->Year
;
160 MAKE_LEAP_YEAR(ld
, year
);
162 if (IS_LEAP_YEAR(year
) && (tp
->Month
) > 2)
165 ts
->tv_sec
= tp
->Second
+ tp
->Minute
* SECS_PER_MIN
166 + tp
->Hour
* SECS_PER_HOUR
167 + (year
* 365 + ld
+ accum_days_in_year
[(tp
->Month
)] + (tp
->Day
- 1) + DAYS_DELTA_DECADE
) * SECS_PER_DAY
168 + sys_tz
.tz_minuteswest
* SECS_PER_MIN
;
172 /* Convert linear UNIX date to a FAT time/date pair. */
173 void exfat_time_unix2fat(struct exfat_sb_info
*sbi
, struct timespec
*ts
,
176 time_t second
= ts
->tv_sec
;
177 time_t day
, month
, year
;
180 second
-= sys_tz
.tz_minuteswest
* SECS_PER_MIN
;
182 /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */
183 if (second
< UNIX_SECS_1980
) {
192 #if (BITS_PER_LONG == 64)
193 if (second
>= UNIX_SECS_2108
) {
203 day
= second
/ SECS_PER_DAY
- DAYS_DELTA_DECADE
;
205 MAKE_LEAP_YEAR(ld
, year
);
206 if (year
* 365 + ld
> day
)
209 MAKE_LEAP_YEAR(ld
, year
);
210 day
-= year
* 365 + ld
;
212 if (IS_LEAP_YEAR(year
) && day
== accum_days_in_year
[3]) {
215 if (IS_LEAP_YEAR(year
) && day
> accum_days_in_year
[3])
217 for (month
= 1; month
< 12; month
++) {
218 if (accum_days_in_year
[month
+ 1] > day
)
222 day
-= accum_days_in_year
[month
];
224 tp
->Second
= second
% SECS_PER_MIN
;
225 tp
->Minute
= (second
/ SECS_PER_MIN
) % 60;
226 tp
->Hour
= (second
/ SECS_PER_HOUR
) % 24;
232 static struct inode
*exfat_iget(struct super_block
*sb
, loff_t i_pos
);
233 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
234 static int exfat_generic_ioctl(struct inode
*inode
, struct file
*filp
, unsigned int cmd
, unsigned long arg
);
236 static long exfat_generic_ioctl(struct file
*filp
, unsigned int cmd
, unsigned long arg
);
238 static int exfat_sync_inode(struct inode
*inode
);
239 static struct inode
*exfat_build_inode(struct super_block
*sb
, FILE_ID_T
*fid
, loff_t i_pos
);
240 static void exfat_detach(struct inode
*inode
);
241 static void exfat_attach(struct inode
*inode
, loff_t i_pos
);
242 static inline unsigned long exfat_hash(loff_t i_pos
);
243 static int exfat_write_inode(struct inode
*inode
, struct writeback_control
*wbc
);
244 static void exfat_write_super(struct super_block
*sb
);
246 static void __lock_super(struct super_block
*sb
)
248 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
251 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
252 mutex_lock(&sbi
->s_lock
);
256 static void __unlock_super(struct super_block
*sb
)
258 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
261 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
262 mutex_unlock(&sbi
->s_lock
);
266 static int __is_sb_dirty(struct super_block
*sb
)
268 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
271 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
276 static void __set_sb_clean(struct super_block
*sb
)
278 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
281 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
286 /*======================================================================*/
287 /* Directory Entry Operations */
288 /*======================================================================*/
290 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
291 static int exfat_readdir(struct file
*filp
, struct dir_context
*ctx
)
293 static int exfat_readdir(struct file
*filp
, void *dirent
, filldir_t filldir
)
296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
297 struct inode
*inode
= file_inode(filp
);
299 struct inode
*inode
= filp
->f_path
.dentry
->d_inode
;
301 struct super_block
*sb
= inode
->i_sb
;
302 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
303 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
304 BD_INFO_T
*p_bd
= &(EXFAT_SB(sb
)->bd_info
);
312 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
317 /* Fake . and .. for the root directory. */
318 if ((p_fs
->vol_type
== EXFAT
) || (inode
->i_ino
== EXFAT_ROOT_INO
)) {
320 if (inode
->i_ino
== EXFAT_ROOT_INO
)
321 inum
= EXFAT_ROOT_INO
;
324 else /* (cpos == 1) */
325 inum
= parent_ino(filp
->f_path
.dentry
);
327 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
328 if (!dir_emit_dots(filp
, ctx
))
330 if (filldir(dirent
, "..", cpos
+1, cpos
, inum
, DT_DIR
) < 0)
334 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
344 if (cpos
& (DENTRY_SIZE
- 1)) {
350 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
351 EXFAT_I(inode
)->fid
.rwoffset
= cpos
>> DENTRY_SIZE_BITS
;
353 err
= FsReadDir(inode
, &de
);
355 /* at least we tried to read a sector
356 * move cpos to next sector position (should be aligned)
358 if (err
== FFS_MEDIAERR
) {
359 cpos
+= 1 << p_bd
->sector_size_bits
;
360 cpos
&= ~((1 << p_bd
->sector_size_bits
)-1);
367 cpos
= EXFAT_I(inode
)->fid
.rwoffset
<< DENTRY_SIZE_BITS
;
372 if (!memcmp(de
.ShortName
, DOS_CUR_DIR_NAME
, DOS_NAME_LENGTH
)) {
374 } else if (!memcmp(de
.ShortName
, DOS_PAR_DIR_NAME
, DOS_NAME_LENGTH
)) {
375 inum
= parent_ino(filp
->f_path
.dentry
);
377 loff_t i_pos
= ((loff_t
) EXFAT_I(inode
)->fid
.start_clu
<< 32) |
378 ((EXFAT_I(inode
)->fid
.rwoffset
-1) & 0xffffffff);
380 struct inode
*tmp
= exfat_iget(sb
, i_pos
);
385 inum
= iunique(sb
, EXFAT_ROOT_INO
);
389 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
390 if (!dir_emit(ctx
, de
.Name
, strlen(de
.Name
), inum
,
391 (de
.Attr
& ATTR_SUBDIR
) ? DT_DIR
: DT_REG
))
393 if (filldir(dirent
, de
.Name
, strlen(de
.Name
), cpos
-1, inum
,
394 (de
.Attr
& ATTR_SUBDIR
) ? DT_DIR
: DT_REG
) < 0)
398 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
406 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
416 static int exfat_ioctl_volume_id(struct inode
*dir
)
418 struct super_block
*sb
= dir
->i_sb
;
419 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
420 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
425 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
426 static int exfat_generic_ioctl(struct inode
*inode
, struct file
*filp
,
427 unsigned int cmd
, unsigned long arg
)
429 static long exfat_generic_ioctl(struct file
*filp
,
430 unsigned int cmd
, unsigned long arg
)
433 #if EXFAT_CONFIG_KERNEL_DEBUG
434 #if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
435 struct inode
*inode
= filp
->f_dentry
->d_inode
;
438 #endif /* EXFAT_CONFIG_KERNEL_DEBUG */
441 case EXFAT_IOCTL_GET_VOLUME_ID
:
442 return exfat_ioctl_volume_id(inode
);
443 #if EXFAT_CONFIG_KERNEL_DEBUG
444 case EXFAT_IOC_GET_DEBUGFLAGS
: {
445 struct super_block
*sb
= inode
->i_sb
;
446 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
448 flags
= sbi
->debug_flags
;
449 return put_user(flags
, (int __user
*)arg
);
451 case EXFAT_IOC_SET_DEBUGFLAGS
: {
452 struct super_block
*sb
= inode
->i_sb
;
453 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
455 if (!capable(CAP_SYS_ADMIN
))
458 if (get_user(flags
, (int __user
*) arg
))
462 sbi
->debug_flags
= flags
;
467 #endif /* EXFAT_CONFIG_KERNEL_DEBUG */
469 return -ENOTTY
; /* Inappropriate ioctl for device */
473 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
474 static int exfat_file_fsync(struct file
*filp
, int datasync
)
476 struct inode
*inode
= filp
->f_mapping
->host
;
477 struct super_block
*sb
= inode
->i_sb
;
480 res
= generic_file_fsync(filp
, datasync
);
481 err
= FsSyncVol(sb
, 1);
483 return res
? res
: err
;
487 const struct file_operations exfat_dir_operations
= {
488 .llseek
= generic_file_llseek
,
489 .read
= generic_read_dir
,
490 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
491 .iterate
= exfat_readdir
,
493 .readdir
= exfat_readdir
,
495 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
496 .ioctl
= exfat_generic_ioctl
,
497 .fsync
= exfat_file_fsync
,
499 .unlocked_ioctl
= exfat_generic_ioctl
,
500 .fsync
= generic_file_fsync
,
504 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,00)
505 static int exfat_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
,
507 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
508 static int exfat_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
,
509 struct nameidata
*nd
)
511 static int exfat_create(struct inode
*dir
, struct dentry
*dentry
, int mode
,
512 struct nameidata
*nd
)
515 struct super_block
*sb
= dir
->i_sb
;
524 PRINTK("exfat_create entered\n");
526 ts
= CURRENT_TIME_SEC
;
528 err
= FsCreateFile(dir
, (UINT8
*) dentry
->d_name
.name
, FM_REGULAR
, &fid
);
530 if (err
== FFS_INVALIDPATH
)
532 else if (err
== FFS_FILEEXIST
)
534 else if (err
== FFS_FULL
)
536 else if (err
== FFS_NAMETOOLONG
)
543 dir
->i_ctime
= dir
->i_mtime
= dir
->i_atime
= ts
;
545 (void) exfat_sync_inode(dir
);
547 mark_inode_dirty(dir
);
549 i_pos
= ((loff_t
) fid
.dir
.dir
<< 32) | (fid
.entry
& 0xffffffff);
551 inode
= exfat_build_inode(sb
, &fid
, i_pos
);
553 err
= PTR_ERR(inode
);
557 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= ts
;
558 /* timestamp is already written, so mark_inode_dirty() is unnecessary. */
560 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
561 d_instantiate(dentry
, inode
);
565 PRINTK("exfat_create exited\n");
569 static int exfat_find(struct inode
*dir
, struct qstr
*qname
,
577 err
= FsLookupFile(dir
, (UINT8
*) qname
->name
, fid
);
584 static int exfat_d_anon_disconn(struct dentry
*dentry
)
586 return IS_ROOT(dentry
) && (dentry
->d_flags
& DCACHE_DISCONNECTED
);
589 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,00)
590 static struct dentry
*exfat_lookup(struct inode
*dir
, struct dentry
*dentry
,
593 static struct dentry
*exfat_lookup(struct inode
*dir
, struct dentry
*dentry
,
594 struct nameidata
*nd
)
597 struct super_block
*sb
= dir
->i_sb
;
599 struct dentry
*alias
;
607 PRINTK("exfat_lookup entered\n");
608 err
= exfat_find(dir
, &dentry
->d_name
, &fid
);
610 if (err
== -ENOENT
) {
617 i_pos
= ((loff_t
) fid
.dir
.dir
<< 32) | (fid
.entry
& 0xffffffff);
618 inode
= exfat_build_inode(sb
, &fid
, i_pos
);
620 err
= PTR_ERR(inode
);
624 i_mode
= inode
->i_mode
;
625 if (S_ISLNK(i_mode
)) {
626 EXFAT_I(inode
)->target
= MALLOC(i_size_read(inode
)+1);
627 if (!EXFAT_I(inode
)->target
) {
631 FsReadFile(dir
, &fid
, EXFAT_I(inode
)->target
, i_size_read(inode
), &ret
);
632 *(EXFAT_I(inode
)->target
+ i_size_read(inode
)) = '\0';
635 alias
= d_find_alias(inode
);
636 if (alias
&& !exfat_d_anon_disconn(alias
)) {
637 CHECK_ERR(d_unhashed(alias
));
638 if (!S_ISDIR(i_mode
))
639 d_move(alias
, dentry
);
642 PRINTK("exfat_lookup exited 1\n");
649 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
650 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
651 dentry
->d_op
= sb
->s_root
->d_op
;
652 dentry
= d_splice_alias(inode
, dentry
);
654 dentry
->d_op
= sb
->s_root
->d_op
;
655 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
658 dentry
= d_splice_alias(inode
, dentry
);
660 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
662 PRINTK("exfat_lookup exited 2\n");
667 PRINTK("exfat_lookup exited 3\n");
671 static int exfat_unlink(struct inode
*dir
, struct dentry
*dentry
)
673 struct inode
*inode
= dentry
->d_inode
;
674 struct super_block
*sb
= dir
->i_sb
;
680 PRINTK("exfat_unlink entered\n");
682 ts
= CURRENT_TIME_SEC
;
684 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
686 err
= FsRemoveFile(dir
, &(EXFAT_I(inode
)->fid
));
688 if (err
== FFS_PERMISSIONERR
)
695 dir
->i_mtime
= dir
->i_atime
= ts
;
697 (void) exfat_sync_inode(dir
);
699 mark_inode_dirty(dir
);
702 inode
->i_mtime
= inode
->i_atime
= ts
;
704 remove_inode_hash(inode
);
708 PRINTK("exfat_unlink exited\n");
712 static int exfat_symlink(struct inode
*dir
, struct dentry
*dentry
, const char *target
)
714 struct super_block
*sb
= dir
->i_sb
;
720 UINT64 len
= (UINT64
) strlen(target
);
725 PRINTK("exfat_symlink entered\n");
727 ts
= CURRENT_TIME_SEC
;
729 err
= FsCreateFile(dir
, (UINT8
*) dentry
->d_name
.name
, FM_SYMLINK
, &fid
);
731 if (err
== FFS_INVALIDPATH
)
733 else if (err
== FFS_FILEEXIST
)
735 else if (err
== FFS_FULL
)
742 err
= FsWriteFile(dir
, &fid
, (char *) target
, len
, &ret
);
745 FsRemoveFile(dir
, &fid
);
755 dir
->i_ctime
= dir
->i_mtime
= dir
->i_atime
= ts
;
757 (void) exfat_sync_inode(dir
);
759 mark_inode_dirty(dir
);
761 i_pos
= ((loff_t
) fid
.dir
.dir
<< 32) | (fid
.entry
& 0xffffffff);
763 inode
= exfat_build_inode(sb
, &fid
, i_pos
);
765 err
= PTR_ERR(inode
);
769 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= ts
;
770 /* timestamp is already written, so mark_inode_dirty() is unneeded. */
772 EXFAT_I(inode
)->target
= MALLOC(len
+1);
773 if (!EXFAT_I(inode
)->target
) {
777 MEMCPY(EXFAT_I(inode
)->target
, target
, len
+1);
779 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
780 d_instantiate(dentry
, inode
);
784 PRINTK("exfat_symlink exited\n");
788 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
789 static int exfat_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
791 static int exfat_mkdir(struct inode
*dir
, struct dentry
*dentry
, int mode
)
794 struct super_block
*sb
= dir
->i_sb
;
803 PRINTK("exfat_mkdir entered\n");
805 ts
= CURRENT_TIME_SEC
;
807 err
= FsCreateDir(dir
, (UINT8
*) dentry
->d_name
.name
, &fid
);
809 if (err
== FFS_INVALIDPATH
)
811 else if (err
== FFS_FILEEXIST
)
813 else if (err
== FFS_FULL
)
815 else if (err
== FFS_NAMETOOLONG
)
822 dir
->i_ctime
= dir
->i_mtime
= dir
->i_atime
= ts
;
824 (void) exfat_sync_inode(dir
);
826 mark_inode_dirty(dir
);
829 i_pos
= ((loff_t
) fid
.dir
.dir
<< 32) | (fid
.entry
& 0xffffffff);
831 inode
= exfat_build_inode(sb
, &fid
, i_pos
);
833 err
= PTR_ERR(inode
);
837 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= ts
;
838 /* timestamp is already written, so mark_inode_dirty() is unneeded. */
840 dentry
->d_time
= dentry
->d_parent
->d_inode
->i_version
;
841 d_instantiate(dentry
, inode
);
845 PRINTK("exfat_mkdir exited\n");
849 static int exfat_rmdir(struct inode
*dir
, struct dentry
*dentry
)
851 struct inode
*inode
= dentry
->d_inode
;
852 struct super_block
*sb
= dir
->i_sb
;
858 PRINTK("exfat_rmdir entered\n");
860 ts
= CURRENT_TIME_SEC
;
862 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
864 err
= FsRemoveDir(dir
, &(EXFAT_I(inode
)->fid
));
866 if (err
== FFS_INVALIDPATH
)
868 else if (err
== FFS_FILEEXIST
)
870 else if (err
== FFS_NOTFOUND
)
872 else if (err
== FFS_DIRBUSY
)
879 dir
->i_mtime
= dir
->i_atime
= ts
;
881 (void) exfat_sync_inode(dir
);
883 mark_inode_dirty(dir
);
887 inode
->i_mtime
= inode
->i_atime
= ts
;
889 remove_inode_hash(inode
);
893 PRINTK("exfat_rmdir exited\n");
897 static int exfat_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
898 struct inode
*new_dir
, struct dentry
*new_dentry
)
900 struct inode
*old_inode
, *new_inode
;
901 struct super_block
*sb
= old_dir
->i_sb
;
908 PRINTK("exfat_rename entered\n");
910 old_inode
= old_dentry
->d_inode
;
911 new_inode
= new_dentry
->d_inode
;
913 ts
= CURRENT_TIME_SEC
;
915 EXFAT_I(old_inode
)->fid
.size
= i_size_read(old_inode
);
917 err
= FsMoveFile(old_dir
, &(EXFAT_I(old_inode
)->fid
), new_dir
, new_dentry
);
919 if (err
== FFS_PERMISSIONERR
)
921 else if (err
== FFS_INVALIDPATH
)
923 else if (err
== FFS_FILEEXIST
)
925 else if (err
== FFS_NOTFOUND
)
927 else if (err
== FFS_FULL
)
933 new_dir
->i_version
++;
934 new_dir
->i_ctime
= new_dir
->i_mtime
= new_dir
->i_atime
= ts
;
935 if (IS_DIRSYNC(new_dir
))
936 (void) exfat_sync_inode(new_dir
);
938 mark_inode_dirty(new_dir
);
940 i_pos
= ((loff_t
) EXFAT_I(old_inode
)->fid
.dir
.dir
<< 32) |
941 (EXFAT_I(old_inode
)->fid
.entry
& 0xffffffff);
943 exfat_detach(old_inode
);
944 exfat_attach(old_inode
, i_pos
);
945 if (IS_DIRSYNC(new_dir
))
946 (void) exfat_sync_inode(old_inode
);
948 mark_inode_dirty(old_inode
);
950 if ((S_ISDIR(old_inode
->i_mode
)) && (old_dir
!= new_dir
)) {
952 if (!new_inode
) inc_nlink(new_dir
);
955 old_dir
->i_version
++;
956 old_dir
->i_ctime
= old_dir
->i_mtime
= ts
;
957 if (IS_DIRSYNC(old_dir
))
958 (void) exfat_sync_inode(old_dir
);
960 mark_inode_dirty(old_dir
);
963 exfat_detach(new_inode
);
964 drop_nlink(new_inode
);
965 if (S_ISDIR(new_inode
->i_mode
))
966 drop_nlink(new_inode
);
967 new_inode
->i_ctime
= ts
;
972 PRINTK("exfat_rename exited\n");
976 static int exfat_cont_expand(struct inode
*inode
, loff_t size
)
978 struct address_space
*mapping
= inode
->i_mapping
;
979 loff_t start
= i_size_read(inode
), count
= size
- i_size_read(inode
);
982 if ((err
= generic_cont_expand_simple(inode
, size
)) != 0)
985 inode
->i_ctime
= inode
->i_mtime
= CURRENT_TIME_SEC
;
986 mark_inode_dirty(inode
);
988 if (IS_SYNC(inode
)) {
989 err
= filemap_fdatawrite_range(mapping
, start
, start
+ count
- 1);
990 err2
= sync_mapping_buffers(mapping
);
991 err
= (err
)?(err
):(err2
);
992 err2
= write_inode_now(inode
, 1);
993 err
= (err
)?(err
):(err2
);
995 err
= filemap_fdatawait_range(mapping
, start
, start
+ count
- 1);
1001 static int exfat_allow_set_time(struct exfat_sb_info
*sbi
, struct inode
*inode
)
1003 mode_t allow_utime
= sbi
->options
.allow_utime
;
1005 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
1006 if (!uid_eq(current_fsuid(), inode
->i_uid
))
1008 if (current_fsuid() != inode
->i_uid
)
1011 if (in_group_p(inode
->i_gid
))
1013 if (allow_utime
& MAY_WRITE
)
1017 /* use a default check */
1021 static int exfat_sanitize_mode(const struct exfat_sb_info
*sbi
,
1022 struct inode
*inode
, umode_t
*mode_ptr
)
1024 mode_t i_mode
, mask
, perm
;
1026 i_mode
= inode
->i_mode
;
1028 if (S_ISREG(i_mode
) || S_ISLNK(i_mode
))
1029 mask
= sbi
->options
.fs_fmask
;
1031 mask
= sbi
->options
.fs_dmask
;
1033 perm
= *mode_ptr
& ~(S_IFMT
| mask
);
1035 /* Of the r and x bits, all (subject to umask) must be present.*/
1036 if ((perm
& (S_IRUGO
| S_IXUGO
)) != (i_mode
& (S_IRUGO
|S_IXUGO
)))
1039 if (exfat_mode_can_hold_ro(inode
)) {
1040 /* Of the w bits, either all (subject to umask) or none must be present. */
1041 if ((perm
& S_IWUGO
) && ((perm
& S_IWUGO
) != (S_IWUGO
& ~mask
)))
1044 /* If exfat_mode_can_hold_ro(inode) is false, can't change w bits. */
1045 if ((perm
& S_IWUGO
) != (S_IWUGO
& ~mask
))
1049 *mode_ptr
&= S_IFMT
| perm
;
1054 static int exfat_setattr(struct dentry
*dentry
, struct iattr
*attr
)
1057 struct exfat_sb_info
*sbi
= EXFAT_SB(dentry
->d_sb
);
1058 struct inode
*inode
= dentry
->d_inode
;
1059 unsigned int ia_valid
;
1063 PRINTK("exfat_setattr entered\n");
1065 if ((attr
->ia_valid
& ATTR_SIZE
)
1066 && (attr
->ia_size
> i_size_read(inode
))) {
1067 error
= exfat_cont_expand(inode
, attr
->ia_size
);
1068 if (error
|| attr
->ia_valid
== ATTR_SIZE
)
1070 attr
->ia_valid
&= ~ATTR_SIZE
;
1073 ia_valid
= attr
->ia_valid
;
1075 if ((ia_valid
& (ATTR_MTIME_SET
| ATTR_ATIME_SET
| ATTR_TIMES_SET
))
1076 && exfat_allow_set_time(sbi
, inode
)) {
1077 attr
->ia_valid
&= ~(ATTR_MTIME_SET
| ATTR_ATIME_SET
| ATTR_TIMES_SET
);
1080 error
= inode_change_ok(inode
, attr
);
1081 attr
->ia_valid
= ia_valid
;
1086 if (((attr
->ia_valid
& ATTR_UID
) &&
1087 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
1088 (!uid_eq(attr
->ia_uid
, sbi
->options
.fs_uid
))) ||
1089 ((attr
->ia_valid
& ATTR_GID
) &&
1090 (!gid_eq(attr
->ia_gid
, sbi
->options
.fs_gid
))) ||
1092 (attr
->ia_uid
!= sbi
->options
.fs_uid
)) ||
1093 ((attr
->ia_valid
& ATTR_GID
) &&
1094 (attr
->ia_gid
!= sbi
->options
.fs_gid
)) ||
1096 ((attr
->ia_valid
& ATTR_MODE
) &&
1097 (attr
->ia_mode
& ~(S_IFREG
| S_IFLNK
| S_IFDIR
| S_IRWXUGO
)))) {
1102 * We don't return -EPERM here. Yes, strange, but this is too
1105 if (attr
->ia_valid
& ATTR_MODE
) {
1106 if (exfat_sanitize_mode(sbi
, inode
, &attr
->ia_mode
) < 0)
1107 attr
->ia_valid
&= ~ATTR_MODE
;
1110 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
1112 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
1114 error
= inode_setattr(inode
, attr
);
1116 if (attr
->ia_valid
& ATTR_SIZE
) {
1117 old_size
= i_size_read(inode
);
1118 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
1119 down_write(&EXFAT_I(inode
)->truncate_lock
);
1120 truncate_setsize(inode
, attr
->ia_size
);
1121 _exfat_truncate(inode
, old_size
);
1122 up_write(&EXFAT_I(inode
)->truncate_lock
);
1124 truncate_setsize(inode
, attr
->ia_size
);
1125 _exfat_truncate(inode
, old_size
);
1128 setattr_copy(inode
, attr
);
1129 mark_inode_dirty(inode
);
1132 PRINTK("exfat_setattr exited\n");
1136 static int exfat_getattr(struct vfsmount
*mnt
, struct dentry
*dentry
, struct kstat
*stat
)
1138 struct inode
*inode
= dentry
->d_inode
;
1140 PRINTK("exfat_getattr entered\n");
1142 generic_fillattr(inode
, stat
);
1143 stat
->blksize
= EXFAT_SB(inode
->i_sb
)->fs_info
.cluster_size
;
1145 PRINTK("exfat_getattr exited\n");
1149 const struct inode_operations exfat_dir_inode_operations
= {
1150 .create
= exfat_create
,
1151 .lookup
= exfat_lookup
,
1152 .unlink
= exfat_unlink
,
1153 .symlink
= exfat_symlink
,
1154 .mkdir
= exfat_mkdir
,
1155 .rmdir
= exfat_rmdir
,
1156 .rename
= exfat_rename
,
1157 .setattr
= exfat_setattr
,
1158 .getattr
= exfat_getattr
,
1161 /*======================================================================*/
1162 /* File Operations */
1163 /*======================================================================*/
1165 static void *exfat_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
1167 struct exfat_inode_info
*ei
= EXFAT_I(dentry
->d_inode
);
1168 nd_set_link(nd
, (char *)(ei
->target
));
1172 const struct inode_operations exfat_symlink_inode_operations
= {
1173 .readlink
= generic_readlink
,
1174 .follow_link
= exfat_follow_link
,
1177 static int exfat_file_release(struct inode
*inode
, struct file
*filp
)
1179 struct super_block
*sb
= inode
->i_sb
;
1181 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
1186 const struct file_operations exfat_file_operations
= {
1187 .llseek
= generic_file_llseek
,
1188 .read
= do_sync_read
,
1189 .write
= do_sync_write
,
1190 .aio_read
= generic_file_aio_read
,
1191 .aio_write
= generic_file_aio_write
,
1192 .mmap
= generic_file_mmap
,
1193 .release
= exfat_file_release
,
1194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
1195 .ioctl
= exfat_generic_ioctl
,
1196 .fsync
= exfat_file_fsync
,
1198 .unlocked_ioctl
= exfat_generic_ioctl
,
1199 .fsync
= generic_file_fsync
,
1201 .splice_read
= generic_file_splice_read
,
1204 static void _exfat_truncate(struct inode
*inode
, loff_t old_size
)
1206 struct super_block
*sb
= inode
->i_sb
;
1207 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
1208 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
1214 * This protects against truncating a file bigger than it was then
1215 * trying to write into the hole.
1217 if (EXFAT_I(inode
)->mmu_private
> i_size_read(inode
))
1218 EXFAT_I(inode
)->mmu_private
= i_size_read(inode
);
1220 if (EXFAT_I(inode
)->fid
.start_clu
== 0) goto out
;
1222 err
= FsTruncateFile(inode
, old_size
, i_size_read(inode
));
1225 inode
->i_ctime
= inode
->i_mtime
= CURRENT_TIME_SEC
;
1226 if (IS_DIRSYNC(inode
))
1227 (void) exfat_sync_inode(inode
);
1229 mark_inode_dirty(inode
);
1231 inode
->i_blocks
= ((i_size_read(inode
) + (p_fs
->cluster_size
- 1))
1232 & ~((loff_t
)p_fs
->cluster_size
- 1)) >> 9;
1237 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,36)
1238 static void exfat_truncate(struct inode
*inode
)
1240 _exfat_truncate(inode
, i_size_read(inode
));
1244 const struct inode_operations exfat_file_inode_operations
= {
1245 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,36)
1246 .truncate
= exfat_truncate
,
1248 .setattr
= exfat_setattr
,
1249 .getattr
= exfat_getattr
,
1252 /*======================================================================*/
1253 /* Address Space Operations */
1254 /*======================================================================*/
1256 static int exfat_bmap(struct inode
*inode
, sector_t sector
, sector_t
*phys
,
1257 unsigned long *mapped_blocks
, int *create
)
1259 struct super_block
*sb
= inode
->i_sb
;
1260 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
1261 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
1262 BD_INFO_T
*p_bd
= &(sbi
->bd_info
);
1263 const unsigned long blocksize
= sb
->s_blocksize
;
1264 const unsigned char blocksize_bits
= sb
->s_blocksize_bits
;
1265 sector_t last_block
;
1266 int err
, clu_offset
, sec_offset
;
1267 unsigned int cluster
;
1272 if ((p_fs
->vol_type
== FAT12
) || (p_fs
->vol_type
== FAT16
)) {
1273 if (inode
->i_ino
== EXFAT_ROOT_INO
) {
1274 if (sector
< (p_fs
->dentries_in_root
>> (p_bd
->sector_size_bits
-DENTRY_SIZE_BITS
))) {
1275 *phys
= sector
+ p_fs
->root_start_sector
;
1282 last_block
= (i_size_read(inode
) + (blocksize
- 1)) >> blocksize_bits
;
1283 if (sector
>= last_block
) {
1284 if (*create
== 0) return 0;
1289 clu_offset
= sector
>> p_fs
->sectors_per_clu_bits
; /* cluster offset */
1290 sec_offset
= sector
& (p_fs
->sectors_per_clu
- 1); /* sector offset in cluster */
1292 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
1294 err
= FsMapCluster(inode
, clu_offset
, &cluster
);
1297 if (err
== FFS_FULL
)
1301 } else if (cluster
!= CLUSTER_32(~0)) {
1302 *phys
= START_SECTOR(cluster
) + sec_offset
;
1303 *mapped_blocks
= p_fs
->sectors_per_clu
- sec_offset
;
1309 static int exfat_get_block(struct inode
*inode
, sector_t iblock
,
1310 struct buffer_head
*bh_result
, int create
)
1312 struct super_block
*sb
= inode
->i_sb
;
1313 unsigned long max_blocks
= bh_result
->b_size
>> inode
->i_blkbits
;
1315 unsigned long mapped_blocks
;
1320 err
= exfat_bmap(inode
, iblock
, &phys
, &mapped_blocks
, &create
);
1327 max_blocks
= min(mapped_blocks
, max_blocks
);
1329 EXFAT_I(inode
)->mmu_private
+= max_blocks
<< sb
->s_blocksize_bits
;
1330 set_buffer_new(bh_result
);
1332 map_bh(bh_result
, sb
, phys
);
1335 bh_result
->b_size
= max_blocks
<< sb
->s_blocksize_bits
;
1341 static int exfat_readpage(struct file
*file
, struct page
*page
)
1344 ret
= mpage_readpage(page
, exfat_get_block
);
1348 static int exfat_readpages(struct file
*file
, struct address_space
*mapping
,
1349 struct list_head
*pages
, unsigned nr_pages
)
1352 ret
= mpage_readpages(mapping
, pages
, nr_pages
, exfat_get_block
);
1356 static int exfat_writepage(struct page
*page
, struct writeback_control
*wbc
)
1359 ret
= block_write_full_page(page
, exfat_get_block
, wbc
);
1363 static int exfat_writepages(struct address_space
*mapping
,
1364 struct writeback_control
*wbc
)
1367 ret
= mpage_writepages(mapping
, wbc
, exfat_get_block
);
1371 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
1372 static void exfat_write_failed(struct address_space
*mapping
, loff_t to
)
1374 struct inode
*inode
= mapping
->host
;
1375 if (to
> i_size_read(inode
)) {
1376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
1377 truncate_pagecache(inode
, i_size_read(inode
));
1379 truncate_pagecache(inode
, to
, i_size_read(inode
));
1381 EXFAT_I(inode
)->fid
.size
= i_size_read(inode
);
1382 _exfat_truncate(inode
, i_size_read(inode
));
1388 static int exfat_write_begin(struct file
*file
, struct address_space
*mapping
,
1389 loff_t pos
, unsigned len
, unsigned flags
,
1390 struct page
**pagep
, void **fsdata
)
1394 ret
= cont_write_begin(file
, mapping
, pos
, len
, flags
, pagep
, fsdata
,
1396 &EXFAT_I(mapping
->host
)->mmu_private
);
1398 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
1400 exfat_write_failed(mapping
, pos
+len
);
1405 static int exfat_write_end(struct file
*file
, struct address_space
*mapping
,
1406 loff_t pos
, unsigned len
, unsigned copied
,
1407 struct page
*pagep
, void *fsdata
)
1409 struct inode
*inode
= mapping
->host
;
1410 FILE_ID_T
*fid
= &(EXFAT_I(inode
)->fid
);
1413 err
= generic_write_end(file
, mapping
, pos
, len
, copied
, pagep
, fsdata
);
1415 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
1417 exfat_write_failed(mapping
, pos
+len
);
1420 if (!(err
< 0) && !(fid
->attr
& ATTR_ARCHIVE
)) {
1421 inode
->i_mtime
= inode
->i_ctime
= CURRENT_TIME_SEC
;
1422 fid
->attr
|= ATTR_ARCHIVE
;
1423 mark_inode_dirty(inode
);
1428 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
1429 static ssize_t
exfat_direct_IO(int rw
, struct kiocb
*iocb
, struct iov_iter
*iter
,
1432 static ssize_t
exfat_direct_IO(int rw
, struct kiocb
*iocb
,
1433 const struct iovec
*iov
,
1434 loff_t offset
, unsigned long nr_segs
)
1437 struct inode
*inode
= iocb
->ki_filp
->f_mapping
->host
;
1438 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
1439 struct address_space
*mapping
= iocb
->ki_filp
->f_mapping
;
1444 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
1445 if (EXFAT_I(inode
)->mmu_private
< (offset
+ iov_iter_count(iter
)))
1447 if (EXFAT_I(inode
)->mmu_private
< (offset
+ iov_length(iov
, nr_segs
)))
1451 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,00)
1452 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
1453 ret
= blockdev_direct_IO(rw
, iocb
, inode
, iter
,
1454 offset
, exfat_get_block
);
1456 ret
= blockdev_direct_IO(rw
, iocb
, inode
, iov
,
1457 offset
, nr_segs
, exfat_get_block
);
1460 ret
= blockdev_direct_IO(rw
, iocb
, inode
, inode
->i_sb
->s_bdev
, iov
,
1461 offset
, nr_segs
, exfat_get_block
, NULL
);
1464 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
1465 if ((ret
< 0) && (rw
& WRITE
))
1466 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
1467 exfat_write_failed(mapping
, offset
+iov_iter_count(iter
));
1469 exfat_write_failed(mapping
, offset
+iov_length(iov
, nr_segs
));
1475 static sector_t
_exfat_bmap(struct address_space
*mapping
, sector_t block
)
1479 /* exfat_get_cluster() assumes the requested blocknr isn't truncated. */
1480 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
1481 down_read(&EXFAT_I(mapping
->host
)->truncate_lock
);
1482 blocknr
= generic_block_bmap(mapping
, block
, exfat_get_block
);
1483 up_read(&EXFAT_I(mapping
->host
)->truncate_lock
);
1485 down_read(&EXFAT_I(mapping
->host
)->i_alloc_sem
);
1486 blocknr
= generic_block_bmap(mapping
, block
, exfat_get_block
);
1487 up_read(&EXFAT_I(mapping
->host
)->i_alloc_sem
);
1493 const struct address_space_operations exfat_aops
= {
1494 .readpage
= exfat_readpage
,
1495 .readpages
= exfat_readpages
,
1496 .writepage
= exfat_writepage
,
1497 .writepages
= exfat_writepages
,
1498 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
1499 .sync_page
= block_sync_page
,
1501 .write_begin
= exfat_write_begin
,
1502 .write_end
= exfat_write_end
,
1503 .direct_IO
= exfat_direct_IO
,
1507 /*======================================================================*/
1508 /* Super Operations */
1509 /*======================================================================*/
1511 static inline unsigned long exfat_hash(loff_t i_pos
)
1513 return hash_32(i_pos
, EXFAT_HASH_BITS
);
1516 static struct inode
*exfat_iget(struct super_block
*sb
, loff_t i_pos
) {
1517 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
1518 struct exfat_inode_info
*info
;
1519 struct hlist_head
*head
= sbi
->inode_hashtable
+ exfat_hash(i_pos
);
1520 struct inode
*inode
= NULL
;
1521 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
1522 struct hlist_node
*node
;
1524 spin_lock(&sbi
->inode_hash_lock
);
1525 hlist_for_each_entry(info
, node
, head
, i_hash_fat
) {
1527 spin_lock(&sbi
->inode_hash_lock
);
1528 hlist_for_each_entry(info
, head
, i_hash_fat
) {
1530 CHECK_ERR(info
->vfs_inode
.i_sb
!= sb
);
1532 if (i_pos
!= info
->i_pos
)
1534 inode
= igrab(&info
->vfs_inode
);
1538 spin_unlock(&sbi
->inode_hash_lock
);
1542 static void exfat_attach(struct inode
*inode
, loff_t i_pos
)
1544 struct exfat_sb_info
*sbi
= EXFAT_SB(inode
->i_sb
);
1545 struct hlist_head
*head
= sbi
->inode_hashtable
+ exfat_hash(i_pos
);
1547 spin_lock(&sbi
->inode_hash_lock
);
1548 EXFAT_I(inode
)->i_pos
= i_pos
;
1549 hlist_add_head(&EXFAT_I(inode
)->i_hash_fat
, head
);
1550 spin_unlock(&sbi
->inode_hash_lock
);
1553 static void exfat_detach(struct inode
*inode
)
1555 struct exfat_sb_info
*sbi
= EXFAT_SB(inode
->i_sb
);
1557 spin_lock(&sbi
->inode_hash_lock
);
1558 hlist_del_init(&EXFAT_I(inode
)->i_hash_fat
);
1559 EXFAT_I(inode
)->i_pos
= 0;
1560 spin_unlock(&sbi
->inode_hash_lock
);
1563 /* doesn't deal with root inode */
1564 static int exfat_fill_inode(struct inode
*inode
, FILE_ID_T
*fid
)
1566 struct exfat_sb_info
*sbi
= EXFAT_SB(inode
->i_sb
);
1567 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
1570 memcpy(&(EXFAT_I(inode
)->fid
), fid
, sizeof(FILE_ID_T
));
1572 FsReadStat(inode
, &info
);
1574 EXFAT_I(inode
)->i_pos
= 0;
1575 EXFAT_I(inode
)->target
= NULL
;
1576 inode
->i_uid
= sbi
->options
.fs_uid
;
1577 inode
->i_gid
= sbi
->options
.fs_gid
;
1579 inode
->i_generation
= get_seconds();
1581 if (info
.Attr
& ATTR_SUBDIR
) { /* directory */
1582 inode
->i_generation
&= ~1;
1583 inode
->i_mode
= exfat_make_mode(sbi
, info
.Attr
, S_IRWXUGO
);
1584 inode
->i_op
= &exfat_dir_inode_operations
;
1585 inode
->i_fop
= &exfat_dir_operations
;
1587 i_size_write(inode
, info
.Size
);
1588 EXFAT_I(inode
)->mmu_private
= i_size_read(inode
);
1589 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,00)
1590 set_nlink(inode
,info
.NumSubdirs
);
1592 inode
->i_nlink
= info
.NumSubdirs
;
1594 } else if (info
.Attr
& ATTR_SYMLINK
) { /* symbolic link */
1595 inode
->i_generation
|= 1;
1596 inode
->i_mode
= exfat_make_mode(sbi
, info
.Attr
, S_IRWXUGO
);
1597 inode
->i_op
= &exfat_symlink_inode_operations
;
1599 i_size_write(inode
, info
.Size
);
1600 EXFAT_I(inode
)->mmu_private
= i_size_read(inode
);
1601 } else { /* regular file */
1602 inode
->i_generation
|= 1;
1603 inode
->i_mode
= exfat_make_mode(sbi
, info
.Attr
, S_IRWXUGO
);
1604 inode
->i_op
= &exfat_file_inode_operations
;
1605 inode
->i_fop
= &exfat_file_operations
;
1606 inode
->i_mapping
->a_ops
= &exfat_aops
;
1607 inode
->i_mapping
->nrpages
= 0;
1609 i_size_write(inode
, info
.Size
);
1610 EXFAT_I(inode
)->mmu_private
= i_size_read(inode
);
1612 exfat_save_attr(inode
, info
.Attr
);
1614 inode
->i_blocks
= ((i_size_read(inode
) + (p_fs
->cluster_size
- 1))
1615 & ~((loff_t
)p_fs
->cluster_size
- 1)) >> 9;
1617 exfat_time_fat2unix(sbi
, &inode
->i_mtime
, &info
.ModifyTimestamp
);
1618 exfat_time_fat2unix(sbi
, &inode
->i_ctime
, &info
.CreateTimestamp
);
1619 exfat_time_fat2unix(sbi
, &inode
->i_atime
, &info
.AccessTimestamp
);
1624 static struct inode
*exfat_build_inode(struct super_block
*sb
,
1625 FILE_ID_T
*fid
, loff_t i_pos
) {
1626 struct inode
*inode
;
1629 inode
= exfat_iget(sb
, i_pos
);
1632 inode
= new_inode(sb
);
1634 inode
= ERR_PTR(-ENOMEM
);
1637 inode
->i_ino
= iunique(sb
, EXFAT_ROOT_INO
);
1638 inode
->i_version
= 1;
1639 err
= exfat_fill_inode(inode
, fid
);
1642 inode
= ERR_PTR(err
);
1645 exfat_attach(inode
, i_pos
);
1646 insert_inode_hash(inode
);
1651 static int exfat_sync_inode(struct inode
*inode
)
1653 return exfat_write_inode(inode
, NULL
);
1656 static struct inode
*exfat_alloc_inode(struct super_block
*sb
) {
1657 struct exfat_inode_info
*ei
;
1659 ei
= kmem_cache_alloc(exfat_inode_cachep
, GFP_NOFS
);
1663 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
1664 init_rwsem(&ei
->truncate_lock
);
1667 return &ei
->vfs_inode
;
1670 static void exfat_destroy_inode(struct inode
*inode
)
1672 FREE(EXFAT_I(inode
)->target
);
1673 EXFAT_I(inode
)->target
= NULL
;
1675 kmem_cache_free(exfat_inode_cachep
, EXFAT_I(inode
));
1678 static int exfat_write_inode(struct inode
*inode
, struct writeback_control
*wbc
)
1680 struct super_block
*sb
= inode
->i_sb
;
1681 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
1684 if (inode
->i_ino
== EXFAT_ROOT_INO
)
1687 info
.Attr
= exfat_make_attr(inode
);
1688 info
.Size
= i_size_read(inode
);
1690 exfat_time_unix2fat(sbi
, &inode
->i_mtime
, &info
.ModifyTimestamp
);
1691 exfat_time_unix2fat(sbi
, &inode
->i_ctime
, &info
.CreateTimestamp
);
1692 exfat_time_unix2fat(sbi
, &inode
->i_atime
, &info
.AccessTimestamp
);
1694 FsWriteStat(inode
, &info
);
1699 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
1700 static void exfat_delete_inode(struct inode
*inode
)
1702 truncate_inode_pages(&inode
->i_data
, 0);
1706 static void exfat_clear_inode(struct inode
*inode
)
1708 exfat_detach(inode
);
1709 remove_inode_hash(inode
);
1712 static void exfat_evict_inode(struct inode
*inode
)
1714 truncate_inode_pages(&inode
->i_data
, 0);
1716 if (!inode
->i_nlink
)
1717 i_size_write(inode
, 0);
1718 invalidate_inode_buffers(inode
);
1719 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
1720 end_writeback(inode
);
1724 exfat_detach(inode
);
1726 remove_inode_hash(inode
);
1730 static void exfat_free_super(struct exfat_sb_info
*sbi
)
1733 unload_nls(sbi
->nls_disk
);
1735 unload_nls(sbi
->nls_io
);
1736 if (sbi
->options
.iocharset
!= exfat_default_iocharset
)
1737 kfree(sbi
->options
.iocharset
);
1738 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
1739 /* mutex_init is in exfat_fill_super function. only for 3.7+ */
1740 mutex_destroy(&sbi
->s_lock
);
1745 static void exfat_put_super(struct super_block
*sb
)
1747 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
1748 if (__is_sb_dirty(sb
))
1749 exfat_write_super(sb
);
1753 sb
->s_fs_info
= NULL
;
1754 exfat_free_super(sbi
);
1757 static void exfat_write_super(struct super_block
*sb
)
1763 if (!(sb
->s_flags
& MS_RDONLY
))
1769 static int exfat_sync_fs(struct super_block
*sb
, int wait
)
1773 if (__is_sb_dirty(sb
)) {
1776 err
= FsSyncVol(sb
, 1);
1783 static int exfat_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
1785 struct super_block
*sb
= dentry
->d_sb
;
1786 u64 id
= huge_encode_dev(sb
->s_bdev
->bd_dev
);
1787 FS_INFO_T
*p_fs
= &(EXFAT_SB(sb
)->fs_info
);
1790 if (p_fs
->used_clusters
== (UINT32
) ~0) {
1791 if (FFS_MEDIAERR
== FsGetVolInfo(sb
, &info
))
1795 info
.FatType
= p_fs
->vol_type
;
1796 info
.ClusterSize
= p_fs
->cluster_size
;
1797 info
.NumClusters
= p_fs
->num_clusters
- 2;
1798 info
.UsedClusters
= p_fs
->used_clusters
;
1799 info
.FreeClusters
= info
.NumClusters
- info
.UsedClusters
;
1801 if (p_fs
->dev_ejected
)
1805 buf
->f_type
= sb
->s_magic
;
1806 buf
->f_bsize
= info
.ClusterSize
;
1807 buf
->f_blocks
= info
.NumClusters
;
1808 buf
->f_bfree
= info
.FreeClusters
;
1809 buf
->f_bavail
= info
.FreeClusters
;
1810 buf
->f_fsid
.val
[0] = (u32
)id
;
1811 buf
->f_fsid
.val
[1] = (u32
)(id
>> 32);
1812 buf
->f_namelen
= 260;
1817 static int exfat_remount(struct super_block
*sb
, int *flags
, char *data
)
1819 *flags
|= MS_NODIRATIME
;
1823 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
1824 static int exfat_show_options(struct seq_file
*m
, struct dentry
*root
)
1826 struct exfat_sb_info
*sbi
= EXFAT_SB(root
->d_sb
);
1828 static int exfat_show_options(struct seq_file
*m
, struct vfsmount
*mnt
)
1830 struct exfat_sb_info
*sbi
= EXFAT_SB(mnt
->mnt_sb
);
1832 struct exfat_mount_options
*opts
= &sbi
->options
;
1833 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
1834 if (__kuid_val(opts
->fs_uid
))
1835 seq_printf(m
, ",uid=%u", __kuid_val(opts
->fs_uid
));
1836 if (__kgid_val(opts
->fs_gid
))
1837 seq_printf(m
, ",gid=%u", __kgid_val(opts
->fs_gid
));
1839 if (opts
->fs_uid
!= 0)
1840 seq_printf(m
, ",uid=%u", opts
->fs_uid
);
1841 if (opts
->fs_gid
!= 0)
1842 seq_printf(m
, ",gid=%u", opts
->fs_gid
);
1844 seq_printf(m
, ",fmask=%04o", opts
->fs_fmask
);
1845 seq_printf(m
, ",dmask=%04o", opts
->fs_dmask
);
1846 if (opts
->allow_utime
)
1847 seq_printf(m
, ",allow_utime=%04o", opts
->allow_utime
);
1849 seq_printf(m
, ",codepage=%s", sbi
->nls_disk
->charset
);
1851 seq_printf(m
, ",iocharset=%s", sbi
->nls_io
->charset
);
1852 seq_printf(m
, ",namecase=%u", opts
->casesensitive
);
1853 if (opts
->errors
== EXFAT_ERRORS_CONT
)
1854 seq_puts(m
, ",errors=continue");
1855 else if (opts
->errors
== EXFAT_ERRORS_PANIC
)
1856 seq_puts(m
, ",errors=panic");
1858 seq_puts(m
, ",errors=remount-ro");
1859 #if EXFAT_CONFIG_DISCARD
1861 seq_printf(m
, ",discard");
1866 const struct super_operations exfat_sops
= {
1867 .alloc_inode
= exfat_alloc_inode
,
1868 .destroy_inode
= exfat_destroy_inode
,
1869 .write_inode
= exfat_write_inode
,
1870 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
1871 .delete_inode
= exfat_delete_inode
,
1872 .clear_inode
= exfat_clear_inode
,
1874 .evict_inode
= exfat_evict_inode
,
1876 .put_super
= exfat_put_super
,
1877 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
1878 .write_super
= exfat_write_super
,
1880 .sync_fs
= exfat_sync_fs
,
1881 .statfs
= exfat_statfs
,
1882 .remount_fs
= exfat_remount
,
1883 .show_options
= exfat_show_options
,
1886 /*======================================================================*/
1887 /* Super Block Read Operations */
1888 /*======================================================================*/
1905 #if EXFAT_CONFIG_DISCARD
1907 #endif /* EXFAT_CONFIG_DISCARD */
1910 static const match_table_t exfat_tokens
= {
1911 {Opt_uid
, "uid=%u"},
1912 {Opt_gid
, "gid=%u"},
1913 {Opt_umask
, "umask=%o"},
1914 {Opt_dmask
, "dmask=%o"},
1915 {Opt_fmask
, "fmask=%o"},
1916 {Opt_allow_utime
, "allow_utime=%o"},
1917 {Opt_codepage
, "codepage=%u"},
1918 {Opt_charset
, "iocharset=%s"},
1919 {Opt_namecase
, "namecase=%u"},
1920 {Opt_debug
, "debug"},
1921 {Opt_err_cont
, "errors=continue"},
1922 {Opt_err_panic
, "errors=panic"},
1923 {Opt_err_ro
, "errors=remount-ro"},
1924 #if EXFAT_CONFIG_DISCARD
1925 {Opt_discard
, "discard"},
1926 #endif /* EXFAT_CONFIG_DISCARD */
1930 static int parse_options(char *options
, int silent
, int *debug
,
1931 struct exfat_mount_options
*opts
)
1934 substring_t args
[MAX_OPT_ARGS
];
1938 opts
->fs_uid
= current_uid();
1939 opts
->fs_gid
= current_gid();
1940 opts
->fs_fmask
= opts
->fs_dmask
= current
->fs
->umask
;
1941 opts
->allow_utime
= (unsigned short) -1;
1942 opts
->codepage
= exfat_default_codepage
;
1943 opts
->iocharset
= exfat_default_iocharset
;
1944 opts
->casesensitive
= 0;
1945 opts
->errors
= EXFAT_ERRORS_RO
;
1946 #if EXFAT_CONFIG_DISCARD
1954 while ((p
= strsep(&options
, ",")) != NULL
) {
1959 token
= match_token(p
, exfat_tokens
, args
);
1962 if (match_int(&args
[0], &option
))
1964 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
1965 opts
->fs_uid
= KUIDT_INIT(option
);
1967 opts
->fs_uid
= option
;
1971 if (match_int(&args
[0], &option
))
1973 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
1974 opts
->fs_gid
= KGIDT_INIT(option
);
1976 opts
->fs_gid
= option
;
1982 if (match_octal(&args
[0], &option
))
1984 if (token
!= Opt_dmask
)
1985 opts
->fs_fmask
= option
;
1986 if (token
!= Opt_fmask
)
1987 opts
->fs_dmask
= option
;
1989 case Opt_allow_utime
:
1990 if (match_octal(&args
[0], &option
))
1992 opts
->allow_utime
= option
& (S_IWGRP
| S_IWOTH
);
1995 if (match_int(&args
[0], &option
))
1997 opts
->codepage
= option
;
2000 if (opts
->iocharset
!= exfat_default_iocharset
)
2001 kfree(opts
->iocharset
);
2002 iocharset
= match_strdup(&args
[0]);
2005 opts
->iocharset
= iocharset
;
2008 if (match_int(&args
[0], &option
))
2010 opts
->casesensitive
= option
;
2013 opts
->errors
= EXFAT_ERRORS_CONT
;
2016 opts
->errors
= EXFAT_ERRORS_PANIC
;
2019 opts
->errors
= EXFAT_ERRORS_RO
;
2024 #if EXFAT_CONFIG_DISCARD
2028 #endif /* EXFAT_CONFIG_DISCARD */
2031 printk(KERN_ERR
"[EXFAT] Unrecognized mount option %s or missing value\n", p
);
2038 if (opts
->allow_utime
== (unsigned short) -1)
2039 opts
->allow_utime
= ~opts
->fs_dmask
& (S_IWGRP
| S_IWOTH
);
2044 static void exfat_hash_init(struct super_block
*sb
)
2046 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
2049 spin_lock_init(&sbi
->inode_hash_lock
);
2050 for (i
= 0; i
< EXFAT_HASH_SIZE
; i
++)
2051 INIT_HLIST_HEAD(&sbi
->inode_hashtable
[i
]);
2054 static int exfat_read_root(struct inode
*inode
)
2056 struct super_block
*sb
= inode
->i_sb
;
2057 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
2059 FS_INFO_T
*p_fs
= &(sbi
->fs_info
);
2062 ts
= CURRENT_TIME_SEC
;
2064 EXFAT_I(inode
)->fid
.dir
.dir
= p_fs
->root_dir
;
2065 EXFAT_I(inode
)->fid
.dir
.flags
= 0x01;
2066 EXFAT_I(inode
)->fid
.entry
= -1;
2067 EXFAT_I(inode
)->fid
.start_clu
= p_fs
->root_dir
;
2068 EXFAT_I(inode
)->fid
.flags
= 0x01;
2069 EXFAT_I(inode
)->fid
.type
= TYPE_DIR
;
2070 EXFAT_I(inode
)->fid
.rwoffset
= 0;
2071 EXFAT_I(inode
)->fid
.hint_last_off
= -1;
2073 EXFAT_I(inode
)->target
= NULL
;
2075 FsReadStat(inode
, &info
);
2077 inode
->i_uid
= sbi
->options
.fs_uid
;
2078 inode
->i_gid
= sbi
->options
.fs_gid
;
2080 inode
->i_generation
= 0;
2081 inode
->i_mode
= exfat_make_mode(sbi
, ATTR_SUBDIR
, S_IRWXUGO
);
2082 inode
->i_op
= &exfat_dir_inode_operations
;
2083 inode
->i_fop
= &exfat_dir_operations
;
2085 i_size_write(inode
, info
.Size
);
2086 inode
->i_blocks
= ((i_size_read(inode
) + (p_fs
->cluster_size
- 1))
2087 & ~((loff_t
)p_fs
->cluster_size
- 1)) >> 9;
2088 EXFAT_I(inode
)->i_pos
= ((loff_t
) p_fs
->root_dir
<< 32) | 0xffffffff;
2089 EXFAT_I(inode
)->mmu_private
= i_size_read(inode
);
2091 exfat_save_attr(inode
, ATTR_SUBDIR
);
2092 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= ts
;
2093 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,00)
2094 set_nlink(inode
,info
.NumSubdirs
+ 2);
2096 inode
->i_nlink
= info
.NumSubdirs
+ 2;
2102 static int exfat_fill_super(struct super_block
*sb
, void *data
, int silent
)
2104 struct inode
*root_inode
= NULL
;
2105 struct exfat_sb_info
*sbi
;
2111 * GFP_KERNEL is ok here, because while we do hold the
2112 * supeblock lock, memory pressure can't call back into
2113 * the filesystem, since we're only just about to mount
2114 * it and have no inodes etc active!
2116 sbi
= kzalloc(sizeof(struct exfat_sb_info
), GFP_KERNEL
);
2119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
2120 mutex_init(&sbi
->s_lock
);
2122 sb
->s_fs_info
= sbi
;
2124 sb
->s_flags
|= MS_NODIRATIME
;
2125 sb
->s_magic
= EXFAT_SUPER_MAGIC
;
2126 sb
->s_op
= &exfat_sops
;
2128 error
= parse_options(data
, silent
, &debug
, &sbi
->options
);
2133 sb_min_blocksize(sb
, 512);
2134 sb
->s_maxbytes
= 0x7fffffffffffffffLL
; // maximum file size
2136 ret
= FsMountVol(sb
);
2139 printk(KERN_ERR
"[EXFAT] FsMountVol failed\n");
2144 /* set up enough so that it can read an inode */
2145 exfat_hash_init(sb
);
2148 * The low byte of FAT's first entry must have same value with
2149 * media-field. But in real world, too many devices is
2150 * writing wrong value. So, removed that validity check.
2152 * if (FAT_FIRST_ENT(sb, media) != first)
2155 if (sbi
->fs_info
.vol_type
!= EXFAT
) {
2157 sprintf(buf
, "cp%d", sbi
->options
.codepage
);
2158 sbi
->nls_disk
= load_nls(buf
);
2159 if (!sbi
->nls_disk
) {
2160 printk(KERN_ERR
"[EXFAT] Codepage %s not found\n", buf
);
2165 sbi
->nls_io
= load_nls(sbi
->options
.iocharset
);
2168 root_inode
= new_inode(sb
);
2171 root_inode
->i_ino
= EXFAT_ROOT_INO
;
2172 root_inode
->i_version
= 1;
2173 error
= exfat_read_root(root_inode
);
2177 exfat_attach(root_inode
, EXFAT_I(root_inode
)->i_pos
);
2178 insert_inode_hash(root_inode
);
2179 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
2180 sb
->s_root
= d_make_root(root_inode
);
2182 sb
->s_root
= d_alloc_root(root_inode
);
2185 printk(KERN_ERR
"[EXFAT] Getting the root inode failed\n");
2196 sb
->s_fs_info
= NULL
;
2197 exfat_free_super(sbi
);
2200 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
2201 static int exfat_get_sb(struct file_system_type
*fs_type
,
2202 int flags
, const char *dev_name
,
2203 void *data
, struct vfsmount
*mnt
)
2205 return get_sb_bdev(fs_type
, flags
, dev_name
, data
, exfat_fill_super
, mnt
);
2208 static struct dentry
*exfat_fs_mount(struct file_system_type
*fs_type
,
2209 int flags
, const char *dev_name
,
2211 return mount_bdev(fs_type
, flags
, dev_name
, data
, exfat_fill_super
);
2215 static void init_once(void *foo
)
2217 struct exfat_inode_info
*ei
= (struct exfat_inode_info
*)foo
;
2219 INIT_HLIST_NODE(&ei
->i_hash_fat
);
2220 inode_init_once(&ei
->vfs_inode
);
2223 static int __init
exfat_init_inodecache(void)
2225 exfat_inode_cachep
= kmem_cache_create("exfat_inode_cache",
2226 sizeof(struct exfat_inode_info
),
2227 0, (SLAB_RECLAIM_ACCOUNT
|
2230 if (exfat_inode_cachep
== NULL
)
2235 static void __exit
exfat_destroy_inodecache(void)
2237 kmem_cache_destroy(exfat_inode_cachep
);
2240 #if EXFAT_CONFIG_KERNEL_DEBUG
2241 static void exfat_debug_kill_sb(struct super_block
*sb
)
2243 struct exfat_sb_info
*sbi
= EXFAT_SB(sb
);
2244 struct block_device
*bdev
= sb
->s_bdev
;
2249 flags
= sbi
->debug_flags
;
2251 if (flags
& EXFAT_DEBUGFLAGS_INVALID_UMOUNT
) {
2252 /* invalidate_bdev drops all device cache include dirty.
2253 we use this to simulate device removal */
2255 invalidate_bdev(bdev
);
2259 kill_block_super(sb
);
2261 #endif /* EXFAT_CONFIG_KERNEL_DEBUG */
2263 static struct file_system_type exfat_fs_type
= {
2264 .owner
= THIS_MODULE
,
2266 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
2267 .get_sb
= exfat_get_sb
,
2269 .mount
= exfat_fs_mount
,
2271 #if EXFAT_CONFIG_KERNEL_DEBUG
2272 .kill_sb
= exfat_debug_kill_sb
,
2274 .kill_sb
= kill_block_super
,
2275 #endif /* EXFAT_CONFIG_KERNLE_DEBUG */
2276 .fs_flags
= FS_REQUIRES_DEV
,
2279 static int __init
init_exfat(void)
2285 if (err
== FFS_MEMORYERR
)
2291 printk(KERN_INFO
"exFAT: Version %s\n", EXFAT_VERSION
);
2293 err
= exfat_init_inodecache();
2296 err
= register_filesystem(&exfat_fs_type
);
2305 static void __exit
exit_exfat(void)
2307 exfat_destroy_inodecache();
2308 unregister_filesystem(&exfat_fs_type
);
2312 module_init(init_exfat
);
2313 module_exit(exit_exfat
);
2315 MODULE_LICENSE("GPL");
2316 MODULE_DESCRIPTION("exFAT Filesystem Driver");
2317 #ifdef MODULE_ALIAS_FS
2318 MODULE_ALIAS_FS("exfat");