commit - 14551591612b0ec1b9956851d2e3bb672761636b
commit + be7ce7ce020aa928cb681a0c23ac4ae7a350a42b
blob - 9a191a4cb86e69de67b69d6be99e91a1d7e5b3a7
blob + cdb690ec9b82d32922882b16c1619ac604e5b8d5
--- gotd/session_write.c
+++ gotd/session_write.c
static const struct got_error *
request_gotsys_conf(struct gotd_imsgev *iev)
{
+ const struct got_error *err = NULL;
struct gotd_imsg_packfile_get_content content_req;
const char *refname = "refs/heads/main";
const char *path = "gotsys.conf";
size_t len;
int fd = -1;
- if (ftruncate(gotd_session.content_fd, 0L) == -1)
- return got_error_from_errno("ftruncate");
- if (lseek(gotd_session.content_fd, 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(gotd_session.content_fd);
+ if (err)
+ return err;
len = sizeof(content_req) + strlen(refname) + strlen(path);
wbuf = imsg_create(&iev->ibuf, GOTD_IMSG_PACKFILE_GET_CONTENT,
blob - 67115ca0e835945a579386472c68a9561804ee5c
blob + de3b5c530209dfd7fd4ee70ed891e96ad029fc17
--- gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c
+++ gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c
char repo_path[_POSIX_PATH_MAX];
struct timespec now;
- if (ftruncate(gotd_conf_tmpfd, 0) == -1)
- return got_error_from_errno("ftruncate");
- if (lseek(gotd_conf_tmpfd, 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(gotd_conf_tmpfd);
+ if (err)
+ return err;
if (clock_gettime(CLOCK_MONOTONIC, &now) == -1)
return got_error_from_errno("clock_gettime");
blob - 350b071b5f1207561991a4b1816c64f39e1bb1cf
blob + d4028086ccc9c000cb8dd99582b7dbd43e4bd3b0
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
#include "got_commit_graph.h"
#include "got_blame.h"
#include "got_privsep.h"
+#include "got_opentemp.h"
#include "gotwebd.h"
#include "log.h"
got_gotweb_closefile(FILE *f)
{
const struct got_error *err = NULL;
-
- if (fseek(f, 0, SEEK_SET) == -1)
- err = got_error_from_errno("fseek");
- if (ftruncate(fileno(f), 0) == -1 && err == NULL)
- err = got_error_from_errno("ftruncate");
-
+ err = got_opentemp_truncate(f);
if (fclose(f) == EOF && err == NULL)
err = got_error_from_errno("fclose");
blob - c443107e5db49c2345a36a6bc569434aa7c0fb83
blob + e93015e7ed128c87069556155e432be030c04dc3
--- lib/object_open_io.c
+++ lib/object_open_io.c
#include "got_object.h"
#include "got_repository.h"
#include "got_path.h"
+#include "got_opentemp.h"
#include "got_lib_delta.h"
#include "got_lib_hash.h"
const struct got_error *err = NULL;
int fd;
- if (ftruncate(wrapped_fd, 0L) == -1)
- return got_error_from_errno("ftruncate");
-
- if (lseek(wrapped_fd, 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(wrapped_fd);
+ if (err)
+ return err;
fd = dup(wrapped_fd);
if (fd == -1)
goto done;
}
- if (ftruncate(outfd, 0L) == -1) {
- err = got_error_from_errno("ftruncate");
+ err = got_opentemp_truncatefd(outfd);
+ if (err)
goto done;
- }
- if (lseek(outfd, 0L, SEEK_SET) == -1) {
- err = got_error_from_errno("lseek");
- goto done;
- }
err = got_repo_search_packidx(&packidx, &idx, repo, id);
if (err == NULL) {
blob - 353d91c5566e2cf939a1d1b2aea2461aec1de39c
blob + 010744e377a9c375f87ed601fac9a674f7a112f3
--- lib/object_open_privsep.c
+++ lib/object_open_privsep.c
goto done;
}
- if (ftruncate(outfd, 0L) == -1) {
- err = got_error_from_errno("ftruncate");
- goto done;
- }
- if (lseek(outfd, 0L, SEEK_SET) == -1) {
- err = got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(outfd);
+ if (err)
goto done;
- }
err = got_repo_search_packidx(&packidx, &idx, repo, id);
if (err == NULL) {
blob - 6ba6d58350e8b94da24107ad45bdfcec87ba08bc
blob + 8903a6bf506a3f10ca50910b71b1b63a46822906
--- lib/repository.c
+++ lib/repository.c
const struct got_error *
got_repo_temp_fds_get(int *fd, int *idx, struct got_repository *repo)
{
+ const struct got_error *err = NULL;
int i;
*fd = -1;
if (repo->tempfile_use_mask & (1 << i))
continue;
if (repo->tempfiles[i] != -1) {
- if (ftruncate(repo->tempfiles[i], 0L) == -1)
- return got_error_from_errno("ftruncate");
- if (lseek(repo->tempfiles[i], 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(repo->tempfiles[i]);
+ if (err)
+ return err;
*fd = repo->tempfiles[i];
*idx = i;
repo->tempfile_use_mask |= (1 << i);
err = got_pack_close(&repo->packs[i]);
if (err)
return err;
- if (ftruncate(repo->packs[i].basefd, 0L) == -1)
- return got_error_from_errno("ftruncate");
- if (lseek(repo->packs[i].basefd, 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
- if (ftruncate(repo->packs[i].accumfd, 0L) == -1)
- return got_error_from_errno("ftruncate");
- if (lseek(repo->packs[i].accumfd, 0L, SEEK_SET) == -1)
- return got_error_from_errno("lseek");
+ err = got_opentemp_truncatefd(repo->packs[i].basefd);
+ if (err)
+ return err;
+ err = got_opentemp_truncatefd(repo->packs[i].accumfd);
+ if (err)
+ return err;
}
if (i != 0) {