Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 64-bit compatibility adaptions #5821

Closed
wants to merge 5 commits into from

Conversation

cre4ture
Copy link
Contributor

@cre4ture cre4ture commented Jan 9, 2024

addresses issue #5421

EDIT: I tested it on my own phone. I compiled and run the tests on my phone. The tests are green now.

@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from 38e1f56 to 7afdd05 Compare January 9, 2024 19:50
@cre4ture cre4ture marked this pull request as ready for review January 9, 2024 19:51
@samueltardieu
Copy link
Contributor

Your PR compiles on my Android 64bit system. The result of the test is:

failures:                                               
---- test_df::test_type_option_with_file stdout ----
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils df --output=fstype .
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils df -t f2fs .
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils df -t nonexisting .
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils df --output=fstype
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils df -t ext4 .
thread 'test_df::test_type_option_with_file' panicked at tests/by-util/test_df.rs:292:14:
Command was expected to fail.                           stdout = Filesystem      1K-blocks   Used Available Use% Mounted on
/dev/block/dm-7    928204 925392         0 100% /

 stderr =

---- test_head::test_read_backwards_bytes_proc_fs_modules stdout ----
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils head -c -1 /proc/modules
thread 'test_head::test_read_backwards_bytes_proc_fs_modules' panicked at tests/by-util/test_head.rs:406:40:
Command was expected to succeed.
stdout =
 stderr = head: cannot open '/proc/modules' for reading: Permission denied


---- test_head::test_read_backwards_lines_proc_fs_modules stdout ----
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils head --lines -1 /proc/modules
thread 'test_head::test_read_backwards_lines_proc_fs_modules' panicked at tests/by-util/test_head.rs:420:40:
Command was expected to succeed.
stdout =
 stderr = head: cannot open '/proc/modules' for reading: Permission denied


---- test_head::test_read_backwards_bytes_proc_fs_version stdout ----
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils head -c -1 /proc/version
thread 'test_head::test_read_backwards_bytes_proc_fs_version' panicked at tests/by-util/test_head.rs:392:40:
Command was expected to succeed.
stdout =
 stderr = head: cannot open '/proc/version' for reading: Permission denied


---- test_head::test_read_backwards_bytes_sys_kernel_profiling stdout ----
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils head -c -1 /sys/kernel/profiling
thread 'test_head::test_read_backwards_bytes_sys_kernel_profiling' panicked at tests/by-util/test_head.rs:434:40:
Command was expected to succeed.
stdout =
 stderr = head: cannot open '/sys/kernel/profiling' for reading: Permission denied


---- test_ls::test_ls_allocation_size stdout ----
mkdir: /data/data/com.termux/files/usr/tmp/.tmpBAyiIJ/some-dir1
touch: /data/data/com.termux/files/usr/tmp/.tmpBAyiIJ/some-dir1/empty-file
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils truncate -s 4M some-dir1/file-with-holes
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils dd if=/dev/zero of=some-dir1/zero-file bs=1024 count=4096
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils dd if=/dev/zero of=irregular-file bs=1 count=777
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils ls -l --block-size=512 irregular-file
run: /data/data/com.termux/files/home/Dev/coreutils/target/debug/coreutils ls -s1 some-dir1
thread 'test_ls::test_ls_allocation_size' panicked at tests/by-util/test_ls.rs:124:14:
assertion failed: `(left == right)`

Diff < left / right > :                                 <total 4100
>total 4096
    0 empty-file
    0 file-with-holes
<4100 zero-file
>4096 zero-file

failures:                                                   
    test_df::test_type_option_with_file
    test_head::test_read_backwards_bytes_proc_fs_modules
    test_head::test_read_backwards_bytes_proc_fs_version
    test_head::test_read_backwards_bytes_sys_kernel_profiling
    test_head::test_read_backwards_lines_proc_fs_modules
    test_ls::test_ls_allocation_size

test result: FAILED. 2501 passed; 6 failed; 30 ignored; 0 measured; 0 filtered out; finished in 36.70s

but the failures look unrelated to your change.

@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from 7afdd05 to 6da26c7 Compare January 10, 2024 20:44
@cre4ture
Copy link
Contributor Author

@samueltardieu Thanks for providing your results. I'm still on the way to setup a virtual android device.
I figured out that the issue with the "test_head" was fixed meanwhile on main. I did a rebase. Now this should also be gone.

@samueltardieu
Copy link
Contributor

You can also use your phone and drive it with scrcpy which is an absolute delight to work from the computer on a real device. That's what I did.

@cre4ture
Copy link
Contributor Author

cre4ture commented Jan 13, 2024

You can also use your phone and drive it with scrcpy which is an absolute delight to work from the computer on a real device. That's what I did.

@samueltardieu
Thanks. I got scrcpy running with my own phone. :-) But I'm not sure about the best way to work with rust on android? Do you do crosscompilation? Do you compile on the phone?
I tried to compile on the phone:

  1. with rustup - which didn't work out due to not working cargo execution.
  2. with apk install rust - which works quite smoothly except of an linking error when I try to build the tests:
= note: Pointer tag for 0x41be828500000000 was truncated, see 'https://source.android.com/devices/tech/debug/tagged-pointers'.
          PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
          cc: error: unable to execute command: Aborted
          cc: error: linker command failed due to signal (use -v to see invocation)

Can you point out to a description that was working for you?

@samueltardieu
Copy link
Contributor

