You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this issue testing my Python implementation - your C++ implementation shows the same problem:
You implement truncate by calling the truncate system call. As you might have noticed, there is no truncateat system call which would be required for truncating something with a path relative to a file descriptor. So your implementation assumes that its current working directory is never changed throughout its lifetime.
I have spend a while researching it ( 1, 2 ) and it appears that the best solution is to just divert from the truncate system call to an openat-ftruncate-close-sequence. I have successfully tested this with my Python implementation.
EDIT: Actually, this issue applies to most system calls that you use which take a path as an argument. You are always relying on the current working directory. You should use the savefd file descriptor throughout your code and specify paths relative to it.
The text was updated successfully, but these errors were encountered:
I ran into this issue testing my Python implementation - your C++ implementation shows the same problem:
You implement truncate by calling the
truncate
system call. As you might have noticed, there is notruncateat
system call which would be required for truncating something with a path relative to a file descriptor. So your implementation assumes that its current working directory is never changed throughout its lifetime.I have spend a while researching it ( 1, 2 ) and it appears that the best solution is to just divert from the
truncate
system call to anopenat
-ftruncate
-close
-sequence. I have successfully tested this with my Python implementation.EDIT: Actually, this issue applies to most system calls that you use which take a path as an argument. You are always relying on the current working directory. You should use the
savefd
file descriptor throughout your code and specify paths relative to it.The text was updated successfully, but these errors were encountered: