Skip to content

RFC current read implementation and POSIX

Alexander Aring barebox 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3ramfs: add foofs for testingfs/ramfs.c+69 -03 replies
2/3fs: read: handle zero filesfs/fs.c+0 -30 replies
3/3libbb: read_full: use read return instead sizelib/libbb.c+1 -16 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/3] current read implementation and POSIX

Hi all,

first I want to say "Sascha, please don't apply this patch serie!". I suppose I detected some incompatible POSIX read call behaviour.

History:

I am thinking about to add a procfs into barebox and I begun to hack this while I sitting in the train. I don't want to talk about the procfs idea right now, maybe we don't need something like this. But while I hacked it I detected some misbehaviour of read(2).

Issue:

read returns the number of bytes which are readed if there are no bytes it should return 0;

But if the file is zero read will return nothing, this is fixed in Patch 2/3 (please review carefully, I did this fix fast and check only if it working)

Some commands/functions check if the file is zero and then these functions calls no read but this is wrong. When a file is zero, read can read some bytes of course. A zero file not indicate that the file has no content. Maybe I should reference the ugly POSIX opengroup documentation, but you can see it yourself in linux:

ls -l /proc/version:
-r--r--r-- 1 root root 0 Feb 28 08:30 /proc/version

is a zero file and contains information with "cat /proc/version".

Patch 3/3 fix this issue for commands like edit which use the read_full function which should read contents with the return value of read and not with size value.

To test the behaviour I advice you this steps:

1. Apply patch 1/3 which adds a simple ugly hacked foofs.

2. Compile a sandbox and start it.

3. in barebox run: "mkdir /bar;mount none foofs /bar"

4. run "cat /bar/foobar" and "edit /bar/foobar" -> nothing will be displayed

5. Apply patch 2/3 and 3/3 and rerun steps 2-4

So why I don't fix this issue? Because I can't test everything and I think some filesystem and other commands can't deal with it and maybe we don't want to fix this issue and accept the current behaviour. :-(

Another hint:

Sascha had some problems with zero files in tftpfs maybe there is some relationship between this issue and the zero file tftpfs files... because the read of zero files is currently some kind of broken. :-)

- Alex

Alexander Aring (3):
ramfs: add foofs for testing
fs: read: handle zero files
libbb: read_full: use read return instead size

 fs/fs.c     |  3 ---
 fs/ramfs.c  | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libbb.c |  2 +-
 3 files changed, 70 insertions(+), 4 deletions(-)
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox