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)
commit4f4a7e9532e55a16336b79b74b5fb0236e365279
tree1a9d7ab384520f87873c886f448f6aeb05656d58
parentc971724874fce3d9f28e23074405c03eb1303364
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>
net/cgi-io/Makefile
net/cgi-io/src/main.c