MCPcopy Index your code
hub / github.com/RsyncProject/rsync / do_mkstemp

Function do_mkstemp

syscall.c:1079–1107  ·  view source on GitHub ↗

like mkstemp but forces permissions */

Source from the content-addressed store, hash-verified

1077
1078/* like mkstemp but forces permissions */
1079int do_mkstemp(char *template, mode_t perms)
1080{
1081 RETURN_ERROR_IF(dry_run, 0);
1082 RETURN_ERROR_IF(read_only, EROFS);
1083 perms |= S_IWUSR;
1084
1085#if defined HAVE_SECURE_MKSTEMP && defined HAVE_FCHMOD && (!defined HAVE_OPEN64 || defined HAVE_MKSTEMP64)
1086 {
1087 int fd = mkstemp(template);
1088 if (fd == -1)
1089 return -1;
1090 if (fchmod(fd, perms) != 0 && preserve_perms) {
1091 int errno_save = errno;
1092 close(fd);
1093 unlink(template);
1094 errno = errno_save;
1095 return -1;
1096 }
1097#if defined HAVE_SETMODE && O_BINARY
1098 setmode(fd, O_BINARY);
1099#endif
1100 return fd;
1101 }
1102#else
1103 if (!mktemp(template))
1104 return -1;
1105 return do_open(template, O_RDWR|O_EXCL|O_CREAT, perms);
1106#endif
1107}
1108
1109int do_stat(const char *path, STRUCT_STAT *st)
1110{

Callers 3

secure_mkstempFunction · 0.85
start_delete_delay_tempFunction · 0.85
open_tmpfileFunction · 0.85

Calls 1

do_openFunction · 0.85

Tested by

no test coverage detected