Background:
On CentOS 7 x86_64. I am using applydeltarpm
, and was running out of disk space when creating the new RPM from the delta. I watched the /
disk space usage increase during the apply process to 100%, but could not find the working/temp file on the volume using either ls -l /tmp
or find /tmp -mmin -1 -type f
.
I changed the applydeltarpm
source code to use /var/tmp
instead of /tmp
, and rebuilt the RPM. Now apply works with the modified applydeltarpm
, because /var/tmp
has a lot more disk space. But I still cannot find the temp file created with mkstemp64
.
Question:
The temp file created by mkstemp64
appears to be "non-existent", but still exists as a file descriptor to the creator, and is using considerable disk space when applydeltarpm
creates a large RPM (1 hour to apply on a slow disk). The mkstemp64
documentation says an actual file is created. And the source code shows the template file name is /tmp/deltarpmpageXXXXXX
. But a file with that template name does not exist.
How is this temporary file able to be created on the system without being findable with the usual directory listing ls
, or find
. And how can I find these kinds of "non-existent" files in the system?
(I am curious, because I also am monitoring system security)
References:
https://github.com/rpm-software-management/deltarpm/blob/master/applydeltarpm.c
# line 198
if (pagefd < 0)
{
char tmpname[80];
sprintf(tmpname, "/tmp/deltarpmpageXXXXXX");
#ifdef DELTARPM_64BIT
pagefd = mkstemp64(tmpname);
#else
pagefd = mkstemp(tmpname);
#endif
if (pagefd < 0)
{
fprintf(stderr, "could not create page area\n");
exit(1);
}
unlink(tmpname);
}
https://www.mkssoftware.com/docs/man3/mkstemp.3.asp
The mktemp() function returns a unique file name based on the template parameter. At the time it is generated, no file in the current directory has that name. No file is actually created, so it is possible that another application could create a file with this name.
The mkstemp() function is similar to mktemp() in that it create a unique file name based on template; however, mkstemp() actually creates the file and returns its file descriptor. The name of the created file is stored in template.
The mkstemp64() function is identical to the mkstemp() function except that the file is opened with the O_LARGEFILE flag set.