1 # Copyright (C) 2001 Cluster File Systems, Inc.
3 # This code is issued under the GNU General Public License.
4 # See the file COPYING in this distribution
11 # NOTE: If you are not using a RedHat 12.5 or later kernel, then you need to
12 # apply the "fixes" patch first, as it fixes a number of bugs in ext3.
13 # It will be applied automatically by the extN build process, or you
14 # can apply it to the source kernel tree and fix ext3 also. For chaos22
15 # (or other RH < 12.5 kernels) use the "chaos22" patch instead.
16 EXTN_FIXES = patch-2.4.18-chaos22
17 #EXTN_FIXES = ext3-2.4.18-fixes.diff
18 EXTNP = htree-ext3-2.4.18.diff linux-2.4.18ea-0.8.26.diff
19 EXTNP+= ext3-2.4.18-ino_sb_macro.diff extN-misc-fixup.diff extN-noread.diff
20 EXTNP+= extN-wantedi.diff
21 #EXTNP+= extN-iget-debug.diff
22 EXTNC = balloc.c bitmap.c dir.c file.c fsync.c ialloc.c inode.c ioctl.c
23 EXTNC+= namei.c super.c symlink.c
24 EXTNI = extN_fs.h extN_fs_i.h extN_fs_sb.h extN_jbd.h quotaops.h
25 EXTN_EXTRA = include/linux/xattr.h include/linux/extN_xattr.h fs/extN/xattr.c
26 EXTN_EXTRA += include/linux/quotaops.h
27 extN_SOURCES = $(EXTNC) xattr.c # punch.c
28 extN_DEPENDENCIES = patch-stamp
29 EXTRA_DIST = $(EXTNP) $(EXTN_FIXES) \
30 extN-2.4.18-ino_sb_fixup.diff extN-2.4.18-exports.diff \
31 $(wildcard extN.patch-*)
32 DISTCLEANFILES = -r $(extN_SOURCES) sed-stamp patch-stamp *.orig *.rej
33 SUB=-e "s/ext3/extN/g" -e "s/EXT3/EXTN/g" -e "s/extern __inline__/static inline/"
36 cd .. && rm -f $(EXTN_EXTRA)
38 include $(top_srcdir)/Rules
40 # Following 2 vars are for buildind outside the source tree.
41 extN_orig = $(top_builddir)/$(subdir)/extN.orig
42 extN_include_orig = $(top_builddir)/$(subdir)/extN-include.orig
44 # Create a fresh extN patch.
45 # This is for when the patch-stamp target fails for your kernel.
46 # Just edit the files until you like them, then do `make diff', and
47 # it will create a specialized patch for your particular kernel.
48 # Check it in, and the build should work for you without disrupting
49 # the other developers.
50 # Of course, the ideal is to merge changes so that the default patch
51 # set works for nearly everybody. This is mainly for damage control.
55 l='$(EXTNC)'; for f in $$l; do \
57 (diff -u $(extN_orig)/$$f extN/$$f) >> extN.patchT; \
58 test $$? -le 1 || exit 1; \
60 l='$(EXTNI)'; for f in $$l; do \
62 (diff -u $(extN_include_orig)/$$f $(top_srcdir)/include/linux/$$f)>>extN.patchT;\
63 test $$? -le 1 || exit 1; \
65 l='$(EXTN_EXTRA)'; for f in $$l; do \
66 f=`echo "$$f" | sed 's%^fs/%%'`; \
68 (cd $(top_srcdir) && \
69 diff -u /dev/null $$f) >> extN.patchT; \
70 test $$? -le 1 || exit 1; \
72 mv -f extN.patchT $(top_builddir)/$(subdir)/extN.patch-$(RELEASE)
73 echo "Don't forget to add $(srcdir)/extN.patch-$(RELEASE) to CVS!"
77 # Just do the SUB transformation on all our source files.
80 rm -rf $(extN_orig) $(extN_include_orig)
81 mkdir $(extN_orig) $(extN_include_orig)
82 list='$(EXTNC)'; for f in $$list; do \
83 echo "creating $(extN_orig)/$$f"; \
84 sed $(SUB) $(LINUX)/fs/ext3/$$f > $(extN_orig)/$$f; \
86 list='$(EXTNI)'; for i in $$list; do \
87 s=`echo $$i | sed "s/extN/ext3/"`; \
88 echo "creating $(extN_include_orig)/$$i"; \
89 sed $(SUB) $(LINUX)/include/linux/$$s > $(extN_include_orig)/$$i; \
94 # Patch the kernel files with our ext3 patches. We need to go through some
95 # extra hoops because the include files are in a different tree and because
96 # patch likes to make local copies of files with (sym)links when it is patching
97 # them. To avoid this, we copy/patch in the source dir instead of the build
98 # dir (if they are different).
99 # We also want to preserve the pristine transformed files for the diff target.
103 patch-stamp: sed-stamp $(EXTNP)
104 test -e $(top_builddir)/include/linux || mkdir -p $(top_builddir)/include/linux
105 cp -a $(extN_orig)/* $(top_builddir)/$(subdir)
106 cp -a $(extN_include_orig)/* $(top_builddir)/include/linux
107 test -e $(top_builddir)/fs || ln -s . $(top_builddir)/fs
108 list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(top_builddir)/$$f; done
109 if [ -f $(srcdir)/extN.patch-$(RELEASE) ]; then \
110 echo "applying patch $(srcdir)/extN.patch-$(RELEASE)"; \
111 (cd $(top_builddir) && patch -p0) < $(srcdir)/extN.patch-$(RELEASE);\
114 grep -q "err = extN_mark_inode_dirty" $(extN_orig)/namei.c || \
115 list="ext3-use-after-free.diff $$list"; \
116 sed '/i_version/q' $(extN_orig)/namei.c | tail -2 | \
117 grep -q extN_mark_inode_dirty && list="$(EXTN_FIXES) $$list"; \
118 grep -q "if (do_sync_supers)" $(extN_orig)/super.c && \
119 list="ext3-unmount_sync.diff $$list"; \
120 for p in $$list; do \
121 echo "applying patch $$p"; \
122 sed $(SUB) $(srcdir)/$$p | \
123 (cd $(top_builddir) && patch -p1) || exit $$?; \
125 echo "It is OK if the next patch says it is skipping this patch"; \
126 echo "applying patch $(srcdir)/extN-2.4.18-exports.diff"; \
127 (cd $(top_builddir) && \
128 patch -N -p1) < $(srcdir)/extN-2.4.18-exports.diff; \
129 echo "applying patch $(srcdir)/extN-2.4.18-ino_sb_fix.diff"; \
130 (cd $(top_builddir) && \
131 patch -p1) < $(srcdir)/extN-2.4.18-ino_sb_fixup.diff || exit $$?; \
138 $(extN_SOURCES) $(EXTNI) $(EXTN_EXTRA): patch-stamp
140 # Don't distribute any patched files.
142 $(RM) $(top_srcdir)/fs
143 list='$(EXTNC)'; for f in $$list; do $(RM) $(distdir)/$$f; done
144 list='$(EXTNI)'; for i in $$list; do \
145 $(RM) $(distdir)/../include/linux/$$i; \
147 list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(distdir)/../$$f; done