Changeset f7017572 in mainline


Ignore:
Timestamp:
2008-01-27T18:54:16Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
acfdcb0
Parents:
15b9970
Message:

VFS_WRITE and tmpfs_write fixes.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/vfs/vfs1.c

    r15b9970 rf7017572  
    3939#include "../tester.h"
    4040
     41char text[] = "O xein', angellein Lakedaimoniois hoti teide "
     42        "keimetha tois keinon rhemasi peithomenoi.";
     43
    4144char *test_vfs1(bool quiet)
    4245{
     
    4649        if (mkdir("/mydir", 0) != 0)
    4750                return "mkdir() failed.\n";
     51        if (!quiet)
     52                printf("Created directory /mydir\n");
     53       
     54        int fd0 = open("/mydir/myfile", O_CREAT);
     55        if (fd0 < 0)
     56                return "open() failed.\n";
     57        if (!quiet)
     58                printf("Created /mydir/myfile, handle=%d\n", fd0);
     59
     60        ssize_t cnt;
     61        size_t size = sizeof(text);
     62        cnt = write(fd0, text, size);
     63        if (cnt < 0)
     64                return "write() failed.\n";
     65        if (!quiet)
     66                printf("Written %d btyes to handle %d.\n", cnt, fd0);
     67        if (lseek(fd0, 0, SEEK_SET) != 0)
     68                return "lseek() failed.\n";
    4869
    4970        DIR *dirp;
     
    5778        closedir(dirp);
    5879
    59         int fd1 = open("/dir1/file1", 0);
    60         int fd2 = open("/dir2/file2", 0);
     80        int fd1 = open("/dir1/file1", O_RDONLY);
     81        int fd2 = open("/dir2/file2", O_RDONLY);
    6182
    6283        if (fd1 < 0)
     
    7091        char buf[10];
    7192
    72         ssize_t cnt = read(fd1, buf, sizeof(buf));
     93        cnt = read(fd0, buf, sizeof(buf));
    7394        if (cnt < 0)
    7495                return "read() failed.\n";
    7596
    7697        if (!quiet)
    77                 printf("Read %d bytes: %.*s\n", cnt, cnt, buf);
     98                printf("Read %d bytes from handle %d: %.*s\n", cnt, fd0, cnt,
     99                    buf);
     100
     101        cnt = read(fd1, buf, sizeof(buf));
     102        if (cnt < 0)
     103                return "read() failed.\n";
     104
     105        if (!quiet)
     106                printf("Read %d bytes from handle %d: %.*s\n", cnt, fd1, cnt,
     107                    buf);
    78108
    79109        return NULL;
  • uspace/lib/libc/generic/vfs.c

    r15b9970 rf7017572  
    166166        async_serialize_end();
    167167        futex_up(&vfs_phone_futex);
    168         return (ssize_t) IPC_GET_ARG1(answer);
     168        if (rc == EOK)
     169                return (ssize_t) IPC_GET_ARG1(answer);
     170        else
     171                return -1;
    169172}
    170173
     
    196199        async_serialize_end();
    197200        futex_up(&vfs_phone_futex);
    198         return (ssize_t) IPC_GET_ARG1(answer);
     201        if (rc == EOK)
     202                return (ssize_t) IPC_GET_ARG1(answer);
     203        else
     204                return -1;
    199205}
    200206
  • uspace/srv/fs/tmpfs/tmpfs.c

    r15b9970 rf7017572  
    116116                        tmpfs_read(callid, &call);
    117117                        break;
     118                case VFS_WRITE:
     119                        tmpfs_write(callid, &call);
     120                        break;
    118121                default:
    119122                        ipc_answer_0(callid, ENOTSUP);
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r15b9970 rf7017572  
    498498                /* The file size is not changing. */
    499499                (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);
    501501                return;
    502502        }
     
    512512        if (!newdata) {
    513513                ipc_answer_0(callid, ENOMEM);
    514                 ipc_answer_1(rid, EOK, 0);
     514                ipc_answer_2(rid, EOK, 0, dentry->size);
    515515                return;
    516516        }
  • uspace/srv/vfs/vfs_ops.c

    r15b9970 rf7017572  
    371371        vfs_file_t *file = vfs_file_get(fd);
    372372        file->node = node;
    373         if (oflag & O_APPEND)
     373        if (oflag & O_APPEND) 
    374374                file->append = true;
    375375
     
    471471        else {
    472472                /* Update the cached version of node's size. */
    473                 file->node->size = IPC_GET_ARG2(answer);
     473                if (rc == EOK)
     474                        file->node->size = IPC_GET_ARG2(answer);
    474475                rwlock_write_unlock(&file->node->contents_rwlock);
    475476        }
    476477
    477478        /* Update the position pointer and unlock the open file. */
    478         file->pos += bytes;
     479        if (rc == EOK)
     480                file->pos += bytes;
    479481        futex_up(&file->lock);
    480482
Note: See TracChangeset for help on using the changeset viewer.