Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    r472c09d r19f857a  
    4545#include <ipc/services.h>
    4646#include <ipc/devmap.h>
     47#include <macros.h>
    4748#include <async.h>
    4849#include <errno.h>
    49 #include <string.h>
     50#include <str.h>
    5051#include <byteorder.h>
    5152#include <adt/hash_table.h>
     
    7980static int fat_has_children(bool *, fs_node_t *);
    8081static fs_index_t fat_index_get(fs_node_t *);
    81 static size_t fat_size_get(fs_node_t *);
     82static aoff64_t fat_size_get(fs_node_t *);
    8283static unsigned fat_lnkcnt_get(fs_node_t *);
    8384static char fat_plb_get_char(unsigned);
     
    722723        fibril_mutex_lock(&childp->idx->lock);
    723724       
    724         /*
    725          * If possible, create the Sub-directory Identifier Entry and the
    726          * Sub-directory Parent Pointer Entry (i.e. "." and ".."). These entries
    727          * are not mandatory according to Standard ECMA-107 and HelenOS VFS does
    728          * not use them anyway, so this is rather a sign of our good will.
    729          */
    730         rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE);
    731         if (rc != EOK) {
     725        if (childp->type == FAT_DIRECTORY) {
    732726                /*
    733                  * Rather than returning an error, simply skip the creation of
    734                  * these two entries.
     727                 * If possible, create the Sub-directory Identifier Entry and
     728                 * the Sub-directory Parent Pointer Entry (i.e. "." and "..").
     729                 * These entries are not mandatory according to Standard
     730                 * ECMA-107 and HelenOS VFS does not use them anyway, so this is
     731                 * rather a sign of our good will.
    735732                 */
    736                 goto skip_dots;
    737         }
    738         d = (fat_dentry_t *)b->data;
    739         if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
    740             str_cmp(d->name, FAT_NAME_DOT) == 0) {
    741                 memset(d, 0, sizeof(fat_dentry_t));
    742                 str_cpy(d->name, 8, FAT_NAME_DOT);
    743                 str_cpy(d->ext, 3, FAT_EXT_PAD);
    744                 d->attr = FAT_ATTR_SUBDIR;
    745                 d->firstc = host2uint16_t_le(childp->firstc);
    746                 /* TODO: initialize also the date/time members. */
    747         }
    748         d++;
    749         if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
    750             str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) {
    751                 memset(d, 0, sizeof(fat_dentry_t));
    752                 str_cpy(d->name, 8, FAT_NAME_DOT_DOT);
    753                 str_cpy(d->ext, 3, FAT_EXT_PAD);
    754                 d->attr = FAT_ATTR_SUBDIR;
    755                 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ?
    756                     host2uint16_t_le(FAT_CLST_RES0) :
    757                     host2uint16_t_le(parentp->firstc);
    758                 /* TODO: initialize also the date/time members. */
    759         }
    760         b->dirty = true;                /* need to sync block */
    761         /*
    762          * Ignore the return value as we would have fallen through on error
    763          * anyway.
    764          */
    765         (void) block_put(b);
     733                rc = fat_block_get(&b, bs, childp, 0, BLOCK_FLAGS_NONE);
     734                if (rc != EOK) {
     735                        /*
     736                         * Rather than returning an error, simply skip the
     737                         * creation of these two entries.
     738                         */
     739                        goto skip_dots;
     740                }
     741                d = (fat_dentry_t *) b->data;
     742                if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
     743                    (str_cmp((char *) d->name, FAT_NAME_DOT)) == 0) {
     744                        memset(d, 0, sizeof(fat_dentry_t));
     745                        str_cpy((char *) d->name, 8, FAT_NAME_DOT);
     746                        str_cpy((char *) d->ext, 3, FAT_EXT_PAD);
     747                        d->attr = FAT_ATTR_SUBDIR;
     748                        d->firstc = host2uint16_t_le(childp->firstc);
     749                        /* TODO: initialize also the date/time members. */
     750                }
     751                d++;
     752                if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
     753                    (str_cmp((char *) d->name, FAT_NAME_DOT_DOT) == 0)) {
     754                        memset(d, 0, sizeof(fat_dentry_t));
     755                        str_cpy((char *) d->name, 8, FAT_NAME_DOT_DOT);
     756                        str_cpy((char *) d->ext, 3, FAT_EXT_PAD);
     757                        d->attr = FAT_ATTR_SUBDIR;
     758                        d->firstc = (parentp->firstc == FAT_CLST_ROOT) ?
     759                            host2uint16_t_le(FAT_CLST_RES0) :
     760                            host2uint16_t_le(parentp->firstc);
     761                        /* TODO: initialize also the date/time members. */
     762                }
     763                b->dirty = true;                /* need to sync block */
     764                /*
     765                 * Ignore the return value as we would have fallen through on error
     766                 * anyway.
     767                 */
     768                (void) block_put(b);
     769        }
    766770skip_dots:
    767771
     
    912916}
    913917
    914 size_t fat_size_get(fs_node_t *fn)
     918aoff64_t fat_size_get(fs_node_t *fn)
    915919{
    916920        return FAT_NODE(fn)->size;
     
    977981        /* Accept the mount options */
    978982        char *opts;
    979         int rc = async_string_receive(&opts, 0, NULL);
     983        int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
    980984       
    981985        if (rc != EOK) {
     
    11541158void fat_read(ipc_callid_t rid, ipc_call_t *request)
    11551159{
    1156         dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
    1157         fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    1158         off_t pos = (off_t)IPC_GET_ARG3(*request);
     1160        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1161        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     1162        aoff64_t pos =
     1163            (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    11591164        fs_node_t *fn;
    11601165        fat_node_t *nodep;
     
    12201225        } else {
    12211226                unsigned bnum;
    1222                 off_t spos = pos;
     1227                aoff64_t spos = pos;
    12231228                char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1];
    12241229                fat_dentry_t *d;
     
    12361241                bnum = (pos * sizeof(fat_dentry_t)) / bps;
    12371242                while (bnum < nodep->size / bps) {
    1238                         off_t o;
     1243                        aoff64_t o;
    12391244
    12401245                        rc = fat_block_get(&b, bs, nodep, bnum,
     
    12921297void fat_write(ipc_callid_t rid, ipc_call_t *request)
    12931298{
    1294         dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
    1295         fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    1296         off_t pos = (off_t)IPC_GET_ARG3(*request);
     1299        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1300        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     1301        aoff64_t pos =
     1302            (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    12971303        fs_node_t *fn;
    12981304        fat_node_t *nodep;
     
    13031309        unsigned spc;
    13041310        unsigned bpc;           /* bytes per cluster */
    1305         off_t boundary;
     1311        aoff64_t boundary;
    13061312        int flags = BLOCK_FLAGS_NONE;
    13071313        int rc;
     
    14491455void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
    14501456{
    1451         dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
    1452         fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    1453         size_t size = (off_t)IPC_GET_ARG3(*request);
     1457        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1458        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     1459        aoff64_t size =
     1460            (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    14541461        fs_node_t *fn;
    14551462        fat_node_t *nodep;
Note: See TracChangeset for help on using the changeset viewer.