diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-06-03 06:45:09 -0400 |
---|---|---|
committer | Artem Bityutskiy <dedekind1@gmail.com> | 2011-07-04 03:54:33 -0400 |
commit | 83cef708c606f46a2b527af025acb3d24555f0c4 (patch) | |
tree | f5f91da8f13a7f013304ae596e56e7d52a5dcd76 /fs/ubifs/misc.h | |
parent | d033c98b17ecf30d64d83d96938ce7bfb47f7520 (diff) |
UBIFS: introduce more I/O helpers
Introduce the following I/O helper functions: 'ubifs_leb_read()',
'ubifs_leb_write()', 'ubifs_leb_change()', 'ubifs_leb_unmap()',
'ubifs_leb_map()', 'ubifs_is_mapped().
The idea is to wrap all UBI I/O functions in order to encapsulate various
assertions and error path handling (error message, stack dump, switching to R/O
mode). And there are some other benefits of this which will be used in the
following patches.
This patch does not switch whole UBIFS to use these functions yet.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/misc.h')
-rw-r--r-- | fs/ubifs/misc.h | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h index 160cd909e957..ee7cb5ebb6e8 100644 --- a/fs/ubifs/misc.h +++ b/fs/ubifs/misc.h | |||
@@ -145,86 +145,6 @@ static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf) | |||
145 | } | 145 | } |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * ubifs_leb_unmap - unmap an LEB. | ||
149 | * @c: UBIFS file-system description object | ||
150 | * @lnum: LEB number to unmap | ||
151 | * | ||
152 | * This function returns %0 on success and a negative error code on failure. | ||
153 | */ | ||
154 | static inline int ubifs_leb_unmap(const struct ubifs_info *c, int lnum) | ||
155 | { | ||
156 | int err; | ||
157 | |||
158 | ubifs_assert(!c->ro_media && !c->ro_mount); | ||
159 | if (c->ro_error) | ||
160 | return -EROFS; | ||
161 | err = ubi_leb_unmap(c->ubi, lnum); | ||
162 | if (err) { | ||
163 | ubifs_err("unmap LEB %d failed, error %d", lnum, err); | ||
164 | return err; | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * ubifs_leb_write - write to a LEB. | ||
172 | * @c: UBIFS file-system description object | ||
173 | * @lnum: LEB number to write | ||
174 | * @buf: buffer to write from | ||
175 | * @offs: offset within LEB to write to | ||
176 | * @len: length to write | ||
177 | * @dtype: data type | ||
178 | * | ||
179 | * This function returns %0 on success and a negative error code on failure. | ||
180 | */ | ||
181 | static inline int ubifs_leb_write(const struct ubifs_info *c, int lnum, | ||
182 | const void *buf, int offs, int len, int dtype) | ||
183 | { | ||
184 | int err; | ||
185 | |||
186 | ubifs_assert(!c->ro_media && !c->ro_mount); | ||
187 | if (c->ro_error) | ||
188 | return -EROFS; | ||
189 | err = ubi_leb_write(c->ubi, lnum, buf, offs, len, dtype); | ||
190 | if (err) { | ||
191 | ubifs_err("writing %d bytes at %d:%d, error %d", | ||
192 | len, lnum, offs, err); | ||
193 | return err; | ||
194 | } | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * ubifs_leb_change - atomic LEB change. | ||
201 | * @c: UBIFS file-system description object | ||
202 | * @lnum: LEB number to write | ||
203 | * @buf: buffer to write from | ||
204 | * @len: length to write | ||
205 | * @dtype: data type | ||
206 | * | ||
207 | * This function returns %0 on success and a negative error code on failure. | ||
208 | */ | ||
209 | static inline int ubifs_leb_change(const struct ubifs_info *c, int lnum, | ||
210 | const void *buf, int len, int dtype) | ||
211 | { | ||
212 | int err; | ||
213 | |||
214 | ubifs_assert(!c->ro_media && !c->ro_mount); | ||
215 | if (c->ro_error) | ||
216 | return -EROFS; | ||
217 | err = ubi_leb_change(c->ubi, lnum, buf, len, dtype); | ||
218 | if (err) { | ||
219 | ubifs_err("changing %d bytes in LEB %d, error %d", | ||
220 | len, lnum, err); | ||
221 | return err; | ||
222 | } | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * ubifs_encode_dev - encode device node IDs. | 148 | * ubifs_encode_dev - encode device node IDs. |
229 | * @dev: UBIFS device node information | 149 | * @dev: UBIFS device node information |
230 | * @rdev: device IDs to encode | 150 | * @rdev: device IDs to encode |