sdfat.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /*
  2. * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _SDFAT_H
  18. #define _SDFAT_H
  19. #include <linux/buffer_head.h>
  20. #include <linux/string.h>
  21. #include <linux/types.h>
  22. #include <linux/nls.h>
  23. #include <linux/fs.h>
  24. #include <linux/mutex.h>
  25. #include <linux/ratelimit.h>
  26. #include <linux/version.h>
  27. #include <linux/kobject.h>
  28. #include "api.h"
  29. #ifdef CONFIG_SDFAT_DFR
  30. #include "dfr.h"
  31. #endif
  32. /*
  33. * sdfat error flags
  34. */
  35. #define SDFAT_ERRORS_CONT (1) /* ignore error and continue */
  36. #define SDFAT_ERRORS_PANIC (2) /* panic on error */
  37. #define SDFAT_ERRORS_RO (3) /* remount r/o on error */
  38. /*
  39. * sdfat allocator flags
  40. */
  41. #define SDFAT_ALLOC_DELAY (1) /* Delayed allocation */
  42. #define SDFAT_ALLOC_SMART (2) /* Smart allocation */
  43. /*
  44. * sdfat allocator destination for smart allocation
  45. */
  46. #define ALLOC_NOWHERE (0)
  47. #define ALLOC_COLD (1)
  48. #define ALLOC_HOT (16)
  49. #define ALLOC_COLD_ALIGNED (1)
  50. #define ALLOC_COLD_PACKING (2)
  51. #define ALLOC_COLD_SEQ (4)
  52. /*
  53. * sdfat nls lossy flag
  54. */
  55. #define NLS_NAME_NO_LOSSY (0x00) /* no lossy */
  56. #define NLS_NAME_LOSSY (0x01) /* just detected incorrect filename(s) */
  57. #define NLS_NAME_OVERLEN (0x02) /* the length is over than its limit */
  58. /*
  59. * sdfat common MACRO
  60. */
  61. #define CLUSTER_16(x) ((u16)((x) & 0xFFFFU))
  62. #define CLUSTER_32(x) ((u32)((x) & 0xFFFFFFFFU))
  63. #define CLUS_EOF CLUSTER_32(~0)
  64. #define CLUS_BAD (0xFFFFFFF7U)
  65. #define CLUS_FREE (0)
  66. #define CLUS_BASE (2)
  67. #define IS_CLUS_EOF(x) ((x) == CLUS_EOF)
  68. #define IS_CLUS_BAD(x) ((x) == CLUS_BAD)
  69. #define IS_CLUS_FREE(x) ((x) == CLUS_FREE)
  70. #define IS_LAST_SECT_IN_CLUS(fsi, sec) \
  71. ((((sec) - (fsi)->data_start_sector + 1) \
  72. & ((1 << (fsi)->sect_per_clus_bits) - 1)) == 0)
  73. #define CLUS_TO_SECT(fsi, x) \
  74. ((((unsigned long long)(x) - CLUS_BASE) << (fsi)->sect_per_clus_bits) + (fsi)->data_start_sector)
  75. #define SECT_TO_CLUS(fsi, sec) \
  76. ((u32)((((sec) - (fsi)->data_start_sector) >> (fsi)->sect_per_clus_bits) + CLUS_BASE))
  77. /* variables defined at sdfat.c */
  78. extern const char *FS_TYPE_STR[];
  79. enum {
  80. FS_TYPE_AUTO,
  81. FS_TYPE_EXFAT,
  82. FS_TYPE_VFAT,
  83. FS_TYPE_MAX
  84. };
  85. /*
  86. * sdfat mount in-memory data
  87. */
  88. struct sdfat_mount_options {
  89. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
  90. kuid_t fs_uid;
  91. kgid_t fs_gid;
  92. #else /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) */
  93. uid_t fs_uid;
  94. gid_t fs_gid;
  95. #endif
  96. unsigned short fs_fmask;
  97. unsigned short fs_dmask;
  98. unsigned short allow_utime; /* permission for setting the [am]time */
  99. unsigned short codepage; /* codepage for shortname conversions */
  100. char *iocharset; /* charset for filename input/display */
  101. struct {
  102. unsigned int pack_ratio;
  103. unsigned int sect_per_au;
  104. unsigned int misaligned_sect;
  105. } amap_opt; /* AMAP-related options (see amap.c) */
  106. unsigned char utf8;
  107. unsigned char casesensitive;
  108. unsigned char adj_hidsect;
  109. unsigned char tz_utc;
  110. unsigned char improved_allocation;
  111. unsigned char defrag;
  112. unsigned char symlink; /* support symlink operation */
  113. unsigned char errors; /* on error: continue, panic, remount-ro */
  114. unsigned char discard; /* flag on if -o dicard specified and device support discard() */
  115. unsigned char fs_type; /* fs_type that user specified */
  116. unsigned short adj_req; /* support aligned mpage write */
  117. };
  118. #define SDFAT_HASH_BITS 8
  119. #define SDFAT_HASH_SIZE (1UL << SDFAT_HASH_BITS)
  120. /*
  121. * SDFAT file system superblock in-memory data
  122. */
  123. struct sdfat_sb_info {
  124. FS_INFO_T fsi; /* private filesystem info */
  125. struct mutex s_vlock; /* volume lock */
  126. int use_vmalloc;
  127. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
  128. int s_dirt;
  129. struct mutex s_lock; /* superblock lock */
  130. int write_super_queued; /* Write_super work is pending? */
  131. struct delayed_work write_super_work; /* Work_queue data structrue for write_super() */
  132. spinlock_t work_lock; /* Lock for WQ */
  133. #endif
  134. struct super_block *host_sb; /* sb pointer */
  135. struct sdfat_mount_options options;
  136. struct nls_table *nls_disk; /* Codepage used on disk */
  137. struct nls_table *nls_io; /* Charset used for input and display */
  138. struct ratelimit_state ratelimit;
  139. spinlock_t inode_hash_lock;
  140. struct hlist_head inode_hashtable[SDFAT_HASH_SIZE];
  141. struct kobject sb_kobj;
  142. #ifdef CONFIG_SDFAT_DBG_IOCTL
  143. long debug_flags;
  144. #endif /* CONFIG_SDFAT_DBG_IOCTL */
  145. #ifdef CONFIG_SDFAT_DFR
  146. struct defrag_info dfr_info;
  147. struct completion dfr_complete;
  148. unsigned int *dfr_new_clus;
  149. int dfr_new_idx;
  150. unsigned int *dfr_page_wb;
  151. void **dfr_pagep;
  152. unsigned int dfr_hint_clus;
  153. unsigned int dfr_hint_idx;
  154. int dfr_reserved_clus;
  155. #ifdef CONFIG_SDFAT_DFR_DEBUG
  156. int dfr_spo_flag;
  157. #endif /* CONFIG_SDFAT_DFR_DEBUG */
  158. #endif /* CONFIG_SDFAT_DFR */
  159. #ifdef CONFIG_SDFAT_TRACE_IO
  160. /* Statistics for allocator */
  161. unsigned int stat_n_pages_written; /* # of written pages in total */
  162. unsigned int stat_n_pages_added; /* # of added blocks in total */
  163. unsigned int stat_n_bdev_pages_written; /* # of written pages owned by bdev inode */
  164. unsigned int stat_n_pages_confused;
  165. #endif
  166. atomic_t stat_n_pages_queued; /* # of pages in the request queue (approx.) */
  167. };
  168. /*
  169. * SDFAT file system inode in-memory data
  170. */
  171. struct sdfat_inode_info {
  172. FILE_ID_T fid;
  173. char *target;
  174. /* NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access */
  175. loff_t i_size_ondisk; /* physically allocated size */
  176. loff_t i_size_aligned; /* block-aligned i_size (used in cont_write_begin) */
  177. loff_t i_pos; /* on-disk position of directory entry or 0 */
  178. struct hlist_node i_hash_fat; /* hash by i_location */
  179. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
  180. struct rw_semaphore truncate_lock; /* protect bmap against truncate */
  181. #endif
  182. #ifdef CONFIG_SDFAT_DFR
  183. struct defrag_info dfr_info;
  184. #endif
  185. struct inode vfs_inode;
  186. };
  187. #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
  188. typedef struct timespec64 sdfat_timespec_t;
  189. #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) */
  190. typedef struct timespec sdfat_timespec_t;
  191. #endif
  192. /*
  193. * FIXME : needs on-disk-slot in-memory data
  194. */
  195. /* static inline functons */
  196. static inline const char *sdfat_get_vol_type_str(unsigned int type)
  197. {
  198. if (type == EXFAT)
  199. return "exfat";
  200. else if (type == FAT32)
  201. return "vfat:32";
  202. else if (type == FAT16)
  203. return "vfat:16";
  204. else if (type == FAT12)
  205. return "vfat:12";
  206. return "unknown";
  207. }
  208. static inline struct sdfat_sb_info *SDFAT_SB(struct super_block *sb)
  209. {
  210. return (struct sdfat_sb_info *)sb->s_fs_info;
  211. }
  212. static inline struct sdfat_inode_info *SDFAT_I(struct inode *inode)
  213. {
  214. return container_of(inode, struct sdfat_inode_info, vfs_inode);
  215. }
  216. /*
  217. * If ->i_mode can't hold S_IWUGO (i.e. ATTR_RO), we use ->i_attrs to
  218. * save ATTR_RO instead of ->i_mode.
  219. *
  220. * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
  221. * bit, it's just used as flag for app.
  222. */
  223. static inline int sdfat_mode_can_hold_ro(struct inode *inode)
  224. {
  225. struct sdfat_sb_info *sbi = SDFAT_SB(inode->i_sb);
  226. if (S_ISDIR(inode->i_mode))
  227. return 0;
  228. if ((~sbi->options.fs_fmask) & S_IWUGO)
  229. return 1;
  230. return 0;
  231. }
  232. /*
  233. * FIXME : needs to check symlink option.
  234. */
  235. /* Convert attribute bits and a mask to the UNIX mode. */
  236. static inline mode_t sdfat_make_mode(struct sdfat_sb_info *sbi,
  237. u32 attr, mode_t mode)
  238. {
  239. if ((attr & ATTR_READONLY) && !(attr & ATTR_SUBDIR))
  240. mode &= ~S_IWUGO;
  241. if (attr & ATTR_SUBDIR)
  242. return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
  243. else if (attr & ATTR_SYMLINK)
  244. return (mode & ~sbi->options.fs_dmask) | S_IFLNK;
  245. else
  246. return (mode & ~sbi->options.fs_fmask) | S_IFREG;
  247. }
  248. /* Return the FAT attribute byte for this inode */
  249. static inline u32 sdfat_make_attr(struct inode *inode)
  250. {
  251. u32 attrs = SDFAT_I(inode)->fid.attr;
  252. if (S_ISDIR(inode->i_mode))
  253. attrs |= ATTR_SUBDIR;
  254. if (sdfat_mode_can_hold_ro(inode) && !(inode->i_mode & S_IWUGO))
  255. attrs |= ATTR_READONLY;
  256. return attrs;
  257. }
  258. static inline void sdfat_save_attr(struct inode *inode, u32 attr)
  259. {
  260. if (sdfat_mode_can_hold_ro(inode))
  261. SDFAT_I(inode)->fid.attr = attr & ATTR_RWMASK;
  262. else
  263. SDFAT_I(inode)->fid.attr = attr & (ATTR_RWMASK | ATTR_READONLY);
  264. }
  265. /* sdfat/statistics.c */
  266. /* bigdata function */
  267. #ifdef CONFIG_SDFAT_STATISTICS
  268. extern int sdfat_statistics_init(struct kset *sdfat_kset);
  269. extern void sdfat_statistics_uninit(void);
  270. extern void sdfat_statistics_set_mnt(FS_INFO_T *fsi);
  271. extern void sdfat_statistics_set_mnt_ro(void);
  272. extern void sdfat_statistics_set_mkdir(u8 flags);
  273. extern void sdfat_statistics_set_create(u8 flags);
  274. extern void sdfat_statistics_set_rw(u8 flags, u32 clu_offset, s32 create);
  275. extern void sdfat_statistics_set_trunc(u8 flags, CHAIN_T *clu);
  276. extern void sdfat_statistics_set_vol_size(struct super_block *sb);
  277. #else
  278. static inline int sdfat_statistics_init(struct kset *sdfat_kset)
  279. {
  280. return 0;
  281. }
  282. static inline void sdfat_statistics_uninit(void) {};
  283. static inline void sdfat_statistics_set_mnt(FS_INFO_T *fsi) {};
  284. static inline void sdfat_statistics_set_mnt_ro(void) {};
  285. static inline void sdfat_statistics_set_mkdir(u8 flags) {};
  286. static inline void sdfat_statistics_set_create(u8 flags) {};
  287. static inline void sdfat_statistics_set_rw(u8 flags, u32 clu_offset, s32 create) {};
  288. static inline void sdfat_statistics_set_trunc(u8 flags, CHAIN_T *clu) {};
  289. static inline void sdfat_statistics_set_vol_size(struct super_block *sb) {};
  290. #endif
  291. /* sdfat/nls.c */
  292. /* NLS management function */
  293. s32 nls_cmp_sfn(struct super_block *sb, u8 *a, u8 *b);
  294. s32 nls_cmp_uniname(struct super_block *sb, u16 *a, u16 *b);
  295. s32 nls_uni16s_to_sfn(struct super_block *sb, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname, s32 *p_lossy);
  296. s32 nls_sfn_to_uni16s(struct super_block *sb, DOS_NAME_T *p_dosname, UNI_NAME_T *p_uniname);
  297. s32 nls_uni16s_to_vfsname(struct super_block *sb, UNI_NAME_T *uniname, u8 *p_cstring, s32 len);
  298. s32 nls_vfsname_to_uni16s(struct super_block *sb, const u8 *p_cstring,
  299. const s32 len, UNI_NAME_T *uniname, s32 *p_lossy);
  300. /* sdfat/mpage.c */
  301. #ifdef CONFIG_SDFAT_ALIGNED_MPAGE_WRITE
  302. int sdfat_mpage_writepages(struct address_space *mapping,
  303. struct writeback_control *wbc, get_block_t *get_block);
  304. #endif
  305. /* sdfat/xattr.c */
  306. #ifdef CONFIG_SDFAT_VIRTUAL_XATTR
  307. void setup_sdfat_xattr_handler(struct super_block *sb);
  308. extern int sdfat_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
  309. extern ssize_t sdfat_getxattr(struct dentry *dentry, const char *name, void *value, size_t size);
  310. extern ssize_t sdfat_listxattr(struct dentry *dentry, char *list, size_t size);
  311. extern int sdfat_removexattr(struct dentry *dentry, const char *name);
  312. #else
  313. static inline void setup_sdfat_xattr_handler(struct super_block *sb) {};
  314. #endif
  315. /* sdfat/misc.c */
  316. #ifdef CONFIG_SDFAT_UEVENT
  317. extern int sdfat_uevent_init(struct kset *sdfat_kset);
  318. extern void sdfat_uevent_uninit(void);
  319. extern void sdfat_uevent_ro_remount(struct super_block *sb);
  320. #else
  321. static inline int sdfat_uevent_init(struct kset *sdfat_kset)
  322. {
  323. return 0;
  324. }
  325. static inline void sdfat_uevent_uninit(void) {};
  326. static inline void sdfat_uevent_ro_remount(struct super_block *sb) {};
  327. #endif
  328. extern void
  329. __sdfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
  330. __printf(3, 4) __cold;
  331. #define sdfat_fs_error(sb, fmt, args...) \
  332. __sdfat_fs_error(sb, 1, fmt, ## args)
  333. #define sdfat_fs_error_ratelimit(sb, fmt, args...) \
  334. __sdfat_fs_error(sb, __ratelimit(&SDFAT_SB(sb)->ratelimit), fmt, ## args)
  335. extern void
  336. __sdfat_msg(struct super_block *sb, const char *lv, int st, const char *fmt, ...)
  337. __printf(4, 5) __cold;
  338. #define sdfat_msg(sb, lv, fmt, args...) \
  339. __sdfat_msg(sb, lv, 0, fmt, ## args)
  340. #define sdfat_log_msg(sb, lv, fmt, args...) \
  341. __sdfat_msg(sb, lv, 1, fmt, ## args)
  342. extern void sdfat_log_version(void);
  343. extern void sdfat_time_fat2unix(struct sdfat_sb_info *sbi, sdfat_timespec_t *ts,
  344. DATE_TIME_T *tp);
  345. extern void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, sdfat_timespec_t *ts,
  346. DATE_TIME_T *tp);
  347. extern TIMESTAMP_T *tm_now(struct sdfat_sb_info *sbi, TIMESTAMP_T *tm);
  348. #ifdef CONFIG_SDFAT_DEBUG
  349. #ifdef CONFIG_SDFAT_DBG_CAREFUL
  350. void sdfat_debug_check_clusters(struct inode *inode);
  351. #else
  352. #define sdfat_debug_check_clusters(inode)
  353. #endif /* CONFIG_SDFAT_DBG_CAREFUL */
  354. #ifdef CONFIG_SDFAT_DBG_BUGON
  355. #define sdfat_debug_bug_on(expr) BUG_ON(expr)
  356. #else
  357. #define sdfat_debug_bug_on(expr)
  358. #endif
  359. #ifdef CONFIG_SDFAT_DBG_WARNON
  360. #define sdfat_debug_warn_on(expr) WARN_ON(expr)
  361. #else
  362. #define sdfat_debug_warn_on(expr)
  363. #endif
  364. #else /* CONFIG_SDFAT_DEBUG */
  365. #define sdfat_debug_check_clusters(inode)
  366. #define sdfat_debug_bug_on(expr)
  367. #define sdfat_debug_warn_on(expr)
  368. #endif /* CONFIG_SDFAT_DEBUG */
  369. #ifdef CONFIG_SDFAT_TRACE_ELAPSED_TIME
  370. u32 sdfat_time_current_usec(struct timeval *tv);
  371. extern struct timeval __t1;
  372. extern struct timeval __t2;
  373. #define TIME_GET(tv) sdfat_time_current_usec(tv)
  374. #define TIME_START(s) sdfat_time_current_usec(s)
  375. #define TIME_END(e) sdfat_time_current_usec(e)
  376. #define TIME_ELAPSED(s, e) ((u32)(((e)->tv_sec - (s)->tv_sec) * 1000000 + \
  377. ((e)->tv_usec - (s)->tv_usec)))
  378. #define PRINT_TIME(n) pr_info("[SDFAT] Elapsed time %d = %d (usec)\n", n, (__t2 - __t1))
  379. #else /* CONFIG_SDFAT_TRACE_ELAPSED_TIME */
  380. #define TIME_GET(tv) (0)
  381. #define TIME_START(s)
  382. #define TIME_END(e)
  383. #define TIME_ELAPSED(s, e) (0)
  384. #define PRINT_TIME(n)
  385. #endif /* CONFIG_SDFAT_TRACE_ELAPSED_TIME */
  386. #define SDFAT_MSG_LV_NONE (0x00000000)
  387. #define SDFAT_MSG_LV_ERR (0x00000001)
  388. #define SDFAT_MSG_LV_INFO (0x00000002)
  389. #define SDFAT_MSG_LV_DBG (0x00000003)
  390. #define SDFAT_MSG_LV_MORE (0x00000004)
  391. #define SDFAT_MSG_LV_TRACE (0x00000005)
  392. #define SDFAT_MSG_LV_ALL (0x00000006)
  393. #define SDFAT_MSG_LEVEL SDFAT_MSG_LV_INFO
  394. #define SDFAT_TAG_NAME "SDFAT"
  395. #define __S(x) #x
  396. #define _S(x) __S(x)
  397. extern void __sdfat_dmsg(int level, const char *fmt, ...) __printf(2, 3) __cold;
  398. #define SDFAT_EMSG_T(level, ...) \
  399. __sdfat_dmsg(level, KERN_ERR "[" SDFAT_TAG_NAME "] [" _S(__FILE__) "(" _S(__LINE__) ")] " __VA_ARGS__)
  400. #define SDFAT_DMSG_T(level, ...) \
  401. __sdfat_dmsg(level, KERN_INFO "[" SDFAT_TAG_NAME "] " __VA_ARGS__)
  402. #define SDFAT_EMSG(...) SDFAT_EMSG_T(SDFAT_MSG_LV_ERR, __VA_ARGS__)
  403. #define SDFAT_IMSG(...) SDFAT_DMSG_T(SDFAT_MSG_LV_INFO, __VA_ARGS__)
  404. #define SDFAT_DMSG(...) SDFAT_DMSG_T(SDFAT_MSG_LV_DBG, __VA_ARGS__)
  405. #define SDFAT_MMSG(...) SDFAT_DMSG_T(SDFAT_MSG_LV_MORE, __VA_ARGS__)
  406. #define SDFAT_TMSG(...) SDFAT_DMSG_T(SDFAT_MSG_LV_TRACE, __VA_ARGS__)
  407. #define EMSG(...)
  408. #define IMSG(...)
  409. #define DMSG(...)
  410. #define MMSG(...)
  411. #define TMSG(...)
  412. #define EMSG_VAR(exp)
  413. #define IMSG_VAR(exp)
  414. #define DMSG_VAR(exp)
  415. #define MMSG_VAR(exp)
  416. #define TMSG_VAR(exp)
  417. #ifdef CONFIG_SDFAT_DBG_MSG
  418. #if (SDFAT_MSG_LEVEL >= SDFAT_MSG_LV_ERR)
  419. #undef EMSG
  420. #undef EMSG_VAR
  421. #define EMSG(...) SDFAT_EMSG(__VA_ARGS__)
  422. #define EMSG_VAR(exp) exp
  423. #endif
  424. #if (SDFAT_MSG_LEVEL >= SDFAT_MSG_LV_INFO)
  425. #undef IMSG
  426. #undef IMSG_VAR
  427. #define IMSG(...) SDFAT_IMSG(__VA_ARGS__)
  428. #define IMSG_VAR(exp) exp
  429. #endif
  430. #if (SDFAT_MSG_LEVEL >= SDFAT_MSG_LV_DBG)
  431. #undef DMSG
  432. #undef DMSG_VAR
  433. #define DMSG(...) SDFAT_DMSG(__VA_ARGS__)
  434. #define DMSG_VAR(exp) exp
  435. #endif
  436. #if (SDFAT_MSG_LEVEL >= SDFAT_MSG_LV_MORE)
  437. #undef MMSG
  438. #undef MMSG_VAR
  439. #define MMSG(...) SDFAT_MMSG(__VA_ARGS__)
  440. #define MMSG_VAR(exp) exp
  441. #endif
  442. /* should replace with trace function */
  443. #if (SDFAT_MSG_LEVEL >= SDFAT_MSG_LV_TRACE)
  444. #undef TMSG
  445. #undef TMSG_VAR
  446. #define TMSG(...) SDFAT_TMSG(__VA_ARGS__)
  447. #define TMSG_VAR(exp) exp
  448. #endif
  449. #endif /* CONFIG_SDFAT_DBG_MSG */
  450. #define ASSERT(expr) { \
  451. if (!(expr)) { \
  452. pr_err("Assertion failed! %s\n", #expr); \
  453. BUG_ON(1); \
  454. } \
  455. }
  456. #endif /* !_SDFAT_H */