Ignore:
Timestamp:
Feb 2, 2016, 9:54:35 PM (8 years ago)
Author:
coas-nagasima
Message:

SDカードの中身を/~/でアクセスできるよう変更

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uKadecot/trunk/uip/apps/webserver/httpd-fs.c

    r108 r154  
    3838#include "pff.h"
    3939#include "diskio.h"
     40#include "mmc_rspi.h"
     41#include <string.h>
    4042
    4143//#define FILE_DUMP
    4244#ifdef FILE_DUMP
    43 #include <string.h>
    4445char path[256] = "";
    4546FATFS fs;
     
    9899        FRESULT res;
    99100#endif
    100         disk_initialize();
     101        ramdisk_initialize();
     102        mmc_rspi_initialize();
    101103#ifdef FILE_DUMP
    102104        if((res = pf_mount(&fs)) != FR_OK){
     
    112114/*-----------------------------------------------------------------------------------*/
    113115int
    114 httpd_fs_open(const char *name, struct httpd_fs_file *file)
     116httpd_fs_open(int drv, const char *name, struct httpd_fs_file *file)
    115117{
    116118        FRESULT res;
    117         FATFS *fs = (FATFS *)&file->fs;
     119        FATFS *fs = (FATFS *)file->fs;
     120
     121        file->pos = 0;
     122        file->len = 0;
     123        file->drv = drv;
     124        file->name = name;
     125        memset(fs, 0, sizeof(FATFS));
     126
     127        if (drv == 0) {
     128                fs->disk_get_status = ramdisk_get_status;
     129                fs->disk_readp = ramdisk_readp;
     130                fs->disk_writep = ramdisk_writep;
     131        }
     132        else {
     133                fs->disk_get_status = mmc_rspi_get_status;
     134                fs->disk_readp = mmc_rspi_readp;
     135                fs->disk_writep = mmc_rspi_writep;
     136        }
    118137
    119138        if (fs->fs_type == 0){
     
    125144
    126145        if((res = pf_open(fs, name)) != FR_OK){
    127                 printf("pf_open(%s) => %d\n", name, res);
     146                printf("pf_open(%d:%s) => %d\n", drv, name, res);
    128147                return 0;
    129148        }
    130149
    131         file->pos = 0;
    132150        file->len = fs->fsize;
    133         file->name = name;
    134151
    135         //printf("httpd_fs_open(%s) %d\n", name, file->len);
     152        //printf("httpd_fs_open(%d:%s) %d\n", drv, name, file->len);
    136153
    137154        return 1;
     
    143160        FRESULT ret;
    144161        UINT rlen;
    145         FATFS *fs = (FATFS *)&file->fs;
     162        FATFS *fs = (FATFS *)file->fs;
    146163
    147164        if((ret = pf_lseek(fs, file->pos)) != FR_OK){
    148                 printf("pf_lseek(%d) => %d\n", file->pos, ret);
     165                printf("pf_lseek(%d:%s, %d) => %d\n", file->drv, file->name, file->pos, ret);
    149166                return 0;
    150167        }
    151168
    152169        if(file->pos != fs->fptr){
    153                 printf("pf_lseek(%d) != %d\n", file->pos, fs->fptr);
     170                printf("pf_lseek(%d:%s, %d) != %d\n", file->drv, file->name, file->pos, fs->fptr);
    154171        }
    155172
    156173        if((ret = pf_read(fs, dst, len, &rlen)) != FR_OK){
    157                 printf("pf_read(%x, %d) => %d\n", dst, len, ret);
     174                printf("pf_read(%d:%s, 0x%p, %d) => %d\n", file->drv, file->name, dst, len, ret);
    158175                return 0;
    159176        }
    160177
    161         //printf("httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
     178        //printf("httpd_fs_read(%d:%s, %d, %d) => %d\n", file->drv, file->name, file->pos, len, rlen);
    162179
    163180        return rlen;
Note: See TracChangeset for help on using the changeset viewer.