Rev 2434 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2434 | Rev 2435 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* |
|
- | 2 | * Copyright (c) 2007 Konopa-Jelen-Majer |
|
- | 3 | * All rights reserved. |
|
- | 4 | * |
|
- | 5 | * Redistribution and use in source and binary forms, with or without |
|
- | 6 | * modification, are permitted provided that the following conditions |
|
- | 7 | * are met: |
|
- | 8 | * |
|
- | 9 | * - Redistributions of source code must retain the above copyright |
|
- | 10 | * notice, this list of conditions and the following disclaimer. |
|
- | 11 | * - Redistributions in binary form must reproduce the above copyright |
|
- | 12 | * notice, this list of conditions and the following disclaimer in the |
|
- | 13 | * documentation and/or other materials provided with the distribution. |
|
- | 14 | * - The name of the author may not be used to endorse or promote products |
|
- | 15 | * derived from this software without specific prior written permission. |
|
- | 16 | * |
|
- | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
- | 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
- | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
- | 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
- | 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
- | 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
- | 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
- | 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
- | 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
- | 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
- | 27 | */ |
|
- | 28 | ||
1 | /** @addtogroup FSDemo |
29 | /** @addtogroup FSDemo |
2 | * @{ |
30 | * @{ |
3 | */ |
31 | */ |
4 | 32 | ||
5 | /** |
33 | /** |
6 | * @file cat.c |
34 | * @file cat.standard.c |
7 | * @brief A file system demonstration task |
35 | * @brief A file system demonstration task - standard library version |
8 | */ |
36 | */ |
9 | 37 | ||
10 | 38 | ||
11 | #include <err.h> |
39 | #include <err.h> |
12 | #include <stdio.h> |
40 | #include <stdio.h> |
Line 16... | Line 44... | ||
16 | #include <async.h> |
44 | #include <async.h> |
17 | #include "../console/console.h" |
45 | #include "../console/console.h" |
18 | #include <io/file.h> |
46 | #include <io/file.h> |
19 | #include <io/stat.h> |
47 | #include <io/stat.h> |
20 | 48 | ||
- | 49 | ||
- | 50 | /** |
|
- | 51 | * This is a very basic linear demonstration script of the standard file library |
|
- | 52 | */ |
|
21 | int main(int argc, char *argv[]) |
53 | int main(int argc, char *argv[]) |
22 | { |
54 | { |
23 | 55 | ||
24 | file_t * file; |
56 | file_t * file; |
25 | unsigned int dir_items_length; |
57 | unsigned int dir_items_length; |
Line 28... | Line 60... | ||
28 | int retval; |
60 | int retval; |
29 | 61 | ||
30 | printf("Cat task\n"); |
62 | printf("Cat task\n"); |
31 | 63 | ||
32 | /* File list in working directory. */ |
64 | /* File list in working directory. */ |
33 | /* printf("File list:\n"); |
65 | printf("File list:\n"); |
34 | dir_items = ls(&dir_items_length); |
66 | dir_items = ls(&dir_items_length); |
35 | printf("Got a list\n"); |
67 | printf("Got a list\n"); |
36 | |
68 | |
37 | int entry; |
69 | int entry; |
38 | for (entry = 0; entry < dir_items_length; entry++) { |
70 | for (entry = 0; entry < dir_items_length; entry++) { |
39 | printf("Inode number: %u\t\t", dir_items[entry].inode_num); |
71 | printf("Inode number: %u\t\t", dir_items[entry].inode_num); |
40 | printf("File name: %s\n", dir_items[entry].name); |
72 | printf("File name: %s\n", dir_items[entry].name); |
41 | |
73 | |
42 | } |
74 | } |
43 | */ |
75 | |
44 | /* We want to change working directory */ |
76 | /* We want to change working directory */ |
45 | retval = chdir("uspace/fs"); |
77 | retval = chdir("uspace/fs"); |
46 | 78 | ||
47 | /* We want to work with specified file. */ |
79 | /* We want to work with specified file. */ |
48 | /* file = fopen("fs.c", F_MODE_READ); |
80 | file = fopen("fs.c", F_MODE_READ); |
49 | retval = fstat( file ); |
81 | retval = fstat( file ); |
50 | |
82 | |
51 | printf("Info about file: %s\n", file->base_info.name); |
83 | printf("Info about file: %s\n", file->base_info.name); |
52 | printf("Inode number: %d\n", file->stat.st_ino); |
84 | printf("Inode number: %d\n", file->stat.st_ino); |
53 | printf("Mode: %d\n", file->stat.st_mode); |
85 | printf("Mode: %d\n", file->stat.st_mode); |
Line 69... | Line 101... | ||
69 | |
101 | |
70 | printf("%d bytes was read into buffer\n", retval); |
102 | printf("%d bytes was read into buffer\n", retval); |
71 | printf("\nContent of the buffer:\n"); |
103 | printf("\nContent of the buffer:\n"); |
72 | printf(buffer); |
104 | printf(buffer); |
73 | printf("\n\n"); |
105 | printf("\n\n"); |
74 | */ |
- | |
75 | /* close the file */ |
106 | /*close the file */ |
76 | // retval = fclose( file ); |
107 | retval = fclose( file ); |
77 | 108 | ||
78 | // return 0; |
109 | return 0; |
79 | } |
110 | } |
80 | 111 | ||
81 | /** |
112 | /** |
82 | * } |
113 | * } |
83 | */ |
114 | */ |