misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
f65c6d4e82
commit
c05a80ca63
|
@ -44,6 +44,7 @@ extern int optind;
|
|||
|
||||
#define STRTOXX_EXIT_CODE 4 /* strtoxx_or_err() */
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
const char *progname = "blkid";
|
||||
|
||||
|
@ -691,6 +692,7 @@ int main(int argc, char **argv)
|
|||
uintmax_t offset = 0, size = 0;
|
||||
|
||||
show[0] = NULL;
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt (argc, argv, "c:df:ghilL:n:ko:O:ps:S:t:u:U:w:v")) != EOF)
|
||||
switch (c) {
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "mbsalign.h"
|
||||
#include "strutils.h"
|
||||
|
@ -278,6 +279,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBTERMCAP)
|
||||
if ((term = getenv("TERM"))) {
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "c.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
|
@ -169,6 +170,7 @@ main (int argc, char *argv[]) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
srandom(time(NULL));
|
||||
/* do args here */
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <blkid.h>
|
||||
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "c.h"
|
||||
|
||||
static void __attribute__((__noreturn__)) usage(int rc)
|
||||
|
@ -35,6 +36,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc != 2)
|
||||
/* we return '2' for backward compatibility
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "pathnames.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "c.h"
|
||||
#include "tt.h"
|
||||
#include "strutils.h"
|
||||
|
@ -991,6 +992,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
/* default output format */
|
||||
tt_flags |= TT_FL_TREE;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "c.h"
|
||||
#include "kill.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "strutils.h"
|
||||
|
||||
struct signv {
|
||||
|
@ -172,6 +173,7 @@ int main (int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
numsig = SIGTERM;
|
||||
do_pid = (! strcmp (progname, "pid")); /* Yecch */
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <getopt.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
|
||||
|
@ -188,6 +189,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
tag = NULL;
|
||||
pri = LOG_NOTICE;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "pathnames.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define EQUAL 0
|
||||
#define GREATER 1
|
||||
|
@ -99,6 +100,7 @@ main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "strutils.h"
|
||||
#include "at.h"
|
||||
#include "sysfs.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/* column IDs */
|
||||
enum {
|
||||
|
@ -1186,6 +1187,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
lsblk = &_ls;
|
||||
memset(lsblk, 0, sizeof(*lsblk));
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "at.h"
|
||||
#include "strutils.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/* column IDs */
|
||||
enum {
|
||||
|
@ -515,6 +516,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv,
|
||||
"p:o:nruhV", long_opts, NULL)) != -1) {
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "c.h"
|
||||
#include "md5.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stddef.h>
|
||||
|
@ -102,6 +104,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c =
|
||||
getopt_long(argc, argv, "f:vVh", longopts, NULL)) != -1)
|
||||
|
@ -183,13 +186,5 @@ int main(int argc, char **argv)
|
|||
printf("%02x", digest[i]);
|
||||
putchar('\n');
|
||||
|
||||
/*
|
||||
* The following is important for cases like disk full,
|
||||
* so shell scripts can bomb out properly rather than
|
||||
* think they succeeded.
|
||||
*/
|
||||
if (fflush(stdout) < 0 || fclose(stdout) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nls.h"
|
||||
#include "widechar.h"
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef MAXSYMLINKS
|
||||
#define MAXSYMLINKS 256
|
||||
|
@ -448,6 +449,7 @@ main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hVlmnovx", longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
|
|
|
@ -22,6 +22,7 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
|
|||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static int do_rename(char *from, char *to, char *s, int verbose)
|
||||
{
|
||||
|
@ -89,6 +90,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "vVh", longopts, NULL)) != -1)
|
||||
switch (c) {
|
||||
|
|
|
@ -35,6 +35,7 @@ extern int optind;
|
|||
#include "uuidd.h"
|
||||
#include "writeall.h"
|
||||
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -455,6 +456,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c =
|
||||
getopt_long(argc, argv, "p:s:T:krtn:dqVh", longopts,
|
||||
|
|
|
@ -24,6 +24,7 @@ extern int optind;
|
|||
#include "uuid.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define DO_TYPE_TIME 1
|
||||
#define DO_TYPE_RANDOM 2
|
||||
|
@ -62,6 +63,7 @@ main (int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "rtVh", longopts, NULL)) != -1)
|
||||
switch (c) {
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "xalloc.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static char *bindirs[] = {
|
||||
"/bin",
|
||||
|
@ -417,6 +418,7 @@ main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
argc--, argv++;
|
||||
if (argc == 0)
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "writeall.h"
|
||||
#include "match.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
struct wipe_desc {
|
||||
loff_t offset; /* magic string offset */
|
||||
|
@ -391,6 +392,7 @@ main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "ahno:pqt:V", longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
|
|
Loading…
Reference in New Issue