file operations).
rnd = open("/dev/urandom", O_RDONLY);
if (rnd == -1) {
- perror("open on /dev/urandom");
+ FILE_OP_ERROR("/dev/urandom", "open");
debug_print("Could not open /dev/urandom.\n");
return FALSE;
}
#else
ret = read(rnd, buf, count);
if (ret != count) {
- perror("read from /dev/urandom");
+ FILE_OP_ERROR("/dev/urandom", "read");
debug_print("Could not read enough data from /dev/urandom, read only %ld of %lu bytes.\n", ret, count);
close(rnd);
return FALSE;
args[4] = NULL;
if (chdir(claws_get_startup_dir()) != 0)
- perror("chdir");
+ FILE_OP_ERROR(claws_get_startup_dir(), "chdir");
if (setgid(getgid()) != 0)
perror("setgid");
if (setuid(getuid()) != 0 )
"-", sanitized_uid, NULL);
if ((fp = g_fopen(path, "rb")) == NULL) {
- perror("fopen1");
+ FILE_OP_ERROR(path, "fopen");
if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
g_free(sanitized_uid);
if ((fpnew = g_fopen(pathnew, "wb")) == NULL) {
- perror("fopen2");
+ FILE_OP_ERROR(pathnew, "fopen");
fclose(fp);
g_free(pathnew);
goto bail;
g_free(pathnew);
if ((fp = g_fopen(filename,"rb")) == NULL) {
- perror("fopen3");
+ FILE_OP_ERROR(filename, "fopen");
goto bail;
}
pathnew = g_strdup_printf("%s.new", filename);
if ((fpnew = g_fopen(pathnew, "wb")) == NULL) {
- perror("fopen4");
+ FILE_OP_ERROR(pathnew, "fopen");
fclose(fp);
g_free(pathnew);
goto bail;
debug_print("md5sum: %s\n", md5sum);
if ((fd =
open(md5_file, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) {
+ FILE_OP_ERROR(md5_file, "create");
free(md5sum);
return;
}
g_free(md5sum);
debug_print("md5sum: %s\n", text);
if (write(fd, text, strlen(text)) < 0)
- perror("write");
+ FILE_OP_ERROR(md5_file, "write");
close(fd);
g_free(text);
}
debug_print("New_file: %s\n", new_file);
if (link(file, new_file) != 0) {
if (errno != EEXIST) {
- perror("link");
+ FILE_OP_ERROR(new_file, "link");
g_free(new_file);
new_file = g_strdup(file);
page->rename = FALSE;
#endif
entry = archive_entry_new();
if ((fd = open(filename, O_RDONLY)) == -1) {
- perror("open file");
+ FILE_OP_ERROR(filename, "open");
}
else {
if (lstat(filename, &st) == -1) {
- perror("lstat file");
+ FILE_OP_ERROR(filename, "lstat");
} else {
archive_entry_copy_stat(entry, &st);
archive_entry_set_pathname(entry, filename);
if (S_ISLNK(st.st_mode)) {
if ((buf = malloc(PATH_MAX + 1)) != NULL) {
- if ((len = readlink(filename, buf, PATH_MAX)) < 0)
- perror("error in readlink");
- else
+ if ((len = readlink(filename, buf, PATH_MAX)) < 0) {
+ FILE_OP_ERROR(filename, "readlink");
+ } else
buf[len] = '\0';
archive_entry_set_symlink(entry, buf);
g_free(buf);
r = fcntl(fd, F_SETLKW, &lock);
if (r < 0) {
/* WARNING POSIX lock could not be applied */
+ perror("lock");
}
/* dot lock file */
int fd;
GStatBuf st;
time_t now;
-
+
/* global timeout */
time(&now);
if (now > start + LOCKTO_GLOB) {
if (fd >= 0) {
/* defeat lock checking programs which test pid */
if (write(fd, "0", 2) < 0)
- perror("write");
+ FILE_OP_ERROR(lockfilename, "write");
close(fd);
break;
+ } else {
+ FILE_OP_ERROR(lockfilename, "open");
}
-
+
/* libEtPan! - adds a delay of 5 seconds between each tries */
sleep(5);
-
+
if (g_stat(lockfilename, &st) < 0) {
if (statfailed++ > 5) {
res = -1;
if (now < st.st_ctime + LOCKTO_RM)
continue;
-
+
/* try to remove stale lockfile */
if (unlink(lockfilename) < 0) {
res = -1;
r = fcntl(fd, F_SETLK, &lock);
if (r < 0) {
/* WARNING POSIX lock could not be applied */
+ perror("lock");
}
return res;
}
fp = my_tmpfile();
if (fp == NULL) {
perror("my_tmpfile");
- privacy_set_error(_("Couldn't create temporary file."));
+ privacy_set_error(_("Couldn't create temporary file, %s"), g_strerror(errno));
return FALSE;
}
procmime_write_mimeinfo(msgcontent, fp);
fp = my_tmpfile();
if (fp == NULL) {
+ perror("my_tmpfile");
privacy_set_error(_("Couldn't create temporary file: %s"), g_strerror(errno));
return FALSE;
}
/* write message content to temporary file */
fp = my_tmpfile();
if (fp == NULL) {
+ perror("my_tmpfile");
privacy_set_error(_("Couldn't create temporary file, %s"), g_strerror(errno));
g_free(kset);
return FALSE;
tmpfile = get_tmp_file();
fp = g_fopen(tmpfile, "wb");
if (fp == NULL) {
- perror("get_tmp_file");
+ FILE_OP_ERROR(tmpfile, "create");
g_free(kset);
return FALSE;
}
canonicalize_file_replace(tmpfile);
fp = g_fopen(tmpfile, "rb");
if (fp == NULL) {
- perror("get_tmp_file");
+ FILE_OP_ERROR(tmpfile, "open");
g_free(kset);
return FALSE;
}
return FALSE;
}
} else {
- perror("get_tmp_file");
+ FILE_OP_ERROR(tmpfile, "create");
g_free(tmpfile);
g_free(enccontent);
return FALSE;
for (cur = files; cur; cur = cur->next) {
file = (char *)cur->data;
if (fprintf(fp, "1 1 %s\n", file) < 0)
- perror(file);
+ FILE_OP_ERROR(file, "fprintf");
g_free(file);
}
if (fclose(fp) == EOF)
- perror(file);
+ FILE_OP_ERROR(file, "fclose");
} else {
- perror(file);
+ FILE_OP_ERROR(file, "fopen");
}
g_free(path);
g_slist_free(files);
infp = procmime_fopen(mimeinfo->data.filename, "rb");
if (!infp) {
- perror("fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return FALSE;
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
- perror("fseek");
+ FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
procmime_fclose(infp);
return FALSE;
}
uncanonicalize = TRUE;
tmpfp = my_tmpfile();
if (!tmpfp) {
- perror("tmpfile");
+ perror("my_tmpfile");
if (tmp_file)
procmime_fclose(outfp);
procmime_fclose(infp);
gboolean err;
if ((outfp = my_tmpfile()) == NULL) {
- perror("tmpfile");
+ perror("my_tmpfile");
return NULL;
}
#ifdef HAVE_FGETS_UNLOCKED