diff options
-rw-r--r-- | fs/btrfs/Makefile | 6 | ||||
-rw-r--r-- | fs/btrfs/super.c | 3 | ||||
-rw-r--r-- | fs/btrfs/version.sh | 43 |
3 files changed, 51 insertions, 1 deletions
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile index 0e2dcc718de2..f8a38b0da7fb 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile | |||
@@ -14,8 +14,12 @@ else | |||
14 | # Normal Makefile | 14 | # Normal Makefile |
15 | 15 | ||
16 | KERNELDIR := /lib/modules/`uname -r`/build | 16 | KERNELDIR := /lib/modules/`uname -r`/build |
17 | all: | 17 | all: version |
18 | $(MAKE) -C $(KERNELDIR) M=`pwd` modules | 18 | $(MAKE) -C $(KERNELDIR) M=`pwd` modules |
19 | |||
20 | version: | ||
21 | bash version.sh | ||
22 | |||
19 | modules_install: | 23 | modules_install: |
20 | $(MAKE) -C $(KERNELDIR) M=`pwd` modules_install | 24 | $(MAKE) -C $(KERNELDIR) M=`pwd` modules_install |
21 | clean: | 25 | clean: |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5e28cf5c2e85..4cb6aac5122e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "print-tree.h" | 45 | #include "print-tree.h" |
46 | #include "xattr.h" | 46 | #include "xattr.h" |
47 | #include "volumes.h" | 47 | #include "volumes.h" |
48 | #include "version.h" | ||
48 | 49 | ||
49 | #define BTRFS_SUPER_MAGIC 0x9123683E | 50 | #define BTRFS_SUPER_MAGIC 0x9123683E |
50 | 51 | ||
@@ -605,6 +606,8 @@ static int __init init_btrfs_fs(void) | |||
605 | err = register_filesystem(&btrfs_fs_type); | 606 | err = register_filesystem(&btrfs_fs_type); |
606 | if (err) | 607 | if (err) |
607 | goto unregister_ioctl; | 608 | goto unregister_ioctl; |
609 | |||
610 | printk(KERN_INFO "%s loaded\n", BTRFS_BUILD_VERSION); | ||
608 | return 0; | 611 | return 0; |
609 | 612 | ||
610 | unregister_ioctl: | 613 | unregister_ioctl: |
diff --git a/fs/btrfs/version.sh b/fs/btrfs/version.sh new file mode 100644 index 000000000000..fd9b53d39860 --- /dev/null +++ b/fs/btrfs/version.sh | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # determine-version -- report a useful version for releases | ||
4 | # | ||
5 | # Copyright 2008, Aron Griffis <agriffis@n01se.net> | ||
6 | # Copyright 2008, Oracle | ||
7 | # Released under the GNU GPLv2 | ||
8 | |||
9 | v="Btrfs v0.15" | ||
10 | |||
11 | which hg > /dev/null | ||
12 | if [ $? == 0 ]; then | ||
13 | last=$(hg tags | grep -m1 -o '^v[0-9.]\+') | ||
14 | |||
15 | # now check if the repo has commits since then... | ||
16 | if [[ $(hg id -t) == $last || \ | ||
17 | $(hg di -r "$last:." | awk '/^diff/{print $NF}' | sort -u) == .hgtags ]] | ||
18 | then | ||
19 | # check if it's dirty | ||
20 | if [[ $(hg id | cut -d' ' -f1) == *+ ]]; then | ||
21 | v=$last+ | ||
22 | else | ||
23 | v=$last | ||
24 | fi | ||
25 | else | ||
26 | # includes dirty flag | ||
27 | v=$last+$(hg id -i) | ||
28 | fi | ||
29 | fi | ||
30 | |||
31 | echo "#ifndef __BUILD_VERSION" > .build-version.h | ||
32 | echo "#define __BUILD_VERSION" >> .build-version.h | ||
33 | echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h | ||
34 | echo "#endif" >> .build-version.h | ||
35 | |||
36 | diff -q version.h .build-version.h >& /dev/null | ||
37 | |||
38 | if [ $? == 0 ]; then | ||
39 | rm .build-version.h | ||
40 | exit 0 | ||
41 | fi | ||
42 | |||
43 | mv .build-version.h version.h | ||