cgi-io: use O_TMPFILE for uploads and attempt to directly link target file
authorJo-Philipp Wich <jo@mein.io>
Fri, 21 Feb 2020 23:13:32 +0000 (00:13 +0100)
committerJohn Crispin <john@phrozen.org>
Sat, 22 Feb 2020 17:17:33 +0000 (18:17 +0100)
commitc2ac5819779a9b3b2dd0be3105f0d10d9878011e
tree7f9f43fca058c07bb717dff4e07a735d138b8bac
parent3d5aa1436185913c2611deb5b2b51b65744f1e0f
cgi-io: use O_TMPFILE for uploads and attempt to directly link target file

Create an anonymous inode in /tmp using O_TMPFILE and attempt to link the
file in place using linkat(). Only fall back to the old file copy when
linking the tempfile fails.

Avoids double memory use if both the temporary upload file and the
destination file are located in /tmp.

Ref: https://github.com/openwrt/luci/issues/3654
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Makefile
src/main.c