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
Supposing a directory /tmp/ at sda1 was set to the "uploads dir" and the function sg_httpupld_save_as() tries to save a uploaded file in any directory at sda2, it raises "Invalid cross-device link", because it uses rename() internally, that returns an EXDEV if the oldpath and newpath are not on the same mounted file system (see rename(3) at man pages).
It is very common to see ARM-based OSes mounted in SD cards but saving files to external hard disks, thus, we should consider a low-level file-copy in Sagui, avoiding possible slow file-copy functions provided by the application.
cheers
Edit 1: (Linux only)
On Linux, kernel-level functions like copy_file_range() and sendfile() must be considered. Those system calls performs an in-kernel copy between two file descriptors. Because this copying is done within the kernel, is more efficient than the combination of read() and write(), which would require transferring data to and from user space.
Two quotes:
copy_file_range():
The copy_file_range() system call first appeared in Linux 4.5, but glibc 2.27 provides a user-space emulation when it is not available.
sendfile():
The original Linux sendfile() system call was not designed to handle large file offsets. Consequently, Linux 2.4 added sendfile64(), with a wider type for the offset argument. The glibc sendfile() wrapper function transparently deals with the kernel differences.
Applications may wish to fall back to read()/write() in the case where sendfile() fails with EINVAL or ENOSYS.
The text was updated successfully, but these errors were encountered:
Hello.
Supposing a directory
/tmp/
atsda1
was set to the "uploads dir" and the functionsg_httpupld_save_as()
tries to save a uploaded file in any directory atsda2
, it raises "Invalid cross-device link
", because it usesrename()
internally, that returns anEXDEV
if theoldpath
andnewpath
are not on the same mounted file system (see rename(3) at man pages).It is very common to see ARM-based OSes mounted in SD cards but saving files to external hard disks, thus, we should consider a low-level file-copy in Sagui, avoiding possible slow file-copy functions provided by the application.
cheers
Edit 1: (Linux only)
On Linux, kernel-level functions like
copy_file_range()
andsendfile()
must be considered. Those system calls performs an in-kernel copy between two file descriptors. Because this copying is done within the kernel, is more efficient than the combination ofread()
andwrite()
, which would require transferring data to and from user space.Two quotes:
copy_file_range()
:sendfile()
:The text was updated successfully, but these errors were encountered: