Rev 2445 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2445 | Rev 2474 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2007 Michal Konopa |
2 | * Copyright (c) 2007 Michal Konopa |
3 | * Copyright (c) 2007 Martin Jelen |
3 | * Copyright (c) 2007 Martin Jelen |
4 | * Copyright (c) 2007 Peter Majer |
4 | * Copyright (c) 2007 Peter Majer |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions |
8 | * modification, are permitted provided that the following conditions |
9 | * are met: |
9 | * are met: |
10 | * |
10 | * |
11 | * - Redistributions of source code must retain the above copyright |
11 | * - Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. |
12 | * notice, this list of conditions and the following disclaimer. |
13 | * - Redistributions in binary form must reproduce the above copyright |
13 | * - Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the |
14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. |
15 | * documentation and/or other materials provided with the distribution. |
16 | * - The name of the author may not be used to endorse or promote products |
16 | * - The name of the author may not be used to endorse or promote products |
17 | * derived from this software without specific prior written permission. |
17 | * derived from this software without specific prior written permission. |
18 | * |
18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ |
29 | */ |
30 | 30 | ||
31 | /** @addtogroup libc |
31 | /** @addtogroup libc |
32 | * @{ |
32 | * @{ |
33 | */ |
33 | */ |
34 | 34 | ||
35 | /** |
35 | /** |
36 | * @file file.h |
36 | * @file file.h |
37 | * @brief The main header for the user library for working with the file system |
37 | * @brief The main header for the user library for working with the file system |
38 | */ |
38 | */ |
39 | 39 | ||
40 | #ifndef _FILE_H |
40 | #ifndef _FILE_H |
41 | #define _FILE_H |
41 | #define _FILE_H |
42 | 42 | ||
43 | #include "../../../fs/const.h" |
43 | #include "../../../fs/const.h" |
44 | #include "../../../fs/type.h" |
44 | #include "../../../fs/type.h" |
45 | #include "../../../fs/stat.h" |
45 | #include "../../../fs/stat.h" |
46 | #include "../../../fs/dir.h" |
46 | #include "../../../fs/dir.h" |
47 | #include "../../../share/message.h" |
47 | #include "../../../share/message.h" |
48 | 48 | ||
49 | #define F_OK 0x00 |
49 | #define F_OK 0x00 |
50 | #define F_FILE_NOT_FOUND 0x01 |
50 | #define F_FILE_NOT_FOUND 0x01 |
51 | #define F_FILE_NOT_OPEN 0x02 |
51 | #define F_FILE_NOT_OPEN 0x02 |
52 | #define F_READ_ERROR 0x10 |
52 | #define F_READ_ERROR 0x10 |
53 | #define F_READ_OVERFLOW 0x11 |
53 | #define F_READ_OVERFLOW 0x11 |
54 | #define F_SYSTEM_ERROR 0xf0 |
54 | #define F_SYSTEM_ERROR 0xf0 |
55 | #define F_IPC_FAILURE 0xf1 |
55 | #define F_IPC_FAILURE 0xf1 |
56 | #define F_MMAP_FAILURE 0xf2 |
56 | #define F_MMAP_FAILURE 0xf2 |
57 | #define F_COMM_FAILURE 0xf3 |
57 | #define F_COMM_FAILURE 0xf3 |
58 | 58 | ||
59 | #define F_ERRTYPE_MASK 0xf0 |
59 | #define F_ERRTYPE_MASK 0xf0 |
60 | 60 | ||
61 | #define F_MODE_READ 0x01 |
61 | #define F_MODE_READ 0x01 |
62 | #define F_MODE_WRITE 0x02 |
62 | #define F_MODE_WRITE 0x02 |
63 | #define F_MODE_READ_WRITE F_MODE_READ | F_MODE_WRITE |
63 | #define F_MODE_READ_WRITE F_MODE_READ | F_MODE_WRITE |
64 | #define F_MODE_APPEND 0x04 |
64 | #define F_MODE_APPEND 0x04 |
65 | 65 | ||
66 | /** |
66 | /** |
67 | * |
67 | * |
68 | */ |
68 | */ |
69 | typedef struct { |
69 | typedef struct { |
70 | char name[30]; |
70 | char name[30]; |
71 | unsigned short inode_num; |
71 | unsigned short inode_num; |
72 | } dir_item_t; |
72 | } dir_item_t; |
73 | 73 | ||
74 | /** |
74 | /** |
75 | * |
75 | * |
76 | */ |
76 | */ |
77 | typedef struct { |
77 | typedef struct { |
78 | size_t size; |
78 | size_t size; |
79 | dir_item_t base_info; |
79 | dir_item_t base_info; |
80 | void *share; |
80 | void *share; |
81 | message_params_t *params; |
81 | message_params_t *params; |
82 | unsigned int handle; |
82 | unsigned int handle; |
83 | stat_t stat; |
83 | stat_t stat; |
84 | } file_t; |
84 | } file_t; |
85 | 85 | ||
86 | static int f_err; |
86 | static int f_err; |
87 | 87 | ||
88 | dir_item_t *ls(unsigned int *length); |
88 | dir_item_t *ls(unsigned int *length); |
89 | int chdir(char *new_dir); |
89 | int chdir(char *new_dir); |
90 | 90 | ||
91 | file_t *fopen(char *name, int mode); |
91 | file_t *fopen(char *name, int mode); |
92 | int fstat(file_t *file); |
92 | int fstat(file_t *file); |
93 | int fread(file_t *file, void *buffer, unsigned int size); |
93 | int fread(file_t *file, void *buffer, unsigned int size); |
94 | int fseek(file_t * file, int offset, int whence); |
94 | int fseek(file_t * file, int offset, int whence); |
95 | int fclose(file_t *file); |
95 | int fclose(file_t *file); |
96 | 96 | ||
97 | #endif |
97 | #endif |
98 | 98 | ||
99 | /** |
99 | /** |
100 | *@} |
100 | *@} |
101 | / |
101 | / |
102 | 102 |