Re: Problems with read() on /proc/devices with x86_64 system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> If your code ever worked, it's probably because of some
>> fortuitous buffering in the 'C' runtime library.
>
>Not my code .. I just did a minimal hack to get it to build with klibc
>(klibc do not support fscanf(), so used fread() and sscanf() ..).
>
Ah, you can't do fread(ptr, 4096, 1, fp), because it would probably never 
return 1 if the file was smaller than 4096. Bad luck with stdio, I'd say. 
Back to read(2).

>>  Most
>> of the 'read' code in drivers that have a /proc interface
>> is not designed for 1-character-at-a-time I/O. It's expected
>> that it will be accessed like `cat` or `more` or other
>> such tools access it, -- one read with 4096-byte buffer --
>> 
>> read(3, "MemTotal:       773860 kB\nMemFre"..., 4096) = 670
>> write(1, "MemTotal:       773860 kB\nMemFre"..., 670) = 670

Jan Engelhardt
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux