yaffs driver refactoring: Change to Linux driver interface
[yaffs2.git] / direct / yportenv.h
index 4208e806661fa8f1d95a58bd0e1d9ab623052b84..abc761b6e8c508be860e535730db8c6b10a1535d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2010 Aleph One Ltd.
+ * Copyright (C) 2002-2011 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
 
 
 /* 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;
 #endif
 
 
@@ -44,10 +41,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 +94,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 +105,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 +157,7 @@ struct iattr {
 #define EACCES 13
 #endif
 
-#ifndef EXDEV  
+#ifndef EXDEV
 #define EXDEV  18
 #endif
 
@@ -221,12 +214,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 +248,16 @@ struct iattr {
 #define S_IFREG                0100000
 #endif
 
-#ifndef S_IREAD 
+#define S_ISSOCK(m)    (((m) & S_IFMT) == S_IFSOCK)
+#define S_ISLNK(m)     (((m) & S_IFMT) == S_IFLNK)
+#define S_ISDIR(m)     (((m) & S_IFMT) == S_IFDIR)
+#define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
+#define S_ISBLK(m)     (((m) & S_IFMT) == S_IFBLK)
+#define S_ISCHR(m)     (((m) & S_IFMT) == S_IFCHR)
+#define S_ISFIFO(m)    (((m) & S_IFMT) == S_IFIFO)
+
+
+#ifndef S_IREAD
 #define S_IREAD                0000400
 #endif
 
@@ -278,8 +296,8 @@ struct iattr {
 #define Y_DUMP_STACK() do { } while (0)
 #endif
 
-#ifndef YBUG
-#define YBUG() do {\
+#ifndef BUG
+#define BUG() do {\
        yaffs_trace(YAFFS_TRACE_BUG,\
                "==>> yaffs bug: " __FILE__ " %d",\
                __LINE__);\