Subversion Repositories HelenOS

Rev

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

Rev 2389 Rev 2402
Line 14... Line 14...
14
#include <ipc/services.h>
14
#include <ipc/services.h>
15
#include <sys/mman.h>
15
#include <sys/mman.h>
16
#include "../fs/fs.h"
16
#include "../fs/fs.h"
17
#include "../share/shared_proto.h"
17
#include "../share/shared_proto.h"
18
#include "../console/console.h"
18
#include "../console/console.h"
-
 
19
#include "../fs/stat.h"
19
 
20
 
20
#define CON_FS_ATTEMPTS     1000
21
#define CON_FS_ATTEMPTS     1000
21
 
22
 
22
static int fs_phone;
23
static int fs_phone;
23
 
24
 
Line 51... Line 52...
51
    printf("OK\n");
52
    printf("OK\n");
52
 
53
 
53
    printf("Connecting the task to FS...");
54
    printf("Connecting the task to FS...");
54
    retval = async_req_2(fs_phone, FS_NEW_CONSUMER, task_get_id(), 0, NULL, NULL);
55
    retval = async_req_2(fs_phone, FS_NEW_CONSUMER, task_get_id(), 0, NULL, NULL);
55
    if (retval < 0) {
56
    if (retval < 0) {
56
        printf("FS_NEW_CONSUMER error: %d\n", retval);
57
        printf("%d\n", retval);
57
        return -1;
58
        return -1;
58
    }
59
    }
59
    printf("OK\n");
60
    printf("OK\n");
60
 
61
 
61
    printf("Sending memory to FS_SERVICE...");
62
    printf("Sending memory to FS_SERVICE...");
Line 218... Line 219...
218
        printf("%d\n", retval);
219
        printf("%d\n", retval);
219
        return -1;
220
        return -1;
220
    }
221
    }
221
    printf("OK\n");
222
    printf("OK\n");
222
   
223
   
-
 
224
    /*
223
    printf("Request for closing file %s once more...", fname);
225
    printf("Request for closing file %s once more...", fname);
224
    retval = send_request(fs_phone, FS_CLOSE, params, share);
226
    retval = send_request(fs_phone, FS_CLOSE, params, share);
225
    if (retval < 0) {
227
    if (retval < 0) {
226
        printf("%d\n", retval);
228
        printf("%d\n", retval);
227
        return -1;
229
        return -1;
228
    }
230
    }
229
    printf("OK\n");
231
    printf("OK\n");
-
 
232
    */
-
 
233
 
-
 
234
    printf("Request for dropping the connection to the FS...");
-
 
235
    retval = send_request(fs_phone, FS_DROP_CONSUMER, params, share);
-
 
236
    if (retval < 0) {
-
 
237
        printf("%d\n", retval);
-
 
238
        return -1;
-
 
239
    }
-
 
240
    printf("OK\n");
-
 
241
   
-
 
242
   
-
 
243
    /* Unmapping share area. */
-
 
244
    printf("Unmapping share area...");
-
 
245
    retval = munmap(share, size);
-
 
246
    if (retval < 0) {
-
 
247
        printf("%d\n", retval);
-
 
248
        return -1;
-
 
249
    }
-
 
250
    printf("OK\n");
-
 
251
   
-
 
252
    printf("Creating address space area...");
-
 
253
    size = ALIGN_UP(BLOCK_SIZE * sizeof(char), PAGE_SIZE);
-
 
254
    share = mmap(share, size, AS_AREA_READ | AS_AREA_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
-
 
255
    if ((int)share < 0){
-
 
256
        printf("As_area_create error: %d\n", (int)share);
-
 
257
        return -1;
-
 
258
    }
-
 
259
    printf("OK\n");
-
 
260
 
-
 
261
    /* Next connection to the FS. */
-
 
262
    printf("Connecting the task to FS...");
-
 
263
    retval = async_req_2(fs_phone, FS_NEW_CONSUMER, task_get_id(), 0, NULL, NULL);
-
 
264
    if (retval < 0) {
-
 
265
        printf("FS_NEW_CONSUMER error: %d\n", retval);
-
 
266
        return -1;
-
 
267
    }
-
 
268
    printf("OK\n");
-
 
269
   
-
 
270
    printf("Sending memory to FS_SERVICE...");
-
 
271
    flags = 0;
-
 
272
    flags = AS_AREA_READ | AS_AREA_WRITE;
-
 
273
    retval = async_req_3(fs_phone, IPC_M_AS_AREA_SEND, (uintptr_t)share, size, flags, NULL, NULL, NULL);
-
 
274
    if (retval < 0) {
-
 
275
        printf("%d\n", retval);
-
 
276
        return -1;
-
 
277
    }
-
 
278
    printf("OK\n");
230
 
279
 
-
 
280
    /* We want to work with specified file. */
-
 
281
    memcpy(fname, "/kernel/arch", 20);
-
 
282
    memcpy(params->fname, fname, 20);
-
 
283
 
-
 
284
    printf("Request for getting info about file %s[STAT called]...", fname);   
-
 
285
    retval = send_request(fs_phone, FS_STAT, params, share);
-
 
286
    if (retval < 0) {
-
 
287
        printf("%d\n", retval);
-
 
288
        return -1;
-
 
289
    }
-
 
290
    printf("OK\n");
-
 
291
   
-
 
292
    stat_t file_info;
-
 
293
    memcpy((void *)(&file_info), share, sizeof(stat_t));
-
 
294
 
-
 
295
    printf("Info about file: %s\n", fname);
-
 
296
    printf("Inode number: %d\n", file_info.st_ino);
-
 
297
    printf("Mode: %d\n", file_info.st_mode);
-
 
298
    printf("Links: %d\n", file_info.st_nlink);
-
 
299
    printf("Size: %d\n", file_info.st_size);
-
 
300
   
231
    return 0;
301
    return 0;
232
}
302
}
233
 
303