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/pfatfs/pff.c

    r108 r154  
    5858#define ABORT(err)      {fs->flag = 0; return err;}
    5959
    60 #if _USE_LFN
    61 static WCHAR LfnBuf[_MAX_LFN+1];
    62 #endif
    63 
    6460/*--------------------------------------------------------*/
    6561/* DBCS code ranges and SBCS extend char conversion table */
     
    509505                ofs = bc % 512; bc /= 512;
    510506                if (ofs != 511) {
    511                         if (disk_readp(buf, fs->fatbase + bc, ofs, 2)) break;
     507                        if (fs->disk_readp(buf, fs->fatbase + bc, ofs, 2)) break;
    512508                } else {
    513                         if (disk_readp(buf, fs->fatbase + bc, 511, 1)) break;
    514                         if (disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break;
     509                        if (fs->disk_readp(buf, fs->fatbase + bc, 511, 1)) break;
     510                        if (fs->disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break;
    515511                }
    516512                wc = LD_WORD(buf);
     
    520516#if _FS_FAT16
    521517        case FS_FAT16 :
    522                 if (disk_readp(buf, fs->fatbase + clst / 256, ((UINT)clst % 256) * 2, 2)) break;
     518                if (fs->disk_readp(buf, fs->fatbase + clst / 256, ((UINT)clst % 256) * 2, 2)) break;
    523519                return LD_WORD(buf);
    524520#endif
    525521#if _FS_FAT32
    526522        case FS_FAT32 :
    527                 if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break;
     523                if (fs->disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break;
    528524                return LD_DWORD(buf) & 0x0FFFFFFF;
    529525#endif
     
    673669        BYTE a, ord, sum;
    674670#endif
     671        FATFS *fs = dj->fs;
    675672
    676673        res = dir_rewind(dj);                   /* Rewind directory object */
     
    681678#endif
    682679        do {
    683                 res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32)      /* Read an entry */
     680                res = fs->disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32)  /* Read an entry */
    684681                        ? FR_DISK_ERR : FR_OK;
    685682                if (res != FR_OK) break;
     
    735732        BYTE ord = 0xFF, sum = 0xFF;
    736733#endif
     734        FATFS *fs = dj->fs;
    737735
    738736        res = FR_NO_FILE;
    739737        while (dj->sect) {
    740                 res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32)      /* Read an entry */
     738                res = fs->disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32)  /* Read an entry */
    741739                        ? FR_DISK_ERR : FR_OK;
    742740                if (res != FR_OK) break;
     
    10721070)
    10731071{
    1074         if (disk_readp(buf, sect, 510, 2))              /* Read the boot record */
     1072        if (fs->disk_readp(buf, sect, 510, 2))          /* Read the boot record */
    10751073                return 3;
    10761074        if (LD_WORD(buf) != 0xAA55)                             /* Check record signature */
    10771075                return 2;
    10781076
    1079         if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146)  /* Check FAT12/16 */
     1077        if (!_FS_32ONLY && !fs->disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146)      /* Check FAT12/16 */
    10801078                return 0;
    1081         if (_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146)  /* Check FAT32 */
     1079        if (_FS_FAT32 && !fs->disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146)      /* Check FAT32 */
    10821080                return 0;
    10831081        return 1;
     
    11061104        DWORD bsect, fsize, tsect, mclst;
    11071105
    1108         if (disk_get_status() & STA_NOINIT)     /* Check if the drive is ready or not */
     1106        if (fs->disk_get_status() & STA_NOINIT) /* Check if the drive is ready or not */
    11091107                return FR_NOT_READY;
    11101108
     
    11141112        if (fmt == 1) {                                         /* Not an FAT boot record, it may be FDISK format */
    11151113                /* Check a partition listed in top of the partition table */
    1116                 if (disk_readp(buf, bsect, MBR_Table, 16)) {    /* 1st partition entry */
     1114                if (fs->disk_readp(buf, bsect, MBR_Table, 16)) {        /* 1st partition entry */
    11171115                        fmt = 3;
    11181116                } else {
     
    11271125
    11281126        /* Initialize the file system object */
    1129         if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR;
     1127        if (fs->disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR;
    11301128
    11311129        fsize = LD_WORD(buf+BPB_FATSz16-13);                            /* Number of sectors per FAT */
     
    11871185        dj.fn = sp;
    11881186#if _USE_LFN
    1189         dj.lfn = LfnBuf;
     1187        dj.lfn = fs->LfnBuf;
    11901188#endif
    11911189        res = follow_path(&dj, dir, path);      /* Follow the file path */
     
    12491247                rcnt = 512 - (UINT)fs->fptr % 512;                      /* Get partial sector data from sector buffer */
    12501248                if (rcnt > btr) rcnt = btr;
    1251                 dr = disk_readp(!buff ? 0 : rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt);
     1249                dr = fs->disk_readp(!buff ? 0 : rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt);
    12521250                if (dr) ABORT(FR_DISK_ERR);
    12531251                fs->fptr += rcnt; rbuff += rcnt;                        /* Update pointers and counters */
     
    12861284
    12871285        if (!btw) {             /* Finalize request */
    1288                 if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR);
     1286                if ((fs->flag & FA__WIP) && fs->disk_writep(0, 0)) ABORT(FR_DISK_ERR);
    12891287                fs->flag &= ~FA__WIP;
    12901288                return FR_OK;
     
    13101308                        if (!sect) ABORT(FR_DISK_ERR);
    13111309                        fs->dsect = sect + cs;
    1312                         if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR);      /* Initiate a sector write operation */
     1310                        if (fs->disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR);  /* Initiate a sector write operation */
    13131311                        fs->flag |= FA__WIP;
    13141312                }
    13151313                wcnt = 512 - (UINT)fs->fptr % 512;                      /* Number of bytes to write to the sector */
    13161314                if (wcnt > btw) wcnt = btw;
    1317                 if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR);   /* Send data to the sector */
     1315                if (fs->disk_writep(p, wcnt)) ABORT(FR_DISK_ERR);       /* Send data to the sector */
    13181316                fs->fptr += wcnt; p += wcnt;                            /* Update pointers and counters */
    13191317                btw -= wcnt; *bw += wcnt;
    13201318                if ((UINT)fs->fptr % 512 == 0) {
    1321                         if (disk_writep(0, 0)) ABORT(FR_DISK_ERR);      /* Finalize the currtent secter write operation */
     1319                        if (fs->disk_writep(0, 0)) ABORT(FR_DISK_ERR);  /* Finalize the currtent secter write operation */
    13221320                        fs->flag &= ~FA__WIP;
    13231321                }
     
    14011399                dj->fn = sp;
    14021400#if _USE_LFN
    1403                 dj->lfn = LfnBuf;
     1401                dj->lfn = fs->LfnBuf;
    14041402#endif
    14051403                res = follow_path(dj, dir, path);               /* Follow the path to the directory */
Note: See TracChangeset for help on using the changeset viewer.