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

cmds/core/df: skip mount point on permission error #2813

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

binjip978
Copy link
Contributor

No description provided.

Signed-off-by: Siarhiej Siemianczuk <pdp.eleven11@gmail.com>
@binjip978
Copy link
Contributor Author

current version fails on fedora, but runs fine under root
2023/11/26 21:25:48 mountinfo()=_,"permission denied", want: _,nil

maybe error message can be improved as well...

Copy link

codecov bot commented Nov 26, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (9f32fba) 75.16% compared to head (5c5c1d1) 75.32%.

Files Patch % Lines
cmds/core/df/df.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2813      +/-   ##
==========================================
+ Coverage   75.16%   75.32%   +0.15%     
==========================================
  Files         432      432              
  Lines       42965    42967       +2     
==========================================
+ Hits        32295    32364      +69     
+ Misses      10670    10603      -67     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@binjip978 binjip978 added the Awaiting reviewer Waiting for a reviewer. label Nov 26, 2023
Copy link
Member

@rminnich rminnich left a comment

Choose a reason for hiding this comment

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

this could confuse people, however: running df on one directory and have it do nothing at all? e.g.
% df /abc
%

People are going to think it's doing nothing or broken. Does it really do this on the standard df, just have a silent failure?

It may need two return params, maybe, if this is the case. What is fedora doing? Can you trace it to a kernel difference?

@binjip978
Copy link
Contributor Author

this could confuse people, however: running df on one directory and have it do nothing at all? e.g. % df /abc %

People are going to think it's doing nothing or broken. Does it really do this on the standard df, just have a silent failure?

It may need two return params, maybe, if this is the case. What is fedora doing? Can you trace it to a kernel difference?

I found this issue because tests for df command on fedora is falling now. We can write and error log to stderr, but I found that df just ignores such error and move on.

Fedora df is doing this, when I execute df with no parameters.

statfs("/proc/sys/fs/binfmt_misc", {f_type=BINFMTFS_MAGIC, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={val=[0, 0]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOSUID|ST_NODEV|ST_NOEXEC|ST_RELATIME}) = 0
statfs("/sys/kernel/debug/tracing", 0x7ffea36266e0) = -1 EACCES (Permission denied)
statfs("/sys/fs/cgroup/net_cls", {f_type=CGROUP_SUPER_MAGIC, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={val=[0, 0]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_RELATIME}) = 0
statfs("/run/user/1000", {f_type=TMPFS_MAGIC, f_bsize=4096, f_blocks=608794, f_bfree=608751, f_bavail=608751, f_files=608794, f_ffree=608631, f_fsid={val=[0x52c35c6f, 0xb1cd1f7b]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOSUID|ST_NODEV|ST_RELATIME}) = 0
statfs("/run/user/1000/gvfs", {f_type=FUSE_SUPER_MAGIC, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={val=[0, 0]}, f_namelen=1024, f_frsize=4096, f_flags=ST_VALID|ST_NOSUID|ST_NODEV|ST_RELATIME}) = 0
newfstatat(1, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}, AT_EMPTY_PATH) = 0
write(1, "Filesystem     1K-blocks     Use"..., 60) = 60
write(1, "/dev/dm-0      498426880 1559012"..., 51) = 51
write(1, "devtmpfs            4096        "..., 54) = 54
write(1, "tmpfs           12175880        "..., 58) = 58
write(1, "efivarfs             154       7"..., 75) = 75
write(1, "tmpfs            4870352     212"..., 54) = 54
write(1, "/dev/dm-0      498426880 1559012"..., 55) = 55
write(1, "/dev/nvme0n1p2    996780   31486"..., 55) = 55
write(1, "tmpfs           12175880       1"..., 54) = 54
write(1, "/dev/nvme0n1p1    613184    1778"..., 59) = 59
write(1, "tmpfs            2435176      17"..., 64) = 64
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?

And current u-root df version is doing this:

statfs("/sys/kernel/debug/tracing", 0xc000124b08) = -1 EACCES (Permission denied)
openat(AT_FDCWD, "/etc/localtime", O_RDONLY) = 3
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\22\0\0\0\22\0\0\0\0"..., 4096) = 2162
read(3, "", 4096)                       = 0
close(3)                                = 0
write(2, "2023/11/27 07:06:16 mountinfo()="..., 672023/11/27 07:06:16 mountinfo()=_,"permission denied", want: _,nil
) = 67
exit_group(1)                           = ?

@rminnich rminnich added Awaiting author Waiting for new changes or feedback for author. and removed Awaiting reviewer Waiting for a reviewer. labels Nov 30, 2023
@binjip978 binjip978 merged commit 722eeaf into u-root:main Dec 1, 2023
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting author Waiting for new changes or feedback for author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants