From: "Łukasz Majewski" <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/8] fs/fat: split out helper to init fsdata
Date: Sun, 3 Sep 2017 16:52:43 +0200 [thread overview]
Message-ID: <6bc19661-c4c5-5e47-a085-0844a349a37b@denx.de> (raw)
In-Reply-To: <20170902163806.27265-2-robdclark@gmail.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 4339 bytes --]
On 09/02/2017 06:37 PM, Rob Clark wrote:
> Want to re-use this in fat dirent iterator in next patch.
>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Łukasz Majewski <lukma@denx.de>
> ---
> fs/fat/fat.c | 73 +++++++++++++++++++++++++++++++++++------------------------
> include/fat.h | 1 +
> 2 files changed, 44 insertions(+), 30 deletions(-)
>
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index 465a6875ed..e1c0a15dc7 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -808,35 +808,17 @@ exit:
> return ret;
> }
>
> -__u8 do_fat_read_at_block[MAX_CLUSTSIZE]
> - __aligned(ARCH_DMA_MINALIGN);
> -
> -int do_fat_read_at(const char *filename, loff_t pos, void *buffer,
> - loff_t maxsize, int dols, int dogetsize, loff_t *size)
> +static int get_fs_info(fsdata *mydata)
> {
> - char fnamecopy[2048];
> boot_sector bs;
> volume_info volinfo;
> - fsdata datablock;
> - fsdata *mydata = &datablock;
> - dir_entry *dentptr = NULL;
> - __u16 prevcksum = 0xffff;
> - char *subname = "";
> - __u32 cursect;
> - int idx, isdir = 0;
> - int files = 0, dirs = 0;
> - int ret = -1;
> - int firsttime;
> __u32 root_cluster = 0;
> - __u32 read_blk;
> - int rootdir_size = 0;
> - int buffer_blk_cnt;
> - int do_read;
> - __u8 *dir_ptr;
> + int ret;
>
> - if (read_bootsectandvi(&bs, &volinfo, &mydata->fatsize)) {
> + ret = read_bootsectandvi(&bs, &volinfo, &mydata->fatsize);
> + if (ret) {
> debug("Error: reading boot sector\n");
> - return -1;
> + return ret;
> }
>
> if (mydata->fatsize == 32) {
> @@ -848,8 +830,7 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,
>
> mydata->fat_sect = bs.reserved;
>
> - cursect = mydata->rootdir_sect
> - = mydata->fat_sect + mydata->fatlength * bs.fats;
> + mydata->rootdir_sect = mydata->fat_sect + mydata->fatlength * bs.fats;
>
> mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
> mydata->clust_size = bs.cluster_size;
> @@ -863,12 +844,12 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,
> mydata->data_begin = mydata->rootdir_sect -
> (mydata->clust_size * 2);
> } else {
> - rootdir_size = ((bs.dir_entries[1] * (int)256 +
> - bs.dir_entries[0]) *
> - sizeof(dir_entry)) /
> - mydata->sect_size;
> + mydata->rootdir_size = ((bs.dir_entries[1] * (int)256 +
> + bs.dir_entries[0]) *
> + sizeof(dir_entry)) /
> + mydata->sect_size;
> mydata->data_begin = mydata->rootdir_sect +
> - rootdir_size -
> + mydata->rootdir_size -
> (mydata->clust_size * 2);
> }
>
> @@ -893,6 +874,38 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,
> debug("Sector size: %d, cluster size: %d\n", mydata->sect_size,
> mydata->clust_size);
>
> + return 0;
> +}
> +
> +__u8 do_fat_read_at_block[MAX_CLUSTSIZE]
> + __aligned(ARCH_DMA_MINALIGN);
> +
> +int do_fat_read_at(const char *filename, loff_t pos, void *buffer,
> + loff_t maxsize, int dols, int dogetsize, loff_t *size)
> +{
> + char fnamecopy[2048];
> + fsdata datablock;
> + fsdata *mydata = &datablock;
> + dir_entry *dentptr = NULL;
> + __u16 prevcksum = 0xffff;
> + char *subname = "";
> + __u32 cursect;
> + int idx, isdir = 0;
> + int files = 0, dirs = 0;
> + int ret = -1;
> + int firsttime;
> + __u32 root_cluster = 0;
> + __u32 read_blk;
> + int rootdir_size = 0;
> + int buffer_blk_cnt;
> + int do_read;
> + __u8 *dir_ptr;
> +
> + if (get_fs_info(mydata))
> + return -1;
> +
> + cursect = mydata->rootdir_sect;
> +
> /* "cwd" is always the root... */
> while (ISDIRDELIM(*filename))
> filename++;
> diff --git a/include/fat.h b/include/fat.h
> index 71879f01ca..6d3fc8e4a6 100644
> --- a/include/fat.h
> +++ b/include/fat.h
> @@ -174,6 +174,7 @@ typedef struct {
> __u16 clust_size; /* Size of clusters in sectors */
> int data_begin; /* The sector of the first cluster, can be negative */
> int fatbufnum; /* Used by get_fatent, init to -1 */
> + int rootdir_size;
> } fsdata;
>
> typedef int (file_detectfs_func)(void);
>
--
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
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
next prev parent reply other threads:[~2017-09-03 14:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-02 16:37 [U-Boot] [PATCH v2 0/8] fs/fat: cleanups + readdir implementation Rob Clark
2017-09-02 16:37 ` [U-Boot] [PATCH v2 1/8] fs/fat: split out helper to init fsdata Rob Clark
2017-09-03 14:52 ` Łukasz Majewski [this message]
2017-09-03 15:47 ` Rob Clark
2017-09-03 16:16 ` Łukasz Majewski
2017-09-05 8:55 ` Simon Glass
2017-09-02 16:37 ` [U-Boot] [PATCH v2 2/8] fs/fat: introduce new director iterators Rob Clark
2017-09-03 15:08 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
2017-09-05 9:54 ` Rob Clark
2017-09-09 4:55 ` Simon Glass
2017-09-09 10:34 ` Rob Clark
2017-09-02 16:37 ` [U-Boot] [PATCH v2 3/8] fat/fs: convert to directory iterators Rob Clark
2017-09-03 15:08 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
2017-09-06 2:18 ` Rob Clark
2017-09-02 16:37 ` [U-Boot] [PATCH v2 4/8] fs: add fs_readdir() Rob Clark
2017-09-03 15:16 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
2017-09-05 10:48 ` Rob Clark
2017-09-02 16:38 ` [U-Boot] [PATCH v2 5/8] fs/fat: implement opendir/readdir/closedir Rob Clark
2017-09-03 15:17 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
2017-09-02 16:38 ` [U-Boot] [PATCH v2 6/8] fat/fs: remove a bunch of dead code Rob Clark
2017-09-05 8:56 ` Simon Glass
2017-09-02 16:38 ` [U-Boot] [PATCH v2 7/8] fat/fs: move ls to generic implementation Rob Clark
2017-09-03 15:19 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
2017-09-06 2:12 ` Rob Clark
2017-09-02 16:38 ` [U-Boot] [PATCH v2 8/8] fs/fat: fix case for FAT shortnames Rob Clark
2017-09-03 15:22 ` Łukasz Majewski
2017-09-05 8:56 ` Simon Glass
-- strict thread matches above, loose matches on Subject: below --
2017-08-14 13:16 [U-Boot] [PATCH v2 0/8] fs/fat: cleanups + readdir implementation Rob Clark
2017-08-14 13:16 ` [U-Boot] [PATCH v2 1/8] fs/fat: split out helper to init fsdata Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6bc19661-c4c5-5e47-a085-0844a349a37b@denx.de \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.