Do you do crosscompilation? Do you compile on the phone?

For this test, I compiled coreutils on my phone.

I tried to compile on the phone:

1. with rustup - which didn't work out due to not working cargo execution.
2. with apk install rust - which works quite smoothly except of an linking error when I try to build the tests:

I think I installed it along with build tools with apt install rust build-essential.

      cc: error: unable to execute command: Aborted

It looks like you don't have a C compiler, it should come with build-essential.

@cre4ture
Copy link
Contributor Author

cre4ture commented Jan 13, 2024

it runs now somehow. I still have the error, but it seems to be sporadically and randomly. When I re-run the build it gets further than before. If I repeat it 3-4 times, then whole compilation is done.

EDIT: It seems that the issue is that there is not enough RAM. I got this error message once:

= note: LLVM ERROR: out of memory
          Allocation failed
          PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
          cc: error: unable to execute command: Aborted
          cc: error: linker command failed due to signal (use -v to see invocation)

But I get 36 failing tests. Can you confirm that?

---- test_df::test_block_size_1024 stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -B 1024 --output=size
thread 'test_df::test_block_size_1024' panicked at tests/by-util/test_df.rs:531:14:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_block_size_in_posix_portability_mode stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -P -B 1024
thread 'test_df::test_block_size_in_posix_portability_mode' panicked at tests/by-util/test_df.rs:579:14:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_block_size_from_env stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=size
thread 'test_df::test_block_size_from_env' panicked at tests/by-util/test_df.rs:606:14:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_default_block_size stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=size
thread 'test_df::test_default_block_size' panicked at tests/by-util/test_df.rs:485:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_block_size_from_env_precedences stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=size
thread 'test_df::test_block_size_from_env_precedences' panicked at tests/by-util/test_df.rs:625:14:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_block_size_with_suffix stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -B K --output=size
thread 'test_df::test_block_size_with_suffix' panicked at tests/by-util/test_df.rs:555:14:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_default_block_size_in_posix_portability_mode stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -P
thread 'test_df::test_default_block_size_in_posix_portability_mode' panicked at tests/by-util/test_df.rs:515:40:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_default_headers stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df
thread 'test_df::test_default_headers' panicked at tests/by-util/test_df.rs:175:30:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_arguments_override_themselves stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --help --help
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -aa
thread 'test_df::test_df_arguments_override_themselves' panicked at tests/by-util/test_df.rs:48:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_compatible_no_size_arg stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -a
thread 'test_df::test_df_compatible_no_size_arg' panicked at tests/by-util/test_df.rs:17:27:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_compatible stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -ah
thread 'test_df::test_df_compatible' panicked at tests/by-util/test_df.rs:27:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_compatible_si stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -aH
thread 'test_df::test_df_compatible_si' panicked at tests/by-util/test_df.rs:37:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_conflicts_overriding stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -hH
thread 'test_df::test_df_conflicts_overriding' panicked at tests/by-util/test_df.rs:66:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_output stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -H --total
thread 'test_df::test_df_output' panicked at tests/by-util/test_df.rs:110:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_compatible_type stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -aT
thread 'test_df::test_df_compatible_type' panicked at tests/by-util/test_df.rs:32:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_output_overridden stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -hH --total
thread 'test_df::test_df_output_overridden' panicked at tests/by-util/test_df.rs:144:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_shortened_long_argument stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --a
thread 'test_df::test_df_shortened_long_argument' panicked at tests/by-util/test_df.rs:22:28:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_df_compatible_sync stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --sync
thread 'test_df::test_df_compatible_sync' panicked at tests/by-util/test_df.rs:42:31:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_exclude_type_option stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -x ext4 -x ext3
thread 'test_df::test_exclude_type_option' panicked at tests/by-util/test_df.rs:299:53:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_exclude_all_types stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype
thread 'test_df::test_exclude_all_types' panicked at tests/by-util/test_df.rs:306:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_ignore_block_size_from_env_in_posix_portability_mode stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -P
thread 'test_df::test_ignore_block_size_from_env_in_posix_portability_mode' panicked at tests/by-util/test_df.rs:684:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_invalid_block_size_from_env stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=size
thread 'test_df::test_invalid_block_size_from_env' panicked at tests/by-util/test_df.rs:658:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_iuse_percentage stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --total --output=itotal,iused,ipcent
thread 'test_df::test_iuse_percentage' panicked at tests/by-util/test_df.rs:455:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_order_same stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=source
thread 'test_df::test_order_same' panicked at tests/by-util/test_df.rs:204:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_output_file_all_filesystems stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=file
thread 'test_df::test_output_file_all_filesystems' panicked at tests/by-util/test_df.rs:807:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_output_mp_repeat stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df / /
thread 'test_df::test_output_mp_repeat' panicked at tests/by-util/test_df.rs:217:49:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_output_multiple_occurrences stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=source --output=target
thread 'test_df::test_output_multiple_occurrences' panicked at tests/by-util/test_df.rs:788:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_output_option stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output
thread 'test_df::test_output_option' panicked at tests/by-util/test_df.rs:235:33:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_output_selects_columns stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=source
thread 'test_df::test_output_selects_columns' panicked at tests/by-util/test_df.rs:751:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_precedence_of_human_readable_header_over_output_header stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -H --output=size
thread 'test_df::test_precedence_of_human_readable_header_over_output_header' panicked at tests/by-util/test_df.rs:185:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_precedence_of_block_size_arg_over_env stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -B 999 --output=size
thread 'test_df::test_precedence_of_block_size_arg_over_env' panicked at tests/by-util/test_df.rs:644:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_total stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --total
thread 'test_df::test_total' panicked at tests/by-util/test_df.rs:347:45:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_type_option stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype
thread 'test_df::test_type_option' panicked at tests/by-util/test_df.rs:250:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_use_percentage stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --total --output=used,avail,pcent --block-size=1
thread 'test_df::test_use_percentage' panicked at tests/by-util/test_df.rs:430:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_df::test_type_option_with_file stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -t f2fs .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -t nonexisting .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype
thread 'test_df::test_type_option_with_file' panicked at tests/by-util/test_df.rs:281:10:
Command was expected to succeed.
stdout = 
 stderr = thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


