FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/services/ffs/ffs.c @ 213:ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 06 Jan 2014 04:20:29 +0000 |
parents | |
children | 30a173257f4a |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #ifndef TARGET |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "ffs.cfg" |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #if ((TARGET == 1) || (RIV_ENV== 1)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "ffs/board/task.h" |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 #if (TARGET == 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 #include <stdlib.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 #include <string.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 #include <limits.h> |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 #include "ffs/ffs.h" |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 #include "ffs/board/core.h" |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 #include "ffs/board/ffstrace.h" |
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 * |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 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
|
35 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 // 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
|
37 // 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
|
38 #if (TARGET == 0) |
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 {int x; }; |
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_BEGIN() |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 int result; \ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 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
|
43 #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
|
44 #endif |
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 * 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
|
48 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 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
|
55 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 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
|
58 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 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
|
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 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
|
63 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
|
64 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 // 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
|
66 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 return fs.initerror; |
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 if (size < 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 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
|
74 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
|
75 return EFFS_NOSPACE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 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
|
78 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 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
|
80 // 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
|
81 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
|
82 return i; |
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 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
|
85 return EFFS_NOTFOUND; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 journal_begin(0); |
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 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
|
90 return dir; |
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 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
|
93 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 // 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
|
97 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
|
98 && is_open_option(option, (FFS_O_EXCL))) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 return EFFS_EXISTS; |
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 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
|
102 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 // 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
|
105 // 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
|
106 // return an error |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 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
|
108 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 } |
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 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
|
112 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 // 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
|
115 // 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
|
116 // 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
|
117 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
|
118 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 journal_begin(i); |
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 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
|
122 return dir; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 // 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
|
125 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
|
126 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 // 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
|
129 // 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
|
130 // 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
|
131 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
|
132 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
|
133 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 // 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
|
137 // 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
|
138 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
|
139 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 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
|
141 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 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
|
143 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 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
|
145 fs.chunk_size_max : size_remaining); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 journal_begin(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 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
|
150 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
|
151 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 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
|
154 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 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
|
156 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 return EFFS_OK; |
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 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 // 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
|
166 // 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
|
167 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
|
168 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 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
|
170 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 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
|
172 0, &fb); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 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
|
175 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 } |
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 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
|
180 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
|
181 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 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
|
183 cp, 0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 // 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
|
187 // 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
|
188 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
|
189 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 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
|
192 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 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
|
194 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 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
|
196 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 } |
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 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
|
201 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
|
202 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 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
|
204 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 // 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
|
207 // 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
|
208 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
|
209 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 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
|
212 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 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
|
214 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
|
215 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 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
|
217 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 } |
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 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
|
222 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
|
223 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 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
|
225 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
|
226 } |
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 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
|
229 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
|
230 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 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
|
233 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 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
|
235 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 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
|
237 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 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
|
242 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
|
243 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
|
244 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 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
|
246 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 // 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
|
249 // 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
|
250 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
|
251 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 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
|
253 } |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 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
|
257 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 int error; |
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 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
|
261 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
|
262 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 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
|
264 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 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
|
266 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 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
|
269 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 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
|
271 } |
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 * 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
|
275 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
276 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 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
|
278 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 iref_t i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_stat('%s', ?) ?\n", name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); |
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 (name == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 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
|
288 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 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
|
290 i = EFFS_OK; |
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 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
|
294 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 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
|
297 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
298 iref_t i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_lstat('%s', ?) ?\n", name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 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
|
304 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
|
305 i = EFFS_OK; |
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 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
|
309 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 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
|
312 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 iref_t i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_xlstat('%s', ?) ?\n", name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
317 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
318 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
|
319 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
|
320 i = EFFS_OK; |
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 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
|
324 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 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
|
327 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 iref_t i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_fstat('%d', ?) ?\n", fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 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
|
334 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
|
335 i = EFFS_OK; |
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 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
|
339 } |
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 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
|
342 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
|
343 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 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
|
345 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
346 int size; |
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 tw(tr(TR_FUNC, TrApi, "ffs_symlink('%s', '%s') ?\n", pathname, src)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 // 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
|
352 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 return fs.initerror; |
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 if (src == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 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
|
360 if (i > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 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
|
363 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 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
|
366 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 journal_begin(0); |
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 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
|
370 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 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
|
373 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 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
|
382 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 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
|
384 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 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
|
386 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 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
|
388 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 } |
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 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
|
393 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
|
394 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 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
|
396 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 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
|
399 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 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
|
403 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 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
|
405 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 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
|
407 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 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
|
409 } |
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 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
|
412 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
|
413 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 iref_t i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_remove('%s')\n", pathname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 // 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
|
420 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 return fs.initerror; |
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 ((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
|
425 return i; |
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 (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
|
428 return EFFS_LOCKED; |
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 = 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
|
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 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
|
434 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
436 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
443 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
|
444 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 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
|
446 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 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
|
448 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 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
|
450 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
451 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
454 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
|
455 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 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
|
457 } |
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 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
|
460 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
|
461 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
462 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
463 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
464 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
|
465 pathname, action, param)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 pathname, action, param)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 // 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
|
470 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 return fs.initerror; |
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 (pathname == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
475 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
476 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 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
|
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 = 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
|
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 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
|
483 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 } |
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 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
|
487 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
488 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
489 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
490 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
496 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
|
497 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
498 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
|
499 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
500 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
|
501 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
502 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
|
503 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
505 } |
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 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
|
508 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
|
509 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 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
|
511 } |
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 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
|
514 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
|
515 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
516 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
|
517 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
518 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
|
519 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
520 tw(tr(TR_FUNC, TrApi, "ffs_rename('%s', '%s') ?\n", pathname, newname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
521 ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
522 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 // 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
|
524 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
525 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
527 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 // 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
|
529 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
|
530 return oldi; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
531 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
|
532 return oldi; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
533 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
|
534 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
536 journal_begin(oldi); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
537 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
538 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
|
539 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
|
540 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
548 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
|
549 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
|
550 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
551 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
552 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
|
553 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
554 else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
556 } |
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 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
|
559 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
562 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
564 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
565 return EFFS_OK; |
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 // TASKEND |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
568 |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
571 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
|
572 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 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
|
574 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
575 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
|
576 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
577 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 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
|
579 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
580 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
581 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
582 |
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 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
|
585 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
|
586 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 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
|
588 } |
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 * Directory Operations |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
592 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
594 // 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
|
595 // semantics. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 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
|
597 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
|
598 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
599 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
|
600 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
601 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 tw(tr(TR_FUNC, TrApi, "ffs_mkdir('%s')\n", pathname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 // 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
|
606 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
608 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
609 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 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
|
611 if (i > 0) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
612 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 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
|
614 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
616 journal_begin(0); |
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 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
|
619 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
621 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
|
622 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
623 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
630 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
|
631 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
632 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
|
633 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 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
|
635 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 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
|
637 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
638 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 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
|
642 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
643 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
|
644 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
646 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
|
647 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
648 int i; |
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 tw(tr(TR_FUNC, TrApi, "ffs_opendir('%s', ?)\n", name)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
651 ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); |
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 (dir == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
654 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
655 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 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
|
657 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 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
|
659 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
660 dir->this = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 dir->index = 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 // 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
|
664 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
|
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 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
|
668 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
669 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
670 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
|
671 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
672 iref_t i; |
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 tw(tr(TR_BEGIN, TrApi, "ffs_readdir(?, ?, ?) {\n")); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
675 ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
677 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
|
678 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
|
679 return EFFS_INVALID; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
682 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
|
683 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 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
|
685 dir->index = i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
686 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
687 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
|
688 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
689 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
|
690 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
691 |
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 * Preformat and Format |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 // 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
|
698 // EFFS_NOFORMAT! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
699 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
|
700 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
|
701 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
702 effs_t i; |
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 tw(tr(TR_BEGIN, TrApi, "ffs_format('%s', 0x%x) {\n", name, magic)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
705 ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
707 // TASKBEGIN effs_t FORMAT(path=name, size=magic) iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
709 if (magic != 0x2BAD) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 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
|
711 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
712 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
713 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 if (name == NULL) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
715 name = "/ffs-5.54"; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 if (*name != '/') { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 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
|
720 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
721 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 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
|
724 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
|
725 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 } |
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 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
|
729 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
730 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
731 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
|
732 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
734 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
735 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 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
|
741 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 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
|
743 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
744 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
|
745 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
746 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
|
747 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
748 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
751 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
|
752 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 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
|
754 } |
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 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
|
757 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
|
758 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
759 effs_t i; |
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 tw(tr(TR_BEGIN, TrApi, "ffs_preformat(0x%x) {\n", magic)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
764 // 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
|
765 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
766 if (magic != 0xDEAD) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
767 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
|
768 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
769 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
770 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
771 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
|
772 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
|
773 return EFFS_ACCESS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
774 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
776 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
|
777 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
|
778 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
779 } |
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 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
|
782 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
783 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
784 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
|
785 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
786 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
788 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
793 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
|
794 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 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
|
796 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
797 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
|
798 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
799 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
|
800 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
801 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
804 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
|
805 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
806 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
|
807 } |
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 /****************************************************************************** |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 * 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
|
811 ******************************************************************************/ |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
812 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
|
813 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
|
814 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
815 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
|
816 char *name; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
817 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
|
818 int error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
819 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
|
820 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
821 tw(tr(TR_FUNC, TrApi, "ffs_open('%s', 0x%x) ?\n", pathname, option)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
822 ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
824 // 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
|
825 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
826 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
829 // 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
|
830 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
|
831 !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
|
832 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
834 // 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
|
835 // with WR! |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
836 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
|
837 !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
|
838 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
|
839 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
840 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
841 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
|
842 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
|
843 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
844 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 } |
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 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
|
848 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
|
849 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
850 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
|
851 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
|
852 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
853 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
854 // 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
|
855 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
|
856 if (is_open_option(fs.fd[other_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
|
857 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
|
858 return EFFS_LOCKED; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
859 } |
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 // Init default values |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
862 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
|
863 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
864 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
|
865 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
|
866 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
|
867 return error; |
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 // Create segmenthead |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
870 journal_begin(0); |
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 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
|
873 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
874 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
875 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
|
876 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
877 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
|
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 return EFFS_NOTFOUND; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
881 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
882 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 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
|
884 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
|
885 return EFFS_EXISTS; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
886 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
|
887 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
888 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 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
|
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_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
|
892 return EFFS_NOTAFILE; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 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
|
895 // 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
|
896 // 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
|
897 // 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
|
898 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
|
899 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
900 // 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
|
901 journal_begin(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 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
|
904 return i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
905 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
906 // 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
|
907 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
|
908 journal_end(0); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
909 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 // If any further segments exist then remove them now |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 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
|
912 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
|
913 return error; |
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 tw(tr_bstat()); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
916 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
917 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 // 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
|
920 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
|
921 } |
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 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
|
924 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
|
925 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
926 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
927 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
928 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
|
929 #if (TARGET == 1) |
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 = (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
|
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 #else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 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
|
934 return EFFS_MEMORY; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
936 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
937 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
938 // Save 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
|
939 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
|
940 fs.fd[fdi].options = option; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
942 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
|
943 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
944 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
947 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
|
948 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
949 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
|
950 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 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
|
952 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 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
|
954 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
955 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
957 |
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 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
|
960 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
|
961 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
962 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
|
963 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
964 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 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
|
966 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
967 int error; |
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 tw(tr(TR_FUNC, TrApi, "ffs_close(%d) ?\n", fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
971 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
972 // 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
|
973 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
974 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
975 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
976 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
977 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
|
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_fd_valid(fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
980 return EFFS_BADFD; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
981 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
982 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
|
983 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
|
984 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
985 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
986 #if (TARGET == 1) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
987 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
|
988 #else |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
989 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
|
990 #endif |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
991 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
993 // 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
|
994 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
|
995 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
|
996 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
997 return EFFS_OK; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1002 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
|
1003 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 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
|
1005 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1006 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
|
1007 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1008 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
|
1009 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 return result; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 } |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 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
|
1015 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1016 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
|
1017 } |
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 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
|
1020 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
|
1021 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1022 effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1023 iref_t i; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1024 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
|
1025 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
|
1026 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
|
1027 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1028 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
|
1029 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
|
1030 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 // 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
|
1032 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1034 return fs.initerror; |
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 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
|
1037 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1039 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
|
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_fd_valid(fdi)) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1042 return EFFS_BADFD; |
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 (!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
|
1045 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
|
1046 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1047 // 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
|
1048 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
|
1049 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
|
1050 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 // 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
|
1052 // write buffer. |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 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
|
1054 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
|
1055 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1056 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1057 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1058 size_done = 0; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1059 size_remaining = amount; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1060 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1061 do { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1062 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
|
1063 // 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
|
1064 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
|
1065 &chunk_offset); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1066 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1067 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
|
1068 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
|
1069 // 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
|
1070 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
|
1071 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
|
1072 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1073 else { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 // 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
|
1075 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
|
1076 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
|
1077 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
|
1078 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1079 } |
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 fs.fd[fdi].dirty = 1; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1082 fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1083 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1084 // 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
|
1085 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
|
1086 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1087 if (size_remaining <= 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
|
1088 size = size_remaining; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1089 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", 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 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
|
1093 size); |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 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
|
1096 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
|
1097 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
|
1098 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 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
|
1100 size_remaining -= size; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1102 // 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
|
1103 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
|
1104 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
|
1105 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1106 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1107 } 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
|
1108 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1109 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
|
1110 return amount; |
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 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1115 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
|
1116 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1117 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
|
1118 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1119 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
|
1120 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1121 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
|
1122 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1123 return result; |
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 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
|
1127 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1129 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
|
1130 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1131 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
|
1132 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1133 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1134 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
|
1135 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 int error; |
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 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
|
1139 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
|
1140 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 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
|
1142 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 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
|
1144 } |
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 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
|
1147 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
|
1148 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1149 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 // 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
|
1151 // 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
|
1152 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
|
1153 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
|
1154 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1155 effs_t error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1156 int fp_new; |
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 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
|
1159 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
|
1160 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1161 // 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
|
1162 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1163 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1164 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1165 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1166 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
|
1167 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1168 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
|
1169 return EFFS_BADFD; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1170 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 switch(whence) { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 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
|
1173 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
|
1174 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1175 fp_new = offset; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1176 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1177 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
|
1178 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
|
1179 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
|
1180 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1181 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
|
1182 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 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
|
1184 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
|
1185 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 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
|
1187 break; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 default: |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 return EFFS_INVALID; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 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
|
1193 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
|
1194 return error; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1195 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1196 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
|
1197 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 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
|
1202 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 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
|
1204 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1205 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
|
1206 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1207 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
|
1208 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1209 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1212 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
|
1213 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1214 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
|
1215 } |
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 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
|
1218 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
|
1219 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1220 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
|
1221 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
|
1222 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1223 // 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
|
1224 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1226 return fs.initerror; |
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 if (path == NULL) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1229 return EFFS_BADNAME; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1230 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 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
|
1232 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1236 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
|
1237 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1238 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
|
1239 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1240 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
|
1241 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 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
|
1243 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 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
|
1248 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1249 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
|
1250 } |
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 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
|
1253 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
|
1254 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 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
|
1256 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
|
1257 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1258 // 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
|
1259 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1260 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1261 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1262 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1263 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
|
1264 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1265 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1268 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
|
1269 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1270 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
|
1271 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1272 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
|
1273 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1274 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
|
1275 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 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
|
1280 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1281 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
|
1282 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1283 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1284 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
|
1285 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1286 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
|
1287 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
|
1288 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 // 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
|
1290 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 if (fs.initerror) |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 return fs.initerror; |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 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
|
1295 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 // TASKEND |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1299 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
|
1300 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1301 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
|
1302 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1303 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
|
1304 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1305 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
|
1306 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1307 return result; |
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 |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1310 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
|
1311 { |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1312 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
|
1313 } |
ef7d7da61c56
FFS code integration: remaining C files imported, but not yet integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1314 |