yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git] / direct / yportenv.h
index 939cd3a407bd494d96ba61b0348fe383273c0809..5a79f93583b963d715b0dee9a0b533363c1511e1 100644 (file)
@@ -1,8 +1,7 @@
 /*
  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2011 Aleph One Ltd.
- *   for Toby Churchill Ltd and Brightstar Engineering
+ * Copyright (C) 2002-2018 Aleph One Ltd.
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
  *
 #define __YPORTENV_H__
 
 
+#ifdef __rtems__
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define CONFIG_YAFFS_DIRECT 1
+#define CONFIG_YAFFS_SHORT_NAMES_IN_RAM 1
+#define CONFIG_YAFFS_YAFFS2 1
+#define CONFIG_YAFFS_PROVIDE_DEFS 1
+#define CONFIG_YAFFSFS_PROVIDE_VALUES 1
+#define CONFIG_YAFFS_DEFINES_TYPES 1
+#define CONFIG_YAFFS_USE_32_BIT_TIME_T 1
+#define NO_Y_INLINE 1
+#define loff_t off_t
+
+#endif /* __rtems__ */
+
 /* Definition of types */
+#ifdef CONFIG_YAFFS_DEFINES_TYPES
 typedef unsigned char u8;
 typedef unsigned short u16;
-typedef unsigned u32;
-
-
-#ifndef WIN32
-#include <sys/stat.h>
+typedef unsigned int u32;
+typedef unsigned long long u64;
+typedef signed int s32;
 #endif
 
-
 #ifdef CONFIG_YAFFS_PROVIDE_DEFS
 /* File types */
 
@@ -44,10 +60,6 @@ typedef unsigned u32;
 #define DT_WHT         14
 
 
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
-
 /*
  * Attribute flags.
  * These are or-ed together to select what has been changed.
@@ -101,7 +113,7 @@ struct iattr {
 #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
 
 #ifndef O_RDONLY
-#define O_RDONLY        00
+#define O_RDONLY       00
 #endif
 
 #ifndef O_WRONLY
@@ -112,8 +124,8 @@ struct iattr {
 #define O_RDWR         02
 #endif
 
-#ifndef O_CREAT                
-#define O_CREAT        0100
+#ifndef O_CREAT
+#define O_CREAT                0100
 #endif
 
 #ifndef O_EXCL
@@ -164,7 +176,7 @@ struct iattr {
 #define EACCES 13
 #endif
 
-#ifndef EXDEV  
+#ifndef EXDEV
 #define EXDEV  18
 #endif
 
@@ -221,12 +233,28 @@ struct iattr {
 #endif
 
 
-// Mode flags
+/* Mode flags */
 
 #ifndef S_IFMT
 #define S_IFMT         0170000
 #endif
 
+#ifndef S_IFSOCK
+#define S_IFSOCK       0140000
+#endif
+
+#ifndef S_IFIFO
+#define S_IFIFO                0010000
+#endif
+
+#ifndef S_IFCHR
+#define S_IFCHR                0020000
+#endif
+
+#ifndef S_IFBLK
+#define S_IFBLK                0060000
+#endif
+
 #ifndef S_IFLNK
 #define S_IFLNK                0120000
 #endif
@@ -239,7 +267,42 @@ struct iattr {
 #define S_IFREG                0100000
 #endif
 
-#ifndef S_IREAD 
+#ifndef S_ISSOCK
+#define S_ISSOCK(m)    (((m) & S_IFMT) == S_IFSOCK)
+#endif
+#ifndef S_ISLNK
+#define S_ISLNK(m)     (((m) & S_IFMT) == S_IFLNK)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(m)     (((m) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_ISBLK
+#define S_ISBLK(m)     (((m) & S_IFMT) == S_IFBLK)
+#endif
+#ifndef S_ISCHR
+#define S_ISCHR(m)     (((m) & S_IFMT) == S_IFCHR)
+#endif
+#ifndef S_ISFIFO
+#define S_ISFIFO(m)    (((m) & S_IFMT) == S_IFIFO)
+#endif
+
+
+#ifndef S_IRUSR
+#define S_IRUSR                0000400
+#endif
+
+#ifndef S_IWUSR
+#define        S_IWUSR         0000200
+#endif
+
+#ifndef S_IXUSR
+#define        S_IXUSR         0000100
+#endif
+
+#ifndef S_IREAD
 #define S_IREAD                0000400
 #endif
 
@@ -251,6 +314,16 @@ struct iattr {
 #define        S_IEXEC 0000100
 #endif
 
+
+#else
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#endif
+
+#endif
+
+/* Create some less common define values if they don't exist */
 #ifndef XATTR_CREATE
 #define XATTR_CREATE 1
 #endif
@@ -266,12 +339,8 @@ struct iattr {
 #define F_OK   0
 #endif
 
-#else
-#include <errno.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#endif
-
+#ifndef S_ISSOCK
+#define S_ISSOCK(m)    (((m) & S_IFMT) == S_IFSOCK)
 #endif
 
 #ifndef Y_DUMP_STACK