Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 8a49fed in mainline for uspace/srv/fs/minixfs/mfs_ops.c


Ignore:
Timestamp:
2011-04-30T11:45:33Z (11 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
44c6091f
Parents:
2874547
Message:

Added implementation of mfs_truncate(), it does not prune indirect blocks yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs_ops.c

    r2874547 r8a49fed  
    791791}
    792792
     793void
     794mfs_truncate(ipc_callid_t rid, ipc_call_t *request)
     795{
     796        devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(*request);
     797        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     798        aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request),
     799                                                IPC_GET_ARG4(*request));
     800        fs_node_t *fn;
     801        int r;
     802
     803        mfsdebug("mfs_truncate()\n");
     804
     805        r = mfs_node_get(&fn, handle, index);
     806        if (r != EOK) {
     807                async_answer_0(rid, r);
     808                return;
     809        }
     810
     811        if (!fn) {
     812                async_answer_0(rid, r);
     813                return;
     814        }
     815
     816        struct mfs_node *mnode = fn->data;
     817        struct mfs_ino_info *ino_i = mnode->ino_i;
     818
     819        if (ino_i->i_size == size)
     820                r = EOK;
     821        else
     822                r = inode_shrink(mnode, ino_i->i_size - size);
     823
     824        async_answer_0(rid, r);
     825        mfs_node_put(fn);
     826}
     827
    793828int mfs_instance_get(devmap_handle_t handle, struct mfs_instance **instance)
    794829{
Note: See TracChangeset for help on using the changeset viewer.