Messages in this thread | | | Date | Fri, 24 Feb 2006 08:42:35 +0100 (MET) | From | Jan Engelhardt <> | Subject | Re: Problems with read() on /proc/devices with x86_64 system |
| |
>> 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |