Changeset 0bd5ff1 in mainline for uspace/srv/fs/exfat/exfat_ops.c


Ignore:
Timestamp:
2011-08-02T19:54:35Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
963ea42
Parents:
59c0777
Message:

Implement exfat_match

File:
1 edited

Legend:

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

    r59c0777 r0bd5ff1  
    391391int exfat_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
    392392{
    393         /* TODO */
     393        exfat_node_t *parentp = EXFAT_NODE(pfn);
     394        char name[EXFAT_FILENAME_LEN+1];
     395        exfat_file_dentry_t df;
     396        exfat_stream_dentry_t ds;
     397        devmap_handle_t devmap_handle;
     398        int rc;
     399
     400        fibril_mutex_lock(&parentp->idx->lock);
     401        devmap_handle = parentp->idx->devmap_handle;
     402        fibril_mutex_unlock(&parentp->idx->lock);
     403       
     404        exfat_directory_t di;
     405        rc = exfat_directory_open(parentp, &di);
     406        if (rc != EOK)
     407                return rc;
     408
     409        while (exfat_directory_read_file(&di, name, EXFAT_FILENAME_LEN,
     410            &df, &ds) == EOK) {
     411                if (stricmp(name, component) == 0) {
     412                        /* hit */
     413                        exfat_node_t *nodep;
     414                        aoff64_t o = di.pos % (BPS(di.bs) / sizeof(exfat_dentry_t));
     415                        exfat_idx_t *idx = exfat_idx_get_by_pos(devmap_handle,
     416                                parentp->firstc, di.bnum * DPS(di.bs) + o);
     417                        if (!idx) {
     418                                /*
     419                                 * Can happen if memory is low or if we
     420                                 * run out of 32-bit indices.
     421                                 */
     422                                rc = exfat_directory_close(&di);
     423                                return (rc == EOK) ? ENOMEM : rc;
     424                        }
     425                        rc = exfat_node_get_core(&nodep, idx);
     426                        fibril_mutex_unlock(&idx->lock);
     427                        if (rc != EOK) {
     428                                (void) exfat_directory_close(&di);
     429                                return rc;
     430                        }
     431                        *rfn = FS_NODE(nodep);
     432                        rc = exfat_directory_close(&di);
     433                        if (rc != EOK)
     434                                (void) exfat_node_put(*rfn);
     435                        return rc;
     436                } else {
     437                        rc = exfat_directory_next(&di);
     438                        if (rc != EOK)
     439                                break;
     440                }
     441        }
     442        (void) exfat_directory_close(&di);
    394443        *rfn = NULL;
    395444        return EOK;
Note: See TracChangeset for help on using the changeset viewer.