Ignore:
Timestamp:
2011-08-15T17:20:15Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9558eaa
Parents:
8a06c1b
Message:

exFAT: add exfat_directory_expand and exfat_directory_lookup_free functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat_directory.c

    r8a06c1b r7d78d163  
    351351}
    352352
     353int exfat_directory_expand(exfat_directory_t *di)
     354{
     355        int rc;
     356
     357        if (!di->nodep)
     358                return ENOSPC;
     359
     360        rc = exfat_node_expand(di->nodep->idx->devmap_handle, di->nodep, 1);
     361        if (rc != EOK)
     362                return rc;
     363
     364        di->fragmented = di->nodep->fragmented;
     365        di->nodep->size += BPC(di->bs);
     366        di->nodep->dirty = true;                /* need to sync node */
     367        di->blocks = di->nodep->size / BPS(di->bs);
     368       
     369        return EOK;
     370}
     371
     372int exfat_directory_lookup_free(exfat_directory_t *di, size_t count)
     373{
     374        int rc;
     375        exfat_dentry_t *d;
     376        size_t found;
     377        aoff64_t pos;
     378
     379        rc = exfat_directory_seek(di, 0);
     380        if (rc != EOK)
     381                return rc;
     382
     383        do {
     384                found = 0;
     385                pos = 0;
     386                do {
     387                        if (exfat_directory_get(di, &d) == EOK) {
     388                                switch (exfat_classify_dentry(d)) {
     389                                case EXFAT_DENTRY_LAST:
     390                                case EXFAT_DENTRY_FREE:
     391                                        if (found==0) pos = di->pos;
     392                                        found++;
     393                                        if (found == count) {
     394                                                exfat_directory_seek(di, pos);
     395                                                return EOK;
     396                                        }
     397                                        break;
     398                                default:
     399                                        found = 0;
     400                                        break;
     401                                }
     402                        }
     403                } while (exfat_directory_next(di) == EOK);     
     404        } while (exfat_directory_expand(di) == EOK);
     405        return ENOSPC;
     406}
     407
    353408
    354409/**
Note: See TracChangeset for help on using the changeset viewer.