Subversion Repositories HelenOS

Rev

Rev 2707 | Rev 2711 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2707 Rev 2710
Line 495... Line 495...
495
     * Check whether the file needs to grow.
495
     * Check whether the file needs to grow.
496
     */
496
     */
497
    if (pos + len <= dentry->size) {
497
    if (pos + len <= dentry->size) {
498
        /* The file size is not changing. */
498
        /* The file size is not changing. */
499
        (void) ipc_data_write_finalize(callid, dentry->data + pos, len);
499
        (void) ipc_data_write_finalize(callid, dentry->data + pos, len);
500
        ipc_answer_1(rid, EOK, len);
500
        ipc_answer_2(rid, EOK, len, dentry->size);
501
        return;
501
        return;
502
    }
502
    }
503
    size_t delta = (pos + len) - dentry->size;
503
    size_t delta = (pos + len) - dentry->size;
504
    /*
504
    /*
505
     * At this point, we are deliberately extremely straightforward and
505
     * At this point, we are deliberately extremely straightforward and
Line 509... Line 509...
509
     * possible.
509
     * possible.
510
     */
510
     */
511
    void *newdata = realloc(dentry->data, dentry->size + delta);
511
    void *newdata = realloc(dentry->data, dentry->size + delta);
512
    if (!newdata) {
512
    if (!newdata) {
513
        ipc_answer_0(callid, ENOMEM);
513
        ipc_answer_0(callid, ENOMEM);
514
        ipc_answer_1(rid, EOK, 0);
514
        ipc_answer_2(rid, EOK, 0, dentry->size);
515
        return;
515
        return;
516
    }
516
    }
517
    /* Clear any newly allocated memory in order to emulate gaps. */
517
    /* Clear any newly allocated memory in order to emulate gaps. */
518
    memset(newdata + dentry->size, 0, delta);
518
    memset(newdata + dentry->size, 0, delta);
519
    dentry->size += delta;
519
    dentry->size += delta;