---- test_ls::test_ls_allocation_size stdout ----
mkdir: /data/data/com.termux/files/usr/tmp/.tmpYsPnNd/some-dir1
touch: /data/data/com.termux/files/usr/tmp/.tmpYsPnNd/some-dir1/empty-file
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils truncate -s 4M some-dir1/file-with-holes
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils dd if=/dev/zero of=some-dir1/zero-file bs=1024 count=4096
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils dd if=/dev/zero of=irregular-file bs=1 count=777
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils ls -l --block-size=512 irregular-file
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils ls -s1 some-dir1
thread 'test_ls::test_ls_allocation_size' panicked at tests/by-util/test_ls.rs:124:14:
assertion failed: `(left == right)`

Diff < left / right > :
<total 4100
>total 4096
    0 empty-file
    0 file-with-holes
<4100 zero-file
>4096 zero-file
 




failures:
    test_df::test_block_size_1024
    test_df::test_block_size_from_env
    test_df::test_block_size_from_env_precedences
    test_df::test_block_size_in_posix_portability_mode
    test_df::test_block_size_with_suffix
    test_df::test_default_block_size
    test_df::test_default_block_size_in_posix_portability_mode
    test_df::test_default_headers
    test_df::test_df_arguments_override_themselves
    test_df::test_df_compatible
    test_df::test_df_compatible_no_size_arg
    test_df::test_df_compatible_si
    test_df::test_df_compatible_sync
    test_df::test_df_compatible_type
    test_df::test_df_conflicts_overriding
    test_df::test_df_output
    test_df::test_df_output_overridden
    test_df::test_df_shortened_long_argument
    test_df::test_exclude_all_types
    test_df::test_exclude_type_option
    test_df::test_ignore_block_size_from_env_in_posix_portability_mode
    test_df::test_invalid_block_size_from_env
    test_df::test_iuse_percentage
    test_df::test_order_same
    test_df::test_output_file_all_filesystems
    test_df::test_output_mp_repeat
    test_df::test_output_multiple_occurrences
    test_df::test_output_option
    test_df::test_output_selects_columns
    test_df::test_precedence_of_block_size_arg_over_env
    test_df::test_precedence_of_human_readable_header_over_output_header
    test_df::test_total
    test_df::test_type_option
    test_df::test_type_option_with_file
    test_df::test_use_percentage
    test_ls::test_ls_allocation_size

test result: FAILED. 2479 passed; 36 failed; 29 ignored; 0 measured; 0 filtered out; finished in 45.30s

error: test failed, to rerun pass `--test tests`

@samueltardieu
Copy link
Contributor

Compiling your PR branch, I get 7 failures:

failures:
    test_df::test_type_option_with_file
    test_head::test_read_backwards_bytes_proc_fs_modules
    test_head::test_read_backwards_bytes_proc_fs_version
    test_head::test_read_backwards_bytes_sys_kernel_profiling
   test_head::test_read_backwards_lines_proc_fs_modules
    test_ls::test_ls_allocation_size
    test_tail::test_follow_name_truncate4

test result: FAILED. 2500 passed; 7 failed; 30 ignored;

but I suspect they depend on the particular Android version for 4 of them at least.

@cre4ture
Copy link
Contributor Author

I'm failing to get a remote debugging running. Have you ever tried this? Do you have recommendations?

@samueltardieu
Copy link
Contributor

I'm failing to get a remote debugging running. Have you ever tried this? Do you have recommendations?

I haven't attempted it. Why not a local debugging with gdb? Isn't that working?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@cre4ture
Copy link
Contributor Author

@samueltardieu: I pushed some more changes to make all the tests green for me. Can you confirm?
@sylvestre: I think this pull request is at a state acceptable for merging. Can you do a review?
Additionally: We should add a android x64 into the CI/CD to avoid regressions.

@samueltardieu
Copy link
Contributor

@samueltardieu: I pushed some more changes to make all the tests green for me. Can you confirm?

All green for me too, congrats!

@sylvestre I think this pull request is at a state acceptable for merging. Can you do a review?

Note that there are too many commits (including merge commits), you should maybe squash them, then maybe split them so that you get a clean history.

Additionally: We should add a android x64 into the CI/CD to avoid regressions.

Agreed!

@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from f26b77b to ad88cf3 Compare January 15, 2024 14:42
@cre4ture
Copy link
Contributor Author

I did a cleanup of the commits. Hope its fine now. :-)

@samueltardieu
Copy link
Contributor

I did a cleanup of the commits. Hope its fine now. :-)

It is much more readable indeed! (well, but for the latest commit title which is too long for git…)

