Timeline for How does cat 'know' the optimum block size to use?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 1, 2015 at 17:57 | vote | accept | EmmaV | ||
| Nov 26, 2015 at 15:23 | comment | added | dhag | Yes, stat -f -c %s file allows you to access that value from the command line. The output file system block size is taken into account, I had elided that part but will expand my answer (the largest of the output size, input size, and hard-coded value is used). I don't see that pseudo-files such as /dev/zero are handled in a special way: GNU cat will also simply use stat on those. | |
| Nov 25, 2015 at 23:37 | comment | added | EmmaV | So I would use stat -f -c %s file to find the block size of the file system where the input file is? Doesn't the block size of the file system where the output file is going matter? And what about copying e.g. /dev/zero to a raw block device? | |
| Nov 25, 2015 at 21:46 | comment | added | dhag | Good point, Andreas. I updated my answer to say a little more about st_blksize. | |
| Nov 25, 2015 at 21:46 | history | edited | dhag | CC BY-SA 3.0 | Expanded explanation. |
| Nov 25, 2015 at 21:05 | comment | added | Andreas Wiese | For a deeper understanding, perhaps you should mention where ST_BLKSIZE is coming from — to help OP understand that this is no "magic" but a file property that can be queried through stat(2). | |
| Nov 25, 2015 at 20:13 | history | answered | dhag | CC BY-SA 3.0 |