Changeset 8334a427 in mainline


Ignore:
Timestamp:
2008-11-04T23:13:20Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4f1c0b4
Parents:
c472aff
Message:

More fat_truncate() bits.

File:
1 edited

Legend:

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

    rc472aff r8334a427  
    690690                int status;
    691691                unsigned nclsts;
    692                 fat_cluster_t mcl, lcl;
    693        
     692                fat_cluster_t mcl, lcl; 
     693 
    694694                nclsts = (ROUND_UP(pos + bytes, bps * spc) - boundary) /
    695695                    bps * spc;
     
    706706                /* zero fill any gaps */
    707707                fat_fill_gap(bs, nodep, mcl, pos);
    708                 b = _fat_block_get(bs, dev_handle, lcl,
    709                     (pos / bps) % spc);
     708                b = _fat_block_get(bs, dev_handle, lcl, (pos / bps) % spc);
    710709                (void) ipc_data_write_finalize(callid, b->data + pos % bps,
    711710                    bytes);
     
    727726void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
    728727{
    729         ipc_answer_0(rid, ENOTSUP);
     728        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     729        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     730        size_t size = (off_t)IPC_GET_ARG3(*request);
     731        fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index);
     732        int rc;
     733
     734        if (!nodep) {
     735                ipc_answer_0(rid, ENOENT);
     736                return;
     737        }
     738
     739        if (nodep->size == size) {
     740                rc = EOK;
     741        } else if (nodep->size < size) {
     742                /*
     743                 * TODO: the standard says we have the freedom to grow the file.
     744                 * For now, we simply return an error.
     745                 */
     746                rc = EINVAL;
     747        } else {
     748                /*
     749                 * The file is to be shrunk.
     750                 */
     751                rc = ENOTSUP;   /* XXX */
     752        }
     753        fat_node_put(nodep);
     754        ipc_answer_0(rid, rc);
     755        return;
     756
    730757}
    731758
Note: See TracChangeset for help on using the changeset viewer.