let inodes = self.inodes + rhs.inodes;
let inodes_used = self.inodes_used + rhs.inodes_used;
let inodes = self.inodes.saturating_add(rhs.inodes);
let inodes_used = self.inodes_used.saturating_add(rhs.inodes_used);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really have sometimes a number of inodes greater than u64::MAX?

If this is the case, is it ok to compute a wrong value by saturating the addition?

Copy link
Contributor Author

@cre4ture cre4ture Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this peace of code does an accumulation. As far as I understood the code, this accumulation is purely needed to compute an optional finalising row called "total" in the output. This "total" row shall display the sum of each column. Thus, also the inodes are accumulated.

On my phones system, there are apparently several filesystems that reports "inodes" as exactly u64::MAX. Summing that up always causes an int 64 overflow. But is it relevant? I guess not really as the number is anyway insanely high. If someone finds a usecase where this is relevant, we can still extend the integer type to u128.
Alternatively. one could automatically filter the filesystem with u64::MAX because the number might anyway not be valid.
EDIT: One addition could be that we don't print the value in the total row when it is at u64::MAX because the sum is invalid. That might be the easiest and also correct behavior as long as we don't extent to u128.
EDIT2: The feature to compute the "total" row is apparently not available in the df implementation on my phone (toybox 0.8.4-android)

Output of pre-installed (toybox, NOT GNU) of df on my phone:

~/rust/coreutils $ df -i
Filesystem                                           Inodes  IUsed                IFree IUse% Mounted on
/dev/block/dm-15                       18446744073709551615   3141 18446744073709548474    1% /
tmpfs                                               1457181   1464              1455717    1% /dev
tmpfs                                               1457181     65              1457116    1% /mnt
/dev/block/dm-16                       18446744073709551615   3002 18446744073709548613    1% /system_ext
/dev/block/dm-17                                        304    298                    6   99% /product
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/app
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/priv-app
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/lib64
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/lib
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/overlay
overlay                                18446744073709551615      0 18446744073709551615    0% /product/etc/permissions
overlay                                18446744073709551615      0 18446744073709551615    0% /product/framework
/dev/block/dm-18                       18446744073709551615      0 18446744073709551615    0% /vendor
/dev/block/dm-19                       18446744073709551615      0 18446744073709551615    0% /odm
/dev/block/dm-20                       18446744073709551615      0 18446744073709551615    0% /my_product
/dev/block/dm-21                       18446744073709551615      0 18446744073709551615    0% /my_engineering
/dev/block/dm-23                       18446744073709551615      0 18446744073709551615    0% /my_carrier
/dev/block/dm-24                       18446744073709551615      0 18446744073709551615    0% /my_region
/dev/block/dm-25                       18446744073709551615      0 18446744073709551615    0% /my_heytap
/dev/block/dm-26                       18446744073709551615      0 18446744073709551615    0% /my_stock
/dev/block/dm-27                       18446744073709551615      0 18446744073709551615    0% /my_preload
/dev/block/dm-28                       18446744073709551615      0 18446744073709551615    0% /my_bigball
/dev/block/dm-29                       18446744073709551615      0 18446744073709551615    0% /my_manifest
tmpfs                                               1457181     99              1457082    1% /apex
/dev/block/loop7                                         48     35                   13   73% /apex/com.android.i18n@1
/dev/block/loop8                                         32     29                    3   91% /apex/com.android.wifi@319999900
/dev/block/loop5                                         32     20                   12   63% /apex/com.android.apex.cts.shim@1
/dev/block/loop6                                         32     23                    9   72% /apex/com.android.appsearch@300000000
/dev/block/loop11                                       304    290                   14   96% /apex/com.android.vndk.v31@1
/dev/block/dm-30                                         32     25                    7   79% /apex/com.android.extservices@341131030
/dev/block/dm-32                                         32     28                    4   88% /apex/com.android.permission@341110010
/dev/block/loop15                                        64     50                   14   79% /apex/com.android.runtime@1
/dev/block/dm-33                                        176    167                    9   95% /apex/com.android.conscrypt@341110002
/dev/block/dm-31                                        112    112                    0  100% /apex/com.android.art@341110062
/dev/block/loop16                                       608    596                   12   99% /apex/com.android.vndk.v30@1
/dev/block/dm-34                                         32     20                   12   63% /apex/com.android.tzdata@313110000
/dev/block/dm-35                                         32     20                   12   63% /apex/com.android.scheduling@340819220
/dev/block/dm-36                                         32     31                    1   97% /apex/com.android.os.statsd@341114000
/dev/block/dm-37                                         64     58                    6   91% /apex/com.android.media@341111002
/dev/block/dm-38                                         32     27                    5   85% /apex/com.android.mediaprovider@341111020
/dev/block/dm-39                                         48     36                   12   75% /apex/com.android.adbd@340912202
/dev/block/dm-40                                        128    114                   14   90% /apex/com.android.media.swcodec@341111002
/dev/block/dm-42                                         32     21                   11   66% /apex/com.android.cellbroadcast@341110000
/dev/block/dm-41                                         16     16                    0  100% /apex/com.android.neuralnetworks@341010000
/dev/block/loop27                                        32     26                    6   82% /apex/com.google.mainline.primary.libs@331059000
/dev/block/dm-43                                         32     20                   12   63% /apex/com.android.ipsec@340914200
/dev/block/dm-44                                         80     66                   14   83% /apex/com.android.tethering@341112070
/dev/block/dm-45                                         80     75                    5   94% /apex/com.google.mainline.primary.libs@341177000
/dev/block/dm-46                                         16     16                    0  100% /apex/com.android.resolv@341110000
/dev/block/dm-47                                         32     24                    8   75% /apex/com.android.sdkext@341110000
/dev/block/bootdevice/by-name/cache                  114688     55               114633    1% /cache
/dev/block/bootdevice/by-name/userdata             12812797 348578             12464219    3% /data
/dev/fuse                                          12812797 348578             12464219    3% /storage/emulated
/data/media                                        12812797 348578             12464219    3% /storage/emulated/0/Android/data
~/rust/coreutils $ 

for completion the output of uutils:

~/rust/coreutils $ target/debug/coreutils df -i --total
Filesystem                                           Inodes  IUsed                IFree IUse% Mounted on
/dev/block/dm-15                       18446744073709551615   3141 18446744073709548474    1% /
tmpfs                                               1457181   1464              1455717    1% /dev
tmpfs                                               1457181     65              1457116    1% /mnt
/dev/block/by-name/metadata                            4096     31                 4065    1% /metadata
/dev/block/dm-16                       18446744073709551615   3002 18446744073709548613    1% /system_ext
/dev/block/dm-17                                        304    298                    6   99% /product
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/app
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/priv-app
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/lib64
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/lib
overlay-overlay                        18446744073709551615      0 18446744073709551615    0% /product/overlay
overlay                                18446744073709551615      0 18446744073709551615    0% /product/etc/permissions
overlay                                18446744073709551615      0 18446744073709551615    0% /product/framework
/dev/block/dm-18                       18446744073709551615      0 18446744073709551615    0% /vendor
/dev/block/dm-19                       18446744073709551615      0 18446744073709551615    0% /odm
/dev/block/dm-20                       18446744073709551615      0 18446744073709551615    0% /my_product
/dev/block/dm-21                       18446744073709551615      0 18446744073709551615    0% /my_engineering
/dev/block/dm-23                       18446744073709551615      0 18446744073709551615    0% /my_carrier
/dev/block/dm-24                       18446744073709551615      0 18446744073709551615    0% /my_region
/dev/block/dm-25                       18446744073709551615      0 18446744073709551615    0% /my_heytap
/dev/block/dm-26                       18446744073709551615      0 18446744073709551615    0% /my_stock
/dev/block/dm-27                       18446744073709551615      0 18446744073709551615    0% /my_preload
/dev/block/dm-28                       18446744073709551615      0 18446744073709551615    0% /my_bigball
/dev/block/dm-29                       18446744073709551615      0 18446744073709551615    0% /my_manifest
tmpfs                                               1457181     99              1457082    1% /apex
/dev/block/loop7                                         48     35                   13   73% /apex/com.android.i18n@1
/dev/block/loop7                                         48     35                   13   73% /apex/com.android.i18n
/dev/block/loop8                                         32     29                    3   91% /apex/com.android.wifi@319999900
/dev/block/loop5                                         32     20                   12   63% /apex/com.android.apex.cts.shim@1
/dev/block/loop8                                         32     29                    3   91% /apex/com.android.wifi
/dev/block/loop6                                         32     23                    9   72% /apex/com.android.appsearch@300000000
/dev/block/loop6                                         32     23                    9   72% /apex/com.android.appsearch
/dev/block/loop5                                         32     20                   12   63% /apex/com.android.apex.cts.shim
/dev/block/loop11                                       304    290                   14   96% /apex/com.android.vndk.v31@1
/dev/block/loop11                                       304    290                   14   96% /apex/com.android.vndk.v31
/dev/block/dm-30                                         32     25                    7   79% /apex/com.android.extservices@341131030
/dev/block/dm-30                                         32     25                    7   79% /apex/com.android.extservices
/dev/block/dm-32                                         32     28                    4   88% /apex/com.android.permission@341110010
/dev/block/dm-32                                         32     28                    4   88% /apex/com.android.permission
/dev/block/loop15                                        64     50                   14   79% /apex/com.android.runtime@1
/dev/block/loop15                                        64     50                   14   79% /apex/com.android.runtime
/dev/block/dm-33                                        176    167                    9   95% /apex/com.android.conscrypt@341110002
/dev/block/dm-31                                        112    112                    0  100% /apex/com.android.art@341110062
/dev/block/dm-33                                        176    167                    9   95% /apex/com.android.conscrypt
/dev/block/dm-31                                        112    112                    0  100% /apex/com.android.art
/dev/block/loop16                                       608    596                   12   99% /apex/com.android.vndk.v30@1
/dev/block/loop16                                       608    596                   12   99% /apex/com.android.vndk.v30
/dev/block/dm-34                                         32     20                   12   63% /apex/com.android.tzdata@313110000
/dev/block/dm-34                                         32     20                   12   63% /apex/com.android.tzdata
/dev/block/dm-35                                         32     20                   12   63% /apex/com.android.scheduling@340819220
/dev/block/dm-35                                         32     20                   12   63% /apex/com.android.scheduling
/dev/block/dm-36                                         32     31                    1   97% /apex/com.android.os.statsd@341114000
/dev/block/dm-36                                         32     31                    1   97% /apex/com.android.os.statsd
/dev/block/dm-37                                         64     58                    6   91% /apex/com.android.media@341111002
/dev/block/dm-37                                         64     58                    6   91% /apex/com.android.media
/dev/block/dm-38                                         32     27                    5   85% /apex/com.android.mediaprovider@341111020
/dev/block/dm-38                                         32     27                    5   85% /apex/com.android.mediaprovider
/dev/block/dm-39                                         48     36                   12   75% /apex/com.android.adbd@340912202
/dev/block/dm-39                                         48     36                   12   75% /apex/com.android.adbd
/dev/block/dm-40                                        128    114                   14   90% /apex/com.android.media.swcodec@341111002
/dev/block/dm-40                                        128    114                   14   90% /apex/com.android.media.swcodec
/dev/block/dm-42                                         32     21                   11   66% /apex/com.android.cellbroadcast@341110000
/dev/block/dm-41                                         16     16                    0  100% /apex/com.android.neuralnetworks@341010000
/dev/block/dm-41                                         16     16                    0  100% /apex/com.android.neuralnetworks
/dev/block/dm-42                                         32     21                   11   66% /apex/com.android.cellbroadcast
/dev/block/loop27                                        32     26                    6   82% /apex/com.google.mainline.primary.libs@331059000
/dev/block/dm-43                                         32     20                   12   63% /apex/com.android.ipsec@340914200
/dev/block/dm-43                                         32     20                   12   63% /apex/com.android.ipsec
/dev/block/dm-44                                         80     66                   14   83% /apex/com.android.tethering@341112070
/dev/block/dm-44                                         80     66                   14   83% /apex/com.android.tethering
/dev/block/dm-45                                         80     75                    5   94% /apex/com.google.mainline.primary.libs@341177000
/dev/block/dm-46                                         16     16                    0  100% /apex/com.android.resolv@341110000
/dev/block/dm-46                                         16     16                    0  100% /apex/com.android.resolv
/dev/block/dm-47                                         32     24                    8   75% /apex/com.android.sdkext@341110000
/dev/block/dm-47                                         32     24                    8   75% /apex/com.android.sdkext
/dev/block/bootdevice/by-name/cache                  114688     55               114633    1% /cache
/dev/block/bootdevice/by-name/userdata             12812797 348591             12464206    3% /data
/dev/fuse                                          12812797 348591             12464206    3% /storage/emulated
/data/media                                        12812797 348591             12464206    3% /storage/emulated/0/Android/data
/data/media                                        12812797 348591             12464206    3% /storage/emulated/0/Android/obb
total                                  18446744073709551615 1406308 18446744073709551615    1% -
~/rust/coreutils $ 

filesystem types:

~/rust/coreutils $ target/debug/coreutils df --output=source,fstype,target,itotal,iused,iavail,ipcent
Filesystem                             Type     Mounted on                                                     Inodes  IUsed                IFree IUse%
/dev/block/dm-15                       erofs    /                                                18446744073709551615   3141 18446744073709548474    1%
tmpfs                                  tmpfs    /dev                                                          1457181   1464              1455717    1%
tmpfs                                  tmpfs    /mnt                                                          1457181     65              1457116    1%
/dev/block/by-name/metadata            ext4     /metadata                                                        4096     31                 4065    1%
/dev/block/dm-16                       erofs    /system_ext                                      18446744073709551615   3002 18446744073709548613    1%
/dev/block/dm-17                       ext4     /product                                                          304    298                    6   99%
overlay-overlay                        overlay  /product/app                                     18446744073709551615      0 18446744073709551615    0%
overlay-overlay                        overlay  /product/priv-app                                18446744073709551615      0 18446744073709551615    0%
overlay-overlay                        overlay  /product/lib64                                   18446744073709551615      0 18446744073709551615    0%
overlay-overlay                        overlay  /product/lib                                     18446744073709551615      0 18446744073709551615    0%
overlay-overlay                        overlay  /product/overlay                                 18446744073709551615      0 18446744073709551615    0%
overlay                                overlay  /product/etc/permissions                         18446744073709551615      0 18446744073709551615    0%
overlay                                overlay  /product/framework                               18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-18                       erofs    /vendor                                          18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-19                       erofs    /odm                                             18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-20                       erofs    /my_product                                      18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-21                       erofs    /my_engineering                                  18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-23                       erofs    /my_carrier                                      18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-24                       erofs    /my_region                                       18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-25                       erofs    /my_heytap                                       18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-26                       erofs    /my_stock                                        18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-27                       erofs    /my_preload                                      18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-28                       erofs    /my_bigball                                      18446744073709551615      0 18446744073709551615    0%
/dev/block/dm-29                       erofs    /my_manifest                                     18446744073709551615      0 18446744073709551615    0%
tmpfs                                  tmpfs    /apex                                                         1457181     99              1457082    1%
/dev/block/loop7                       ext4     /apex/com.android.i18n@1                                           48     35                   13   73%
/dev/block/loop7                       ext4     /apex/com.android.i18n                                             48     35                   13   73%
/dev/block/loop8                       ext4     /apex/com.android.wifi@319999900                                   32     29                    3   91%
/dev/block/loop5                       ext4     /apex/com.android.apex.cts.shim@1                                  32     20                   12   63%
/dev/block/loop8                       ext4     /apex/com.android.wifi                                             32     29                    3   91%
/dev/block/loop6                       ext4     /apex/com.android.appsearch@300000000                              32     23                    9   72%
/dev/block/loop6                       ext4     /apex/com.android.appsearch                                        32     23                    9   72%
/dev/block/loop5                       ext4     /apex/com.android.apex.cts.shim                                    32     20                   12   63%
/dev/block/loop11                      ext4     /apex/com.android.vndk.v31@1                                      304    290                   14   96%
/dev/block/loop11                      ext4     /apex/com.android.vndk.v31                                        304    290                   14   96%
/dev/block/dm-30                       ext4     /apex/com.android.extservices@341131030                            32     25                    7   79%
/dev/block/dm-30                       ext4     /apex/com.android.extservices                                      32     25                    7   79%
/dev/block/dm-32                       ext4     /apex/com.android.permission@341110010                             32     28                    4   88%
/dev/block/dm-32                       ext4     /apex/com.android.permission                                       32     28                    4   88%
/dev/block/loop15                      ext4     /apex/com.android.runtime@1                                        64     50                   14   79%
/dev/block/loop15                      ext4     /apex/com.android.runtime                                          64     50                   14   79%
/dev/block/dm-33                       ext4     /apex/com.android.conscrypt@341110002                             176    167                    9   95%
/dev/block/dm-31                       ext4     /apex/com.android.art@341110062                                   112    112                    0  100%
/dev/block/dm-33                       ext4     /apex/com.android.conscrypt                                       176    167                    9   95%
/dev/block/dm-31                       ext4     /apex/com.android.art                                             112    112                    0  100%
/dev/block/loop16                      ext4     /apex/com.android.vndk.v30@1                                      608    596                   12   99%
/dev/block/loop16                      ext4     /apex/com.android.vndk.v30                                        608    596                   12   99%
/dev/block/dm-34                       ext4     /apex/com.android.tzdata@313110000                                 32     20                   12   63%
/dev/block/dm-34                       ext4     /apex/com.android.tzdata                                           32     20                   12   63%
/dev/block/dm-35                       ext4     /apex/com.android.scheduling@340819220                             32     20                   12   63%
/dev/block/dm-35                       ext4     /apex/com.android.scheduling                                       32     20                   12   63%
/dev/block/dm-36                       ext4     /apex/com.android.os.statsd@341114000                              32     31                    1   97%
/dev/block/dm-36                       ext4     /apex/com.android.os.statsd                                        32     31                    1   97%
/dev/block/dm-37                       ext4     /apex/com.android.media@341111002                                  64     58                    6   91%
/dev/block/dm-37                       ext4     /apex/com.android.media                                            64     58                    6   91%
/dev/block/dm-38                       ext4     /apex/com.android.mediaprovider@341111020                          32     27                    5   85%
/dev/block/dm-38                       ext4     /apex/com.android.mediaprovider                                    32     27                    5   85%
/dev/block/dm-39                       ext4     /apex/com.android.adbd@340912202                                   48     36                   12   75%
/dev/block/dm-39                       ext4     /apex/com.android.adbd                                             48     36                   12   75%
/dev/block/dm-40                       ext4     /apex/com.android.media.swcodec@341111002                         128    114                   14   90%
/dev/block/dm-40                       ext4     /apex/com.android.media.swcodec                                   128    114                   14   90%
/dev/block/dm-42                       ext4     /apex/com.android.cellbroadcast@341110000                          32     21                   11   66%
/dev/block/dm-41                       ext4     /apex/com.android.neuralnetworks@341010000                         16     16                    0  100%
/dev/block/dm-41                       ext4     /apex/com.android.neuralnetworks                                   16     16                    0  100%
/dev/block/dm-42                       ext4     /apex/com.android.cellbroadcast                                    32     21                   11   66%
/dev/block/loop27                      ext4     /apex/com.google.mainline.primary.libs@331059000                   32     26                    6   82%
/dev/block/dm-43                       ext4     /apex/com.android.ipsec@340914200                                  32     20                   12   63%
/dev/block/dm-43                       ext4     /apex/com.android.ipsec                                            32     20                   12   63%
/dev/block/dm-44                       ext4     /apex/com.android.tethering@341112070                              80     66                   14   83%
/dev/block/dm-44                       ext4     /apex/com.android.tethering                                        80     66                   14   83%
/dev/block/dm-45                       ext4     /apex/com.google.mainline.primary.libs@341177000                   80     75                    5   94%
/dev/block/dm-46                       ext4     /apex/com.android.resolv@341110000                                 16     16                    0  100%
/dev/block/dm-46                       ext4     /apex/com.android.resolv                                           16     16                    0  100%
/dev/block/dm-47                       ext4     /apex/com.android.sdkext@341110000                                 32     24                    8   75%
/dev/block/dm-47                       ext4     /apex/com.android.sdkext                                           32     24                    8   75%
/dev/block/bootdevice/by-name/cache    ext4     /cache                                                         114688     55               114633    1%
/dev/block/bootdevice/by-name/userdata f2fs     /data                                                        12812797 348595             12464202    3%
/dev/fuse                              fuse     /storage/emulated                                            12812797 348595             12464202    3%
/data/media                            sdcardfs /storage/emulated/0/Android/data                             12812797 348595             12464202    3%
/data/media                            sdcardfs /storage/emulated/0/Android/obb                              12812797 348595             12464202    3%
~/rust/coreutils $ 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awfully similar to a -1 cast to uint64_t

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you retry with --total as well? That would be interesting to see how GNU coreutils perform.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some editing to give more detail. So please read again. The df-variant that runs on my phone is "toybox" and not GNU. It doesn't support the "--total" argument.

