1 #include <linux/types.h>
7 int ext4_read_content(int dev,int part,const char *filename, void *buf, int offset, int len)
10 block_dev_desc_t *dev_desc;
12 dev_desc = get_dev("mmc", dev);
14 printf("ext4_read_content get dev error\n");
18 get_partition_info(dev_desc,part,&info);
19 /* set the device as block device */
20 ext4fs_set_blk_dev(dev_desc, &info);
22 /* mount the filesystem */
23 if (!ext4fs_mount(info.size)) {
24 printf("Bad ext4 partition part=%d\n", part);
29 if (ext4_read_file(filename, (unsigned char *)buf, offset,len) == -1) {
30 printf("** Error ext4_read_file() **\n");
33 printf("ext4_read_content %s\n",buf);
43 int ext4_read_content(int dev, wchar_t* partition_name, const char *filename, void *buf, int offset, int len)
45 disk_partition_t info;
46 block_dev_desc_t *dev_desc;
48 dev_desc = get_dev("mmc", dev);
50 printf("ext4_read_content get dev error\n");
54 if(get_partition_info_by_name (dev_desc, partition_name, &info) == -1){
55 printf("## Valid EFI partition not found ##\n");
59 /* set the device as block device */
60 ext4fs_set_blk_dev(dev_desc, &info);
62 /* mount the filesystem */
63 if (!ext4fs_mount(info.size)) {
64 // printf("Bad ext4 partition part=%d\n", part);
69 if (ext4_read_file(filename, (unsigned char *)buf, offset,len) == -1) {
70 printf("** Error ext4_read_file() **\n");
83 int ext4_write_content(int dev, wchar_t* partition_name,char* filename,unsigned char *ram_address,int file_size)
85 disk_partition_t info;
86 block_dev_desc_t *dev_desc;
88 dev_desc = get_dev("mmc", dev);
90 printf("ext4_write_data get dev error\n");
94 if(get_partition_info_by_name (dev_desc, partition_name, &info) == -1){
95 printf("## Valid EFI partition not found ##\n");
99 /* set the device as block device */
100 ext4fs_set_blk_dev(dev_desc, &info);
102 /* mount the filesystem */
103 if (!ext4fs_mount(info.size)) {
104 // printf("Bad ext4 partition part=%d\n", part);
109 if (ext4fs_write(filename, (unsigned char *)ram_address, file_size)) {
110 printf("** Error ext4fs_write() **\n");
123 int ext4_write_content(int dev,int part,char* filename,unsigned char *ram_address,int file_size)
125 disk_partition_t info;
126 block_dev_desc_t *dev_desc;
128 dev_desc = get_dev("mmc", dev);
129 if(NULL == dev_desc){
130 printf("ext4_write_data get dev error\n");
134 get_partition_info(dev_desc,part,&info);
135 /* set the device as block device */
136 ext4fs_set_blk_dev(dev_desc, &info);
138 /* mount the filesystem */
139 if (!ext4fs_mount(info.size)) {
140 printf("Bad ext4 partition part=%d\n", part);
145 if (ext4fs_write(filename, (unsigned char *)ram_address, file_size)) {
146 printf("** Error ext4fs_write() **\n");