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

fs::copy() does not handle sparse files #58635

Closed
haraldh opened this issue Feb 22, 2019 · 5 comments
Closed

fs::copy() does not handle sparse files #58635

haraldh opened this issue Feb 22, 2019 · 5 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@haraldh
Copy link
Contributor

haraldh commented Feb 22, 2019

A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.

Not handling sparse files could fill up the users disk very quickly.

In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.

In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
/dev/stdout or for root setting permissions on /dev/null.

See also
#26933
#37885

@haraldh
Copy link
Contributor Author

haraldh commented Feb 22, 2019

see #58636 for the fix

haraldh added a commit to haraldh/rust-1 that referenced this issue Feb 22, 2019
A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.

In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.

In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
`/dev/stdout` or for root setting permissions on `/dev/null`.

Not handling sparse files could fill up the users disk very quickly.

Fixes:
rust-lang#26933
rust-lang#37885
rust-lang#58635
@Centril Centril added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 22, 2019
@Mark-Simulacrum
Copy link
Member

I believe we've decided that sparse files are not something we want to handle; the file mode and special device issue we've fixed. Closing.

@avirtuos
Copy link

avirtuos commented Mar 3, 2022

@Mark-Simulacrum I realize this is an old issue but can you share some insights into why it was decided that sparse files are not something you want to handle? There are a few growing rust projects related to VMMs like ( https://github.com/firecracker-microvm/firecracker ) that are built largely with rust and frequently trip over this limitation.

@Mark-Simulacrum
Copy link
Member

Likely largely based on discussion in #55909 and #58636, though it's been some time since then. Feel free to drop by #t-libs on Zulip and ask for folks opinions now.

(It may also be that the necessary work to make this happen is easier now, if the kernel APIs have simplified somewhat).

@avirtuos
Copy link

avirtuos commented Mar 4, 2022

@Mark-Simulacrum thanks, will follow up as you suggest after reading those items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants