summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--helpers/mknod.c26
2 files changed, 21 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index bb5bad8..76c6a07 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,8 +47,8 @@ AC_CHECK_FUNCS(
fread free fscanf fseek fstat fwrite getgrgid getpwuid \
localtime lstat malloc memcmp memcpy memset mkdir mkfifo open \
printf puts readlink scandir sleep snprintf sprintf stat \
- strchr strcmp strcpy strftime strlen strncpy strtol unlink \
- vfprintf
+ strchr strcmp strcpy strerror strftime strlen strncpy strtol \
+ unlink vfprintf
],
[],
[funcs_missing=true])
diff --git a/helpers/mknod.c b/helpers/mknod.c
index e9e9737..10b0e1b 100644
--- a/helpers/mknod.c
+++ b/helpers/mknod.c
@@ -70,6 +70,18 @@ _err(const char *fmt, ...)
fputc('\n', stderr);
}
+static void __attribute__((format(__printf__, 1, 2)))
+_errno(const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s: ", _program_name);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fprintf(stderr, ": %s\n", strerror(errno));
+}
+
static int
_get_work_area(int argc, char *argv[], char **work_area)
{
@@ -199,7 +211,7 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
if (mkfifo(name, mode) != 0) {
- _err(_("Failed to create link \"%s\""), name);
+ _errno(_("Failed to create link \"%s\""), name);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
@@ -232,7 +244,7 @@ main(int argc, char *argv[])
*/
fd = open(name, O_CREAT | O_EXCL, mode);
if (fd < 0 || close(fd) < 0) {
- _err(_("Failed to create node"));
+ _errno(_("Failed to create node"));
free(specials_file_name);
return EXIT_FAILURE;
}
@@ -245,7 +257,7 @@ main(int argc, char *argv[])
goto opened;
}
}
- _err(_("Failed to lock specials file"));
+ _errno(_("Failed to lock specials file"));
free(specials_file_name);
unlink(name);
return EXIT_FAILURE;
@@ -255,7 +267,7 @@ main(int argc, char *argv[])
specials_file = fopen(specials_file_name, "a");
if (specials_file == NULL) {
- _err(_("Failed to open specials file stream"));
+ _errno(_("Failed to open specials file stream"));
unlink(specials_lock_name);
free(specials_file_name);
unlink(name);
@@ -264,7 +276,7 @@ main(int argc, char *argv[])
/* If "specials" is empty, write header. */
if (fstat(fileno(specials_file), &stat_buf) != 0) {
- _err(_("Failed to stat specials file"));
+ _errno(_("Failed to stat specials file"));
fclose(specials_file);
unlink(specials_lock_name);
free(specials_file_name);
@@ -275,7 +287,7 @@ main(int argc, char *argv[])
if (fputs("version=1\n", specials_file) < 0 ||
fputs("type major minor name\n",
specials_file) < 0) {
- _err(_("Failed to write specials file"));
+ _errno(_("Failed to write specials file"));
fclose(specials_file);
unlink(specials_lock_name);
free(specials_file_name);
@@ -286,7 +298,7 @@ main(int argc, char *argv[])
if (fprintf(specials_file, "%c %8ld %8ld %s\n", type, major, minor,
name) < 0) {
- _err(_("Failed to write specials file"));
+ _errno(_("Failed to write specials file"));
fclose(specials_file);
unlink(specials_lock_name);
free(specials_file_name);