public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V4 3/3] fs: add filesystem switch libary, implement ls and fsload commands
Date: Tue, 30 Oct 2012 21:23:05 +0100 (CET)	[thread overview]
Message-ID: <964860449.281207.1351628585903.JavaMail.root@advansee.com> (raw)
In-Reply-To: <1350924231-5830-3-git-send-email-swarren@wwwdotorg.org>

Hi Stephen,

On Monday, October 22, 2012 6:43:51 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Implement "ls" and "fsload" commands that act like
> {fat,ext2}{ls,load},
> and transparently handle either file-system. This scheme could easily
> be
> extended to other filesystem types; I only didn't do it for zfs
> because
> I don't have any filesystems of that type to test with.
> 
> Replace the implementation of {fat,ext[24]}{ls,load} with this new
> code
> too.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Sorry to come after this has been applied. I've been ultra busy lately.

[--snip--]
> diff --git a/fs/fs.c b/fs/fs.c
> new file mode 100644
> index 0000000..23ffa25
> --- /dev/null
> +++ b/fs/fs.c
> @@ -0,0 +1,308 @@
[--snip--]
> +int do_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> argv[],
> +		int fstype)
> +{
> +	unsigned long addr;
> +	const char *addr_str;
> +	const char *filename;
> +	unsigned long bytes;
> +	unsigned long pos;
> +	int len_read;
> +	char buf[12];
> +
> +	if (argc < 5)

With the arguments now made optional, this should rather be:
+	if (argc < 2)

> +		return CMD_RET_USAGE;
> +
> +	if (fs_set_blk_dev(argv[1], argv[2], fstype))

With <dev[:part]> being optional, this should rather be:
+	if (fs_set_blk_dev(argv[1], (argc >= 3) ? argv[2] : NULL, fstype))

> +		return 1;
> +
> +	if (argc >= 4) {
> +		addr = simple_strtoul(argv[3], NULL, 0);

0 is just natural here. However, this raises the issue of the users of the
legacy fat and ext commands, which used 16 here. So should we use 0 because it
is cleaner, or 16 in order not to break compatibility for existing users?

> +	} else {
> +		addr_str = getenv("loadaddr");
> +		if (addr_str != NULL)
> +			addr = simple_strtoul(addr_str, NULL, 16);

Ditto.

> +		else
> +			addr = CONFIG_SYS_LOAD_ADDR;
> +	}
> +	if (argc >= 5) {
> +		filename = argv[4];
> +	} else {
> +		filename = getenv("bootfile");
> +		if (!filename) {
> +			puts("** No boot file defined **\n");
> +			return 1;
> +		}
> +	}
> +	if (argc >= 6)
> +		bytes = simple_strtoul(argv[5], NULL, 0);

Ditto.

> +	else
> +		bytes = 0;
> +	if (argc >= 7)
> +		pos = simple_strtoul(argv[6], NULL, 0);

Ditto.

> +	else
> +		pos = 0;
> +
> +	len_read = fs_read(filename, addr, pos, bytes);
> +	if (len_read <= 0)
> +		return 1;
> +
> +	printf("%d bytes read\n", len_read);
> +
> +	sprintf(buf, "0x%x", len_read);
> +	setenv("filesize", buf);
> +
> +	return 0;
> +}
> +
> +int do_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> +	int fstype)
> +{
> +	if (argc < 2)
> +		return CMD_RET_USAGE;
> +
> +	if (fs_set_blk_dev(argv[1], (argc >= 3) ? argv[2] : NULL, fstype))
> +		return 1;
> +
> +	if (fs_ls(argc == 4 ? argv[3] : "/"))

IMHO, it would be better to just ignore the possible extra arguments, like in:
+	if (fs_ls(argc >= 4 ? argv[3] : "/"))

> +		return 1;
> +
> +	return 0;
> +}
[--snip--]

Best regards,
Beno?t

  parent reply	other threads:[~2012-10-30 20:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 16:43 [U-Boot] [PATCH V4 1/3] fs: delete unused Makefile Stephen Warren
2012-10-22 16:43 ` [U-Boot] [PATCH V4 2/3] fs: separate CONFIG_FS_{FAT, EXT4} from CONFIG_CMD_{FAT, EXT*} Stephen Warren
2012-10-22 16:43 ` [U-Boot] [PATCH V4 3/3] fs: add filesystem switch libary, implement ls and fsload commands Stephen Warren
2012-10-30 11:05   ` Andreas Bießmann
2012-10-30 16:47     ` Tom Rini
2012-10-30 18:29       ` [U-Boot] [PATCH] fs/fs.c: fix fs_set_blk_dev() for manual relocation Andreas Bießmann
2012-10-30 18:41         ` Stephen Warren
2012-10-30 22:19           ` Tom Rini
2012-10-31  9:42           ` Andreas Bießmann
2012-10-30 17:50     ` [U-Boot] [PATCH] fs: handle CONFIG_NEEDS_MANUAL_RELOC Stephen Warren
2012-10-31  9:47       ` Andreas Bießmann
2012-11-04 18:28         ` Tom Rini
2012-10-30 20:23   ` Benoît Thébaudeau [this message]
2012-10-30 21:18     ` [U-Boot] [PATCH V4 3/3] fs: add filesystem switch libary, implement ls and fsload commands Stephen Warren
2012-10-30 21:29       ` Tom Rini
2012-10-30 21:59       ` Benoît Thébaudeau
2012-10-30 22:01         ` Stephen Warren
2012-10-31 10:43   ` Andreas Bießmann
2012-10-31 17:03     ` Stephen Warren
2012-10-29 22:55 ` [U-Boot] [PATCH V4 1/3] fs: delete unused Makefile Tom Rini

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=964860449.281207.1351628585903.JavaMail.root@advansee.com \
    --to=benoit.thebaudeau@advansee.com \
    --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