FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/services/ffs/ffs.c @ 992:a7b0b426f9ca
target-utils: boot ROM UART autodetection revamped
The new implementation should work with both the familiar Calypso C035
boot ROM version found in our regular targets as well as the older
Calypso F741979B version found on the vintage D-Sample board.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 30 Dec 2015 21:28:41 +0000 |
parents | 30a173257f4a |
children |
rev | line source |
---|---|
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Flash File System (ffs) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * ffs public API functions |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * $Id: ffs.c 1.69.1.24.1.40 Thu, 08 Jan 2004 15:05:23 +0100 tsj $ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 * |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 f ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
11 #include "ffs.h" |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #if ((TARGET == 1) || (RIV_ENV== 1)) |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
14 #include "task.h" |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #if (TARGET == 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 #include <stdlib.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #include <string.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 #include <limits.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
24 #include "core.h" |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
25 #include "ffstrace.h" |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 * |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 extern struct fs_s fs; // defined in core.c |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 // These dummy defines and struct are only use to simulate FFS on the |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 // PC. The ones that is used in target are located in task.h |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 #if (TARGET == 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 struct ffs_blocking_s {int x; }; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 #define FFS_BLOCKING_CALL_BEGIN() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 int result; \ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 struct ffs_blocking_s fb; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 #define FFS_BLOCKING_CALL_END() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 * Create, Read and Write |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 req_id_t ffs_file_write_b(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 ffs_options_t option, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 iref_t i, dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 int chunk_size, size_remaining, bytes_free; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 tw(tr(TR_FUNC, TrApi, "ffs_file_write('%s', 0x%x, %d, %d) ?\n", |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 pathname, (int) src, size, option)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 ttw(ttr(TTrApi, "ffs_file_write('%s', 0x%x, %d, %d) ?" NL, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 pathname, (int) src, size, option)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 // TASKBEGIN effs_t FILE_WRITE(path=pathname, src=src, size=size, value16=option) iref_t i, dir; char *name; effs_t error; int chunk_size, size_remaining, bytes_free; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (size < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 ffs_query(Q_BYTES_FREE, &bytes_free); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 if (bytes_free < size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 return EFFS_NOSPACE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 chunk_size = (size > fs.chunk_size_max ? fs.chunk_size_max : size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 if ((i = object_lookup(pathname, &name, &dir)) < 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 // Object not found, continue like fcreate() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 if (i != EFFS_NOTFOUND) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 if (!is_open_option(option, FFS_O_CREATE)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 return EFFS_NOTFOUND; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 if ((dir = object_create(name, src, chunk_size, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 return dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 journal_end(OT_FILE); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 // Object found, continue like fupdate() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 if (is_open_option(option, (FFS_O_CREATE)) |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
95 && is_open_option(option, (FFS_O_EXCL))) |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 if (get_fdi(i) >= 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 // Even though the ffs architecture allows to have data in |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 // directory objects, we don't want to complicate matters, so we |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 // return an error |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 if (is_object(inode_addr(i), OT_DIR) && !(fs.flags & FS_DIR_DATA)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 if ((i = is_readonly(i, pathname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 // Save the segment (if any) in the global variable because this |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 // global variable will be updated if the inode is going to be |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 // relocated if an inode_reclaim() is triggeret by the object_create() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 fs.i_backup = segment_next(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 journal_begin(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 if ((dir = object_create(name, src, chunk_size, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 return dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 // Do not link child - we are replacing the complete file! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 fs.link_child = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 // If any other segments exist then remove them FIXME: If we get a |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 // power failure here then the remaining segments wil not be removed |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 // before inode_reclaim() has been executed |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 if (fs.i_backup > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 if ((error = object_remove(fs.i_backup)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 // Save dir in fs.i_backup because this will be updated if some of the |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 // chunks below trigger a inode reclaim! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 fs.i_backup = dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 size_remaining = size - chunk_size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 while (size_remaining > 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 chunk_size = (size_remaining > fs.chunk_size_max ? |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 fs.chunk_size_max : size_remaining); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
143 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 if ((i = segment_create((char*) src + size - size_remaining, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 chunk_size, fs.i_backup)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 journal_end(OT_SEGMENT); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 size_remaining -= chunk_size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 // Note: ffs_fcreate() is deprecated and should not be used. Use |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 // ffs_file_write(..., FFS_O_CREATE | FFS_O_EXCL) instead. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 effs_t ffs_fcreate(const char *pathname, void *src, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 result = ffs_file_write_b(pathname, src, size, FFS_O_CREATE | FFS_O_EXCL, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 req_id_t ffs_fcreate_nb(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 return ffs_file_write_b(pathname, src, size, FFS_O_CREATE | FFS_O_EXCL, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 // Note: ffs_fupdate() is deprecated and should not be used. Use |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 // ffs_file_write(...,FFS_O_TRUNC) instead. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 effs_t ffs_fupdate(const char *pathname, void *src, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 result = ffs_file_write_b(pathname, src, size, FFS_O_TRUNC, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 req_id_t ffs_fupdate_nb(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 return ffs_file_write_b(pathname, src, size, FFS_O_TRUNC, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 // Note: ffs_fwrite() is deprecated and should not be used. Use |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 // ffs_file_write(...,FFS_O_CREATE | FFS_O_TRUNC) instead. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 effs_t ffs_fwrite(const char *pathname, void *src, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 result = ffs_file_write_b(pathname, src, size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 FFS_O_CREATE | FFS_O_TRUNC, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 req_id_t ffs_fwrite_nb(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 return ffs_file_write_b(pathname, src, size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 FFS_O_CREATE | FFS_O_TRUNC, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 effs_t ffs_file_write(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 ffs_options_t option) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 result = ffs_file_write_b(pathname, src, size, option, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 req_id_t ffs_file_write_nb(const char *pathname, void *src, int size, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 ffs_options_t option, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 return ffs_file_write_b(pathname, src, size, option, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 // Note important: ffs_fread() is deprecated and should not be used. Use |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 // ffs_file_read() instead. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 int ffs_fread(const char *name, void *addr, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 return ffs_file_read(name, addr, size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 int ffs_file_read(const char *name, void *addr, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 tw(tr(TR_BEGIN, TrApi, "file_read('%s', 0x%x, %d) {\n", |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 name, (int) addr, size)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 if ((error = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 error = file_read(name, addr, size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 tw(tr(TR_END, TrApi, "} %d\n", error)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 return ffs_end(error); // number of bytes read |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 * Stat, Symlink, Remove and Rename |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 effs_t ffs_stat(const char *name, struct stat_s *stat) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
276 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 tw(tr(TR_FUNC, TrApi, "ffs_stat('%s', ?) ?\n", name)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
279 ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 if (name == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 if ((i = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 if ((i = object_stat(name, (struct xstat_s*) stat, 0, 0, 0)) > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 i = EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
288 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
290 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
291 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
292 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 effs_t ffs_lstat(const char *name, struct stat_s *stat) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 tw(tr(TR_FUNC, TrApi, "ffs_lstat('%s', ?) ?\n", name)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
298 ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 if ((i = ffs_begin()) == EFFS_OK) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 if ((i = object_stat(name, (struct xstat_s*)stat, 1, 0, 0)) > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 i = EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
304 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
305 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
306 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 effs_t ffs_xlstat(const char *name, struct xstat_s *stat) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
312 tw(tr(TR_FUNC, TrApi, "ffs_xlstat('%s', ?) ?\n", name)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
313 ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
314 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
315 if ((i = ffs_begin()) == EFFS_OK) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 if ((i = object_stat(name, stat, 1, 0, 1)) > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
317 i = EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
318 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
319 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
320 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 effs_t ffs_fstat(fd_t fdi, struct stat_s *stat) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 tw(tr(TR_FUNC, TrApi, "ffs_fstat('%d', ?) ?\n", fdi)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
328 ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 if ((i = ffs_begin()) == EFFS_OK) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 if ((i = object_stat( 0, (struct xstat_s*) stat, 0, fdi, 0)) > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 i = EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 req_id_t ffs_symlink_b(const char *pathname, const char *src, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 iref_t i, dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 int size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 tw(tr(TR_FUNC, TrApi, "ffs_symlink('%s', '%s') ?\n", pathname, src)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
346 ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 // TASKBEGIN effs_t SYMLINK(path=pathname, src=src) iref_t i, dir; int size; char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 if (src == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 i = object_lookup(pathname, &name, &dir); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 if (i > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 if (i != EFFS_NOTFOUND) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 size = ffs_strlen(src) + 1; // include null-terminator |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 if ((i = object_create(name, src, size, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 journal_end(OT_LINK); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 effs_t ffs_symlink(const char *pathname, const char *actualpath) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
379 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 result = ffs_symlink_b(pathname, actualpath, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 req_id_t ffs_symlink_nb(const char *pathname, const char *src, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
392 return ffs_symlink_b(pathname, src, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 int ffs_readlink(const char *name, char *addr, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
396 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 tw(tr(TR_FUNC, TrApi, "ffs_readlink('%s')\n", name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 if ((error = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 error = object_read(name, addr, size, 1); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 return ffs_end(error); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 req_id_t ffs_remove_b(const char *pathname, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
412 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
413 tw(tr(TR_FUNC, TrApi, "ffs_remove('%s')\n", pathname)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
414 ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
416 // TASKBEGIN effs_t REMOVE(path=pathname) iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
420 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 if ((i = object_lookup_once(pathname, 0, 0)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
424 if (get_fdi(i) >= 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
425 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
426 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
427 if ((i = is_readonly(i, pathname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
428 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
429 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
430 if ((i = object_remove(i)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
431 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
433 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
436 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
439 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
440 effs_t ffs_remove(const char *pathname) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
441 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
442 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
443 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
444 result = ffs_remove_b(pathname, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
446 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
448 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
450 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
451 req_id_t ffs_remove_nb(const char *pathname, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
452 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
453 return ffs_remove_b(pathname, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
454 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
455 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 req_id_t ffs_fcontrol_b(const char *pathname, int8 action, int param, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
457 T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
458 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
459 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
460 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
461 tw(tr(TR_FUNC, TrApi, "ffs_fcontrol('%s', %d, 0x%x) ?\n", |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
462 pathname, action, param)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
463 ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
464 pathname, action, param)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
465 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 // TASKBEGIN effs_t FCONTROL(path=pathname, value16=action, size=param) iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 if (pathname == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
473 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
474 if ((i = ffs_strcmp(pathname, "/dev/ffs")) != 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
475 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
476 if ((i = object_lookup_once(pathname, 0, 0)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
478 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
479 if ((i = is_readonly(i, pathname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
480 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
481 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 if ((i = object_control(i, action, param)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
485 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
486 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
487 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
488 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
489 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
490 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
492 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
493 effs_t ffs_fcontrol(const char *pathname, int8 action, int param) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
494 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
495 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
496 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
497 result = ffs_fcontrol_b(pathname, action, param, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
498 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
499 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
500 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
501 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
502 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
503 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 req_id_t ffs_fcontrol_nb(const char *pathname, int8 action, int param, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
505 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
506 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
507 return ffs_fcontrol_b(pathname, action, param, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
508 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
509 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 req_id_t ffs_rename_b(const char *pathname, const char *newname, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
511 T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
512 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
513 iref_t i, oldi, dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
514 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
515 struct inode_s *ip; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
516 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
517 tw(tr(TR_FUNC, TrApi, "ffs_rename('%s', '%s') ?\n", pathname, newname)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
518 ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
519 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
520 // TASKBEGIN effs_t RENAME(path=pathname, src=newname) iref_t i, oldi, dir; char *name; struct inode_s *ip; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
521 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
522 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
524 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
525 // pathname MUST exist, not be open and MUST be writable |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 if ((oldi = object_lookup_once(pathname, 0, 0)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
527 return oldi; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 if ((oldi = is_readonly(oldi, pathname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
529 return oldi; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
530 if (get_fdi(oldi) >= 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
531 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
532 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
533 journal_begin(oldi); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
534 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 if ((i = object_lookup_once(newname, &name, &dir)) < 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
536 if (i != EFFS_NOTFOUND) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
537 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
538 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
539 else { // newname obj exist |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
540 ip = inode_addr(oldi); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 if (is_object(ip, OT_FILE)) { // is old obj a file? |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
542 if ((i = is_readonly(i, newname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
543 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
544 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
545 ip = inode_addr(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
546 if (!is_object(ip, OT_FILE)) // newname MUST be a file |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
548 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
549 fs.journal.repli = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
550 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
551 else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
552 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
553 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
554 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 if ((i = object_rename(oldi, name, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
556 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
557 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
558 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
559 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
562 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
564 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
565 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
566 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
567 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
568 effs_t ffs_rename(const char *pathname, const char *newname) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
569 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
570 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
571 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
572 result = ffs_rename_b(pathname, newname, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
574 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
575 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
576 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
577 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
579 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
580 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
581 req_id_t ffs_rename_nb(const char *pathname, const char *newname, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
582 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
583 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
584 return ffs_rename_b(pathname, newname, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
585 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
586 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
588 * Directory Operations |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
589 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
590 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
591 // All directory operations are more or less similar to unix |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
592 // semantics. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 req_id_t ffs_mkdir_b(const char *pathname, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
594 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
595 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 iref_t i, dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
597 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
598 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
599 tw(tr(TR_FUNC, TrApi, "ffs_mkdir('%s')\n", pathname)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
600 ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
601 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 // TASKBEGIN effs_t MKDIR(path=pathname) iref_t i, dir; char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
606 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 i = object_lookup(pathname, &name, &dir); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
608 if (i > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
609 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 if (i != EFFS_NOTFOUND) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
611 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
612 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
614 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 if ((i = object_create(name, 0, 0, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
616 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
617 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
618 journal_end(OT_DIR); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
619 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
621 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
622 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
623 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
626 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
627 effs_t ffs_mkdir(const char *pathname) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
628 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
629 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
630 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
631 result = ffs_mkdir_b(pathname, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
632 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
633 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
635 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
637 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
638 req_id_t ffs_mkdir_nb(const char *pathname, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
639 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
640 return ffs_mkdir_b(pathname, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
642 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
643 int ffs_opendir(const char *name, struct dir_s *dir) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
644 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 int i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
646 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
647 tw(tr(TR_FUNC, TrApi, "ffs_opendir('%s', ?)\n", name)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
648 ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
649 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
650 if (dir == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
651 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
652 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
653 if ((i = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
654 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
655 if ((i = dir_open(name)) >= 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
657 dir->this = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 dir->index = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
659 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
660 // Now count the number of entries in the directory |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 dir_traverse(-i, (iref_t *) &i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
662 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
663 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
664 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
665 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
666 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
667 int ffs_readdir(struct dir_s *dir, char *name, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
668 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
669 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
670 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
671 tw(tr(TR_BEGIN, TrApi, "ffs_readdir(?, ?, ?) {\n")); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
672 ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
673 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
674 if (dir == NULL || name == NULL || size < 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
675 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
677 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
678 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
679 if ((i = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
680 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
681 if ((i = dir_next(dir->this, dir->index, name, size))) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
682 dir->index = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
683 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 tw(tr(TR_END, TrApi, "} ('%s') %d\n", name, i)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
685 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
686 return ffs_end(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
687 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
688 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
689 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
690 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
691 * Preformat and Format |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
692 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
693 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
694 // Note that we do NOT call ffs_begin() because it will just return |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 // EFFS_NOFORMAT! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 req_id_t ffs_format_b(const char *name, uint16 magic, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
698 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
699 effs_t i; |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
700 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
701 tw(tr(TR_BEGIN, TrApi, "ffs_format('%s', 0x%x) {\n", name, magic)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
702 ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
703 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
704 // TASKBEGIN effs_t FORMAT(path=name, size=magic) iref_t i; |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
705 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 if (magic != 0x2BAD) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
707 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
709 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
711 if (name == NULL) { |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
712 name = "/ffs-5.54"; |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
713 } |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
715 if (*name != '/') { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 tw(tr(TR_END, TrApi, "} %d\n", EFFS_BADNAME)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
720 if ((i = is_formattable(1)) < 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
721 tw(tr(TR_END, TrApi, "} %d\n", i)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
724 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
725 if ((i = fs_format(name)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
727 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
728 tw(tr(TR_END, TrApi, "} %d\n", i)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
729 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
730 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
731 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
732 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
734 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
735 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
736 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
737 effs_t ffs_format(const char *name, uint16 magic) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
738 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
739 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
741 result = ffs_format_b(name, magic, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
743 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
744 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
745 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
746 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
747 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
748 req_id_t ffs_format_nb(const char *name, uint16 magic, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
749 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
750 return ffs_format_b(name, magic, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
751 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
752 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 req_id_t ffs_preformat_b(uint16 magic, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
754 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
755 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
756 effs_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
757 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
758 tw(tr(TR_BEGIN, TrApi, "ffs_preformat(0x%x) {\n", magic)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
759 ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
760 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
761 // TASKBEGIN effs_t PREFORMAT(path="/", size=magic) effs_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 if (magic != 0xDEAD) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
764 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
765 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
766 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
767 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
768 if (!ffs_is_modifiable("")) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
769 tw(tr(TR_END, TrApi, "} %d\n", EFFS_ACCESS)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
770 return EFFS_ACCESS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
771 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
772 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
773 if ((i = is_formattable(0)) < 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
774 tw(tr(TR_END, TrApi, "} %d\n", i)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
776 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
777 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
778 if ((i = fs_preformat()) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
779 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
780 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
781 tw(tr(TR_END, TrApi, "} %d\n", i)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
782 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
783 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
784 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
785 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
786 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
788 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
789 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
790 effs_t ffs_preformat(uint16 magic) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
791 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
792 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
793 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
794 result = ffs_preformat_b(magic, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
796 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
797 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
798 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
799 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
800 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
801 req_id_t ffs_preformat_nb(uint16 magic, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
802 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
803 return ffs_preformat_b(magic, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
804 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
805 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
806 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
807 * Open, Read, Write, Close |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
808 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
809 req_id_t ffs_open_b(const char *pathname, ffs_options_t option, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
811 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
812 iref_t i, dir, dummy; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
813 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
814 fd_t other_fdi, fdi = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
815 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
816 struct inode_s *ip; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
817 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
818 tw(tr(TR_FUNC, TrApi, "ffs_open('%s', 0x%x) ?\n", pathname, option)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
819 ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
820 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
821 // TASKBEGIN fd_t OPEN(path=pathname, value16=option) iref_t i, dir, dummy; char *name; fd_t other_fdi, fdi = 0; int error; struct inode_s *ip; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
822 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
824 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
825 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
826 // Minimum one of the flags RD or WR must be specifyed |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 if (!is_open_option(option, FFS_O_RDONLY) && |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 !is_open_option(option, FFS_O_WRONLY)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
829 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
830 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
831 // RDONLY must not be combined with any other options if not together |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
832 // with WR! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 if (is_open_option(option, FFS_O_RDONLY) && |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
834 !is_open_option(option, FFS_O_WRONLY)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
835 if (!(option == FFS_O_RDONLY)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
836 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
837 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
838 for (fdi = 0; fdi < fs.fd_max; fdi++) { // Find free fd |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
839 if (fs.fd[fdi].options == 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
840 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
841 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
842 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
843 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
844 if (fdi >= fs.fd_max) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 return EFFS_NUMFD; // Too many open files in system |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
846 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
847 i = object_lookup(pathname, &name, &dir); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
848 if (i < 0 && i != EFFS_NOTFOUND) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
849 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
850 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
851 // Open one file several times in RD is okay but only one time in WR |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
852 if (i != EFFS_NOTFOUND && (other_fdi = get_fdi(i)) >= 0) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
853 if (is_open_option(fs.fd[other_fdi].options, FFS_O_WRONLY) || |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
854 is_open_option(option, FFS_O_WRONLY)) |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
855 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
856 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
857 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
858 // Init default values |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
859 fs.fd[fdi].fp = fs.fd[fdi].size = fs.fd[fdi].wfp = fs.fd[fdi].dirty = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
860 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
861 if (i == EFFS_NOTFOUND) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
862 if (is_open_option(option, (FFS_O_CREATE | FFS_O_WRONLY))) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
863 if ((error = is_filename(name)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
864 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
865 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
866 // Create segmenthead |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
867 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
868 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
869 if ((i = object_create(name, 0, 0, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
870 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
871 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
872 journal_end(OT_FILE); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
873 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
874 fs.fd[fdi].seghead = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
875 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
876 else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
877 return EFFS_NOTFOUND; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
878 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
879 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
880 if (is_open_option(option, FFS_O_WRONLY)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
881 if (is_open_option(option, (FFS_O_CREATE | FFS_O_EXCL))) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
882 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 if ((i = is_readonly(i, pathname)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
884 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
885 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
886 ip = inode_addr(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
887 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
888 if (is_object(ip, OT_DIR)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
890 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
891 if (is_open_option(option, FFS_O_TRUNC)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
892 // Save the segment (if any) in the global variable because this |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 // global variable will be updated if the inode is relocated by |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 // an inode_reclaim() triggeret by object_create() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
895 fs.i_backup = segment_next(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
896 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
897 // Replace old seghead with a new and remove all old segments |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
898 journal_begin(i); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
899 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
900 if ((i = object_create(name, 0, 0, -dir)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
901 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
902 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
903 // Do not link child |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
904 fs.link_child = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
905 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
906 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
907 // If any further segments exist then remove them now |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
908 if (fs.i_backup > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
909 if ((error = object_remove(fs.i_backup)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
912 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
913 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
914 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
915 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
916 // Get total size of the file. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
917 fs.fd[fdi].size = segfile_seek(i, INT_MAX, &dummy, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
920 if (is_open_option(option, FFS_O_APPEND)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
921 fs.fd[fdi].fp = fs.fd[fdi].size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
922 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
923 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
924 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
925 if (is_open_option(option, FFS_O_WRONLY)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
926 #if (TARGET == 1) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
927 if ((fs.fd[fdi].buf = (char *) target_malloc(fs.fd_buf_size)) == 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
928 return EFFS_MEMORY; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
929 #else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
930 if ((fs.fd[fdi].buf = malloc(fs.fd_buf_size)) == 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
931 return EFFS_MEMORY; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
932 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
934 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 // Save data in file descriptor |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
936 fs.fd[fdi].seghead = i; |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
937 fs.fd[fdi].options = option; |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
938 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
939 return fdi + FFS_FD_OFFSET; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
940 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
942 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
943 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
944 fd_t ffs_open(const char *pathname, ffs_options_t option) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
945 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
946 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
947 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
948 result = ffs_open_b(pathname, option, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
949 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
950 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
952 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
954 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
955 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 req_id_t ffs_open_nb(const char *pathname, ffs_options_t option, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
957 T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
958 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
959 return ffs_open_b(pathname, option, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
960 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
961 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
962 req_id_t ffs_close_b(fd_t fdi, T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
963 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
964 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
966 tw(tr(TR_FUNC, TrApi, "ffs_close(%d) ?\n", fdi)); |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
967 ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
968 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
969 // TASKBEGIN effs_t CLOSE(fdi=fdi) iref_t i; int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
971 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
972 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
973 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
974 fdi -= FFS_FD_OFFSET; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
975 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
976 if (!is_fd_valid(fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
977 return EFFS_BADFD; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
978 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
979 if (is_open_option(fs.fd[fdi].options, FFS_O_WRONLY )) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
980 if ((error = datasync(fdi)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
981 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
982 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
983 #if (TARGET == 1) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
984 target_free(fs.fd[fdi].buf); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
985 #else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
986 free(fs.fd[fdi].buf); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
987 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
988 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
989 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
990 // Clear all data in file descriptor |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
991 fs.fd[fdi].seghead = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 fs.fd[fdi].options = fs.fd[fdi].fp = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
993 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
994 return EFFS_OK; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
995 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
996 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
997 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
998 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
999 effs_t ffs_close(fd_t fdi) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1000 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1001 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1002 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1003 result = ffs_close_b(fdi, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1005 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1006 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1007 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1008 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1009 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 req_id_t ffs_close_nb(fd_t fdi, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1012 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1013 return ffs_close_b( fdi, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1015 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1016 req_id_t ffs_write_b(fd_t fdi, void *src, int amount, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1017 T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1018 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1019 effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1020 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1021 int size_remaining, fp_offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1022 int size, size_done; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1023 offset_t chunk_offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1024 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1025 tw(tr(TR_BEGIN, TrApi, "ffs_write_b(%d, 0x%x, %d) ?{\n", fdi, src, amount)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1026 ttw(ttr(TTrApi, "ffs_write_b(%d, 0x%x, %d) ?" NL, fdi, src, amount)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1027 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1028 // TASKBEGIN int WRITE(fdi=fdi, src=src, size=amount) effs_t error; iref_t i; int size_remaining, fp_offset; int size, size_done; offset_t chunk_offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1029 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1030 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1032 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 if (amount < 0 || src == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1034 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1035 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1036 fdi -= FFS_FD_OFFSET; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1037 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 if (!is_fd_valid(fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1039 return EFFS_BADFD; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1040 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1041 if (!is_open_option(fs.fd[fdi].options, FFS_O_WRONLY )) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1042 return EFFS_INVALID; // not opened with write flag |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1043 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1044 // If FFS_O_APPEEND is specified move fp to eof |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1045 if (is_open_option(fs.fd[fdi].options, FFS_O_APPEND )) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1046 fs.fd[fdi].fp = fs.fd[fdi].size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1047 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1048 // If fp has been moved outside the write buf (by a read) then flush the |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1049 // write buffer. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1050 if (fs.fd[fdi].fp >= (fs.fd[fdi].wfp + fs.chunk_size_max)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 if ((error = datasync(fdi)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1052 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1054 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1055 size_done = 0; |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1056 size_remaining = amount; |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1057 |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1058 do { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1059 if (!fs.fd[fdi].dirty ) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1060 // Buffer is not dirty so find the chunk that fp points to. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1061 segfile_seek(fs.fd[fdi].seghead, fs.fd[fdi].fp, &i, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1062 &chunk_offset); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1063 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1064 if ((fs.fd[fdi].size == fs.fd[fdi].fp && |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1065 chunk_offset == fs.chunk_size_max) || fs.fd[fdi].size == 0 ) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1066 // End of file and last chunk is full or empty seghead. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1067 fs.fd[fdi].wfp = fs.fd[fdi].size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1068 fs.fd[fdi].wch = 0; // Create new chunk (not update). |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1069 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1070 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1071 // Work on this chunk and update it later by datasyns |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1072 segment_read(i, fs.fd[fdi].buf, fs.fd_buf_size, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1073 fs.fd[fdi].wfp = fs.fd[fdi].fp - chunk_offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 fs.fd[fdi].wch = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1075 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1076 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1077 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1078 fs.fd[fdi].dirty = 1; |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1079 fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1080 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1081 // Fill the buffer to max or just add the rest |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1082 size = fs.chunk_size_max - fp_offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1083 |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1084 if (size_remaining <= fs.chunk_size_max - fp_offset) |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1085 size = size_remaining; |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1086 |
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1087 tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", size)); |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1088 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1089 memcpy(fs.fd[fdi].buf + fp_offset, (uint8*)src + size_done, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1091 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1092 fs.fd[fdi].fp += size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1093 if (fs.fd[fdi].fp > fs.fd[fdi].size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 fs.fd[fdi].size = fs.fd[fdi].fp; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1096 size_done += size; // FIXME: remove size_done or size_remaining |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1097 size_remaining -= size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1098 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 // If wrbuf is full (size = chunk_size_max) so create a chunk. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1100 if (fs.fd[fdi].fp >= (fs.fd[fdi].wfp + fs.chunk_size_max)) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 if ((error = datasync(fdi)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1102 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1103 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1104 } while(size_remaining > 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1105 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1106 tw(tr(TR_END, TrApi, "} %d\n", amount)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1107 return amount; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1108 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1109 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1110 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1111 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1112 int ffs_write(fd_t fdi, void *src, int amount) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1113 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1114 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1115 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1116 result = ffs_write_b(fdi, src, amount, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1117 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1118 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1119 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1120 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1121 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1122 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1123 req_id_t ffs_write_nb(fd_t fdi, void *src, int amount, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1124 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1125 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1126 tw(tr(TR_FUNC, TrApi, "ffs_write_nb(%d, 0x%x, %d) ?\n", fdi, src, amount)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1127 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 return ffs_write_b(fdi, src, amount, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1129 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1130 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1131 int ffs_read(fd_t fdi, void *src, int size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1132 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1133 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1134 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1135 tw(tr(TR_BEGIN, TrApi, "ffs_read(%d, 0x%x, %d) {\n", fdi, src, size)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 ttw(ttr(TTrApi, "ffs_read(%d, 0x%x, %d) ?" NL, fdi, src, size)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1137 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1138 if ((error = ffs_begin()) == EFFS_OK) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1139 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1140 error = stream_read(fdi - FFS_FD_OFFSET, src, size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1142 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 tw(tr(TR_END, TrApi, "} %d\n", error)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1144 return ffs_end(error); // number of bytes read |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1145 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1146 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1147 // The seek function will not allow the file offset to be set beyond the end |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1148 // of the existing data in the file or the final offset to be negative. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1149 req_id_t ffs_seek_b(fd_t fdi, int offset, int whence, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1151 { |
217
30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
213
diff
changeset
|
1152 effs_t error; |
213
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1153 int fp_new; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1154 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1155 tw(tr(TR_FUNC, TrApi, "ffs_seek(%d, %d, %d) ?\n", fdi, offset, whence)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1156 ttw(ttr(TTrApi, "ffs_seek(%d, %d, %d) ?" NL, fdi, offset, whence)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1157 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1158 // TASKBEGIN int SEEK(fdi=fdi, size=offset, value16=whence) effs_t error; iref_t i; int fp_new, foffset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1159 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1160 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1161 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1162 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1163 fdi -= FFS_FD_OFFSET; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1164 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1165 if (!is_fd_valid(fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1166 return EFFS_BADFD; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1167 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1168 switch(whence) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1169 case FFS_SEEK_SET: |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1170 if (offset < 0 || offset > fs.fd[fdi].size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 fp_new = offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1173 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1174 case FFS_SEEK_CUR: |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1175 if (fs.fd[fdi].fp + offset < 0 || |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1176 fs.fd[fdi].fp + offset > fs.fd[fdi].size) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1177 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1178 fp_new = fs.fd[fdi].fp + offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1179 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1180 case FFS_SEEK_END: |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1181 if (offset > 0 || fs.fd[fdi].size < -offset) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1182 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 fp_new = (offset + fs.fd[fdi].size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1184 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1185 default: |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1187 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 if (!is_offset_in_buf(fp_new, fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 if ((error = datasync(fdi)) < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1193 return fs.fd[fdi].fp = fp_new; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1194 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1195 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1196 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1197 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 int ffs_seek(fd_t fdi, int offset, int whence) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1199 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1200 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1202 result = ffs_seek_b(fdi, offset, whence, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1204 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1205 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1206 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1207 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1208 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1209 req_id_t ffs_seek_nb(fd_t fdi, int offset, int whence, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1210 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1211 return ffs_seek_b(fdi, offset, whence, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1212 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1213 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1214 req_id_t ffs_truncate_b(const char *path, offset_t length, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1215 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1216 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1217 tw(tr(TR_FUNC, TrApi, "ffs_truncate('%s', %d) \n", path, length)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1218 ttw(ttr(TTrApi, "ffs_ftruncate('%s', %d) ?" NL, path, length)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1219 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1220 // TASKBEGIN effs_t TRUNC(path=path, size=length) iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1221 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1222 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1223 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1224 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 if (path == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1226 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1227 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1228 return object_truncate(path, -1, length); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1229 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1230 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1232 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 effs_t ffs_truncate(const char *path, offset_t length) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1234 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1235 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1236 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1237 result = ffs_truncate_b(path, length, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1238 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1239 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1240 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1241 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1243 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 req_id_t ffs_truncate_nb(const char *path, offset_t length, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1245 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1246 return ffs_truncate_b(path, length, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1248 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1249 req_id_t ffs_ftruncate_b(fd_t fdi, offset_t length, T_RV_RETURN *cp, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1250 struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1251 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1252 tw(tr(TR_FUNC, TrApi, "ffs_ftruncate(%d, %d) \n", fdi, length)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1253 ttw(ttr(TTrApi, "ffs_ftruncate(%d, %d) ?" NL, fdi, length)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1254 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 // TASKBEGIN effs_t FTRUNC(fdi=fdi, size=length) iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1256 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1257 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1258 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1259 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1260 return object_truncate(0, fdi - FFS_FD_OFFSET, length); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1261 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1262 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1263 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1264 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1265 effs_t ffs_ftruncate(fd_t fdi, offset_t length) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1266 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1267 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1268 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1269 result = ffs_ftruncate_b(fdi, length, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1270 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1271 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1272 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1273 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1274 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1275 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 req_id_t ffs_ftruncate_nb(fd_t fdi, offset_t length, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1277 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1278 return ffs_ftruncate_b(fdi, length, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1280 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1281 req_id_t ffs_fdatasync_b(fd_t fdi, T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1282 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1283 tw(tr(TR_FUNC, TrApi, "ffs_fdatasync(%d) \n", fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1284 ttw(ttr(TTrApi, "ffs_fdatasync(%d) ?" NL, fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1285 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1286 // TASKBEGIN effs_t FDATASYNC(fdi=fdi) effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1287 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1288 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1290 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 return datasync(fdi - FFS_FD_OFFSET); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1295 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 effs_t ffs_fdatasync(fd_t fdi) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1297 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1298 FFS_BLOCKING_CALL_BEGIN(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1299 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1300 result = ffs_fdatasync_b(fdi, 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1301 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1302 FFS_BLOCKING_CALL_END(); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1303 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1304 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1305 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1306 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1307 req_id_t ffs_fdatasync_nb(fd_t fdi, T_RV_RETURN *cp) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1308 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1309 return ffs_fdatasync_b(fdi, cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1310 } |