Skip to contentSkip to conversation

Addition of btrfs file-system in U-boot

PATCH Superseded Adnan Ali 3 participants 5 messages Mar 14, 2013 – Mar 15, 2013

Subsystems (4)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Adnan Ali

author
#0 lore raw

PATCH v7 1/1 Addition of btrfs file-system in U-boot

Adnan Ali (1):
Introduced btrfs file-system with btrload command

 Makefile                   |    1 +
 common/Makefile            |    1 +
 common/cmd_btr.c           |   65 +++
 fs/btrfs/Makefile          |   51 ++
 fs/btrfs/btrfs.c           | 1357 ++++++++++++++++++++++++++++++++++++++++++++
 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, 1955 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
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v7 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.

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           | 1357 ++++++++++++++++++++++++++++++++++++++++++++
 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, 1955 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
index 55bd55c..b3da594 100644
@@ -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
index 719fc23..d1fae56 100644
@@ -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 +1357 -0

1,357 lines not on this page · raw message

fs/fs.c +10 -0
index 6f5063c..58b155c 100644
@@ -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
index bfb9680..28a0a66 100644
@@ -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
index 10560c9..5e5b1f0 100644
@@ -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
index b6d69e5..a8b97ea 100644
@@ -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
index 86ca1a6..9518b72 100644
@@ -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
new file mode 100644
index 0000000..b97c98a
@@ -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
#2 lore raw

PATCH v7 1/1 Introduced btrfs file-system with btrload command

Hi,

Quoted 6 lines · Adnan Ali

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.

Quoted 6 lines
v7:     patch re-formated.
v6:     patch re-formated.
v5:     merged with master.
v4:     btrls command added.

This is close enough I think. You shouldn't have 'char' return values on the fs.h interface functions, and no blank line after 'return'. I will leave it to Tom to see if he is happy with the command parameters.

Thanks.

Quoted 20 lines
---
 Makefile                   |    1 +
 common/Makefile            |    1 +
 common/cmd_btr.c           |   65 +++
 fs/btrfs/Makefile          |   51 ++
 fs/btrfs/btrfs.c           | 1357 ++++++++++++++++++++++++++++++++++++++++++++
 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, 1955 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
author
#3 lore raw

PATCH v7 1/1 Introduced btrfs file-system with btrload command

Hi

Quoted 15 lines · Simon Glass

Hi,

Quoted 6 lines · Adnan Ali

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.

Quoted 6 lines
v7:     patch re-formated.
v6:     patch re-formated.
v5:     merged with master.
v4:     btrls command added.
Quoted 8 lines

This is close enough I think. You shouldn't have 'char' return values on the fs.h interface functions, and no blank line after 'return'. I will leave it to Tom to see if he is happy with the command parameters.

Thanks.

Thanks ;)

Quoted 13 lines
Quoted 13 lines
---
  Makefile                   |    1 +
  common/Makefile            |    1 +
  common/cmd_btr.c           |   65 +++
  fs/btrfs/Makefile          |   51 ++
  fs/btrfs/btrfs.c           | 1357 ++++++++++++++++++++++++++++++++++++++++++++
  fs/fs.c                    |   10 +
  include/btrfs.h            |  416 ++++++++++++++
  include/config_fallbacks.h |    4 +
  include/crc.h              |    8 +
  include/fs.h               |    1 +
  lib/Makefile               |    1 +
Quoted 8 lines
Quoted 8 lines
  lib/crc32_c.c              |   40 ++
  12 files changed, 1955 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

Thanks

Adnan Ali

#4 lore raw

PATCH v7 1/1 Introduced btrfs file-system with btrload command

In reply to Adnan Ali
Quoted 5 lines · Adnan Ali

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.

OK, sorry for not doing this part sooner, but I compared the btrfs code in syslinux to your code and there's a lot of whitespace problems in fs/btrfs/btrfs.c that you:
trini at bill-the-cat:~/work/u-boot/u-boot$ ./tools/checkpatch.pl -f fs/btrfs/btrfs.c | grep ^ERROR | wc -l
320
trini at bill-the-cat:~/work/u-boot/u-boot$ ./tools/checkpatch.pl -f ~/work/syslinux/core/fs/btrfs/btrfs.c | grep ^ERR | wc -l
7

Please fix this, use whitespace consistent with the rest of the file for the U-Boot specific functions you're adding and as Simon noted, 'char' for a return type on btrfs_ls isn't really right (please follow fat or ext* for examples).

Thanks and again, sorry for not noticing this sooner in the reviews.

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/20130315/783f502e/attachment.pgp>