summaryrefslogtreecommitdiff
path: root/partprobe/partprobe.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-02-25 18:46:05 +0100
committerJim Meyering <jim@meyering.net>2007-02-25 18:46:05 +0100
commit802504ae11a79d3ed72fc3466dd3a96de1139c12 (patch)
tree662606c28b39c8842b62e9efb3a969ea9e10978c /partprobe/partprobe.c
parent1bfda3859e3f6d19cfdff4794da5d150bec4c6b3 (diff)
downloadparted-802504ae11a79d3ed72fc3466dd3a96de1139c12.tar.gz
partprobe: Detect/report any error when writing to stdout.
* partprobe/Makefile.am (partprobe_LDADD): Add lib/libparted.la. * partprobe/partprobe.c: Include "closeout.h" for close_stdout. Include "version-etc.h" for version_etc prototype. Declare global, program_name. (PROGRAM_NAME, AUTHORS): Define. (help): Use PROGRAM_NAME, rather than hard-coding it. (version): Use gnulib's version_etc. (main): Set program_name. Use atexit to close stdout carefully upon exit.
Diffstat (limited to 'partprobe/partprobe.c')
-rw-r--r--partprobe/partprobe.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c
index f86c370..9a26e9a 100644
--- a/partprobe/partprobe.c
+++ b/partprobe/partprobe.c
@@ -1,6 +1,6 @@
/*
partprobe - informs the OS kernel of partition layout
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
*
* CFLAGS=-Os ./configure --disable-nls --disable-shared --disable-debug
* --enable-discover-only
- *
+ *
* And strip(1) afterwards!
*/
@@ -32,6 +32,17 @@
#include <stdio.h>
#include <string.h>
+#include "closeout.h"
+#include "version-etc.h"
+
+#define AUTHORS \
+ "<http://parted.alioth.debian.org/cgi-bin/trac.cgi/browser/AUTHORS>"
+
+/* The official name of this program (e.g., no `g' prefix). */
+#define PROGRAM_NAME "partprobe"
+
+char *program_name;
+
/* initialized to 0 according to the language lawyers */
static int opt_no_probe;
static int opt_summary;
@@ -98,16 +109,17 @@ error:
static void
help ()
{
- printf ("usage: partprobe [-d] [-h] [-s] [-v] [DEVICES...]\n\n"
+ printf ("usage: %s [-d] [-h] [-s] [-v] [DEVICES...]\n\n"
"-d don't update the kernel\n"
"-s print a summary of contents\n"
- "-v version info\n");
+ "-v version info\n", PROGRAM_NAME);
}
static void
version ()
{
- printf ("partprobe (" PACKAGE VERSION ")\n");
+ version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, VERSION, AUTHORS,
+ (char *) NULL);
}
int
@@ -118,6 +130,9 @@ main (int argc, char* argv[])
PedDevice* dev;
int status = 1;
+ program_name = argv[0];
+ atexit (close_stdout);
+
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
dev_passed = 1;
@@ -158,4 +173,3 @@ main (int argc, char* argv[])
return !status;
}
-