Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
kam
on March 18, 2017
|
parent
|
context
|
favorite
| on:
The Cult of DD
It doesn't need to hunt for the directory entry, just needs to call `fstat()` on the stdin file descriptor.
rwmj
on March 18, 2017
|
next
[–]
Unless the input file is a device, and then you need to call:
ioctl(STDIN_FILENO, BLKGETSIZE64, &size)
ithkuil
on March 18, 2017
|
parent
|
next
[–]
But I guess this is orthogonal to where the file descriptor comes from (i.e. stdin or opening a file whose name is passed in the args)
rwmj
on March 18, 2017
|
root
|
parent
|
next
[–]
It's an orthogonal issue, yes, but calling stat or fstat on any block device whether from stdin or argv will return .st_size == 0, so your progress bar won't display the correct answers (or could display better answers if it used the ioctl).
angry_octet
on March 18, 2017
|
prev
[–]
Oops you're right, has size in the inode.
Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: