Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2434 | jelen | 1 | /** @addtogroup FSDemo |
2 | * @{ |
||
3 | */ |
||
4 | |||
5 | /** |
||
6 | * @file cat.c |
||
7 | * @brief A file system demonstration task |
||
8 | */ |
||
9 | |||
10 | |||
11 | #include <err.h> |
||
12 | #include <stdio.h> |
||
13 | #include <stdlib.h> |
||
14 | #include <string.h> |
||
15 | #include <unistd.h> |
||
16 | #include <async.h> |
||
17 | #include "../console/console.h" |
||
18 | #include <io/file.h> |
||
19 | #include <io/stat.h> |
||
20 | |||
21 | int main(int argc, char *argv[]) |
||
22 | { |
||
23 | |||
24 | file_t * file; |
||
25 | unsigned int dir_items_length; |
||
26 | dir_item_t* dir_items; |
||
27 | char buffer[256]; |
||
28 | int retval; |
||
29 | |||
30 | printf("Cat task\n"); |
||
31 | |||
32 | /* File list in working directory. */ |
||
33 | /* printf("File list:\n"); |
||
34 | dir_items = ls(&dir_items_length); |
||
35 | printf("Got a list\n"); |
||
36 | |||
37 | int entry; |
||
38 | for (entry = 0; entry < dir_items_length; entry++) { |
||
39 | printf("Inode number: %u\t\t", dir_items[entry].inode_num); |
||
40 | printf("File name: %s\n", dir_items[entry].name); |
||
41 | |||
42 | } |
||
43 | */ |
||
44 | /* We want to change working directory */ |
||
45 | retval = chdir("uspace/fs"); |
||
46 | |||
47 | /* We want to work with specified file. */ |
||
48 | /* file = fopen("fs.c", F_MODE_READ); |
||
49 | retval = fstat( file ); |
||
50 | |||
51 | printf("Info about file: %s\n", file->base_info.name); |
||
52 | printf("Inode number: %d\n", file->stat.st_ino); |
||
53 | printf("Mode: %d\n", file->stat.st_mode); |
||
54 | printf("Links: %d\n", file->stat.st_nlink); |
||
55 | printf("Size: %d\n", file->stat.st_size); |
||
56 | |||
57 | retval = fseek( file, 100, 1); |
||
58 | retval = fread( file, buffer, 100); |
||
59 | buffer[100]=0; |
||
60 | |||
61 | printf("%d bytes was read into buffer\n", retval); |
||
62 | printf("\nContent of the buffer:\n"); |
||
63 | printf(buffer); |
||
64 | printf("\n\n"); |
||
65 | |||
66 | retval = fseek( file, 0, 0); |
||
67 | retval = fread( file, buffer, 50); |
||
68 | buffer[50]=0; |
||
69 | |||
70 | printf("%d bytes was read into buffer\n", retval); |
||
71 | printf("\nContent of the buffer:\n"); |
||
72 | printf(buffer); |
||
73 | printf("\n\n"); |
||
74 | */ |
||
75 | /* close the file */ |
||
76 | // retval = fclose( file ); |
||
77 | |||
78 | // return 0; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * } |
||
83 | */ |