Copy link
Contributor Author

@cre4ture cre4ture Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a small image for erofs on my ubuntu PC. Then you can see the GNU output:

uli@hp13-ulix:~$ df --total --output='source','fstype','itotal','iused','iavail','ipcent','size','used','avail','pcent','file','target'
Filesystem     Type       Inodes   IUsed                IFree IUse% 1K-blocks      Used     Avail Use% File Mounted on
tmpfs          tmpfs     2016003    1405              2014598    1%   1612804      2280   1610524   1% -    /run
/dev/nvme0n1p6 ext4      6111232  621990              5489242   11%  95535524  33714300  56922052  38% -    /
tmpfs          tmpfs     2016003      71              2015932    1%   8064012     19696   8044316   1% -    /dev/shm
tmpfs          tmpfs     2016003       4              2015999    1%      5120         4      5116   1% -    /run/lock
efivarfs       efivarfs        0       0                    0     -       192       127        61  68% -    /sys/firmware/efi/efivars
/dev/nvme0n1p7 ext4      9895936  740739              9155197    8% 154706320 122316404  24458476  84% -    /home
/dev/nvme0n1p1 vfat            0       0                    0     -    262144     89720    172424  35% -    /boot/efi
tmpfs          tmpfs      403200     202               402998    1%   1612800       168   1612632   1% -    /run/user/1000
/dev/nvme0n1p5 ntfs3           0       0                    0     - 512032764 370522632 141510132  73% -    /media/uli/WData
/dev/loop27    erofs           -       - 18446744073709551613     -         4         4         0 100% -    /media/uli/486ad2a2-6303-4504-87ff-5176e55b2239
total          -        22458377 1364414             21093963    7% 773831684 526665335 234335733  70% -    -
uli@hp13-ulix:~$ 

