int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    char *filename = "/";
    int ret, dev, part;
    block_dev_desc_t *dev_desc=NULL;
    disk_partition_t info;

    if (argc < 2) {
        printf("usage: fatls <interface> [<dev[:part]>] [directory]\n");
        return 0;
    }

    part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
    if (part < 0)
        return 1;

    dev = dev_desc->dev;
    if (fat_register_device(dev_desc,part)!=0) {
        printf("\n** Unable to use %s %d:%d for fatls **\n",
               argv[1], dev, part);
        return 1;
    }
    if (argc == 4)
        ret = file_fat_ls(argv[3]);
    else
        ret = file_fat_ls(filename);

    if(ret!=0)
        printf("No Fat FS detected\n");
    return ret;
}
Exemple #2
0
int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    char *filename = "/";
    int ret;
    int dev=0;
    int part=1;
    char *ep;
    block_dev_desc_t *dev_desc=NULL;

    if (argc < 3) {
        printf("usage: fatls <interface> <dev[:part]> [directory]\n");
        return 0;
    }
    dev = (int)simple_strtoul(argv[2], &ep, 16);
    dev_desc = get_dev(argv[1],dev);
    if (dev_desc == NULL) {
        puts("\n** Invalid boot device **\n");
        return 1;
    }
    if (*ep) {
        if (*ep != ':') {
            puts("\n** Invalid boot device, use `dev[:part]' **\n");
            return 1;
        }
        part = (int)simple_strtoul(++ep, NULL, 16);
    }
    if (fat_register_device(dev_desc,part)!=0) {
        printf("\n** Unable to use %s %d:%d for fatls **\n",
               argv[1], dev, part);
        return 1;
    }
    if (argc == 4)
        ret = file_fat_ls(argv[3]);
    else
        ret = file_fat_ls(filename);

    if(ret!=0)
        printf("No Fat FS detected\n");
    return ret;
}