Skip to content

Conversation

@DvdGiessen
Copy link
Contributor

On my system the temporary directory is a tmpfs mount:

$ mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=31678096k,nr_inodes=1048576,inode64)

This breaks changeprefix.py because os.rename cannot move files across filesystem boundaries:

$ ./scripts/changeprefix.py --git lfs lfs2
Traceback (most recent call last):
  File "./scripts/changeprefix.py", line 76, in changefile
    os.rename(to_path, from_path)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmp51imc7k8' -> '.gitattributes'

A simple fix is to use shutil.move which does handle this correctly.

This prevents a "OSError: [Errno 18] Invalid cross-device link" if the temporary
file was created on different filesystem (such as a tmpfs mount).
@geky-bot
Copy link
Collaborator

Tests passed ✓, Code: 17116 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
Code Stack Structs Coverage
Default 17116 B (+0.0%) 1448 B (+0.0%) 812 B (+0.0%) Lines 2432/2594 lines (+0.0%)
Readonly 6230 B (+0.0%) 448 B (+0.0%) 812 B (+0.0%) Branches 1279/1610 branches (-0.0%)
Threadsafe 17968 B (+0.0%) 1448 B (+0.0%) 820 B (+0.0%) Benchmarks
Multiversion 17188 B (+0.0%) 1448 B (+0.0%) 816 B (+0.0%) Readed 29369693876 B (+0.0%)
Migrate 18780 B (+0.0%) 1752 B (+0.0%) 816 B (+0.0%) Proged 1482874766 B (+0.0%)
Error-asserts 17896 B (+0.0%) 1440 B (+0.0%) 812 B (+0.0%) Erased 1568888832 B (+0.0%)

@geky
Copy link
Member

geky commented May 13, 2025

Oh interesting. I have the same setup on my machine, so I guess I haven't ran changeprefix.py locally in... years... I usually just checkout the v2-prefix branch.

Thanks for the PR! I'm going to sneak this into the in-flight release.

@geky geky added this to the v2.11 milestone May 13, 2025
@geky geky changed the base branch from master to devel May 13, 2025 18:17
@geky geky merged commit 523319b into littlefs-project:devel May 13, 2025
94 checks passed
@geky geky mentioned this pull request May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants