Newer
Older
return 1;
if ((part = jffs2_part_info(current_dev, current_partnum))){
/* check partition type for cramfs */
if (cramfs_check(part)) {
ret = cramfs_ls (part, filename);
} else {
/* if this is not cramfs assume jffs2 */
ret = jffs2_1pass_ls(part, filename);
}
return ret ? 0 : 1;
/**
* Routine implementing u-boot fsinfo command. This routine prints out
* miscellaneous filesystem informations/statistics.
*
* @param cmdtp command internal data
* @param flag command flag
* @param argc number of arguments supplied to the command
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* make sure we are in sync with env variables */
if (mtdparts_init() !=0)
return 1;
if ((part = jffs2_part_info(current_dev, current_partnum))){
/* check partition type for cramfs */
fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2");
printf("### filesystem type is %s\n", fsname);
if (cramfs_check(part)) {
ret = cramfs_info (part);
} else {
/* if this is not cramfs assume jffs2 */
ret = jffs2_1pass_info(part);
}
return ret ? 0 : 1;
/* command line only */
#ifdef CONFIG_JFFS2_CMDLINE
/**
* Routine implementing u-boot chpart command. Sets new current partition based
* on the user supplied partition id. For partition id format see find_dev_and_part().
*
* @param cmdtp command internal data
* @param flag command flag
* @param argc number of arguments supplied to the command
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
int do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* command line only */
struct mtd_device *dev;
struct part_info *part;
u8 pnum;
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
if (mtdparts_init() !=0)
return 1;
if (argc < 2) {
printf("no partition id specified\n");
return 1;
}
if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0)
return 1;
current_dev = dev;
current_partnum = pnum;
current_save();
printf("partition changed to %s%d,%d\n",
MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum);
return 0;
}
/**
* Routine implementing u-boot mtdparts command. Initialize/update default global
* partition list and process user partition request (list, add, del).
*
* @param cmdtp command internal data
* @param flag command flag
* @param argc number of arguments supplied to the command
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
setenv("mtdids", (char *)mtdids_default);
setenv("mtdparts", (char *)mtdparts_default);
setenv("partition", NULL);
mtdparts_init();
return 0;
} else if (strcmp(argv[1], "delall") == 0) {
/* this may be the first run, initialize lists if needed */
mtdparts_init();
setenv("mtdparts", NULL);
/* jffs2_devices_init() calls current_save() */
return jffs2_devices_init();
/* make sure we are in sync with env variables */
if (mtdparts_init() != 0)
return 1;
if (argc == 1) {
list_partitions();
/* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
#define PART_ADD_DESC_MAXLEN 64
char tmpbuf[PART_ADD_DESC_MAXLEN];
u8 type, num, len;
struct mtd_device *dev;
struct mtd_device *dev_tmp;
struct mtdids *id;
struct part_info *p;
if (id_parse(argv[2], NULL, &type, &num) != 0)
return 1;
if ((id = id_find(type, num)) == NULL) {
printf("no such device %s defined in mtdids variable\n", argv[2]);
return 1;
}
len = strlen(id->mtd_id) + 1; /* 'mtd_id:' */
len += strlen(argv[3]); /* size@offset */
len += strlen(argv[4]) + 2; /* '(' name ')' */
if (argv[5] && (strlen(argv[5]) == 2))
len += 2; /* 'ro' */
if (len >= PART_ADD_DESC_MAXLEN) {
printf("too long partition description\n");
return 1;
}
sprintf(tmpbuf, "%s:%s(%s)%s",
id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : "");
DEBUGF("add tmpbuf: %s\n", tmpbuf);
if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev))
return 1;
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
dev->id->num, dev->id->mtd_id);
if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
device_add(dev);
} else {
/* merge new partition with existing ones*/
p = list_entry(dev->parts.next, struct part_info, link);
if (part_add(dev_tmp, p) != 0) {
device_del(dev);
return 1;
}
}
if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
printf("generated mtdparts too long, reseting to null\n");
return 1;
}
return 0;
}
/* mtdparts del part-id */
if ((argc == 3) && (strcmp(argv[1], "del") == 0)) {
DEBUGF("del: part-id = %s\n", argv[2]);
return delete_partition(argv[2]);
}
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
/***************************************************/
U_BOOT_CMD(
fsload, 3, 0, do_jffs2_fsload,
"fsload\t- load binary file from a filesystem image\n",
"[ off ] [ filename ]\n"
" - load binary file from flash bank\n"
" with offset 'off'\n"
);
U_BOOT_CMD(
ls, 2, 1, do_jffs2_ls,
"ls\t- list files in a directory (default /)\n",
"[ directory ]\n"
" - list files in a directory.\n"
);
U_BOOT_CMD(
fsinfo, 1, 1, do_jffs2_fsinfo,
"fsinfo\t- print information about filesystems\n",
" - print information about filesystems\n"
);
#ifdef CONFIG_JFFS2_CMDLINE
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
chpart, 2, 0, do_jffs2_chpart,
"chpart\t- change active partition\n",
"part-id\n"
" - change active partition (e.g. part-id = nand0,1)\n"
);
U_BOOT_CMD(
mtdparts, 6, 0, do_jffs2_mtdparts,
"mtdparts- define flash/nand partitions\n",
"\n"
" - list partition table\n"
"mtdparts delall\n"
" - delete all partitions\n"
"mtdparts del part-id\n"
" - delete partition (e.g. part-id = nand0,1)\n"
"mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
" - add partition\n"
"mtdparts default\n"
" - reset partition table to defaults\n\n"
"-----\n\n"
"this command uses three environment variables:\n\n"
"'partition' - keeps current partition identifier\n\n"
"partition := <part-id>\n"
"<part-id> := <dev-id>,part_num\n\n"
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
"mtdids=<idmap>[,<idmap>,...]\n\n"
"<idmap> := <dev-id>=<mtd-id>\n"
"<dev-id> := 'nand'|'nor'|'onenand'<dev-num>\n"
"<dev-num> := mtd device number, 0...\n"
"<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
"'mtdparts' - partition list\n\n"
"mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]\n\n"
"<mtd-def> := <mtd-id>:<part-def>[,<part-def>...]\n"
"<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n"
"<part-def> := <size>[@<offset>][<name>][<ro-flag>]\n"
"<size> := standard linux memsize OR '-' to denote all remaining space\n"
"<offset> := partition start offset within the device\n"
"<name> := '(' NAME ')'\n"
"<ro-flag> := when set to 'ro' makes partition read-only (not used, passed to kernel)\n"
#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
/***************************************************/