I want to read a file in the "/proc" directory.
however `read-file' function returns empty string...
Code Select
newLISP v.10.1.12 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.
> (read-file "/proc/cpuinfo")
""
> !cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 13
...
>
Parhaps, this problem is occurd in readFile(nl-filesys.c).
That function checks the filesize, and read by filesize.
But most /proc/* file looks empty file. therefore readFile() reads 0 byte in buffer without sys-error.
Code Select
> !stat /proc/cpuinfo
File: `/proc/cpuinfo'
Size: 0 Blocks: 0 IO Block: 1024 regular empty file
Device: 3h/3d Inode: 4026531982 Links: 1
Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-04-24 04:09:15.028358255 +0900
Modify: 2010-04-24 04:09:15.028358255 +0900
Change: 2010-04-24 04:09:15.028358255 +0900
Therefoere, I think readFile() to use malloc/realloc method is better...
--- kosh