Lines Matching refs:obj

959 			if (Files[i].fs == dp->obj.fs &&	 	/* Check if the object matches with an open object */  in chk_share()
960 Files[i].clu == dp->obj.sclust && in chk_share()
993 if (Files[i].fs == dp->obj.fs in inc_share()
994 && Files[i].clu == dp->obj.sclust in inc_share()
1001 Files[i].fs = dp->obj.fs; in inc_share()
1002 Files[i].clu = dp->obj.sclust; in inc_share()
1178 FFOBJID* obj, /* Corresponding object */ in get_fat() argument
1184 FATFS *fs = obj->fs; in get_fat()
1214 …if ((obj->objsize != 0 && obj->sclust != 0) || obj->stat == 0) { /* Object except root dir must ha… in get_fat()
1215 DWORD cofs = clst - obj->sclust; /* Offset from start cluster */ in get_fat()
1216 …DWORD clen = (DWORD)((LBA_t)((obj->objsize - 1) / SS(fs)) / fs->csize); /* Number of clusters - 1 … in get_fat()
1218 if (obj->stat == 2 && cofs <= clen) { /* Is it a contiguous chain? */ in get_fat()
1222 if (obj->stat == 3 && cofs < obj->n_cont) { /* Is it in the 1st fragment? */ in get_fat()
1226 if (obj->stat != 2) { /* Get value from FAT if FAT chain is valid */ in get_fat()
1227 if (obj->n_frag != 0) { /* Is it on the growing edge? */ in get_fat()
1397 FFOBJID* obj /* Pointer to the corresponding object */ in fill_first_frag() argument
1404 if (obj->stat == 3) { /* Has the object been changed 'fragmented' in this session? */ in fill_first_frag()
1405 for (cl = obj->sclust, n = obj->n_cont; n; cl++, n--) { /* Create cluster chain on the FAT */ in fill_first_frag()
1406 res = put_fat(obj->fs, cl, cl + 1); in fill_first_frag()
1409 obj->stat = 0; /* Change status 'FAT chain is valid' */ in fill_first_frag()
1420 FFOBJID* obj, /* Pointer to the corresponding object */ in fill_last_frag() argument
1428 while (obj->n_frag > 0) { /* Create the chain of last fragment */ in fill_last_frag()
1429 res = put_fat(obj->fs, lcl - obj->n_frag + 1, (obj->n_frag > 1) ? lcl - obj->n_frag + 2 : term); in fill_last_frag()
1431 obj->n_frag--; in fill_last_frag()
1446 FFOBJID* obj, /* Corresponding object */ in remove_chain() argument
1453 FATFS *fs = obj->fs; in remove_chain()
1464 if (pclst != 0 && (!FF_FS_EXFAT || fs->fs_type != FS_EXFAT || obj->stat != 2)) { in remove_chain()
1471 nxt = get_fat(obj, clst); /* Get cluster status */ in remove_chain()
1508 obj->stat = 0; /* Change the chain status 'initial' */ in remove_chain()
1510 if (obj->stat == 0) { /* Is it a fragmented chain from the beginning of this session? */ in remove_chain()
1511 clst = obj->sclust; /* Follow the chain to check if it gets contiguous */ in remove_chain()
1513 nxt = get_fat(obj, clst); in remove_chain()
1520 obj->stat = 2; /* Change the chain status 'contiguous' */ in remove_chain()
1523 …if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Was the cha… in remove_chain()
1524 obj->stat = 2; /* Change the chain status 'contiguous' */ in remove_chain()
1541 FFOBJID* obj, /* Corresponding object */ in create_chain() argument
1547 FATFS *fs = obj->fs; in create_chain()
1555 cs = get_fat(obj, clst); /* Check the cluster status */ in create_chain()
1571 obj->stat = 2; /* Set status 'contiguous' */ in create_chain()
1573 if (obj->stat == 2 && ncl != scl + 1) { /* Is the chain got fragmented? */ in create_chain()
1574 obj->n_cont = scl - obj->sclust; /* Set size of the contiguous part */ in create_chain()
1575 obj->stat = 3; /* Change status 'just fragmented' */ in create_chain()
1578 if (obj->stat != 2) { /* Is the file non-contiguous? */ in create_chain()
1580 obj->n_frag = obj->n_frag ? obj->n_frag + 1 : 2; /* Increment size of last framgent */ in create_chain()
1582 if (obj->n_frag == 0) obj->n_frag = 1; in create_chain()
1583 res = fill_last_frag(obj, clst, ncl); /* Fill last fragment on the FAT and link it to new one */ in create_chain()
1584 if (res == FR_OK) obj->n_frag = 1; in create_chain()
1594 cs = get_fat(obj, ncl); /* Get next cluster status */ in create_chain()
1610 cs = get_fat(obj, ncl); /* Get the cluster status */ in create_chain()
1652 FATFS *fs = fp->obj.fs; in clmt_clust()
1721 FATFS *fs = dp->obj.fs; in dir_sdi()
1728 clst = dp->obj.sclust; /* Table start cluster (0:root) */ in dir_sdi()
1731 if (FF_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ in dir_sdi()
1741 clst = get_fat(&dp->obj, clst); /* Get next cluster */ in dir_sdi()
1769 FATFS *fs = dp->obj.fs; in dir_next()
1786 clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ in dir_next()
1794 clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ in dir_next()
1799 if (FF_FS_EXFAT) dp->obj.stat |= 4; /* exFAT: The directory has been stretched */ in dir_next()
1831 FATFS *fs = dp->obj.fs;
2154 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */
2158 res = move_window(dp->obj.fs, dp->sect);
2169 res = move_window(dp->obj.fs, dp->sect);
2181 res = move_window(dp->obj.fs, dp->sect);
2202 FFOBJID* obj /* Object allocation information to be initialized */ argument
2205 obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Start cluster */
2206 obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); /* Size */
2207 obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; /* Allocation status */
2208 obj->n_frag = 0; /* No last fragment info */
2220 const FFOBJID* obj /* Object with its containing directory information */ argument
2226 dp->obj.fs = obj->fs;
2227 dp->obj.sclust = obj->c_scl;
2228 dp->obj.stat = (BYTE)obj->c_size;
2229 dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2230 dp->obj.n_frag = 0;
2231 dp->blk_ofs = obj->c_ofs;
2253 BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the entry set 85+C0+C1s */
2263 res = move_window(dp->obj.fs, dp->sect);
2266 dp->obj.fs->wflag = 1;
2333 FATFS *fs = dp->obj.fs;
2355 dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */
2363 dp->obj.attr = attr = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
2410 FATFS *fs = dp->obj.fs;
2448 dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK;
2470 dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK;
2492 FATFS *fs = dp->obj.fs;
2508 if (dp->obj.stat & 4) { /* Has the directory been stretched by new allocation? */
2509 dp->obj.stat &= ~4;
2510 res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
2512 …res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if nee…
2514 if (dp->obj.sclust != 0) { /* Is it a sub-directory? */
2517 res = load_obj_xdir(&dj, &dp->obj); /* Load the object status */
2519 dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2520 st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize);
2521 st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2522 fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; /* Update the allocation status */
2598 FATFS *fs = dp->obj.fs;
2648 FATFS *fs = dp->obj.fs;
2884 p = *path; lfn = dp->obj.fs->lfnbuf; di = 0;
3080 FATFS *fs = dp->obj.fs;
3085 dp->obj.sclust = fs->cdir; /* Start at the current directory */
3090 dp->obj.sclust = 0; /* Start from the root directory */
3093 dp->obj.n_frag = 0; /* Invalidate last fragment counter of the object */
3095 if (fs->fs_type == FS_EXFAT && dp->obj.sclust) { /* exFAT: Retrieve the sub-directory's status */
3098 dp->obj.c_scl = fs->cdc_scl;
3099 dp->obj.c_size = fs->cdc_size;
3100 dp->obj.c_ofs = fs->cdc_ofs;
3101 res = load_obj_xdir(&dj, &dp->obj);
3103 dp->obj.objsize = ld_dword(fs->dirbuf + XDIR_FileSize);
3104 dp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2;
3133 if (!(dp->obj.attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */
3138 dp->obj.c_scl = dp->obj.sclust;
3139 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
3140 dp->obj.c_ofs = dp->blk_ofs;
3141 init_alloc_info(fs, &dp->obj); /* Open next directory */
3145 dp->obj.sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */
3629 …FFOBJID* obj, /* Pointer to the FFOBJID, the 1st member in the FIL/DIR structure, to check valid… argument
3636 …if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) { /* Test if the object is valid…
3638 if (lock_volume(obj->fs, 0)) { /* Take a grant to access the volume */
3639 …if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the hosting physical drive is kept in…
3642 unlock_volume(obj->fs, FR_OK); /* Invalidated volume, abort to access */
3648 …if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the hosting physical drive is kept in…
3653 *rfs = (res == FR_OK) ? obj->fs : 0; /* Return corresponding filesystem object if it is valid */
3755 dj.obj.fs = fs;
3782 if (dj.obj.attr & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */
3792 fp->obj.fs = fs;
3793 init_alloc_info(fs, &fp->obj);
3801 if (res == FR_OK && fp->obj.sclust != 0) { /* Remove the cluster chain if exist */
3802 res = remove_chain(&fp->obj, fp->obj.sclust, 0);
3803 fs->last_clst = fp->obj.sclust - 1; /* Reuse the cluster hole */
3819 res = remove_chain(&dj.obj, cl, 0);
3830 if (dj.obj.attr & AM_DIR) { /* File open against a directory */
3833 if ((mode & FA_WRITE) && (dj.obj.attr & AM_RDO)) { /* Write mode open against R/O file */
3844 fp->obj.lockid = inc_share(&dj, (mode & ~FA_READ) ? 1 : 0); /* Lock the file for this session */
3845 if (fp->obj.lockid == 0) res = FR_INT_ERR;
3853 if (dj.obj.attr & AM_DIR) { /* Is it a directory? */
3863 fp->obj.c_scl = dj.obj.sclust; /* Get containing directory info */
3864 fp->obj.c_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat;
3865 fp->obj.c_ofs = dj.blk_ofs;
3866 init_alloc_info(fs, &fp->obj);
3870 fp->obj.sclust = ld_clust(fs, dj.dir); /* Get object allocation info */
3871 fp->obj.objsize = ld_dword(dj.dir + DIR_FileSize);
3876 fp->obj.fs = fs; /* Validate the file object */
3877 fp->obj.id = fs->id;
3886 …if ((mode & FA_SEEKEND) && fp->obj.objsize > 0) { /* Seek to end of file if FA_OPEN_APPEND is spec…
3887 fp->fptr = fp->obj.objsize; /* Offset to seek */
3889 clst = fp->obj.sclust; /* Follow the cluster chain */
3890 for (ofs = fp->obj.objsize; res == FR_OK && ofs > bcs; ofs -= bcs) {
3891 clst = get_fat(&fp->obj, clst);
3908 if (res != FR_OK) dec_share(fp->obj.lockid); /* Decrement file open counter if seek failed */
3917 if (res != FR_OK) fp->obj.fs = 0; /* Invalidate file object on error */
3946 res = validate(&fp->obj, &fs); /* Check validity of the file object */
3949 remain = fp->obj.objsize - fp->fptr;
3957 clst = fp->obj.sclust; /* Follow cluster chain from the origin */
3965 clst = get_fat(&fp->obj, fp->clust); /* Follow cluster chain on the FAT */
4045 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4054 …= wcnt, wbuff += wcnt, fp->fptr += wcnt, fp->obj.objsize = (fp->fptr > fp->obj.objsize) ? fp->fptr…
4059 clst = fp->obj.sclust; /* Follow from the origin */
4061 clst = create_chain(&fp->obj, 0); /* create a new cluster chain */
4070 clst = create_chain(&fp->obj, fp->clust); /* Follow or stretch cluster chain on the FAT */
4077 if (fp->obj.sclust == 0) fp->obj.sclust = clst; /* Set start cluster if the first write */
4113 if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling on the growing edge */
4119 fp->fptr < fp->obj.objsize &&
4160 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4173 res = fill_first_frag(&fp->obj); /* Fill first fragment on the FAT if needed */
4175 …res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed …
4182 res = load_obj_xdir(&dj, &fp->obj); /* Load directory entry block */
4185 fs->dirbuf[XDIR_GenFlags] = fp->obj.stat | 1; /* Update file allocation information */
4186 st_dword(fs->dirbuf + XDIR_FstClus, fp->obj.sclust); /* Update start cluster */
4187 st_qword(fs->dirbuf + XDIR_FileSize, fp->obj.objsize); /* Update file size */
4188 …st_qword(fs->dirbuf + XDIR_ValidFileSize, fp->obj.objsize); /* (FatFs does not support Valid File …
4207 st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation information */
4208 st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */
4243 res = validate(&fp->obj, &fs); /* Lock volume */
4246 res = dec_share(fp->obj.lockid); /* Decrement file open counter */
4247 if (res == FR_OK) fp->obj.fs = 0; /* Invalidate file object */
4249 fp->obj.fs = 0; /* Invalidate file object */
4300 dj.obj.fs = fs;
4305 fs->cdir = dj.obj.sclust;
4308 fs->cdc_scl = dj.obj.c_scl;
4309 fs->cdc_size = dj.obj.c_size;
4310 fs->cdc_ofs = dj.obj.c_ofs;
4314 if (dj.obj.attr & AM_DIR) { /* It is a sub-directory */
4318 fs->cdc_scl = dj.obj.sclust; /* Save containing directory information */
4319 fs->cdc_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat;
4371 dj.obj.fs = fs;
4377 dj.obj.sclust = fs->cdir; /* Start to follow upper directory from current directory */
4378 while ((ccl = dj.obj.sclust) != 0) { /* Repeat while current directory is a sub-directory */
4383 dj.obj.sclust = ld_clust(fs, dj.dir); /* Goto parent directory */
4464 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4468 …res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed …
4478 cl = fp->obj.sclust; /* Origin of the chain */
4485 cl = get_fat(&fp->obj, cl);
4501 if (ofs > fp->obj.objsize) ofs = fp->obj.objsize; /* Clip offset at the file size */
4530 …if (ofs > fp->obj.objsize && (FF_FS_READONLY || !(fp->flag & FA_WRITE))) { /* In read-only mode, c…
4531 ofs = fp->obj.objsize;
4543 clst = fp->obj.sclust; /* start from the first cluster */
4546 clst = create_chain(&fp->obj, 0);
4549 fp->obj.sclust = clst;
4559 …if (FF_FS_EXFAT && fp->fptr > fp->obj.objsize) { /* No FAT chain object needs correct objsize to g…
4560 fp->obj.objsize = fp->fptr;
4563 clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */
4570 clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */
4584 …if (!FF_FS_READONLY && fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is e…
4585 fp->obj.objsize = fp->fptr;
4627 dp->obj.fs = fs;
4632 if (dp->obj.attr & AM_DIR) { /* This object is a sub-directory */
4635 dp->obj.c_scl = dp->obj.sclust; /* Get containing directory information */
4636 dp->obj.c_size = ((DWORD)dp->obj.objsize & 0xFFFFFF00) | dp->obj.stat;
4637 dp->obj.c_ofs = dp->blk_ofs;
4638 init_alloc_info(fs, &dp->obj); /* Get object allocation info */
4642 dp->obj.sclust = ld_clust(fs, dp->dir); /* Get object allocation info */
4649 dp->obj.id = fs->id;
4653 if (dp->obj.sclust != 0) {
4654 dp->obj.lockid = inc_share(dp, 0); /* Lock the sub directory */
4655 if (!dp->obj.lockid) res = FR_TOO_MANY_OPEN_FILES;
4657 dp->obj.lockid = 0; /* Root directory need not to be locked */
4666 if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function failed */
4686 res = validate(&dp->obj, &fs); /* Check validity of the file object */
4689 if (dp->obj.lockid) res = dec_share(dp->obj.lockid); /* Decrement sub-directory open counter */
4690 if (res == FR_OK) dp->obj.fs = 0; /* Invalidate directory object */
4692 dp->obj.fs = 0; /* Invalidate directory object */
4718 res = validate(&dp->obj, &fs); /* Check validity of the directory object */
4807 res = mount_volume(&path, &dj.obj.fs, 0);
4809 INIT_NAMBUF(dj.obj.fs);
4821 LEAVE_FF(dj.obj.fs, res);
4842 FFOBJID obj; local
4856 clst = 2; obj.fs = fs;
4858 stat = get_fat(&obj, clst);
4936 res = validate(&fp->obj, &fs); /* Check validity of the file object */
4940 if (fp->fptr < fp->obj.objsize) { /* Process when fptr is not on the eof */
4942 res = remove_chain(&fp->obj, fp->obj.sclust, 0);
4943 fp->obj.sclust = 0;
4945 ncl = get_fat(&fp->obj, fp->clust);
4950 res = remove_chain(&fp->obj, ncl, fp->clust);
4953 fp->obj.objsize = fp->fptr; /* Set file size to current read/write point */
4986 FFOBJID obj; local
4994 dj.obj.fs = fs;
5007 if (dj.obj.attr & AM_RDO) {
5013 obj.fs = fs;
5015 init_alloc_info(fs, &obj);
5016 dclst = obj.sclust;
5022 if (dj.obj.attr & AM_DIR) { /* Is it a sub-directory? */
5029 sdj.obj.fs = fs; /* Open the sub-directory */
5030 sdj.obj.sclust = dclst;
5033 sdj.obj.objsize = obj.objsize;
5034 sdj.obj.stat = obj.stat;
5050 res = remove_chain(&obj, dclst, 0);
5052 res = remove_chain(&dj.obj, dclst, 0);
5085 dj.obj.fs = fs;
5110 fs->win[SZDIRE + 1] = '.'; pcl = dj.obj.sclust;
5171 djo.obj.fs = fs;
5190 res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
5212 res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
5222 …if ((dir[DIR_Attr] & AM_DIR) && djo.obj.sclust != djn.obj.sclust) { /* Update .. entry in the sub-…
5231 st_clust(fs, dir, djn.obj.sclust);
5279 dj.obj.fs = fs;
5325 dj.obj.fs = fs;
5376 dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
5530 dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
5594 res = validate(&fp->obj, &fs); /* Check validity of the file object */
5596 if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED);
5623 n = get_fat(&fp->obj, clst);
5656 fp->obj.sclust = scl; /* Update object allocation information */
5657 fp->obj.objsize = fsz;
5658 if (FF_FS_EXFAT) fp->obj.stat = 2; /* Set status 'contiguous chain' */
5696 res = validate(&fp->obj, &fs); /* Check validity of the file object */
5700 remain = fp->obj.objsize - fp->fptr;
5708 fp->obj.sclust : get_fat(&fp->obj, fp->clust);