Commit graph

7330 commits

Author SHA1 Message Date
Devin Gunay
b277aa235a use powi instead of unnecessary powf
clippy::suboptimal_flops found a few unnecessary usages of powf (powi is faster)
2022-03-16 00:37:29 -07:00
Jeffrey Finkelstein
f4ca963dca df: separate functions for two main modes of df
Split the code for getting a list of `Filesystem` objects into two
separate functions: one for getting the list of all filesystems (when
running `df` with no arguments) and one for getting only named
filesystems (when running `df` with one or more arguments). This does
not change the behavior of `df` only the organization of the code.
2022-03-15 22:06:55 -04:00
Jeffrey Finkelstein
6f3dcf5998 df: add Filesystem::from_path() function
Add the `Filesystem::from_path()` function which produces the
filesystem on which a given path is mounted. The `Filesystem` is taken
from a list of candidate `MountInfo` objects.
2022-03-15 21:56:39 -04:00
Jeffrey Finkelstein
6371eb8298 df: use for loop over filesystems to display rows
Replace a loop over `Row` objects with a loop over `Filesystem`
objects when it comes time to display each row of the output
table. This helps with code structure, since the `Filesystem` is the
primary object of interest in the `df` program. This makes it easier
for us to independently vary how the list of filesystems is produced
and how the list of filesystems is displayed.
2022-03-15 19:43:28 -04:00
Jeffrey Finkelstein
18bfd1ac68 split: implement round-robin arg to --number
Implement distributing lines of a file in a round-robin manner to a
specified number of chunks. For example,

    $ (seq 1 10 | split -n r/3) && head -v xa[abc]
    ==> xaa <==
    1
    4
    7
    10

    ==> xab <==
    2
    5
    8

    ==> xac <==
    3
    6
    9
2022-03-15 18:22:44 -04:00
kimono-koans
fa6af85b8e
ls: Fix display of inodes and add allocation size feature (#3052) 2022-03-15 16:27:43 +01:00
Sylvestre Ledru
748d414946
Merge pull request #3258 from cakebaker/fix_exclude_type_panic
df: fix panic when using -x argument (#3257)
2022-03-15 16:24:15 +01:00
Sylvestre Ledru
42dd19ca7f
Merge pull request #3101 from refi64/cp-dest-symlink
cp: Avoid following a destination symlink with -P
2022-03-15 08:16:52 +01:00
Ryan Gonzalez
2dc3d867d8 cp: Avoid following a destination symlink with -P
Previously, given 'cp -P a b', where 'a' and 'b' were both symlinks, cp
would end up replacing the target of 'b'.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-03-14 17:49:42 -05:00
Daniel Hofstetter
433504949d df: fix panic when using -x argument (#3257)
Also allow multiple '-x' options
2022-03-14 10:32:42 +01:00
Sylvestre Ledru
8f97283cf3
Merge pull request #3253 from jfinkels/df-filesystem-module-3
df: move Filesystem to filesystem.rs
2022-03-14 09:59:28 +01:00
Sylvestre Ledru
dd6d29f389
Merge pull request #3248 from sylvestre/nproc
nproc: Improve the GNU compat
2022-03-14 08:32:40 +01:00
Sylvestre Ledru
9be49b1bbd
Merge pull request #3255 from sylvestre/field
ci: rename of the tracking size field to match the tracking project
2022-03-13 22:40:27 +01:00
Sylvestre Ledru
0571434a75 ci: rename of the tracking size field to match the tracking project 2022-03-13 21:03:40 +01:00
Jeffrey Finkelstein
b81f4ef6a7 df: add documentation comments for filesystem.rs 2022-03-13 14:30:15 -04:00
Jeffrey Finkelstein
2fac674317 df: move Filesystem to filesystem.rs
Move the `Filesystem` struct into a new module `filesystem.rs`.
2022-03-13 14:30:14 -04:00
Sylvestre Ledru
24b4af768c nproc: Improve the support of OMP_NUM_THREADS 2022-03-13 18:33:16 +01:00
Sylvestre Ledru
d6dad9f412
Merge pull request #3250 from jfinkels/df-remove-fs-selector
df: remove use of FsSelector abstraction
2022-03-13 18:17:49 +01:00
Sylvestre Ledru
c957efe7b5
Merge pull request #3249 from jfinkels/timeout-return-values
timeout: fix bug in --preserve-status mode
2022-03-13 18:17:23 +01:00
Jeffrey Finkelstein
81e2de498a df: remove use of FsSelector abstraction
Remove the use of the `FsSelector` struct when deciding whether a
filesystem type should be included or excluded from the output
table. Instead, just maintain optional `Vec`s of filesystem types to
exclude and include, and check whether the filesystem type is
contained in one of those. This reduces the amount of code required to
implement these checks, and since the number of types given in the
`include` or `exclude` lists is likely to be small, there should not
be much of a difference in performance.
2022-03-12 20:52:40 -05:00
Jeffrey Finkelstein
1aa6fd1468 timeout: fix bug in --preserve-status mode
Fix a bug where `timeout --preserve-status` was not correctly
preserving the status code of the child process if it timed out. When
that happens, the status code of the child process is considered to be
the signal number (in this case, `SIGTERM`). The exit status of
`timeout` is then 128 plus the numeric code associated with `SIGTERM`.
2022-03-12 19:53:11 -05:00
Jeffrey Finkelstein
2d390233fe timeout: add ExitStatus enumeration
Add the `ExitStatus` enumeration in a new module `status.rs` to
contain all the magic numbers in the `timeout` utility.
2022-03-12 19:53:11 -05:00
Sylvestre Ledru
2c6bbcf716 nproc: support --ignore=' 1' as GNU 2022-03-12 19:23:37 +01:00
Sylvestre Ledru
bfd1e14137
Merge pull request #3204 from jfinkels/split-line-bytes
split: implement --line-bytes option
2022-03-12 09:45:07 +01:00
Sylvestre Ledru
2cc951ae79
Merge pull request #3218 from sylvestre/timeout-test
timeout: add a test for empty arg
2022-03-12 09:43:36 +01:00
OHNONOTAMOTH
094198b22a
Consistent tempfile crate declaration (version 3) (#3244) 2022-03-12 09:40:23 +01:00
Sylvestre Ledru
2c10ddf3f4
Merge pull request #3243 from jfinkels/timeout-restructure
timeout: refactor helper func for wait-then-signal
2022-03-12 09:38:05 +01:00
Sylvestre Ledru
0bc6f7b9ba
Merge pull request #3245 from jfinkels/df-fix-internal-tests
df: fix tests of internal helper functions
2022-03-12 09:37:29 +01:00
Jeffrey Finkelstein
9fae445ca9 df: fix tests of internal helper functions
Fix unit tests for the `is_included()` and `filter_mount_list()`
internal helper functions. The function signatures changed but the
tests did not get updated to match.
2022-03-11 22:52:17 -05:00
Jeffrey Finkelstein
a0eed2405c timeout: refactor helper func for wait-then-signal
Factor a helper function `wait_or_kill_process()` out of the main
`timeout()` function. This helper function contains the code to wait
for a child process and send the `SIGKILL` signal if it does not
terminate within a specified amount of time. This does not change the
function of `timeout`, just the organization of the code.
2022-03-11 18:47:30 -05:00
Eli Youngs
565af8237b Fix formatting 2022-03-11 23:43:59 +01:00
Eli Youngs
e23219289a Simplify test cases 2022-03-11 23:43:59 +01:00
Eli Youngs
2afa9cd1a0 printf - Update %g formatting to match GNU 2022-03-11 23:43:59 +01:00
jfinkels
ebd0c09549
util: use seq to enumerate integers (#3239)
Replace a bash loop for enumerating integers with a more concise use
of `seq` in `util/build-gnu.sh`.
2022-03-11 09:38:06 +01:00
Kartik Sharma
5c5f4ca6ad
df: Adds support for mount path prefix matching and input path (#3161)
* Adds support for mount path prefix matching and input path
canonicalization

- Sorts mount paths in reverse lexicographical order
- Canonicalize all paths and clear invalid paths
- Checking of mount path prefix matches input path
2022-03-11 09:36:34 +01:00
Sylvestre Ledru
1795272473
Merge pull request #3176 from jfinkels/df-output-columns-2
df: implement the --output command-line argument
2022-03-11 09:26:17 +01:00
Sylvestre Ledru
e8d1aebd9e
Merge pull request #3242 from jfinkels/multiple-clippy-fixes
Clippy fixes in multiple crates
2022-03-11 09:04:42 +01:00
Sylvestre Ledru
492c467361
Merge pull request #3240 from jfinkels/util-dont-replace-seq
util: remove replacement of seq in GNU tests
2022-03-11 09:03:36 +01:00
Jeffrey Finkelstein
77d92883c7 split: implement --line-bytes option
Implement the `--line-bytes` option to `split`. In this mode, the
program tries to write as many lines of the input as possible to each
chunk of output without exceeding a specified byte limit. The new
`LineBytesChunkWriter` struct represents this functionality.
2022-03-10 22:51:49 -05:00
Jeffrey Finkelstein
c0cd017706 tests: update test_df.rs to use --output argument 2022-03-10 22:50:15 -05:00
Jeffrey Finkelstein
ec048b3857 df: implement the --output command-line argument
Implement the `--output` command-line argument, which allows
specifying an exact sequence of columns to display in the output
table. For example,

    $ df --output=source,fstype | head -n3
    Filesystem       Type
    udev             devtmpfs
    tmpfs            tmpfs

(The spacing does not exactly match the spacing of GNU `df` yet.)

Fixes #3057.
2022-03-10 22:50:15 -05:00
Jeffrey Finkelstein
0b07ecdad2 df: use Options.columns field to control output
Replace the `Options.show_fs_type` and `Options.show_inode_instead`
fields with the more general `Options.columns`, a `Vec` of `Column`
variants representing the exact sequence of columns to display in the
output. This makes `Options` able to represent arbitrary output column
display configurations.
2022-03-10 22:50:15 -05:00
Jeffrey Finkelstein
b42168e9dc Clippy fixes in multiple crates 2022-03-10 22:31:21 -05:00
Jeffrey Finkelstein
a5200efaac util: remove replacement of seq in GNU tests 2022-03-10 18:51:26 -05:00
Sylvestre Ledru
2e8945ba7f
Merge pull request #3221 from uutils/dependabot/cargo/unicode-segmentation-1.9.0
build(deps): bump unicode-segmentation from 1.8.0 to 1.9.0
2022-03-10 00:32:13 +01:00
Sylvestre Ledru
08f40a102e
Merge pull request #3228 from uutils/dependabot/cargo/unindent-0.1.8
build(deps): bump unindent from 0.1.7 to 0.1.8
2022-03-10 00:31:07 +01:00
Sylvestre Ledru
3b78023fcb
Merge pull request #3220 from uutils/dependabot/cargo/strum-0.24.0
build(deps): bump strum from 0.23.0 to 0.24.0
2022-03-10 00:30:29 +01:00
Sylvestre Ledru
2e860e7048
Merge pull request #3116 from nickd0/printf-round-fix
printf: fix printf sci notation round up
2022-03-09 19:47:52 +01:00
Sylvestre Ledru
3955354b3a timeout: add a test for empty arg 2022-03-09 19:45:43 +01:00
dependabot[bot]
fc4f1d869e build(deps): bump strum from 0.23.0 to 0.24.0
Bumps [strum](https://github.com/Peternator7/strum) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/commits)

---
updated-dependencies:
- dependency-name: strum
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-09 19:45:40 +01:00