[U-Boot] [PATCH v6] Introduced btrfs file-system with btrload command
Simon Glass
sjg at chromium.org
Wed Mar 13 23:03:13 CET 2013
Hi Adnan,
On Wed, Mar 13, 2013 at 4:48 AM, Adnan Ali <adnan.ali at codethink.co.uk> wrote:
> 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.
>
> v6: patch re-formated.
> v5: merged with master.
> v4: btrls command added.
> v3: patch re-formated.
> v2: patch error removed.
>
> Signed-off-by: Adnan Ali <adnan.ali at codethink.co.uk>
Sorry there are just a few more nits here, otherwise it looks fine to me.
> ---
> Makefile | 1 +
> common/Makefile | 1 +
> common/cmd_btr.c | 65 +++
> fs/btrfs/Makefile | 51 ++
> fs/btrfs/btrfs.c | 1355 ++++++++++++++++++++++++++++++++++++++++++++
> fs/btrfs/crc32_c.c | 40 ++
> fs/fs.c | 10 +
> include/btrfs.h | 416 ++++++++++++++
> include/config_fallbacks.h | 4 +
> include/fs.h | 1 +
> 10 files changed, 1944 insertions(+)
> create mode 100644 common/cmd_btr.c
> create mode 100644 fs/btrfs/Makefile
> create mode 100644 fs/btrfs/btrfs.c
> create mode 100644 fs/btrfs/crc32_c.c
> create mode 100644 include/btrfs.h
>
[...]
> diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
> new file mode 100644
> index 0000000..19db3a3
> --- /dev/null
> +++ b/fs/btrfs/btrfs.c
> @@ -0,0 +1,1355 @@
> +/*
> + * (C) Copyright 2013 Codethink Limited
> + * Btrfs port to Uboot by
> + * Adnan Ali <adnan.ali at codethink.co.uk>
> +
> + * btrfs.c -- readonly btrfs support for syslinux
> + * Some data structures are derivated from btrfs-tools-0.19 ctree.h
> + * Copyright 2009 Intel Corporation; author: alek.du at intel.com
> + *
> + * 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, Inc., 53 Temple Place Ste 330,
> + * Boston MA 02111-1307, USA; either version 2 of the License, or
> + * (at your option) any later version; incorporated herein by reference.
> + *
> + */
> +
> +#include <common.h>
> +#include <btrfs.h>
> +#include <command.h>
> +#include <config.h>
> +#include <fs.h>
> +#include <linux/compiler.h>
> +#include <linux/ctype.h>
> +#include <linux/stat.h>
> +#include <asm/byteorder.h>
> +
> +unsigned long btr_part_offset;
> +static u16 build_crc_table=1;
Better as u8 I think, or just char (since I don't think we have our
bool type yet). Also if you change it around to 'crc_table_built' then
it can start as 0 (i.e. you don't need to assign it) and this avoid
using the data section.
Note also that you have some lines ending with space, including this one.
> +struct btrfs_info fs;
> +
> +/*
> + * mount btrfs file-system
> + */
> +int btrfs_probe(block_dev_desc_t *rbdd, disk_partition_t *info)
> +{
> + btrfs_block_dev_desc = rbdd;
> + part_info = info;
> + btr_part_offset = info->start;
> + if (btrfs_fs_init(&fs) < 0 ) {
> + debug("btrfs probe failed\n");
Here I think you need two tabs.
> +
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +/*
> + * Read file data
> + */
> +int btrfs_read_file(const char *filename, void *buf, int offset, int len)
> +{
> + int file_len=0;
> + int len_read;
> + struct com32_filedata filedata;
> + int handle;
> + if (offset != 0) {
> + debug("** Cannot support non-zero offset **\n");
> +
> + return -1;
> + }
> +
> + handle=btrfs_open_file(filename, &filedata);
> + if (handle < 0) {
> + debug("** File not found %s Invalid handle**\n", filename);
> +
> + return -1;
> + }
> +
> + /*file handle is valid get the size of the file*/
> + len = filedata.size;
> + if (len == 0)
> + len = file_len;
> +
> + len_read = getfssec(&filedata, (char *)buf);
> + if (len_read != len) {
> + debug("** Unable to read file %s **\n", filename);
> +
> + return -1;
> + }
> +
> + return len_read;
> +
> +}
> +
> +/*
> + * Show directory entries
> + */
> +char btrfs_ls(char *dirname)
> +{
> + struct btrfs_dirent *de;
> + struct _DIR_ *dir;
> +
> + if(*dirname == '/' && *(dirname+1) == 0)
> + *dirname = '.';
> +
> + dir = opendir(dirname);
> + if (dir == NULL)
> + return -1;
> +
> + while ((de = readdir(dir)) != NULL)
> + ;
I think this ; should be intented
> +
> + return 0;
> +}
> +
> +/*
> + * umount btrfs file-system
> + */
> +void btrfs_close(void)
> +{
> +}
> diff --git a/fs/btrfs/crc32_c.c b/fs/btrfs/crc32_c.c
> new file mode 100644
> index 0000000..b97c98a
> --- /dev/null
> +++ b/fs/btrfs/crc32_c.c
What do you think about moving this into lib/ ?
> @@ -0,0 +1,40 @@
> +/*
> + * Copied from Linux kernel crypto/crc32c.c
> + * Copyright (c) 2004 Cisco Systems, Inc.
> + * Copyright (c) 2008 Herbert Xu <herbert at gondor.apana.org.au>
> + *
> + * 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.
> + *
> + */
Regards,
Simon
More information about the U-Boot
mailing list