yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git] / direct / ydirectenv.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Charles Manning <charles@aleph1.co.uk>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1 as
10  * published by the Free Software Foundation.
11  *
12  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
13  */
14
15 /*
16  * ydirectenv.h: Environment wrappers for YAFFS direct.
17  */
18
19 #ifndef __YDIRECTENV_H__
20 #define __YDIRECTENV_H__
21
22 #include "stdlib.h"
23 #include "stdio.h"
24 #include "string.h"
25 #include "yaffs_osglue.h"
26 #include "yaffs_hweight.h"
27
28 void yaffs_bug_fn(const char *file_name, int line_no);
29
30 #define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
31
32
33 #define YCHAR char
34 #define YUCHAR unsigned char
35 #define _Y(x) x
36
37 #ifndef Y_LOFF_T
38 #define Y_LOFF_T loff_t
39 #endif
40
41 /* Some RTOSs (eg. VxWorks) need strnlen. */
42 size_t strnlen(const char *s, size_t maxlen);
43
44 #define yaffs_strcat(a, b)      strcat(a, b)
45 #define yaffs_strcpy(a, b)      strcpy(a, b)
46 #define yaffs_strncpy(a, b, c)  strncpy(a, b, c)
47 #define yaffs_strnlen(s, m)     strnlen(s, m)
48 #ifdef CONFIG_YAFFS_CASE_INSENSITIVE
49 #define yaffs_strcmp(a, b)      strcasecmp(a, b)
50 #define yaffs_strncmp(a, b, c)  strncasecmp(a, b, c)
51 #else
52 #define yaffs_strcmp(a, b)      strcmp(a, b)
53 #define yaffs_strncmp(a, b, c)  strncmp(a, b, c)
54 #endif
55
56 #define hweight8(x)     yaffs_hweight8(x)
57 #define hweight32(x)    yaffs_hweight32(x)
58
59 #define sort(base, n, sz, cmp_fn, swp) qsort(base, n, sz, cmp_fn)
60
61 #define YAFFS_PATH_DIVIDERS  "/"
62
63 #ifdef NO_inline
64 #define inline
65 #else
66 #define inline __inline__
67 #endif
68
69 #define kmalloc(x, flags) yaffsfs_malloc(x)
70 #define kfree(x)   yaffsfs_free(x)
71 #define vmalloc(x) yaffsfs_malloc(x)
72 #define vfree(x) yaffsfs_free(x)
73
74 #define cond_resched()  do {} while (0)
75
76 #define yaffs_trace(msk, fmt, ...) do { \
77         if (yaffs_trace_mask & (msk)) \
78                 printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
79 } while (0)
80
81
82 #define YAFFS_LOSTNFOUND_NAME           "lost+found"
83 #define YAFFS_LOSTNFOUND_PREFIX         "obj"
84
85 #include "yaffscfg.h"
86
87 #define Y_CURRENT_TIME yaffsfs_CurrentTime()
88 #define Y_TIME_CONVERT(x) x
89
90 #define YAFFS_ROOT_MODE                 0666
91 #define YAFFS_LOSTNFOUND_MODE           0666
92
93 #include "yaffs_list.h"
94
95 #include "yaffsfs.h"
96
97 #endif
98
99