X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FInitFile.c;h=a1e3e46feb07d48edfb369e24b70f0e64a638e53;hp=307442a7cc2bcab2c9f7e78498a40217ffc7fd0c;hb=844ea3e96c657de0e887fd3ebce90d1dff7103ad;hpb=4be39dd3718d708ccff65b01a8f634e05b56f3c9 diff --git a/sources/InitFile.c b/sources/InitFile.c index 307442a..a1e3e46 100644 --- a/sources/InitFile.c +++ b/sources/InitFile.c @@ -37,9 +37,9 @@ #include "Gapil.h" #include "macros.h" -ssize_t InitFile(int dirfd, const char *file, const char *buf, size_t count) +ssize_t InitFile(int dirfd, const char *file, const char *buf, size_t size) { - int fd, res; + int fd, written, res; char path[PATH_MAX]; fd = openat(dirfd, ".", O_TMPFILE|O_RDWR, S_IRUSR|S_IWUSR); @@ -47,18 +47,18 @@ ssize_t InitFile(int dirfd, const char *file, const char *buf, size_t count) perror("Cannot get temporary filedescritor"); return(fd); } - res = FullWrite(fd, buf, count); - if (res < 0) { + written = FullWrite(fd, buf, size); + if (written < 0) { perror("error writing on tmp file"); return(res); } snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); res = linkat(AT_FDCWD, path, dirfd, file, AT_SYMLINK_FOLLOW); if (res < 0) { - perror("error writing on tmp file"); + perror("error linking the file"); return(res); } else { - return 0; + return written; } }