Subversion Repositories HelenOS

Rev

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

Rev 2660 Rev 2665
Line 43... Line 43...
43
char *test_vfs1(bool quiet)
43
char *test_vfs1(bool quiet)
44
{
44
{
45
    /* 1. connect to VFS */
45
    /* 1. connect to VFS */
46
    int vfs_phone;
46
    int vfs_phone;
47
    vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0);
47
    vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0);
48
    if (vfs_phone < EOK) {
48
    if (vfs_phone < EOK)
49
        return "Could not connect to VFS.\n";
49
        return "Could not connect to VFS.\n";
50
    }
-
 
51
   
50
   
52
    /* 2. mount TMPFS as / */
51
    /* 2. mount TMPFS as / */
53
    ipcarg_t rc;
52
    ipcarg_t rc;
54
    aid_t req;
53
    aid_t req;
55
    req = async_send_1(vfs_phone, VFS_MOUNT, TMPFS_DEVHANDLE, NULL);
54
    req = async_send_1(vfs_phone, VFS_MOUNT, TMPFS_DEVHANDLE, NULL);
Line 60... Line 59...
60
    if (ipc_data_write_send(vfs_phone, mp, strlen(mp)) != EOK) {
59
    if (ipc_data_write_send(vfs_phone, mp, strlen(mp)) != EOK) {
61
        async_wait_for(req, &rc);
60
        async_wait_for(req, &rc);
62
        return "Could not send mp to VFS.\n";
61
        return "Could not send mp to VFS.\n";
63
    }
62
    }
64
    async_wait_for(req, &rc);
63
    async_wait_for(req, &rc);
65
    if (rc != EOK) {
64
    if (rc != EOK)
66
        return "Mount failed.\n";
65
        return "Mount failed.\n";
67
    }
-
 
68
   
66
   
69
    /* 3. open some files */
67
    /* 3. open some files */
70
    char *path = "/dir2/file2";
68
    char *path = "/dir2/file2";
71
    ipc_call_t answer;
69
    ipc_call_t answer;
72
    req = async_send_2(vfs_phone, VFS_OPEN, 0, 0, &answer);
70
    req = async_send_2(vfs_phone, VFS_OPEN, 0, 0, &answer);
73
    if (ipc_data_write_send(vfs_phone, path, strlen(path)) != EOK) {
71
    if (ipc_data_write_send(vfs_phone, path, strlen(path)) != EOK) {
74
        async_wait_for(req, &rc);
72
        async_wait_for(req, &rc);
75
        return "Could not send path to VFS.\n";
73
        return "Could not send path to VFS.\n";
76
    }
74
    }
77
    async_wait_for(req, &rc);
75
    async_wait_for(req, &rc);
78
    if (rc != EOK) {
76
    if (rc != EOK)
79
        return "Open failed.\n";
77
        return "Open failed.\n";
80
    }
-
 
81
 
-
 
82
    if (!quiet) {
78
    if (!quiet)
83
        printf("Opened %s handle=%d\n", path, IPC_GET_ARG1(answer));
79
        printf("Opened %s handle=%d\n", path, IPC_GET_ARG1(answer));
-
 
80
 
-
 
81
    /* 4. read data */
-
 
82
    char buf[10];
-
 
83
    req = async_send_1(vfs_phone, VFS_READ, 0, &answer);
-
 
84
    if (ipc_data_read_send(vfs_phone, buf, sizeof(buf)) != EOK) {
-
 
85
        async_wait_for(req, &rc);
-
 
86
        return "Could not read data from open file.\n";
84
    }
87
    }
-
 
88
    async_wait_for(req, &rc);
-
 
89
    if (rc != EOK)
-
 
90
        return "Read failed.\n";
-
 
91
    printf("Read %d bytes: %s\n", IPC_GET_ARG1(answer), buf);
85
 
92
 
86
    return NULL;
93
    return NULL;
87
}
94
}