Пример #1
0
static void lookup_partition(const char *name)
{
    int rc;

    if (flash_side == 1) {
        uint32_t other_side_offset;

        rc = open_partition("OTHER_SIDE");
        if (rc == FFS_ERR_PART_NOT_FOUND)
            fprintf(stderr, "side 1 was specified but there doesn't appear"
                    " to be a second side to this flash\n");
        if (rc)
            exit(1);

        /* Just need to know where it starts */
        rc = ffs_part_info(ffsh, ffs_index, NULL, &other_side_offset, NULL, NULL, NULL);
        if (rc)
            exit(1);

        ffs_close(ffsh);
        ffsh = NULL;

        ffs_toc = other_side_offset;
    }

    rc = open_partition(name);
    if (rc)
        exit(1);
}
Пример #2
0
/*
 * Write MSC Command
 */
void msc_cmd_write()
{
	int msc_pt_handle;
	uint32_t processed_bytes;
	
	msc_pt_handle = 0;
	
	if (open_partition("MSC", PARTITION_OPEN_WRITE, &msc_pt_handle))
		goto finish;
	
	write_partition(msc_pt_handle, &msc_cmd, sizeof(msc_cmd), &processed_bytes);
	
finish:
	close_partition(msc_pt_handle);
	return;	
}
Пример #3
0
int main(int argc, char ** argv) {
	if (argc != 2) {
		printf("Need file partition argument!\n");
		exit(1);
	}
	FILE* fd = fopen(argv[1],"rb+");

	struct fat_partition fat_part;
	open_partition(&fat_part, fd, read_func, write_func);

/*	char filenames[110][11];
	list_directory(&fat_part, "/DIR3/", &filenames[0][0], 110, 0);
	char ret = file_open(&fat_part, "/F1", 0);
	char mybuffer[1024];
	int ret2 = file_read(&fat_part, ret, mybuffer,512);
	ret2 = file_read(&fat_part, ret, mybuffer,512);
	ret2 = file_read(&fat_part, ret, mybuffer,512);
	mybuffer[ret2] = 0;
	printf("SIZE: %d\n%s\n",ret2,mybuffer);*/
if (1)
{
	char ret = file_open(&fat_part, "/F1", 0);
	char mybuf[512];
	int i;
	if (ret != -1) {
		for (i = 0; i < 512; i++) mybuf[i] = 'a'+(i*i)%24;
		for (i = 0; i < 256*16; i++)
			file_write(&fat_part, ret, mybuf, 512);
	}
}

if (1) {
	char ret = file_open(&fat_part, "/F1", 0);
	char mybuffer[1000*1024];
	int ret2 = file_read(&fat_part, ret, mybuffer,1000*1024);
	mybuffer[ret2] = 0;
//	printf("%s\nSIZE: %d\n",mybuffer,ret2);
}

	close(fd);
}
Пример #4
0
/*
 * Read MSC command
 */
void msc_cmd_read()
{
	struct msc_command my_cmd;
	int msc_pt_handle;
	uint32_t processed_bytes;
	
	msc_pt_handle = 0;
	
	if (open_partition("MSC", PARTITION_OPEN_READ, &msc_pt_handle))
		goto finish;
	
	if (read_partition(msc_pt_handle, &my_cmd, sizeof(my_cmd), &processed_bytes))
		goto finish;
	
	if (processed_bytes != sizeof(my_cmd))
		goto finish;
	
	memcpy(&msc_cmd, &my_cmd, sizeof(my_cmd));
		
finish:
	close_partition(msc_pt_handle);
	return;
}