[File] [PATCH] reuse fstat() result instead of calling fstat() again

Christos Zoulas christos at zoulas.com
Tue May 7 02:29:25 UTC 2019


On May 6, 10:30am, dvlasenk at redhat.com (Denys Vlasenko) wrote:
-- Subject: [File] [PATCH] reuse fstat() result instead of calling fstat() ag

| This is what happens when
|      magic_file(ms, "some_elf_file")
| is called:
| 
| openat(AT_FDCWD, "some_elf_file", O_RDONLY|O_NONBLOCK) = 6
| fstat(6, {st_mode=S_IFREG|0755, st_size=29560, ...}) = 0
| ^^^^^^^^^^^ fstat #1
| read(6, "\177ELF\2\1\1\0\0\0\...
| fstat(6, {st_mode=S_IFREG|0755, st_size=29560, ...}) = 0
| ^^^^^^^^^^^ fstat #2
| lseek(6, 0, SEEK_SET)   = 0
| fstat(6, {st_mode=S_IFREG|0755, st_size=29560, ...}) = 0
| ^^^^^^^^^^^ fstat #3
| pread64(6, "\6\0\0\0...", 56, 120) = 56
| ...
| 
| This is not necessary. Propagate fstat result deeper into callees.

Committed thanks!

christos


More information about the File mailing list