Lines Matching refs:obj
956 if (Files[i].fs == dp->obj.fs && /* Check if the object matches with an open object */ in chk_share()
957 Files[i].clu == dp->obj.sclust && in chk_share()
990 if (Files[i].fs == dp->obj.fs in inc_share()
991 && Files[i].clu == dp->obj.sclust in inc_share()
998 Files[i].fs = dp->obj.fs; in inc_share()
999 Files[i].clu = dp->obj.sclust; in inc_share()
1162 FFOBJID* obj, /* Corresponding object */ in get_fat() argument
1168 FATFS *fs = obj->fs; in get_fat()
1198 …if ((obj->objsize != 0 && obj->sclust != 0) || obj->stat == 0) { /* Object except root dir must ha… in get_fat()
1199 DWORD cofs = clst - obj->sclust; /* Offset from start cluster */ in get_fat()
1200 …DWORD clen = (DWORD)((LBA_t)((obj->objsize - 1) / SS(fs)) / fs->csize); /* Number of clusters - 1 … in get_fat()
1202 if (obj->stat == 2 && cofs <= clen) { /* Is it a contiguous chain? */ in get_fat()
1206 if (obj->stat == 3 && cofs < obj->n_cont) { /* Is it in the 1st fragment? */ in get_fat()
1210 if (obj->stat != 2) { /* Get value from FAT if FAT chain is valid */ in get_fat()
1211 if (obj->n_frag != 0) { /* Is it on the growing edge? */ in get_fat()
1381 FFOBJID* obj /* Pointer to the corresponding object */ in fill_first_frag() argument
1388 if (obj->stat == 3) { /* Has the object been changed 'fragmented' in this session? */ in fill_first_frag()
1389 for (cl = obj->sclust, n = obj->n_cont; n; cl++, n--) { /* Create cluster chain on the FAT */ in fill_first_frag()
1390 res = put_fat(obj->fs, cl, cl + 1); in fill_first_frag()
1393 obj->stat = 0; /* Change status 'FAT chain is valid' */ in fill_first_frag()
1404 FFOBJID* obj, /* Pointer to the corresponding object */ in fill_last_frag() argument
1412 while (obj->n_frag > 0) { /* Create the chain of last fragment */ in fill_last_frag()
1413 res = put_fat(obj->fs, lcl - obj->n_frag + 1, (obj->n_frag > 1) ? lcl - obj->n_frag + 2 : term); in fill_last_frag()
1415 obj->n_frag--; in fill_last_frag()
1430 FFOBJID* obj, /* Corresponding object */ in remove_chain() argument
1437 FATFS *fs = obj->fs; in remove_chain()
1448 if (pclst != 0 && (!FF_FS_EXFAT || fs->fs_type != FS_EXFAT || obj->stat != 2)) { in remove_chain()
1455 nxt = get_fat(obj, clst); /* Get cluster status */ in remove_chain()
1492 obj->stat = 0; /* Change the chain status 'initial' */ in remove_chain()
1494 if (obj->stat == 0) { /* Is it a fragmented chain from the beginning of this session? */ in remove_chain()
1495 clst = obj->sclust; /* Follow the chain to check if it gets contiguous */ in remove_chain()
1497 nxt = get_fat(obj, clst); in remove_chain()
1504 obj->stat = 2; /* Change the chain status 'contiguous' */ in remove_chain()
1507 …if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Was the cha… in remove_chain()
1508 obj->stat = 2; /* Change the chain status 'contiguous' */ in remove_chain()
1525 FFOBJID* obj, /* Corresponding object */ in create_chain() argument
1531 FATFS *fs = obj->fs; in create_chain()
1539 cs = get_fat(obj, clst); /* Check the cluster status */ in create_chain()
1555 obj->stat = 2; /* Set status 'contiguous' */ in create_chain()
1557 if (obj->stat == 2 && ncl != scl + 1) { /* Is the chain got fragmented? */ in create_chain()
1558 obj->n_cont = scl - obj->sclust; /* Set size of the contiguous part */ in create_chain()
1559 obj->stat = 3; /* Change status 'just fragmented' */ in create_chain()
1562 if (obj->stat != 2) { /* Is the file non-contiguous? */ in create_chain()
1564 obj->n_frag = obj->n_frag ? obj->n_frag + 1 : 2; /* Increment size of last framgent */ in create_chain()
1566 if (obj->n_frag == 0) obj->n_frag = 1; in create_chain()
1567 res = fill_last_frag(obj, clst, ncl); /* Fill last fragment on the FAT and link it to new one */ in create_chain()
1568 if (res == FR_OK) obj->n_frag = 1; in create_chain()
1578 cs = get_fat(obj, ncl); /* Get next cluster status */ in create_chain()
1594 cs = get_fat(obj, ncl); /* Get the cluster status */ in create_chain()
1634 FATFS *fs = fp->obj.fs; in clmt_clust()
1703 FATFS *fs = dp->obj.fs; in dir_sdi()
1710 clst = dp->obj.sclust; /* Table start cluster (0:root) */ in dir_sdi()
1713 if (FF_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ in dir_sdi()
1723 clst = get_fat(&dp->obj, clst); /* Get next cluster */ in dir_sdi()
1751 FATFS *fs = dp->obj.fs; in dir_next()
1768 clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ in dir_next()
1776 clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ in dir_next()
1781 if (FF_FS_EXFAT) dp->obj.stat |= 4; /* exFAT: The directory has been stretched */ in dir_next()
1813 FATFS *fs = dp->obj.fs;
2136 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */
2140 res = move_window(dp->obj.fs, dp->sect);
2151 res = move_window(dp->obj.fs, dp->sect);
2163 res = move_window(dp->obj.fs, dp->sect);
2183 FFOBJID* obj /* Object allocation information to be initialized */ argument
2186 obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Start cluster */
2187 obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); /* Size */
2188 obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; /* Allocation status */
2189 obj->n_frag = 0; /* No last fragment info */
2201 const FFOBJID* obj /* Object with its containing directory information */ argument
2207 dp->obj.fs = obj->fs;
2208 dp->obj.sclust = obj->c_scl;
2209 dp->obj.stat = (BYTE)obj->c_size;
2210 dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2211 dp->obj.n_frag = 0;
2212 dp->blk_ofs = obj->c_ofs;
2234 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the directory entry block 85+C0+C1s */
2243 res = move_window(dp->obj.fs, dp->sect);
2246 dp->obj.fs->wflag = 1;
2312 FATFS *fs = dp->obj.fs;
2334 dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */
2342 dp->obj.attr = attr = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
2389 FATFS *fs = dp->obj.fs;
2427 dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK;
2448 dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK;
2470 FATFS *fs = dp->obj.fs;
2486 if (dp->obj.stat & 4) { /* Has the directory been stretched by new allocation? */
2487 dp->obj.stat &= ~4;
2488 res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
2490 …res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if nee…
2492 if (dp->obj.sclust != 0) { /* Is it a sub-directory? */
2495 res = load_obj_xdir(&dj, &dp->obj); /* Load the object status */
2497 dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2498 st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize);
2499 st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2500 fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; /* Update the allocation status */
2576 FATFS *fs = dp->obj.fs;
2626 FATFS *fs = dp->obj.fs;
2862 p = *path; lfn = dp->obj.fs->lfnbuf; di = 0;
3058 FATFS *fs = dp->obj.fs;
3063 dp->obj.sclust = fs->cdir; /* Start at the current directory */
3068 dp->obj.sclust = 0; /* Start from the root directory */
3071 dp->obj.n_frag = 0; /* Invalidate last fragment counter of the object */
3073 if (fs->fs_type == FS_EXFAT && dp->obj.sclust) { /* exFAT: Retrieve the sub-directory's status */
3076 dp->obj.c_scl = fs->cdc_scl;
3077 dp->obj.c_size = fs->cdc_size;
3078 dp->obj.c_ofs = fs->cdc_ofs;
3079 res = load_obj_xdir(&dj, &dp->obj);
3081 dp->obj.objsize = ld_dword(fs->dirbuf + XDIR_FileSize);
3082 dp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2;
3111 if (!(dp->obj.attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */
3116 dp->obj.c_scl = dp->obj.sclust;
3117 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
3118 dp->obj.c_ofs = dp->blk_ofs;
3119 init_alloc_info(fs, &dp->obj); /* Open next directory */
3123 dp->obj.sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */
3614 …FFOBJID* obj, /* Pointer to the FFOBJID, the 1st member in the FIL/DIR structure, to check valid… argument
3621 …if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) { /* Test if the object is valid…
3623 if (lock_volume(obj->fs, 0)) { /* Take a grant to access the volume */
3624 …if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the hosting phsical drive is kept ini…
3627 unlock_volume(obj->fs, FR_OK); /* Invalidated volume, abort to access */
3633 …if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the hosting phsical drive is kept ini…
3638 *rfs = (res == FR_OK) ? obj->fs : 0; /* Return corresponding filesystem object if it is valid */
3740 dj.obj.fs = fs;
3767 if (dj.obj.attr & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */
3777 fp->obj.fs = fs;
3778 init_alloc_info(fs, &fp->obj);
3786 if (res == FR_OK && fp->obj.sclust != 0) { /* Remove the cluster chain if exist */
3787 res = remove_chain(&fp->obj, fp->obj.sclust, 0);
3788 fs->last_clst = fp->obj.sclust - 1; /* Reuse the cluster hole */
3804 res = remove_chain(&dj.obj, cl, 0);
3815 if (dj.obj.attr & AM_DIR) { /* File open against a directory */
3818 if ((mode & FA_WRITE) && (dj.obj.attr & AM_RDO)) { /* Write mode open against R/O file */
3829 fp->obj.lockid = inc_share(&dj, (mode & ~FA_READ) ? 1 : 0); /* Lock the file for this session */
3830 if (fp->obj.lockid == 0) res = FR_INT_ERR;
3838 if (dj.obj.attr & AM_DIR) { /* Is it a directory? */
3848 fp->obj.c_scl = dj.obj.sclust; /* Get containing directory info */
3849 fp->obj.c_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat;
3850 fp->obj.c_ofs = dj.blk_ofs;
3851 init_alloc_info(fs, &fp->obj);
3855 fp->obj.sclust = ld_clust(fs, dj.dir); /* Get object allocation info */
3856 fp->obj.objsize = ld_dword(dj.dir + DIR_FileSize);
3861 fp->obj.fs = fs; /* Validate the file object */
3862 fp->obj.id = fs->id;
3871 …if ((mode & FA_SEEKEND) && fp->obj.objsize > 0) { /* Seek to end of file if FA_OPEN_APPEND is spec…
3872 fp->fptr = fp->obj.objsize; /* Offset to seek */
3874 clst = fp->obj.sclust; /* Follow the cluster chain */
3875 for (ofs = fp->obj.objsize; res == FR_OK && ofs > bcs; ofs -= bcs) {
3876 clst = get_fat(&fp->obj, clst);
3893 if (res != FR_OK) dec_share(fp->obj.lockid); /* Decrement file open counter if seek failed */
3902 if (res != FR_OK) fp->obj.fs = 0; /* Invalidate file object on error */
3931 res = validate(&fp->obj, &fs); /* Check validity of the file object */
3934 remain = fp->obj.objsize - fp->fptr;
3942 clst = fp->obj.sclust; /* Follow cluster chain from the origin */
3950 clst = get_fat(&fp->obj, fp->clust); /* Follow cluster chain on the FAT */
4030 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4039 …= wcnt, wbuff += wcnt, fp->fptr += wcnt, fp->obj.objsize = (fp->fptr > fp->obj.objsize) ? fp->fptr…
4044 clst = fp->obj.sclust; /* Follow from the origin */
4046 clst = create_chain(&fp->obj, 0); /* create a new cluster chain */
4055 clst = create_chain(&fp->obj, fp->clust); /* Follow or stretch cluster chain on the FAT */
4062 if (fp->obj.sclust == 0) fp->obj.sclust = clst; /* Set start cluster if the first write */
4098 if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling on the growing edge */
4104 fp->fptr < fp->obj.objsize &&
4145 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4158 res = fill_first_frag(&fp->obj); /* Fill first fragment on the FAT if needed */
4160 …res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed …
4167 res = load_obj_xdir(&dj, &fp->obj); /* Load directory entry block */
4170 fs->dirbuf[XDIR_GenFlags] = fp->obj.stat | 1; /* Update file allocation information */
4171 st_dword(fs->dirbuf + XDIR_FstClus, fp->obj.sclust); /* Update start cluster */
4172 st_qword(fs->dirbuf + XDIR_FileSize, fp->obj.objsize); /* Update file size */
4173 …st_qword(fs->dirbuf + XDIR_ValidFileSize, fp->obj.objsize); /* (FatFs does not support Valid File …
4192 st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation information */
4193 st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */
4228 res = validate(&fp->obj, &fs); /* Lock volume */
4231 res = dec_share(fp->obj.lockid); /* Decrement file open counter */
4232 if (res == FR_OK) fp->obj.fs = 0; /* Invalidate file object */
4234 fp->obj.fs = 0; /* Invalidate file object */
4285 dj.obj.fs = fs;
4290 fs->cdir = dj.obj.sclust;
4293 fs->cdc_scl = dj.obj.c_scl;
4294 fs->cdc_size = dj.obj.c_size;
4295 fs->cdc_ofs = dj.obj.c_ofs;
4299 if (dj.obj.attr & AM_DIR) { /* It is a sub-directory */
4303 fs->cdc_scl = dj.obj.sclust; /* Save containing directory information */
4304 fs->cdc_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat;
4356 dj.obj.fs = fs;
4362 dj.obj.sclust = fs->cdir; /* Start to follow upper directory from current directory */
4363 while ((ccl = dj.obj.sclust) != 0) { /* Repeat while current directory is a sub-directory */
4368 dj.obj.sclust = ld_clust(fs, dj.dir); /* Goto parent directory */
4449 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4453 …res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed …
4463 cl = fp->obj.sclust; /* Origin of the chain */
4470 cl = get_fat(&fp->obj, cl);
4486 if (ofs > fp->obj.objsize) ofs = fp->obj.objsize; /* Clip offset at the file size */
4515 …if (ofs > fp->obj.objsize && (FF_FS_READONLY || !(fp->flag & FA_WRITE))) { /* In read-only mode, c…
4516 ofs = fp->obj.objsize;
4528 clst = fp->obj.sclust; /* start from the first cluster */
4531 clst = create_chain(&fp->obj, 0);
4534 fp->obj.sclust = clst;
4544 …if (FF_FS_EXFAT && fp->fptr > fp->obj.objsize) { /* No FAT chain object needs correct objsize to g…
4545 fp->obj.objsize = fp->fptr;
4548 clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */
4555 clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */
4569 …if (!FF_FS_READONLY && fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is e…
4570 fp->obj.objsize = fp->fptr;
4612 dp->obj.fs = fs;
4617 if (dp->obj.attr & AM_DIR) { /* This object is a sub-directory */
4620 dp->obj.c_scl = dp->obj.sclust; /* Get containing directory inforamation */
4621 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
4622 dp->obj.c_ofs = dp->blk_ofs;
4623 init_alloc_info(fs, &dp->obj); /* Get object allocation info */
4627 dp->obj.sclust = ld_clust(fs, dp->dir); /* Get object allocation info */
4634 dp->obj.id = fs->id;
4638 if (dp->obj.sclust != 0) {
4639 dp->obj.lockid = inc_share(dp, 0); /* Lock the sub directory */
4640 if (!dp->obj.lockid) res = FR_TOO_MANY_OPEN_FILES;
4642 dp->obj.lockid = 0; /* Root directory need not to be locked */
4651 if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function failed */
4671 res = validate(&dp->obj, &fs); /* Check validity of the file object */
4674 if (dp->obj.lockid) res = dec_share(dp->obj.lockid); /* Decrement sub-directory open counter */
4675 if (res == FR_OK) dp->obj.fs = 0; /* Invalidate directory object */
4677 dp->obj.fs = 0; /* Invalidate directory object */
4703 res = validate(&dp->obj, &fs); /* Check validity of the directory object */
4809 res = mount_volume(&path, &dj.obj.fs, 0);
4811 INIT_NAMBUF(dj.obj.fs);
4823 LEAVE_FF(dj.obj.fs, res);
4844 FFOBJID obj; local
4858 clst = 2; obj.fs = fs;
4860 stat = get_fat(&obj, clst);
4938 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4942 if (fp->fptr < fp->obj.objsize) { /* Process when fptr is not on the eof */
4944 res = remove_chain(&fp->obj, fp->obj.sclust, 0);
4945 fp->obj.sclust = 0;
4947 ncl = get_fat(&fp->obj, fp->clust);
4952 res = remove_chain(&fp->obj, ncl, fp->clust);
4955 fp->obj.objsize = fp->fptr; /* Set file size to current read/write point */
4988 FFOBJID obj; local
4996 dj.obj.fs = fs;
5009 if (dj.obj.attr & AM_RDO) {
5015 obj.fs = fs;
5017 init_alloc_info(fs, &obj);
5018 dclst = obj.sclust;
5024 if (dj.obj.attr & AM_DIR) { /* Is it a sub-directory? */
5031 sdj.obj.fs = fs; /* Open the sub-directory */
5032 sdj.obj.sclust = dclst;
5035 sdj.obj.objsize = obj.objsize;
5036 sdj.obj.stat = obj.stat;
5052 res = remove_chain(&obj, dclst, 0);
5054 res = remove_chain(&dj.obj, dclst, 0);
5087 dj.obj.fs = fs;
5112 fs->win[SZDIRE + 1] = '.'; pcl = dj.obj.sclust;
5173 djo.obj.fs = fs;
5192 res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
5214 res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
5224 …if ((dir[DIR_Attr] & AM_DIR) && djo.obj.sclust != djn.obj.sclust) { /* Update .. entry in the sub-…
5233 st_clust(fs, dir, djn.obj.sclust);
5281 dj.obj.fs = fs;
5327 dj.obj.fs = fs;
5378 dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
5529 dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
5593 res = validate(&fp->obj, &fs); /* Check validity of the file object */
5595 if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED);
5622 n = get_fat(&fp->obj, clst);
5655 fp->obj.sclust = scl; /* Update object allocation information */
5656 fp->obj.objsize = fsz;
5657 if (FF_FS_EXFAT) fp->obj.stat = 2; /* Set status 'contiguous chain' */
5695 res = validate(&fp->obj, &fs); /* Check validity of the file object */
5699 remain = fp->obj.objsize - fp->fptr;
5707 fp->obj.sclust : get_fat(&fp->obj, fp->clust);