Ignore:
File:
1 edited

Legend:

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

    r19f857a r472c09d  
    4545#include <ipc/services.h>
    4646#include <ipc/devmap.h>
    47 #include <macros.h>
    4847#include <async.h>
    4948#include <errno.h>
    50 #include <str.h>
     49#include <string.h>
    5150#include <byteorder.h>
    5251#include <adt/hash_table.h>
     
    8079static int fat_has_children(bool *, fs_node_t *);
    8180static fs_index_t fat_index_get(fs_node_t *);
    82 static aoff64_t fat_size_get(fs_node_t *);
     81static size_t fat_size_get(fs_node_t *);
    8382static unsigned fat_lnkcnt_get(fs_node_t *);
    8483static char fat_plb_get_char(unsigned);
     
    723722        fibril_mutex_lock(&childp->idx->lock);
    724723       
    725         if (childp->type == FAT_DIRECTORY) {
     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) {
    726732                /*
    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.
     733                 * Rather than returning an error, simply skip the creation of
     734                 * these two entries.
    732735                 */
    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         }
     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);
    770766skip_dots:
    771767
     
    916912}
    917913
    918 aoff64_t fat_size_get(fs_node_t *fn)
     914size_t fat_size_get(fs_node_t *fn)
    919915{
    920916        return FAT_NODE(fn)->size;
     
    981977        /* Accept the mount options */
    982978        char *opts;
    983         int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
     979        int rc = async_string_receive(&opts, 0, NULL);
    984980       
    985981        if (rc != EOK) {
     
    11581154void fat_read(ipc_callid_t rid, ipc_call_t *request)
    11591155{
    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));
     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);
    11641159        fs_node_t *fn;
    11651160        fat_node_t *nodep;
     
    12251220        } else {
    12261221                unsigned bnum;
    1227                 aoff64_t spos = pos;
     1222                off_t spos = pos;
    12281223                char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1];
    12291224                fat_dentry_t *d;
     
    12411236                bnum = (pos * sizeof(fat_dentry_t)) / bps;
    12421237                while (bnum < nodep->size / bps) {
    1243                         aoff64_t o;
     1238                        off_t o;
    12441239
    12451240                        rc = fat_block_get(&b, bs, nodep, bnum,
     
    12971292void fat_write(ipc_callid_t rid, ipc_call_t *request)
    12981293{
    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));
     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);
    13031297        fs_node_t *fn;
    13041298        fat_node_t *nodep;
     
    13091303        unsigned spc;
    13101304        unsigned bpc;           /* bytes per cluster */
    1311         aoff64_t boundary;
     1305        off_t boundary;
    13121306        int flags = BLOCK_FLAGS_NONE;
    13131307        int rc;
     
    14551449void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
    14561450{
    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));
     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);
    14611454        fs_node_t *fn;
    14621455        fat_node_t *nodep;
Note: See TracChangeset for help on using the changeset viewer.