u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 5/5] fat: implement exists() for FAT fs
Date: Mon, 27 Jan 2014 10:09:31 -0700	[thread overview]
Message-ID: <52E692CB.3000206@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ1EPmsZwzLouoFu9bgFGO8PwNd-VFTU1o31pGUp-6rmOg@mail.gmail.com>

On 01/26/2014 08:52 AM, Simon Glass wrote:
> Hi Stephen,
> 
> On 23 January 2014 12:57, Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
> 
>     From: Stephen Warren <swarren at nvidia.com <mailto:swarren@nvidia.com>>
> 
>     This hooks into the generic "file exists" support added in an earlier
>     patch, and provides an implementation for the ext4 filesystem.

>     diff --git a/fs/fat/fat.c b/fs/fat/fat.c

>     @@ -808,7 +808,7 @@ __u8 do_fat_read_at_block[MAX_CLUSTSIZE]
> 
>      long
>      do_fat_read_at(const char *filename, unsigned long pos, void *buffer,
>     -              unsigned long maxsize, int dols)
>     +              unsigned long maxsize, int dols, int dogetsize)
> 
> I think it would be better to combine the three available operations
> (read, ls and getsize) into an enum and pass the required operation
> explicitly into this function in a single parameter.

I had originally thought that, but the implementation of the function
changes the value of dols during operation. I suppose it would be
possible to achieve that using bit-mask operations on the variable, but
it seemed a bit cleaner to just make it a separate variable rather than
using fields within a somewhat unrelated variable.

Would you still prefer to combine them into one:?

>     -       ret = get_contents(mydata, dentptr, pos, buffer, maxsize);
>     +       if (dogetsize)
>     +               ret = FAT2CPU32(dentptr->size);
>     +       else
>     +              
> 
> 
> Doesn't this mean you are actually reading the contents here into a NULL
> buffer? At least I think it needs a comment as to why this works.
> 
>     ret = get_contents(mydata, dentptr, pos, buffer, maxsize);
>             debug("Size: %d, got: %ld\n", FAT2CPU32(dentptr->size), ret);

get_contents() is the function that actually reads the file content;
everything before this point is simply parsing the directory entry for
the file. So, no, I don't think the file content is read at all.

That implementation of dols!=0 is somewhat similar, although it does
"goto exit" at a different location in the code.

  reply	other threads:[~2014-01-27 17:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 19:56 [U-Boot] [PATCH V2 1/5] fs: fix generic save command implementation Stephen Warren
2014-01-23 19:56 ` [U-Boot] [PATCH V2 2/5] fs: implement infra-structure for an 'exists' function Stephen Warren
2014-01-26 15:41   ` Simon Glass
2014-01-27 17:03     ` Stephen Warren
2014-01-27 17:50       ` Simon Glass
2014-01-26 19:44   ` Wolfgang Denk
2014-01-27 20:51     ` Stephen Warren
2014-01-27 21:44       ` Wolfgang Denk
2014-01-23 19:56 ` [U-Boot] [PATCH V2 3/5] sandbox: implement fs_exists() and 'sb exists' shell function Stephen Warren
2014-01-26 15:42   ` Simon Glass
2014-01-23 19:56 ` [U-Boot] [PATCH V2 4/5] ext4: implement exists() for ext4fs Stephen Warren
2014-01-26 15:45   ` Simon Glass
2014-01-23 19:57 ` [U-Boot] [PATCH V2 5/5] fat: implement exists() for FAT fs Stephen Warren
2014-01-26 15:52   ` Simon Glass
2014-01-27 17:09     ` Stephen Warren [this message]
2014-01-26 15:26 ` [U-Boot] [PATCH V2 1/5] fs: fix generic save command implementation Simon Glass
2014-01-27 17:00   ` Stephen Warren

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=52E692CB.3000206@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).