rpm - Linux - How does mkstemp64 create a hidden file, and how can I see it in the file system -


background:

on centos 7 x86_64. using applydeltarpm, , running out of disk space when creating new rpm delta. watched / disk space usage increase during apply process 100%, not find working/temp file on volume using either ls -l /tmp or find /tmp -mmin -1 -type f.

i changed applydeltarpm source code use /var/tmp instead of /tmp, , rebuilt rpm. apply works modified applydeltarpm, because /var/tmp has lot more disk space. still cannot find temp file created mkstemp64.

question:

the temp file created mkstemp64 appears "non-existent", still exists file descriptor creator, , using considerable disk space when applydeltarpm creates large rpm (1 hour apply on slow disk). mkstemp64 documentation says actual file created. , source code shows template file name /tmp/deltarpmpagexxxxxx. file template name not exist.

how temporary file able created on system without being findable usual directory listing ls, or find. , how can find these kinds of "non-existent" files in system?

(i curious, because 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 unique file name based on template parameter. @ time generated, no file in current directory has name. no file created, possible application create file name.

the mkstemp() function similar mktemp() in create unique file name based on template; however, mkstemp() creates file , returns file descriptor. name of created file stored in template.

the mkstemp64() function identical mkstemp() function except file opened o_largefile flag set.

it common practice unlink temporary file right after creation, if it's not needed accessed through filesystem anymore. avoids dangling temporary files if process crashes or forgets unlink later.

unlink() not delete file, removes link file filesystem. every link file in filesystem increases link count of file 1 (there can several links same file). every process, calls open() or mmap() open file, increases file count, until closes descriptor - link count decreased. file exists long there @ least 1 link it. when link count reaches zero, file deleted.

mkstemp() calls open() behind scenes open temporary file , return descriptor.

in order see files opened, not exist in filesystem anymore, can use lsof , search lines, there "(deleted)" after file name.

lsof | grep '(deleted)' 

the (disk)space used these files freed, when processes attached finished or close file descriptor themselves.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -