]> git.proxmox.com Git - mirror_zfs.git/blame - copy-builtin
Fix 'zfs allow' for create time permissions
[mirror_zfs.git] / copy-builtin
CommitLineData
2ee4a18b
ED
1#!/bin/bash
2
3set -e
4
5usage()
6{
7 echo "usage: $0 <kernel source tree>" >&2
8 exit 1
9}
10
11[ "$#" -eq 1 ] || usage
12KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
13
14MODULES=()
517d2471 15MODULES+="spl"
2ee4a18b
ED
16for MODULE_DIR in module/*
17do
18 [ -d "$MODULE_DIR" ] || continue
517d2471 19 [ "spl" = "${MODULE_DIR##*/}" ] && continue
2ee4a18b
ED
20 MODULES+=("${MODULE_DIR##*/}")
21done
22
23if ! [ -e 'zfs_config.h' ]
24then
25 echo >&2
26 echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
27 echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
28 echo >&2
29 exit 1
30fi
31
32make clean || true
33
34rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
35cp --recursive include "$KERNEL_DIR/include/zfs"
36cp --recursive module "$KERNEL_DIR/fs/zfs"
93ce2b4c 37cp zfs_config.h "$KERNEL_DIR/include/zfs/"
2ee4a18b 38
2ee4a18b
ED
39for MODULE in "${MODULES[@]}"
40do
60bd953c
BB
41 sed -i.bak '/obj =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
42 sed -i.bak '/src =/d' "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
2ee4a18b
ED
43done
44
45cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
46config ZFS
c90ea655 47 tristate "ZFS filesystem support"
9a512dca
RY
48 depends on EFI_PARTITION
49 select ZLIB_INFLATE
50 select ZLIB_DEFLATE
2ee4a18b
ED
51 help
52 This is the ZFS filesystem from the ZFS On Linux project.
53
54 See http://zfsonlinux.org/
55
56 To compile this file system support as a module, choose M here.
57
58 If unsure, say N.
59EOF
60
61{
62 cat <<-"EOF"
06480b27 63 ZFS_MODULE_CFLAGS = -I$(srctree)/include/zfs
93ce2b4c
BB
64 ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/spl
65 ZFS_MODULE_CFLAGS += -include $(srctree)/include/zfs/zfs_config.h
c10cdcb5 66 ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
93ce2b4c 67 ZFS_MODULE_CPPFLAGS = -D_KERNEL
c10cdcb5
MT
68 ZFS_MODULE_CPPFLAGS += -UDEBUG -DNDEBUG
69 export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS
2ee4a18b
ED
70
71 obj-$(CONFIG_ZFS) :=
72 EOF
73
74 for MODULE in "${MODULES[@]}"
75 do
76 echo 'obj-$(CONFIG_ZFS) += ' "$MODULE/"
77 done
78} > "$KERNEL_DIR/fs/zfs/Kbuild"
79
80add_after()
81{
82 local FILE="$1"
83 local MARKER="$2"
84 local NEW="$3"
85 local LINE
86
87 while IFS='' read -r LINE
88 do
89 echo "$LINE"
90
91 if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
92 then
93 echo "$NEW"
94 MARKER=''
95 if IFS='' read -r LINE
96 then
97 [ "$LINE" != "$NEW" ] && echo "$LINE"
98 fi
99 fi
100 done < "$FILE" > "$FILE.new"
101
102 mv "$FILE.new" "$FILE"
103}
104
105add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
106add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
107
108echo >&2
109echo " $0: done." >&2
110echo " $0: now you can build the kernel with ZFS support." >&2
111echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2
112echo >&2