Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

linprocfs Input/output error

0 views
Skip to first unread message

Fernando Apesteguía

unread,
Jan 1, 2010, 1:13:24 PM1/1/10
to FreeBSD Hackers
Hi all, I post here cause I didn't get any answers in freebsd-emulation.

In 8.0-RELEASE-p1 if I try to execute this:

cat /compat/linux/proc/cpuinfo > ~/cpuinfo.txt

I get

cat: /compat/linux/proc/cpuinfo: Input/output error

truss shows the read system call returns ERR#5. It is the same with
other files from linprocfs.

cat /compat/linux/proc/[any_file] works fine

What am I missing?

Thanks in advance
_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Jilles Tjoelker

unread,
Jan 1, 2010, 2:40:37 PM1/1/10
to Fernando Apesteguía, FreeBSD Hackers
On Fri, Jan 01, 2010 at 06:45:33PM +0100, Fernando Apestegu�a wrote:
> Hi all, I post here cause I didn't get any answers in freebsd-emulation.

> In 8.0-RELEASE-p1 if I try to execute this:

> cat /compat/linux/proc/cpuinfo > ~/cpuinfo.txt

> I get

> cat: /compat/linux/proc/cpuinfo: Input/output error

> truss shows the read system call returns ERR#5. It is the same with
> other files from linprocfs.

> cat /compat/linux/proc/[any_file] works fine

> What am I missing?

You are not missing anything, this is a bug. A while ago, cat(1) was
changed to use larger buffers when writing to regular files on machines
with sufficient RAM, usually a multiple of MAXPHYS. On the other hand,
pseudofs (the general framework for filesystems such as procfs,
linprocfs and linsysfs) in src/sys/fs/pseudofs/pseudofs_vnops.c
pfs_read() fails any read over MAXPHYS + 1 with EIO. This limit probably
has to do with the allocation of a buffer of that size using sbuf_new(9)
(and so, malloc(9)).

Some sort of limit seems appropriate, but MAXPHYS seems unrelated, and
if the request is too long it should perhaps just truncate it.

--
Jilles Tjoelker

Fernando Apesteguía

unread,
Jan 1, 2010, 2:43:08 PM1/1/10
to Jilles Tjoelker, FreeBSD Hackers
2010/1/1 Jilles Tjoelker <jil...@stack.nl>:

> On Fri, Jan 01, 2010 at 06:45:33PM +0100, Fernando Apestegu�a wrote:
>> Hi all, I post here cause I didn't get any answers in freebsd-emulation.
>
>> In 8.0-RELEASE-p1 if I try to execute this:
>
>> cat /compat/linux/proc/cpuinfo > ~/cpuinfo.txt
>
>> I get
>
>> cat: /compat/linux/proc/cpuinfo: Input/output error
>
>> truss shows the read system call returns ERR#5. It is the same with
>> other files from linprocfs.
>
>> cat /compat/linux/proc/[any_file] works fine
>
>> What am I missing?
>
> You are not missing anything, this is a bug. A while ago, cat(1) was
> changed to use larger buffers when writing to regular files on machines
> with sufficient RAM, usually a multiple of MAXPHYS. On the other hand,
> pseudofs (the general framework for filesystems such as procfs,
> linprocfs and linsysfs) in src/sys/fs/pseudofs/pseudofs_vnops.c
> pfs_read() fails any read over MAXPHYS + 1 with EIO. This limit probably
> has to do with the allocation of a buffer of that size using sbuf_new(9)
> (and so, malloc(9)).
>
> Some sort of limit seems appropriate, but MAXPHYS seems unrelated, and
> if the request is too long it should perhaps just truncate it.

Thanks a lot for the explanation.

Jaakko Heinonen

unread,
Jan 16, 2010, 2:28:28 AM1/16/10
to Jilles Tjoelker, FreeBSD Hackers, d...@freebsd.org, Fernando Apesteguía
On 2010-01-01, Jilles Tjoelker wrote:
> On Fri, Jan 01, 2010 at 06:45:33PM +0100, Fernando Apesteguía wrote:
>
> > cat: /compat/linux/proc/cpuinfo: Input/output error

>
> pfs_read() fails any read over MAXPHYS + 1 with EIO. This limit probably
> has to do with the allocation of a buffer of that size using sbuf_new(9)
> (and so, malloc(9)).
>
> Some sort of limit seems appropriate, but MAXPHYS seems unrelated, and
> if the request is too long it should perhaps just truncate it.

With a quick test this patch seems to work:

%%%
Index: sys/fs/pseudofs/pseudofs_vnops.c
===================================================================
--- sys/fs/pseudofs/pseudofs_vnops.c (revision 202405)
+++ sys/fs/pseudofs/pseudofs_vnops.c (working copy)
@@ -637,10 +637,8 @@ pfs_read(struct vop_read_args *va)
error = EINVAL;
goto ret;
}
- if (buflen > MAXPHYS + 1) {
- error = EIO;
- goto ret;
- }
+ if (buflen > MAXPHYS + 1)
+ buflen = MAXPHYS + 1;

sb = sbuf_new(sb, NULL, buflen, 0);
if (sb == NULL) {
%%%

Maybe des@ can comment if this looks sane?

--
Jaakko

Dag-Erling Smørgrav

unread,
Jan 18, 2010, 8:24:15 AM1/18/10
to Jaakko Heinonen, FreeBSD Hackers, Jilles Tjoelker, Fernando Apesteguía
Jaakko Heinonen <j...@FreeBSD.org> writes:
> Maybe des@ can comment if this looks sane?

Looks good. It may confuse userland apps, but that's their own fault -
and frankly my dear, I don't give a damn :)

DES
--
Dag-Erling Smørgrav - d...@des.no

0 new messages