its placing some dashes "-" and EDIT: its having a silent integer-overlfow for the IFree. I checked it, the real sum without "erofs" would be "21093966" and not "21093963" ... thats 3 off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way, the inodes for erofs are not really relevant in general as it is a read only filesystem

Copy link
Contributor Author

@cre4ture cre4ture Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My test on Ubuntu prooves that the issue with the integeroverflow is actually also visible on non-android systems if they use erofs. So we could actually split this change into an own pull-request.

li@hp13-ulix:~$ dev_rust/coreutils/target/debug/coreutils df --total --output='source','fstype','itotal','iused','iavail','ipcent','size','used','avail','pcent','file','target'
thread 'main' panicked at src/uu/df/src/table.rs:105:22:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
uli@hp13-ulix:~$ 

@@ -656,28 +656,29 @@ impl FsMeta for StatFs {
not(target_arch = "s390x"),
target_pointer_width = "64"
))]
return self.f_bsize;
return self.f_bsize; // i64 -> i64 - OK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure those comments are needed, the Rust compiler is here to tell us if this is ok or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it there to help the reviewer/developer that reads this code to understand what happens. There are a lot of #[cfg(..)] around there and its not directly visible what the main point in the three cases is. But I'll remove it if you insist on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just expressing a preference, I'll let the coreutils maintainers weight on this.

@cre4ture cre4ture changed the title android x64 uses u64 as f_bsize and f_type android 64-bit compatibility adaptions Jan 15, 2024
@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from ad88cf3 to 7eb164e Compare January 22, 2024 20:06
@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from 0958c24 to 1b37a8c Compare February 4, 2024 16:12
@cre4ture
Copy link
Contributor Author

android x64 build is green on main branch - thus I think the remaining fixes in this branch where purely for my device and its not needed in general. I guess we can close it.

@samueltardieu : do you think there is something in this PR we still need?

@samueltardieu
Copy link
Contributor

On my device, two tests fail on main:

failures:
    test_df::test_type_option_with_file
    test_ls::test_ls_allocation_size

test result: FAILED. 2573 passed; 2 failed; 27 ignored; 0 measured; 0 filtered out; finished in 21.55s

while with your PR merged they pass. So I think there is something useful left in this PR.

@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from 1b37a8c to 748e5b5 Compare February 25, 2024 21:06
@cre4ture
Copy link
Contributor Author

ok, thank you for this positive feedback.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@cre4ture cre4ture force-pushed the fix/androidx64_fsext branch from 748e5b5 to c86084f Compare March 8, 2024 22:11
src/uucore/src/lib/features/fsext.rs Outdated Show resolved Hide resolved
src/uucore/src/lib/features/fsext.rs Outdated Show resolved Hide resolved
src/uucore/src/lib/features/fsext.rs Outdated Show resolved Hide resolved
@cre4ture
Copy link
Contributor Author

On my device, two tests fail on main:

failures:
    test_df::test_type_option_with_file
    test_ls::test_ls_allocation_size

test result: FAILED. 2573 passed; 2 failed; 27 ignored; 0 measured; 0 filtered out; finished in 21.55s

while with your PR merged they pass. So I think there is something useful left in this PR.

after a closer look into the issue with test_df::test_type_option_with_file and doing GNU comparison, I concluded that my fix on this PR is actually not a fix but it hides the real problem. I therefor created a new issue ticket for this: #6073

@cre4ture
Copy link
Contributor Author

also the issue with test_ls::test_ls_allocation_size has now its own issue: #6075
therefor this PR here is not needed anymore. Closed.

@cre4ture cre4ture closed this Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants