Repository navigation
Conversation
|
GNU testsuite comparison: |
Merging this PR will improve performance by 9.91%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
9b36ac2 to
7bba917
Compare
montezuma-p
left a comment
There was a problem hiding this comment.
The mount source needs the same decoding. With GNU df 9.7 inside unshare -rm, mount -t tmpfs $'s\nx' $'/tmp/dft/n\nl' gives this mountinfo line:
2455 2443 0:94 / /tmp/dft/n\012l rw,relatime - tmpfs s\012x rw,...
and GNU prints:
s?x /tmp/dft/n?l
Here the source is still read raw (String::from_utf8_lossy(raw[after_fields + 1]) in MountInfo::new), so from reading the code the Filesystem column would show s\012x. Running replace_special_chars() on the source too, and giving that column the ? treatment, would match GNU. #16065 does both, so the two PRs may want to settle which one carries this.
| /// with `?` like GNU df, so that a newline in the name can't split the row. | ||
| fn from_mount_point(os: &OsString) -> Self { | ||
| let bytes: Vec<u8> = uucore::os_str_as_bytes(os) | ||
| .unwrap() |
There was a problem hiding this comment.
could you use os_str_as_bytes_lossy here to avoid the unwrap()?
The kernel escapes newline as \012 in /proc/self/mountinfo and /proc/mounts, but only \040, \011 and \134 were decoded. Mount points containing a newline were then missing from df and ignored by df FILE and stat -c %m. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that a mount point with a newline is found, printing it raw splits the row in two. Replace ASCII control characters with ? in the "Mounted on" column, like GNU df, so the GNU test tests/df/problematic-chars keeps passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d3cdbc4 to
7b1c289
Compare
The kernel escapes newline as
\012in/proc/self/mountinfoand/proc/mounts, butreplace_special_chars()only decoded\040,\011and\134. A mount point with a newline in its name kept a literal\012, sodfdropped it anddf DIR/stat -c %m DIRreported the parent file system.This adds
\012to the decoder.\134stays last so a literal\012in a name (written by the kernel as\134012) is not turned into a newline. Unit tests cover mountinfo and mtab lines with a newline, all four escapes together, and the\134012case.Once the mount is found, printing the newline as is would split its row in two (and fail the GNU test
tests/df/problematic-chars), so the "Mounted on" column now replaces ASCII control characters with?, like GNU df. #16065 does the same for all df columns; whichever lands second can drop the mount-point part.Addresses the mount-point decoding portion of #15753. Mount-source/root decoding and control-character handling in other columns remain outside this PR; #16065 overlaps with that broader work.