4 EXT4_ERRNO_H=ext4_errno.h
5 EXT4_OFLAGS_H=ext4_oflags.h
6 USED_ERRNO_FILE=/tmp/used_errno
7 USED_OFLAGS_FILE=/tmp/used_oflags
11 printf "Usage: %s <lwext4_source_patch>" $1
15 if [[ $# -ne 1 ]];then
19 # First change the working directory to destination.
21 if [[ $? -ne 0 ]];then
25 # Extract definitions from 2 files.
26 sed -n "s/[[:blank:]]*#define \(E[[:alnum:]]\+\)[[:blank:]]\+[[:alnum:]]\+[[:blank:]]*.*/\1/gp" ./include/$EXT4_ERRNO_H > $USED_ERRNO_FILE
27 sed -n "s/[[:blank:]]*#define \(O_[[:alpha:]]\+\)[[:blank:]]\+[[:alnum:]]\+[[:blank:]]*.*/\1/gp" ./include/$EXT4_OFLAGS_H > $USED_OFLAGS_FILE
28 sed -n "s/[[:blank:]]*#define \(SEEK_[[:alpha:]]\+\)[[:blank:]]\+[[:alnum:]]\+[[:blank:]]*.*/\1/gp" ./include/$EXT4_OFLAGS_H >> $USED_OFLAGS_FILE
30 # Add prefix to those definjtions.
32 for errno in $(cat $USED_ERRNO_FILE);do
34 for file in $(find . -name "*.c" | xargs -n 1);do
35 if [[ $(basename $file) != $EXT4_ERRNO_H ]];then
36 sed -i "/${MACRO_NAME}_ERRNO(${errno})/b;s/\\<${errno}\\>/${MACRO_NAME}_ERRNO(${errno})/g" $file
39 for file in $(find . -name "*.h" | xargs -n 1);do
40 if [[ $(basename $file) != $EXT4_ERRNO_H ]];then
41 sed -i "/${MACRO_NAME}_ERRNO(${errno})/b;s/\\<${errno}\\>/${MACRO_NAME}_ERRNO(${errno})/g" $file
46 for oflags in $(cat $USED_OFLAGS_FILE);do
48 for file in $(find . -name "*.c" | xargs -n 1);do
49 if [[ $(dirname $file) != "./blockdev/"* && \
50 $(basename $file) != $EXT4_OFLAGS_H ]];then
51 sed -i "/${MACRO_NAME}_FLAGS(${oflags})/b;s/\\<${oflags}\\>/${MACRO_NAME}_FLAGS(${oflags})/g" $file
54 for file in $(find . -name "*.h" | xargs -n 1);do
55 if [[ $(dirname $file) != "./blockdev/"* && \
56 $(basename $file) != $EXT4_OFLAGS_H ]];then
57 sed -i "/${MACRO_NAME}_FLAGS(${oflags})/b;s/\\<${oflags}\\>/${MACRO_NAME}_FLAGS(${oflags})/g" $file
63 for patches in $(dirname $0)/*.patch ;do