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

Allow /tmp and /var to be on different partitions - invalid cross-device link #20

Closed
YBonline opened this issue Jul 28, 2023 · 7 comments
Assignees

Comments

@YBonline
Copy link

My system is setup with /var on its own partition, along with /tmp being a tmpfs

Whenever trying to use uhppoted-httpd when it tries to write to the files, it always gives a rename : invalid cross-device link error

My understand is you need to use move instead of rename to account for them being separate partitions.

@uhppoted
Copy link
Owner

Huh! In theory Go Rename is supposed to do a move:

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. Even within the same directory, on non-Unix platforms Rename is not an atomic operation.

I wonder if they tested it on a tmpfs .. ok, let me look into it.

@YBonline
Copy link
Author

https://stackoverflow.com/questions/42392600/oserror-errno-18-invalid-cross-device-link

os.rename only works if source and destination are on the same file system. You should use shutil.move instead.

At least according to my googling

@uhppoted
Copy link
Owner

Seems to be an open issue in Go: #41487 os: if rename system call fails, try ioctl(FICLONE).

Hmm, I use os.Rename everywhere ... ok, am going to have to figure out a nice way to do it.

@twystd twystd moved this to In Progress in dev-cycle v0.8.6 Jul 31, 2023
@twystd twystd self-assigned this Jul 31, 2023
twystd pushed a commit to uhppoted/uhppoted-lib that referenced this issue Jul 31, 2023
@uhppoted
Copy link
Owner

Hi,

Well, that was minor can of worms :-) .. however, FWIW, there's a provisional fix for this issue in the main branch which:

  1. First attempts to do a rename
  2. If the rename fails then attempts to do a file copy and delete

The actual change turned out to be fairly small and relatively low impact - I've tested it briefly and it behaves as expected.

If you would like to try it out you'll have to clone the repo and build it locally. Which is reasonably straightforward - the instructions are in the README (Building from source) but if it's problem let me know and I can put up a nightly build on github.

Note: the current implementation can potentially leave a temporary file in place if the machine crashes while copying the file. Hopefully this should be rare enough not to be an immediate problem while I work on cleaning up temporary files on startup.

twystd pushed a commit that referenced this issue Aug 1, 2023
@uhppoted
Copy link
Owner

uhppoted commented Aug 1, 2023

Ok, uhppoted-httpd should be good to go.

NTS: also update:

  • uhppoted-app-db
  • uhppoted-app-sheets
  • uhppoted-app-wild-apricot
  • uhppoted-codegen
  • uhppoted-lib:eventlog
  • uhppoted-lib:listen
  • uhppoted-lib:kvs

@uhppoted
Copy link
Owner

uhppoted commented Aug 1, 2023

And that's a wrap .. will leave this open for a couple of days in case something weird turns up.

@uhppoted uhppoted moved this from In Progress to Done in dev-cycle v0.8.6 Aug 1, 2023
@uhppoted
Copy link
Owner

uhppoted commented Aug 9, 2023

Closing this - seems to be ok so far. Feel free to reopen if you run into anything.

@uhppoted uhppoted closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants