RFC fs: add pread and pwrite functions
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 RFC Latest2 patches 4 repliesIn review
- v14 patches 2 repliesSuperseded
Changes in v2 from the cover letter
rewritten pread and pwrite functions
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | fs: fix return type of readfs/ include/ | +2 | 0 replies | |
| 2/2 | fs: add pread and pwrite functionsfs/ include/ | +77 | 4 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [RFC PATCH v2 0/2] fs: add pread and pwrite functions
These Patches fixes the return type of read function and add two new functions, pread and pwrite in fs layer of barebox.
In my opinion this implementation of pread and pwrite could be better if fs interface has as read callback:
int (*read)(struct device_d *dev, loff_t pos, ... flags, etc...);
not a "FILE *" as parameter.
instead of:
int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size);
I don't want to screw up the interface, it's only a notice. This would be funny if we change that. :-/
The current implementation of pread and pwrite saves the current file pos and restore them after do some file manipulation. Could be optimize if a filesystem driver doesn't read the pos from FILE pointer and I can give the offset over a parameter. In case of read it would be "f->pos" and pread it would be "offset".
Another thing is:
We could optimize it (pwrite and pread) and (read and write) looks very similar. The only different between these functions is a "const void *buf" and "void *buf"
I thinking a about a function with a functionpointer as parameter like
static ssize_t __do_read_or_write(int fd, void *buf, size_t count,
ssize_t func(int fd, void *buf, size_t count))
Which func is for read = __read and for write = __write, but I got trouble because the function prototype "void *" and "const void*". I can do more parameters and decide it as runtime, but I don't like to do that, looks very ugly.
Regards
Alex
v2:
rewritten pread and pwrite functions
Alexander Aring (2):
fs: fix return type of read
fs: add pread and pwrite functions
fs/fs.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- include/fs.h | 4 ++- 2 files changed, 78 insertions(+), 15 deletions(-)
Signature · 7 lines
1.8.1.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox