diff options
| author | ngkaho1234 <ngkaho1234@gmail.com> | 2016-01-30 22:33:21 +0800 |
|---|---|---|
| committer | ngkaho1234 <ngkaho1234@gmail.com> | 2016-02-01 23:05:58 +0000 |
| commit | 7a2fbb4fdb0fbbe196d6d936dee74e65c25909ab (patch) | |
| tree | 92a78f6d367c7b4891bdee44b1cc00c38ec4ec0b | |
| parent | 9d03d7a99143840029ad69ff40a2b4d5dbb68c82 (diff) | |
Add toolkit that helps adding prefix to flags and errno V2.
| -rw-r--r-- | prefix_patch/ext4_errno.patch | 161 | ||||
| -rw-r--r-- | prefix_patch/ext4_oflags.patch | 48 | ||||
| -rwxr-xr-x | prefix_patch/lwext4_rename.sh | 12 |
3 files changed, 105 insertions, 116 deletions
diff --git a/prefix_patch/ext4_errno.patch b/prefix_patch/ext4_errno.patch index 06e5b28..7fd0595 100644 --- a/prefix_patch/ext4_errno.patch +++ b/prefix_patch/ext4_errno.patch @@ -1,11 +1,12 @@ ---- include/ext4_errno.h 2016-01-25 09:51:20.605385376 +0000 -+++ include/ext4_errno.h 2016-01-25 09:19:09.410384455 +0000 -@@ -43,47 +43,95 @@ extern "C" { +diff --git a/include/ext4_errno.h b/include/ext4_errno.h +index edf89a9..60a3472 100644 +--- a/include/ext4_errno.h ++++ b/include/ext4_errno.h +@@ -43,46 +43,74 @@ extern "C" { #include "ext4_config.h" #if !CONFIG_HAVE_OWN_ERRNO -+ - #include <errno.h> +-#include <errno.h> -#else -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ @@ -29,96 +30,86 @@ -#define ENODATA 61 /* No data available */ -#define ENOTSUP 95 /* Not supported */ -#endif -+ -+#define LWEXT4_EPERM EPERM /* Operation not permitted */ -+#define LWEXT4_ENOENT ENOENT /* No such file or directory */ -+#define LWEXT4_EIO EIO /* I/O error */ -+#define LWEXT4_ENXIO ENXIO /* No such device or address */ -+#define LWEXT4_E2BIG E2BIG /* Argument list too long */ -+#define LWEXT4_ENOMEM ENOMEM /* Out of memory */ -+#define LWEXT4_EACCES EACCES /* Permission denied */ -+#define LWEXT4_EFAULT EFAULT /* Bad address */ -+#define LWEXT4_EEXIST EEXIST /* File exists */ -+#define LWEXT4_ENODEV ENODEV /* No such device */ -+#define LWEXT4_ENOTDIR ENOTDIR /* Not a directory */ -+#define LWEXT4_EISDIR EISDIR /* Is a directory */ -+#define LWEXT4_EINVAL EINVAL /* Invalid argument */ -+#define LWEXT4_EFBIG EFBIG /* File too large */ -+#define LWEXT4_ENOSPC ENOSPC /* No space left on device */ -+#define LWEXT4_EROFS EROFS /* Read-only file system */ -+#define LWEXT4_EMLINK EMLINK /* Too many links */ -+#define LWEXT4_ERANGE ERANGE /* Math result not representable */ -+#define LWEXT4_ENOTEMPTY ENOTEMPTY /* Directory not empty */ - #ifndef ENODATA - #ifdef ENOATTR +-#ifndef ENODATA +- #ifdef ENOATTR - #define ENODATA ENOATTR -+ #define LWEXT4_ENODATA ENOATTR - #else +- #else - #define ENODATA 61 -+ #define LWEXT4_ENODATA 61 ++ #include <errno.h> ++ ++ #define LWEXT4_ERRNO(errno) (errno) ++ ++ #ifndef ENODATA ++ #ifdef ENOATTR ++ #define ENOATTR ENOATTR ++ #else ++ #define ENODATA 61 ++ #endif #endif -+#else -+#define LWEXT4_ENODATA ENODATA - #endif +-#endif - #ifndef ENOTSUP +-#ifndef ENOTSUP -#define ENOTSUP 95 -+#define LWEXT4_ENOTSUP 95 -+#else -+#define LWEXT4_ENOTSUP ENOTSUP - #endif - - #ifndef EOK - #define EOK 0 - #endif - -+#define LWEXT4_EOK EOK +-#endif ++ #ifndef ENOTSUP ++ #define ENOTSUP 95 ++ #endif + -+#else /* CONFIG_HAVE_OWN_ERRNO */ ++ #ifndef EOK ++ #define EOK 0 ++ #endif + -+#define LWEXT4_EOK 0 -+#define LWEXT4_EPERM 1 /* Operation not permitted */ -+#define LWEXT4_ENOENT 2 /* No such file or directory */ -+#define LWEXT4_ESRCH 3 /* No such process */ -+#define LWEXT4_EINTR 4 /* Interrupted system call */ -+#define LWEXT4_EIO 5 /* I/O error */ -+#define LWEXT4_ENXIO 6 /* No such device or address */ -+#define LWEXT4_E2BIG 7 /* Argument list too long */ -+#define LWEXT4_ENOEXEC 8 /* Exec format error */ -+#define LWEXT4_EBADF 9 /* Bad file number */ -+#define LWEXT4_ECHILD 10 /* No child processes */ -+#define LWEXT4_EAGAIN 11 /* Try again */ -+#define LWEXT4_ENOMEM 12 /* Out of memory */ -+#define LWEXT4_EACCES 13 /* Permission denied */ -+#define LWEXT4_EFAULT 14 /* Bad address */ -+#define LWEXT4_ENOTBLK 15 /* Block device required */ -+#define LWEXT4_EBUSY 16 /* Device or resource busy */ -+#define LWEXT4_EEXIST 17 /* File exists */ -+#define LWEXT4_EXDEV 18 /* Cross-device link */ -+#define LWEXT4_ENODEV 19 /* No such device */ -+#define LWEXT4_ENOTDIR 20 /* Not a directory */ -+#define LWEXT4_EISDIR 21 /* Is a directory */ -+#define LWEXT4_EINVAL 22 /* Invalid argument */ -+#define LWEXT4_ENFILE 23 /* File table overflow */ -+#define LWEXT4_EMFILE 24 /* Too many open files */ -+#define LWEXT4_ENOTTY 25 /* Not a typewriter */ -+#define LWEXT4_ETXTBSY 26 /* Text file busy */ -+#define LWEXT4_EFBIG 27 /* File too large */ -+#define LWEXT4_ENOSPC 28 /* No space left on device */ -+#define LWEXT4_ESPIPE 29 /* Illegal seek */ -+#define LWEXT4_EROFS 30 /* Read-only file system */ -+#define LWEXT4_EMLINK 31 /* Too many links */ -+#define LWEXT4_EPIPE 32 /* Broken pipe */ -+#define LWEXT4_EDOM 33 /* Math argument out of domain of func */ -+#define LWEXT4_ERANGE 34 /* Math result not representable */ -+#define LWEXT4_ENOTEMPTY 39 /* Directory not empty */ -+#define LWEXT4_ENODATA 61 /* No data available */ -+#define LWEXT4_ENOTSUP 95 /* Not supported */ ++#else /* CONFIG_HAVE_OWN_ERRNO */ + -+#endif /* CONFIG_HAVE_OWN_ERRNO */ ++ #define LWEXT4_ERRNO(errno) (LWEXT4_##errno) + ++ enum ext4_errno { ++ LWEXT4_ERRNO(EOK) = 0 ++ LWEXT4_ERRNO(EPERM) = 1 /* Operation not permitted */ ++ LWEXT4_ERRNO(ENOENT) = 2 /* No such file or directory */ ++ LWEXT4_ERRNO(ESRCH) = 3 /* No such process */ ++ LWEXT4_ERRNO(EINTR) = 4 /* Interrupted system call */ ++ LWEXT4_ERRNO(EIO) = 5 /* I/O error */ ++ LWEXT4_ERRNO(ENXIO) = 6 /* No such device or address */ ++ LWEXT4_ERRNO(E2BIG) = 7 /* Argument list too long */ ++ LWEXT4_ERRNO(ENOEXEC) = 8 /* Exec format error */ ++ LWEXT4_ERRNO(EBADF) = 9 /* Bad file number */ ++ LWEXT4_ERRNO(ECHILD) = 10 /* No child processes */ ++ LWEXT4_ERRNO(EAGAIN) = 11 /* Try again */ ++ LWEXT4_ERRNO(ENOMEM) = 12 /* Out of memory */ ++ LWEXT4_ERRNO(EACCES) = 13 /* Permission denied */ ++ LWEXT4_ERRNO(EFAULT) = 14 /* Bad address */ ++ LWEXT4_ERRNO(ENOTBLK) = 15 /* Block device required */ ++ LWEXT4_ERRNO(EBUSY) = 16 /* Device or resource busy */ ++ LWEXT4_ERRNO(EEXIST) = 17 /* File exists */ ++ LWEXT4_ERRNO(EXDEV) = 18 /* Cross-device link */ ++ LWEXT4_ERRNO(ENODEV) = 19 /* No such device */ ++ LWEXT4_ERRNO(ENOTDIR) = 20 /* Not a directory */ ++ LWEXT4_ERRNO(EISDIR) = 21 /* Is a directory */ ++ LWEXT4_ERRNO(EINVAL) = 22 /* Invalid argument */ ++ LWEXT4_ERRNO(ENFILE) = 23 /* File table overflow */ ++ LWEXT4_ERRNO(EMFILE) = 24 /* Too many open files */ ++ LWEXT4_ERRNO(ENOTTY) = 25 /* Not a typewriter */ ++ LWEXT4_ERRNO(ETXTBSY) = 26 /* Text file busy */ ++ LWEXT4_ERRNO(EFBIG) = 27 /* File too large */ ++ LWEXT4_ERRNO(ENOSPC) = 28 /* No space left on device */ ++ LWEXT4_ERRNO(ESPIPE) = 29 /* Illegal seek */ ++ LWEXT4_ERRNO(EROFS) = 30 /* Read-only file system */ ++ LWEXT4_ERRNO(EMLINK) = 31 /* Too many links */ ++ LWEXT4_ERRNO(EPIPE) = 32 /* Broken pipe */ ++ LWEXT4_ERRNO(EDOM) = 33 /* Math argument out of domain of func */ ++ LWEXT4_ERRNO(ERANGE) = 34 /* Math result not representable */ ++ LWEXT4_ERRNO(ENOTEMPTY) = 39 /* Directory not empty */ ++ LWEXT4_ERRNO(ENODATA) = 61 /* No data available */ ++ LWEXT4_ERRNO(ENOTSUP) = 95 /* Not supported */ ++ }; + ++#endif /* CONFIG_HAVE_OWN_ERRNO */ + +-#ifndef EOK +-#define EOK 0 +-#endif + #ifdef __cplusplus } - #endif diff --git a/prefix_patch/ext4_oflags.patch b/prefix_patch/ext4_oflags.patch index 560ce11..1362baa 100644 --- a/prefix_patch/ext4_oflags.patch +++ b/prefix_patch/ext4_oflags.patch @@ -1,6 +1,8 @@ ---- include/ext4_oflags.h 2016-01-25 09:51:20.615385376 +0000 -+++ include/ext4_oflags.h 2016-01-25 09:19:09.420384455 +0000 -@@ -45,51 +45,37 @@ extern "C" { +diff --git a/include/ext4_oflags.h b/include/ext4_oflags.h +index 7f7be7e..e99d1af 100644 +--- a/include/ext4_oflags.h ++++ b/include/ext4_oflags.h +@@ -45,51 +45,33 @@ extern "C" { #if CONFIG_HAVE_OWN_OFLAGS @@ -31,13 +33,17 @@ - #ifndef O_APPEND - #define O_APPEND 02000 - #endif -+ #define LWEXT4_O_RDONLY 00 -+ #define LWEXT4_O_WRONLY 01 -+ #define LWEXT4_O_RDWR 02 -+ #define LWEXT4_O_CREAT 0100 -+ #define LWEXT4_O_EXCL 0200 -+ #define LWEXT4_O_TRUNC 01000 -+ #define LWEXT4_O_APPEND 02000 ++ #define LWEXT4_FLAGS(flags) (LWEXT4_##flags) ++ ++ enum ext4_oflags { ++ LWEXT4_FLAGS(O_RDONLY) = 00 ++ LWEXT4_FLAGS(O_WRONLY) = 01 ++ LWEXT4_FLAGS(O_RDWR) = 02 ++ LWEXT4_FLAGS(O_CREAT) = 0100 ++ LWEXT4_FLAGS(O_EXCL) = 0200 ++ LWEXT4_FLAGS(O_TRUNC) = 01000 ++ LWEXT4_FLAGS(O_APPEND) = 02000 ++ }; /********************************FILE SEEK FLAGS*****************************/ @@ -52,31 +58,23 @@ - #ifndef SEEK_END - #define SEEK_END 2 - #endif -+ #define LWEXT4_SEEK_SET 0 -+ #define LWEXT4_SEEK_CUR 1 -+ #define LWEXT4_SEEK_END 2 ++ enum ext4_seek_flags { ++ LWEXT4_FLAGS(SEEK_SET) = 0 ++ LWEXT4_FLAGS(SEEK_CUR) = 1 ++ LWEXT4_FLAGS(SEEK_END) = 2 ++ }; #else + #include <unistd.h> #include <fcntl.h> + -+ #define LWEXT4_O_RDONLY O_RDONLY -+ #define LWEXT4_O_WRONLY O_WRONLY -+ #define LWEXT4_O_RDWR O_RDWR -+ #define LWEXT4_O_CREAT O_CREAT -+ #define LWEXT4_O_EXCL O_EXCL -+ #define LWEXT4_O_TRUNC O_TRUNC -+ #define LWEXT4_O_APPEND O_APPEND -+ -+ #define LWEXT4_SEEK_SET SEEK_SET -+ #define LWEXT4_SEEK_CUR SEEK_CUR -+ #define LWEXT4_SEEK_END SEEK_END ++ #define LWEXT4_FLAGS(flags) (flags) + #endif #ifdef __cplusplus -@@ -101,3 +87,4 @@ extern "C" { +@@ -101,3 +83,4 @@ extern "C" { /** * @} */ diff --git a/prefix_patch/lwext4_rename.sh b/prefix_patch/lwext4_rename.sh index bbdc324..6540743 100755 --- a/prefix_patch/lwext4_rename.sh +++ b/prefix_patch/lwext4_rename.sh @@ -1,6 +1,6 @@ #!/bin/sh -PREFIX_TO_ADD=LWEXT4 +MACRO_NAME=LWEXT4 EXT4_ERRNO_H=ext4_errno.h EXT4_OFLAGS_H=ext4_oflags.h USED_ERRNO_FILE=/tmp/used_errno @@ -33,12 +33,12 @@ for errno in $(cat $USED_ERRNO_FILE);do echo "For $errno" for file in $(find . -name "*.c" | xargs -n 1);do if [[ $(basename $file) != $EXT4_ERRNO_H ]];then - sed -i "s/\\<${errno}\\>/${PREFIX_TO_ADD}_${errno}/g" $file + sed -i "s/\\<${errno}\\>/${MACRO_NAME}_ERRNO(${errno})/g" $file fi done for file in $(find . -name "*.h" | xargs -n 1);do if [[ $(basename $file) != $EXT4_ERRNO_H ]];then - sed -i "s/\\<${errno}\\>/${PREFIX_TO_ADD}_${errno}/g" $file + sed -i "s/\\<${errno}\\>/${MACRO_NAME}_ERRNO(${errno})/g" $file fi done done @@ -48,18 +48,18 @@ for oflags in $(cat $USED_OFLAGS_FILE);do for file in $(find . -name "*.c" | xargs -n 1);do if [[ $(dirname $file) != "./blockdev/"* && \ $(basename $file) != $EXT4_OFLAGS_H ]];then - sed -i "s/\\<${oflags}\\>/${PREFIX_TO_ADD}_${oflags}/g" $file + sed -i "s/\\<${oflags}\\>/${MACRO_NAME}_FLAGS(${oflags})/g" $file fi done for file in $(find . -name "*.h" | xargs -n 1);do if [[ $(dirname $file) != "./blockdev/"* && \ $(basename $file) != $EXT4_OFLAGS_H ]];then - sed -i "s/\\<${oflags}\\>/${PREFIX_TO_ADD}_${oflags}/g" $file + sed -i "s/\\<${oflags}\\>/${MACRO_NAME}_FLAGS(${oflags})/g" $file fi done done # Do final patching. for patches in $(dirname $0)/*.patch ;do - patch -p0 < $patches + patch -p1 < $patches done |
