Re: Question on /proc API & bug in sysctl

Aaron Ucko (UCKO@vax1.rockhurst.edu)
Sat, 23 Mar 1996 15:23:14 -0600 (CST)


>> While looking at the code of the sysctl in /proc I found several
>> problems. The interface provided is buggy. By this I mean that it
>> does not respect the interface for file access. There should be
>> no difference between accessing a normal file in an ext2 filesystem
>> (for instance) and a file in /proc.
>>
>> To show the bug, just try to do a simple dd in /proc/sys/kernel/ostype
>> (for instance):
>> dd if=/proc/sys/kernel/ostype of=/dev/tty bs=1 skip=3
>>
>> You will see that whatever skip you provide you will always get
>> the string from the beginning. THIS IS NOT CORRECT AND DOES NOT
>> RESPECT THE INTERFACE.
>>
>> I know this a kind of details but you may come to a problem when
>> new BIG entries will be added to this directory aalong with
>> companion program to display contents.
>
>The reason for this behaviour is that most /proc entries do NOT support
>lseek().

Therefore the bug is in dd and not in the kernel: if dd finds that lseek
fails with such-and-such an error, it should just read the specified amount
of data itself and ignore it.

-- Aaron Ucko (ucko@vax1.rockhurst.edu; finger for PGP public key) | httyp!
"That's right," he said. "We're philosophers. We think, therefore we am."
-- Terry Pratchett, _Small Gods_ | Geek Code 3.1 [for explanation, finger
hayden@mankato.msus.edu]: GCS/M/S/C d- s: a18 C++(+++)>++++ UL++>++++ P++
L++>+++++ E- W(-) N++(+) o+ K- w--- O M@ V-(--) PS++(+++) PE- Y(+) PGP(+) t(+)
!5 X-- R(-) tv-@ b++(+++) DI+ !D-- G++(+++) e->+++++(*) h!>+ r-(--)>+++ y?