Introduced btrfs file-system with btrload command
Subsystems (4)
PATCH v9 1/1 Introduced btrfs file-system with btrload command
Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.
v8: patch re-formated. v7: patch re-formated. v6: patch re-formated. v5: merged with master. v4: btrls command added.
--- Makefile | 1 + common/Makefile | 1 + common/cmd_btr.c | 65 +++ fs/btrfs/Makefile | 51 ++ fs/btrfs/btrfs.c | 1374 ++++++++++++++++++++++++++++++++++++++++++++ fs/fs.c | 10 + include/btrfs.h | 416 ++++++++++++++ include/config_fallbacks.h | 4 + include/crc.h | 8 + include/fs.h | 1 + lib/Makefile | 1 + lib/crc32_c.c | 40 ++ 12 files changed, 1972 insertions(+) create mode 100644 common/cmd_btr.c create mode 100644 fs/btrfs/Makefile create mode 100644 fs/btrfs/btrfs.c create mode 100644 include/btrfs.h create mode 100644 lib/crc32_c.c
Makefile +1 -0
@@ -257,6 +257,7 @@ endif LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o LIBS-y += fs/libfs.o \ + fs/btrfs/libbtrfs.o \ fs/cbfs/libcbfs.o \ fs/cramfs/libcramfs.o \ fs/ext4/libext4fs.o \
common/Makefile +1 -0
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o +COBJS-$(CONFIG_CMD_BTR) += cmd_btr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
common/cmd_btr.c new file +65 -0
65 lines not on this page · raw message
fs/btrfs/Makefile new file +51 -0
51 lines not on this page · raw message
fs/btrfs/btrfs.c new file +1374 -0
1,374 lines not on this page · raw message
fs/fs.c +10 -0
@@ -17,6 +17,7 @@#include <config.h> #include <common.h> #include <part.h> +#include <btrfs.h> #include <ext4fs.h> #include <fat.h> #include <fs.h>
@@ -88,6 +89,15 @@ static struct fstype_info fstypes[] = { .read = fs_read_sandbox, },#endif +#ifdef CONFIG_FS_BTR + { + .fstype = FS_TYPE_BTR, + .probe = btrfs_probe, + .close = btrfs_close, + .ls = btrfs_ls, + .read = btrfs_read_file, + }, +#endif { .fstype = FS_TYPE_ANY, .probe = fs_probe_unsupported,
include/btrfs.h new file +416 -0
416 lines not on this page · raw message
include/config_fallbacks.h +4 -0
@@ -26,4 +26,8 @@#define CONFIG_EXT4_WRITE #endif +#if defined(CONFIG_CMD_BTR ) && !defined(CONFIG_FS_BTR ) +#define CONFIG_FS_BTR +#endif +#endif /* __CONFIG_FALLBACKS_H */
include/crc.h +8 -0
@@ -97,4 +97,12 @@ cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len);extern uint16_t cyg_crc16 (unsigned char *s,int len); +/* CRC init for btrfs file-system*/ + +void crc32c_init (u32 *crc32c_table,u32 pol); + +/* CRC calculate for btrfs file-system*/ + +u32 crc32c_cal (u32 crc,const char *data,size_t length,u32 *crc32c_table); +#endif /* _SERVICES_CRC_CRC_H_ */
include/fs.h +1 -0
@@ -22,6 +22,7 @@#define FS_TYPE_FAT 1#define FS_TYPE_EXT 2#define FS_TYPE_SANDBOX 3 +#define FS_TYPE_BTR 4/* * Tell the fs layer which block device an partition to use for future
lib/Makefile +1 -0
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o endif COBJS-y += crc32.o +COBJS-y += crc32_c.o COBJS-y += ctype.o COBJS-y += div64.o COBJS-y += linux_string.o
lib/crc32_c.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copied from Linux kernel crypto/crc32c.c +* Copyright (c) 2004 Cisco Systems, Inc. +* Copyright (c) 2008 Herbert Xu <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +* +*/ +#include <linux/stat.h> +#include <command.h> +#include <asm/byteorder.h> +#include <linux/compiler.h> +#include <common.h> +#include <config.h> + +u32 crc32c_cal (u32 crc,const char *data,size_t length,u32 *crc32c_table) +{ +while (length--) + crc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >>8 ); + +return crc; +} + +void crc32c_init (u32 *crc32c_table,u32 pol) +{ +int i, j; +u32 v; +const u32 poly = pol;/* Bit-reflected CRC32C polynomial */ + +for (i =0 ; i <256 ; i++) { + v = i; +for (j =0 ; j <8 ; j++) + v = (v >>1 ) ^ ((v &1 ) ? poly :0 ); + + crc32c_table[i] = v; + } +}
Signature · 1 line
1.7.9.5
PATCH v9 1/1 Introduced btrfs file-system with btrload command
Dear Adnan Ali,
Quoted 9 lines · In message <[email protected]> you…
Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.v8: patch re-formated. v7: patch re-formated. v6: patch re-formated.
What exactly is going on here? Why do you have to go through so many iterations just reformatting again and again and again?
Makefile endif · line 260
Quoted 6 lines
+++ b/Makefile
Makefile +1
-0@@ -257,6 +257,7 @@ endif LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o LIBS-y += fs/libfs.o \ + fs/btrfs/libbtrfs.o \
Indentation by TAB only, please.
common/cmd_btr.c line 37
Quoted 4 lines
common/cmd_btr.c new file +4
-0+if (argc >5 ) +strcpy (subvolname, argv[5 ]); +else +strcpy (subvolname,"" );
Please just to:
subvolname[0] = '\0';
fs/btrfs/btrfs.c line 59
Quoted 11 lines
fs/btrfs/btrfs.c new file +11
-0+void btrfs_type (char num) +{ +switch (num) { +case BTRFS_FILE : +printf ("<FILE> " );break ; +case BTRFS_DIR : +printf ("<DIR> " );break ; +case BTRFS_SYMLNK : +printf ("<SYM> " );break ; +default : +printf ("<UNKNOWN>" );break ;
Can you please use puts() instead of print() for all output that does not really need any formatting?
fs/btrfs/btrfs.c line 113
Quoted 9 lines
fs/btrfs/btrfs.c new file +9
-0+if (ret <0 ) + low = mid +1 ; +else if (ret >0 ) + high = mid; +else { + *slot = mid; + +return 0 ; + }
Is this imported code?
CodingStyle says to use braces in all branches if not all branches of a conditional statement are single line statements. This should be fixed globally.
fs/btrfs/btrfs.c line 134
Quoted 7 lines
fs/btrfs/btrfs.c new file +7
-0+if (__le64_to_cpu (m1->logical) >__le64_to_cpu (m2->logical)) + +return 1 ; + +if (__le64_to_cpu (m1->logical) <__le64_to_cpu (m2->logical)) + +return -1 ;
Is this imported code? Otherwise: can we drop these empty lines before the returns?
fs/btrfs/btrfs.c line 160
Quoted 3 lines
fs/btrfs/btrfs.c new file +3
-0+if (ret ==0 )/* already in map */ + +return ;
Ditto.
fs/btrfs/btrfs.c line 191
Quoted 5 lines
fs/btrfs/btrfs.c new file +5
-0+if (ret ==0 ) + slot++; +else if (slot ==0 ) + +return -1 ;
Ditto. etc. This should be fixed globally.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de To be is to program.
PATCH v9 1/1 Introduced btrfs file-system with btrload command
Quoted 9 lines · Wolfgang Denk
Dear Adnan Ali,
Quoted 6 lines · In message <[email protected]> you…
Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.
Quoted 6 lines
Quoted 3 lines
v8: patch re-formated. v7: patch re-formated. v6: patch re-formated.What exactly is going on here? Why do you have to go through so many iterations just reformatting again and again and again?
Yes, most of "patch re-formatted" really means "reworked for checkpatch problems".
Quoted 6 lines
Quoted 6 lines
fs/btrfs/btrfs.c new file +6
-0+void btrfs_type (char num) +{ +switch (num) { +case BTRFS_FILE : +printf ("<FILE> " );break ; +case BTRFS_DIR :
Quoted 8 lines
fs/btrfs/btrfs.c line 59
Quoted 5 lines
fs/btrfs/btrfs.c new file +5
-0+printf ("<DIR> " );break ; +case BTRFS_SYMLNK : +printf ("<SYM> " );break ; +default : +printf ("<UNKNOWN>" );break ;Can you please use
puts()instead ofprint()for all output that does not really need any formatting?
Agreed (and with the other stuff I've snipped too, as those are introduced).
Quoted 11 lines
fs/btrfs/btrfs.c line 113
Quoted 9 lines
fs/btrfs/btrfs.c new file +9
-0+if (ret <0 ) + low = mid +1 ; +else if (ret >0 ) + high = mid; +else { + *slot = mid; + +return 0 ; + }Is this imported code?
Yes.
Quoted 10 lines
fs/btrfs/btrfs.c line 134
Quoted 7 lines
fs/btrfs/btrfs.c new file +7
-0+if (__le64_to_cpu (m1->logical) >__le64_to_cpu (m2->logical)) + +return 1 ; + +if (__le64_to_cpu (m1->logical) <__le64_to_cpu (m2->logical)) + +return -1 ;Is this imported code? Otherwise: can we drop these empty lines before the returns?
This, and the rest are not. But checkpatch.pl doesn't complain about them either, annoyingly. Adnan, try doing a diff between the syslinux and u-boot files to look for other whitespace oddities that got introduced. Thanks. And, thanks for fixing all of the problems checkpatch does catch.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130320/30786bec/attachment.pgp>
PATCH v9 1/1 Introduced btrfs file-system with btrload command
Quoted 31 lines · Tom Rini
Quoted 9 lines · Wolfgang Denk
Dear Adnan Ali,
Quoted 6 lines · In message <[email protected]> you…
Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.Quoted 5 lines
Quoted 3 lines
v8: patch re-formated. v7: patch re-formated. v6: patch re-formated.What exactly is going on here? Why do you have to go through so many iterations just reformatting again and again and again?
Yes, most of "patch re-formatted" really means "reworked for checkpatch problems".
Quoted 5 lines
Quoted 5 lines
fs/btrfs/btrfs.c new file +5
-0+void btrfs_type (char num) +{ +switch (num) { +case BTRFS_FILE : +printf ("<FILE> " );break ;Quoted 8 lines
fs/btrfs/btrfs.c line 59
Quoted 6 lines
fs/btrfs/btrfs.c new file +6
-0+case BTRFS_DIR : +printf ("<DIR> " );break ; +case BTRFS_SYMLNK : +printf ("<SYM> " );break ; +default : +printf ("<UNKNOWN>" );break ;Can you please use
puts()instead ofprint()for all output that does not really need any formatting?
Quoted 2 lines
Agreed (and with the other stuff I've snipped too, as those are introduced).
Simon was happy with that after i changed all error messages to
debug. But i can change unformatted messages to puts. if everyone
is agrees.
Quoted 11 lines
Quoted 10 lines
fs/btrfs/btrfs.c line 113
Quoted 9 lines
fs/btrfs/btrfs.c new file +9
-0+if (ret <0 ) + low = mid +1 ; +else if (ret >0 ) + high = mid; +else { + *slot = mid; + +return 0 ; + }Is this imported code?
Yes.
yes
Quoted 10 lines
Quoted 10 lines
fs/btrfs/btrfs.c line 134
Quoted 8 lines
fs/btrfs/btrfs.c new file +7
-0+if (__le64_to_cpu (m1->logical) >__le64_to_cpu (m2->logical)) + +return 1 ; + +if (__le64_to_cpu (m1->logical) <__le64_to_cpu (m2->logical)) + +return -1 ;Is this imported code? Otherwise: can we drop these empty lines before the returns?
It wasn't like that simon asked me to add line before return statement.
He was happy with that too. Again i will remove it once everyone agreed it is the right way.
Quoted 6 lines
This, and the rest are not. But checkpatch.pl doesn't complain about them either, annoyingly. Adnan, try doing a diff between the syslinux and u-boot files to look for other whitespace oddities that got introduced. Thanks. And, thanks for fixing all of the problems checkpatch does catch.
According to checkpatch there are no whitespaces and errors.
But what exactly are you after. Even though i have removed all errors and warnings from whole patch.
Thanks
Adnan Ali
PATCH v9 1/1 Introduced btrfs file-system with btrload command
Quoted 32 lines · Adnan Ali
Quoted 31 lines · Tom Rini
Quoted 9 lines · Wolfgang Denk
Dear Adnan Ali,
Quoted 6 lines · In message <[email protected]> you…
Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.Quoted 5 lines
Quoted 3 lines
v8: patch re-formated. v7: patch re-formated. v6: patch re-formated.What exactly is going on here? Why do you have to go through so many iterations just reformatting again and again and again?
Yes, most of "patch re-formatted" really means "reworked for checkpatch problems".
Quoted 13 lines
fs/btrfs/btrfs.c line 59
Quoted 11 lines
fs/btrfs/btrfs.c new file +11
-0+void btrfs_type (char num) +{ +switch (num) { +case BTRFS_FILE : +printf ("<FILE> " );break ; +case BTRFS_DIR : +printf ("<DIR> " );break ; +case BTRFS_SYMLNK : +printf ("<SYM> " );break ; +default : +printf ("<UNKNOWN>" );break ;Can you please use
puts()instead ofprint()for all output that does not really need any formatting?
Quoted 5 lines
Quoted 2 lines
Agreed (and with the other stuff I've snipped too, as those are introduced).
Simon was happy with that after i changed all error messages to
debug. But i can change unformatted messages to puts. if everyone
is agrees.
OK, so what we're saying is that here you should use puts() (which still always prints, but is quicker when using a constant string with no formatting characaters).
Quoted 22 lines
Quoted 11 lines
Quoted 10 lines
fs/btrfs/btrfs.c line 113
Quoted 9 lines
fs/btrfs/btrfs.c new file +9
-0+if (ret <0 ) + low = mid +1 ; +else if (ret >0 ) + high = mid; +else { + *slot = mid; + +return 0 ; + }Is this imported code?
Yes.
yes
Quoted 10 lines
Quoted 10 lines
fs/btrfs/btrfs.c line 134
Quoted 8 lines
fs/btrfs/btrfs.c new file +7
-0+if (__le64_to_cpu (m1->logical) >__le64_to_cpu (m2->logical)) + +return 1 ; + +if (__le64_to_cpu (m1->logical) <__le64_to_cpu (m2->logical)) + +return -1 ;Is this imported code? Otherwise: can we drop these empty lines before the returns?
Quoted 3 lines
It wasn't like that simon asked me to add line before return statement.
He was happy with that too. Again i will remove it once everyone agreed it is the right way.
What Simon means (and the right style is):
if (foo)
return;
if (bar)
return;
I think what you had before was:
if (foo)
return; if (bar) return;
Or even:
if (foo) return;
Quoted 9 lines
Quoted 6 lines
This, and the rest are not. But checkpatch.pl doesn't complain about them either, annoyingly. Adnan, try doing a diff between the syslinux and u-boot files to look for other whitespace oddities that got introduced. Thanks. And, thanks for fixing all of the problems checkpatch does catch.
According to checkpatch there are no whitespaces and errors.
But what exactly are you after. Even though i have removed all errors and warnings from whole patch.
Yes, you've fixed everything checkpatch finds, so thanks. There's a few things however that checkpatch didn't catch such as using puts() when you're printing strings and not using formatting characters or spacing problems in Makefiles, or the if (...) blank line return construct.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130320/45f64f12/attachment.pgp>