Messages in this thread | | | Date | Mon, 26 Apr 1999 21:58:31 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: sed not working on /proc files |
| |
On Mon, 26 Apr 1999, Richard B. Johnson wrote:
> On Mon, 26 Apr 1999, Chip Salzenberg wrote: > > > According to Jeremy Fitzhardinge: > > > On 26-Apr-99 Stefan Monnier wrote: > > > > open("/proc/meminfo", O_RDONLY) = 3 > > > > fstat(3, {st_mode=0, st_size=0, ...}) = 0 > > > > mmap(0, 0, PROT_READ, MAP_PRIVATE, 3, 0) = 0 > > > > > > This is the problem. It stats the file, mmaps 0 bytes from it and finishes > > > with no action. Presumeably if the mmap failed or stat said the file isn't a > > > regular file it would use normal read. > > > > Hm. Would it be a Bad Thing for mmap to fail on /proc files that > > don't report true sizes? > > -- > > I don't know. And I don't know how to make it fail. I understand that > the reason why most sizes are not reported are that sizes are dynamic, > i.e., /proc/interrupts is bigger each time a value increase over 10. Since > the /proc file-system does know when a directory access is made, it > might be a good idea to actually calculate the length (but only at > directory access time, not when data are being accumumated which would > be a large overhead that is wasted because /proc is seldom read. > > It is also possible to just return a size of, maybe, 1024 bytes for > each of the files that are normally 0 size. I don't think a premature > EOF would affect most Unix tools. This would have zero overhead and > might make life easier.
I hate answering my own mail, but here goes, I modified ../linux/fs/proc/root.c, line 596, to provide a phony size of 1000 bytes for /proc/interrupts.
It now works with sed and less. The premature EOF doesn't seem to hurt. You may want to perform such a test on whatever else you find appropriate.
If everything seems to work okay, then ask Linus. It's his code. There is zero overhead to making such a phony size, but, as I said, it's Linus' code. He may have a good reason for zero-length files.
Cheers, Dick Johnson ***** FILE SYSTEM WAS MODIFIED ***** Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips). Warning : It's hard to remain at the trailing edge of technology.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |