MCPcopy Create free account
hub / github.com/git/git / create_tempfile_mode

Function create_tempfile_mode

tempfile.c:137–162  ·  view source on GitHub ↗

Make sure errno contains a meaningful value on error */

Source from the content-addressed store, hash-verified

135
136/* Make sure errno contains a meaningful value on error */
137struct tempfile *create_tempfile_mode(const char *path, int mode)
138{
139 struct tempfile *tempfile = new_tempfile();
140
141 strbuf_add_absolute_path(&tempfile->filename, path);
142 tempfile->fd = open(tempfile->filename.buf,
143 O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, mode);
144 if (O_CLOEXEC && tempfile->fd < 0 && errno == EINVAL)
145 /* Try again w/o O_CLOEXEC: the kernel might not support it */
146 tempfile->fd = open(tempfile->filename.buf,
147 O_RDWR | O_CREAT | O_EXCL, mode);
148 if (tempfile->fd < 0) {
149 deactivate_tempfile(tempfile);
150 return NULL;
151 }
152 activate_tempfile(tempfile);
153 if (adjust_shared_perm(the_repository, tempfile->filename.buf)) {
154 int save_errno = errno;
155 error("cannot fix permission bits on %s", tempfile->filename.buf);
156 delete_tempfile(&tempfile);
157 errno = save_errno;
158 return NULL;
159 }
160
161 return tempfile;
162}
163
164struct tempfile *register_tempfile(const char *path)
165{

Callers 2

lock_fileFunction · 0.85
create_tempfileFunction · 0.85

Calls 7

new_tempfileFunction · 0.85
strbuf_add_absolute_pathFunction · 0.85
deactivate_tempfileFunction · 0.85
activate_tempfileFunction · 0.85
adjust_shared_permFunction · 0.85
errorFunction · 0.85
delete_tempfileFunction · 0.85

Tested by

no test coverage detected