* [PATCH 01/33] bash-completion: add mount and umount
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 02/33] blkid, hwclock, ldattach: use program_invocation_short_name Sami Kerola
` (32 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
bash-completion/mount | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++
bash-completion/umount | 60 ++++++++++++++++++++++++++++++++++
2 files changed, 147 insertions(+)
create mode 100644 bash-completion/mount
create mode 100644 bash-completion/umount
diff --git a/bash-completion/mount b/bash-completion/mount
new file mode 100644
index 0000000..2303cb7
--- /dev/null
+++ b/bash-completion/mount
@@ -0,0 +1,87 @@
+_mount_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-t'|'--types')
+ local TYPES
+ TYPES="
+adfs noadfs hfsplus nohfsplus smbfs nosmbfs
+affs noaffs hpfs nohpfs squashfs nosquashfs
+autofs noautofs iso9660 noiso9660 sysv nosysv
+cifs nocifs jfs nojfs tmpfs notmpfs
+coda nocoda minix nominix ubifs noubifs
+coherent nocoherent msdos nomsdos udf noudf
+cramfs nocramfs ncpfs noncpfs ufs noufs
+debugfs nodebugfs nfs nonfs umsdos noumsdos
+devpts nodevpts nfs4 nonfs4 usbfs nousbfs
+efs noefs ntfs nontfs vfat novfat
+ext noext proc noproc xenix noxenix
+ext2 noext2 qnx4 noqnx4 xfs noxfs
+ext3 noext3 ramfs noramfs xiafs noxiafs
+ext4 noext4 reiserfs noreiserfs
+hfs nohfs romfs noromfs
+"
+ COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
+ return 0
+ ;;
+ '-L'|'--label')
+ local LABELS
+ LABELS="$(lsblk -o LABEL -nr)"
+ COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
+ return 0
+ ;;
+ '-U'|'--uuid')
+ local UUIDS
+ UUIDS="$(lsblk -o UUID -nr)"
+ COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
+ return 0
+ ;;
+ '-h'|'--help'|'-V'|'--version')
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS=" --all
+ --no-canonicalize
+ --fake
+ --fork
+ --fstab
+ --help
+ --internal-only
+ --show-labels
+ --no-mtab
+ --options
+ --test-opts
+ --read-only
+ --types
+ --source
+ --target
+ --verbose
+ --version
+ --read-write
+ --label
+ --uuid
+ --bind
+ --move
+ --rbind
+ --make-shared
+ --make-slave
+ --make-private
+ --make-unbindable
+ --make-rshared
+ --make-rslave
+ --make-rprivate
+ --make-runbindable"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+}
+complete -F _mount_module mount
diff --git a/bash-completion/umount b/bash-completion/umount
new file mode 100644
index 0000000..f178bd7
--- /dev/null
+++ b/bash-completion/umount
@@ -0,0 +1,60 @@
+_umount_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-t'|'--types')
+ local TYPES
+ TYPES="
+adfs noadfs hfsplus nohfsplus smbfs nosmbfs
+affs noaffs hpfs nohpfs squashfs nosquashfs
+autofs noautofs iso9660 noiso9660 sysv nosysv
+cifs nocifs jfs nojfs tmpfs notmpfs
+coda nocoda minix nominix ubifs noubifs
+coherent nocoherent msdos nomsdos udf noudf
+cramfs nocramfs ncpfs noncpfs ufs noufs
+debugfs nodebugfs nfs nonfs umsdos noumsdos
+devpts nodevpts nfs4 nonfs4 usbfs nousbfs
+efs noefs ntfs nontfs vfat novfat
+ext noext proc noproc xenix noxenix
+ext2 noext2 qnx4 noqnx4 xfs noxfs
+ext3 noext3 ramfs noramfs xiafs noxiafs
+ext4 noext4 reiserfs noreiserfs
+"
+ COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
+ return 0
+ ;;
+ '-h'|'--help'|'-V'|'--version')
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS=" --all
+ --all-targets
+ --no-canonicalize
+ --detach-loop
+ --fake
+ --force
+ --internal-only
+ --no-mtab
+ --lazy
+ --test-opts
+ --recursive
+ --read-only
+ --types
+ --verbose
+ --help
+ --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ local DEVS_MPOINTS
+ DEVS_MPOINTS="$(mount | awk '{print $1, $3}')"
+ COMPREPLY=( $(compgen -W "$DEVS_MPOINTS" -- $cur) )
+ return 0
+}
+complete -F _umount_module umount
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 02/33] blkid, hwclock, ldattach: use program_invocation_short_name
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
2013-04-13 19:54 ` [PATCH 01/33] bash-completion: add mount and umount Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 03/33] utmpdump: add option to write to a file Sami Kerola
` (31 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/blkid.c | 4 +---
sys-utils/hwclock.h | 1 -
sys-utils/ldattach.c | 3 ---
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index ce712ac..f4a9cf5 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -51,8 +51,6 @@ extern int optind;
#include "ttyutils.h"
#include "xalloc.h"
-const char *progname = "blkid";
-
int raw_chars;
static void print_version(FILE *out)
@@ -98,7 +96,7 @@ static void usage(int error)
" -O <offset> probe at the given offset\n"
" -u <list> filter by \"usage\" (e.g. -u filesystem,raid)\n"
" -n <list> filter by filesystem type (e.g. -n vfat,ext3)\n"
- "\n", progname);
+ "\n", program_invocation_short_name);
exit(error);
}
diff --git a/sys-utils/hwclock.h b/sys-utils/hwclock.h
index 175a6d1..69b0ce2 100644
--- a/sys-utils/hwclock.h
+++ b/sys-utils/hwclock.h
@@ -24,7 +24,6 @@ extern struct clock_ops *probe_for_kd_clock(void);
typedef int bool;
/* hwclock.c */
-extern char *progname;
extern int debug;
extern unsigned long epoch_option;
extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
index c06aed2..5c460fe 100644
--- a/sys-utils/ldattach.c
+++ b/sys-utils/ldattach.c
@@ -42,7 +42,6 @@
# define TIOCSETD 0x5423
#endif
-static const char *progname;
static int debug = 0;
struct ld_table {
@@ -238,8 +237,6 @@ int main(int argc, char **argv)
atexit(close_stdout);
/* parse options */
- progname = program_invocation_short_name;
-
if (argc == 0)
usage(EXIT_SUCCESS);
while ((optc =
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 03/33] utmpdump: add option to write to a file
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
2013-04-13 19:54 ` [PATCH 01/33] bash-completion: add mount and umount Sami Kerola
2013-04-13 19:54 ` [PATCH 02/33] blkid, hwclock, ldattach: use program_invocation_short_name Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 04/33] cfdisk: add long options to the command Sami Kerola
` (30 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
bash-completion/utmpdump | 2 +-
login-utils/utmpdump.1 | 4 ++-
login-utils/utmpdump.c | 92 ++++++++++++++++++++++++++++--------------------
3 files changed, 58 insertions(+), 40 deletions(-)
diff --git a/bash-completion/utmpdump b/bash-completion/utmpdump
index 3b868ce..48af5bc 100644
--- a/bash-completion/utmpdump
+++ b/bash-completion/utmpdump
@@ -11,7 +11,7 @@ _utmpdump_module()
esac
case $cur in
-*)
- OPTS="--follow --reverse --version --help"
+ OPTS="--follow --reverse --output --version --help"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
diff --git a/login-utils/utmpdump.1 b/login-utils/utmpdump.1
index 35565a4..25f361a 100644
--- a/login-utils/utmpdump.1
+++ b/login-utils/utmpdump.1
@@ -19,7 +19,7 @@
.SH NAME
utmpdump \- dump UTMP and WTMP files in raw format
.SH SYNOPSIS
-utmpdump [\-frh] [ filename ]
+utmpdump [\-frohV] [ filename ]
.SH DESCRIPTION
.B utmpdump
is a simple program to dump UTMP and WTMP files in raw format, so they
@@ -33,6 +33,8 @@ is passed.
Output appended data as the file grows.
.IP "\fB\-r\fR, \fB\-\-reverse\fP
Undump, write back edited login information into utmp or wtmp files.
+.IP "\fB\-o\fR, \fB\-\-output\fP \fIfile\fR
+Write command output to file instead of standard output.
.IP "\fB\-h\fR, \fB\-\-help\fP"
Print a help text and exit.
.IP "\fB\-V\fR, \fB\-\-version\fP"
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index b015e1b..af3f7c0 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -83,7 +83,7 @@ static void xcleanse(char *s, int len)
*s = '?';
}
-static void print_utline(struct utmp ut)
+static void print_utline(struct utmp ut, FILE *out)
{
char *addr_string, *time_string;
struct in_addr in;
@@ -97,7 +97,7 @@ static void print_utline(struct utmp ut)
cleanse(ut.ut_host);
/* pid id user line host addr time */
- printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n",
+ fprintf(out, "[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n",
ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user,
12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host,
addr_string, time_string);
@@ -107,28 +107,28 @@ static void print_utline(struct utmp ut)
#define EVENTS (IN_MODIFY|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT)
#define NEVENTS 4
-static void roll_file(const char *filename, off_t *size)
+static void roll_file(const char *filename, off_t *size, FILE *out)
{
- FILE *fp;
+ FILE *in;
struct stat st;
struct utmp ut;
off_t pos;
- if (!(fp = fopen(filename, "r")))
+ if (!(in = fopen(filename, "r")))
err(EXIT_FAILURE, _("cannot open %s"), filename);
- if (fstat(fileno(fp), &st) == -1)
+ if (fstat(fileno(in), &st) == -1)
err(EXIT_FAILURE, _("%s: stat failed"), filename);
if (st.st_size == *size)
goto done;
- if (fseek(fp, *size, SEEK_SET) != (off_t) -1) {
- while (fread(&ut, sizeof(ut), 1, fp) == 1)
- print_utline(ut);
+ if (fseek(in, *size, SEEK_SET) != (off_t) -1) {
+ while (fread(&ut, sizeof(ut), 1, in) == 1)
+ print_utline(ut, out);
}
- pos = ftello(fp);
+ pos = ftello(in);
/* If we've successfully read something, use the file position, this
* avoids data duplication. If we read nothing or hit an error,
* reset to the reported size, this handles truncated files.
@@ -136,10 +136,10 @@ static void roll_file(const char *filename, off_t *size)
*size = (pos != -1 && pos != *size) ? pos : st.st_size;
done:
- fclose(fp);
+ fclose(in);
}
-static int follow_by_inotify(FILE *fp, const char *filename)
+static int follow_by_inotify(FILE *in, const char *filename, FILE *out)
{
char buf[NEVENTS * sizeof(struct inotify_event)];
int fd, wd, event;
@@ -150,8 +150,8 @@ static int follow_by_inotify(FILE *fp, const char *filename)
if (fd == -1)
return -1; /* probably reached any limit ... */
- size = ftello(fp);
- fclose(fp);
+ size = ftello(in);
+ fclose(in);
wd = inotify_add_watch(fd, filename, EVENTS);
if (wd == -1)
@@ -172,7 +172,7 @@ static int follow_by_inotify(FILE *fp, const char *filename)
(struct inotify_event *) &buf[event];
if (ev->mask & IN_MODIFY)
- roll_file(filename, &size);
+ roll_file(filename, &size, out);
else {
close(wd);
wd = -1;
@@ -187,33 +187,33 @@ static int follow_by_inotify(FILE *fp, const char *filename)
}
#endif /* HAVE_INOTIFY_INIT */
-static FILE *dump(FILE *fp, const char *filename, int follow)
+static FILE *dump(FILE *in, const char *filename, int follow, FILE *out)
{
struct utmp ut;
if (follow)
- fseek(fp, -10 * sizeof(ut), SEEK_END);
+ fseek(in, -10 * sizeof(ut), SEEK_END);
- while (fread(&ut, sizeof(ut), 1, fp) == 1)
- print_utline(ut);
+ while (fread(&ut, sizeof(ut), 1, in) == 1)
+ print_utline(ut, out);
if (!follow)
- return fp;
+ return in;
#ifdef HAVE_INOTIFY_INIT
- if (follow_by_inotify(fp, filename) == 0)
+ if (follow_by_inotify(in, filename, out) == 0)
return NULL; /* file already closed */
else
#endif
/* fallback for systems without inotify or with non-free
* inotify instances */
for (;;) {
- while (fread(&ut, sizeof(ut), 1, fp) == 1)
- print_utline(ut);
+ while (fread(&ut, sizeof(ut), 1, in) == 1)
+ print_utline(ut, out);
sleep(1);
}
- return fp;
+ return in;
}
@@ -245,7 +245,7 @@ static int gettok(char *line, char *dest, int size, int eatspace)
return eaten + 1;
}
-static void undump(FILE *fp)
+static void undump(FILE *in, FILE *out)
{
struct utmp ut;
char s_addr[16], s_time[29], *linestart, *line;
@@ -255,7 +255,7 @@ static void undump(FILE *fp)
s_addr[15] = 0;
s_time[28] = 0;
- while (fgets(linestart, 1023, fp)) {
+ while (fgets(linestart, 1023, in)) {
line = linestart;
memset(&ut, '\0', sizeof(ut));
sscanf(line, "[%hd] [%d] [%4c] ", &ut.ut_type, &ut.ut_pid, ut.ut_id);
@@ -270,7 +270,7 @@ static void undump(FILE *fp)
ut.ut_addr = inet_addr(s_addr);
ut.ut_time = strtotime(s_time);
- ignore_result( fwrite(&ut, sizeof(ut), 1, stdout) );
+ ignore_result( fwrite(&ut, sizeof(ut), 1, out) );
++count;
}
@@ -286,8 +286,9 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
_(" %s [options] [filename]\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -f, --follow output appended data as the file grows\n"
- " -r, --reverse write back dumped data into utmp file\n"), out);
+ fputs(_(" -f, --follow output appended data as the file grows\n"), out);
+ fputs(_(" -r, --reverse write back dumped data into utmp file\n"), out);
+ fputs(_(" -o, --output <file> write to file instead of standard output\n"), out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
@@ -298,13 +299,14 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
int main(int argc, char **argv)
{
int c;
- FILE *fp = NULL;
+ FILE *in = NULL, *out = NULL;
int reverse = 0, follow = 0;
const char *filename = NULL;
static const struct option longopts[] = {
{ "follow", 0, 0, 'f' },
{ "reverse", 0, 0, 'r' },
+ { "output", required_argument, 0, 'o' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ NULL, 0, 0, 0 }
@@ -315,7 +317,7 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long(argc, argv, "frhV", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "fro:hV", longopts, NULL)) != -1) {
switch (c) {
case 'r':
reverse = 1;
@@ -325,6 +327,13 @@ int main(int argc, char **argv)
follow = 1;
break;
+ case 'o':
+ out = fopen(optarg, "w");
+ if (!out)
+ err(EXIT_FAILURE, _("cannot open %s"),
+ optarg);
+ break;
+
case 'h':
usage(stdout);
break;
@@ -336,28 +345,35 @@ int main(int argc, char **argv)
}
}
+ if (!out)
+ out = stdout;
+
if (optind < argc) {
filename = argv[optind];
- fp = fopen(filename, "r");
- if (!fp)
+ in = fopen(filename, "r");
+ if (!in)
err(EXIT_FAILURE, _("cannot open %s"), filename);
} else {
if (follow)
errx(EXIT_FAILURE, _("following standard input is unsupported"));
filename = "/dev/stdin";
- fp = stdin;
+ in = stdin;
}
if (reverse) {
fprintf(stderr, _("Utmp undump of %s\n"), filename);
- undump(fp);
+ undump(in, out);
} else {
fprintf(stderr, _("Utmp dump of %s\n"), filename);
- fp = dump(fp, filename, follow);
+ in = dump(in, filename, follow, out);
}
- if (fp && fp != stdin)
- fclose(fp);
+ if (out != stdout)
+ if (close_stream(out))
+ err(EXIT_FAILURE, _("write failed"));
+
+ if (in && in != stdin)
+ fclose(in);
return EXIT_SUCCESS;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 04/33] cfdisk: add long options to the command
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (2 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 03/33] utmpdump: add option to write to a file Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-26 11:30 ` Karel Zak
2013-04-13 19:54 ` [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax Sami Kerola
` (29 subsequent siblings)
33 siblings, 1 reply; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Includes update to bash completion, and manual as well.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
bash-completion/cfdisk | 24 ++++++++++++-----
fdisks/cfdisk.8 | 18 ++++++-------
fdisks/cfdisk.c | 71 ++++++++++++++++++++++++++++++--------------------
3 files changed, 70 insertions(+), 43 deletions(-)
diff --git a/bash-completion/cfdisk b/bash-completion/cfdisk
index 6cd9d6f..65039ee 100644
--- a/bash-completion/cfdisk
+++ b/bash-completion/cfdisk
@@ -5,25 +5,37 @@ _cfdisk_module()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
- '-c')
+ '-c'|'--cylinders')
COMPREPLY=( $(compgen -W "cylinders" -- $cur) )
return 0
;;
- '-h')
+ '-h'|'--heads')
COMPREPLY=( $(compgen -W "heads" -- $cur) )
return 0
;;
- '-s')
+ '-s'|'--sectors')
COMPREPLY=( $(compgen -W "sectors" -- $cur) )
return 0
;;
- '-v')
+ '-P'|'--print')
+ COMPREPLY=( $(compgen -W "r s t" -- $cur) )
+ return 0
+ ;;
+ '-v'|'-V'|'--version'|'--help')
return 0
;;
esac
case $cur in
-*)
- OPTS="-a -z -c -h -s"
+ OPTS=" --cylinders
+ --heads
+ --sectors
+ --guess
+ --print
+ --zero
+ --arrow
+ --help
+ --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
@@ -31,7 +43,7 @@ _cfdisk_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro "name,type")"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
}
diff --git a/fdisks/cfdisk.8 b/fdisks/cfdisk.8
index be88fdb..efd33ce 100644
--- a/fdisks/cfdisk.8
+++ b/fdisks/cfdisk.8
@@ -11,7 +11,7 @@
.\" permission notice identical to this one.
.\"
.\" " for hilit mode
-.TH CFDISK 8 "July 2009" "util-linux" "System Administration"
+.TH CFDISK 8 "April 2013" "util-linux" "System Administration"
.SH NAME
cfdisk \- display or manipulate disk partition table
.SH SYNOPSIS
@@ -397,18 +397,18 @@ When in a sub-menu or at a prompt to enter a filename, you can hit the
key to return to the main command line.
.SH OPTIONS
.TP
-.B \-a
+\fB\-a\fR, \fB\-\-arrow\fR
Use an arrow cursor instead of reverse video for highlighting the
current partition.
.TP
-.B \-g
+\fB\-g\fR, \fB\-\-guess\fR
Do not use the geometry given by the disk driver, but try to
guess a geometry from the partition table.
.TP
-.B \-v
+\fB\-v\fR, \fB\-V\fR, \fB\-\-version\fR
Print the version number and copyright.
.TP
-.B \-z
+\fB\-z\fR, \fB\-\-zero\fR
Start with zeroed partition table. This option is useful when you
want to repartition your entire disk.
.I Note:
@@ -416,17 +416,17 @@ this option does not zero the partition table on the disk; rather, it
simply starts the program without reading the existing partition
table.
.TP
-.BI \-c " cylinders"
+\fB\-c\fR, \fB\-\-cylinders\fR \fcylinders\fR
.TP
-.BI \-h " heads"
+\fB\-h\fR, \fB\-\-heads\fR \fIheads\fR
.TP
-.BI \-s " sectors-per-track"
+\fB\-s\fR, \fB\-\-sectors\fR \fsectors-per-track\fR
Override the number of cylinders, heads and sectors per track read
from the BIOS. If your BIOS or adapter does not supply this
information or if it supplies incorrect information, use these options
to set the disk geometry values.
.TP
-.BI \-P " opt"
+\fB\-P\fR, \fB\-\-print\fR \fIr|s|t\fR
Prints the partition table in specified formats.
.I opt
can be one or more of "r", "s" or "t". See the
diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index 136ff9d..db9e233 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -2737,27 +2737,25 @@ copyright(void) {
fprintf(stderr, _("Copyright (C) 1994-2002 Kevin E. Martin & aeb\n"));
}
-static void
-usage(char *prog_name) {
- /* Unfortunately, xgettext does not handle multi-line strings */
- /* so, let's use explicit \n's instead */
- fprintf(stderr, _("\n"
-"Usage:\n"
-"Print version:\n"
-" %s -v\n"
-"Print partition table:\n"
-" %s -P {r|s|t} [options] device\n"
-"Interactive use:\n"
-" %s [options] device\n"
-"\n"
-"Options:\n"
-"-a: Use arrow instead of highlighting;\n"
-"-z: Start with a zero partition table, instead of reading the pt from disk;\n"
-"-c C -h H -s S: Override the kernel's idea of the number of cylinders,\n"
-" the number of heads and the number of sectors/track.\n\n"),
- prog_name, prog_name, prog_name);
+static void __attribute__ ((__noreturn__)) usage(FILE *out)
+{
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options] device\n"), program_invocation_short_name);
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -c, --cylinders <number> set the number of cylinders to use\n"), out);
+ fputs(_(" -h, --heads <number> set the number of heads to use\n"), out);
+ fputs(_(" -s, --sectors <number> set the number of sectors to use\n"), out);
+ fputs(_(" -g, --guess guess a geometry from partition table\n"), out);
+ fputs(_(" -P, --print <r|s|t> print partition table in specified format\n"), out);
+ fputs(_(" -z, --zero start with zeroed partition table\n"), out);
+ fputs(_(" -a, --arrow use arrow for highlighting the current partition\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_(" --help display this help and exit\n"), out);
+ fputs(USAGE_VERSION, out);
+ fprintf(out, USAGE_MAN_TAIL("cfdisk(8)"));
copyright();
+ exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
int
@@ -2766,12 +2764,29 @@ main(int argc, char **argv)
int c;
int i, len;
+ enum {
+ OPT_HELP = CHAR_MAX + 1,
+ };
+
+ static const struct option longopts[] = {
+ {"cylinders", required_argument, 0, 'c'},
+ {"heads", required_argument, 0, 'h'},
+ {"sectors", required_argument, 0, 's'},
+ {"guess", no_argument, 0, 'g'},
+ {"print", required_argument, 0, 'P'},
+ {"zero", no_argument, 0, 'z'},
+ {"arrow", no_argument, 0, 'a'},
+ {"help", no_argument, 0, OPT_HELP},
+ {"version", no_argument, 0, 'V'},
+ {NULL, no_argument, 0, '0'},
+ };
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt(argc, argv, "ac:gh:s:vzP:")) != -1)
+ while ((c = getopt_long(argc, argv, "ac:gh:s:vVzP:", longopts, NULL)) != -1)
switch (c) {
case 'a':
arrow_cursor = TRUE;
@@ -2801,9 +2816,10 @@ main(int argc, char **argv)
}
break;
case 'v':
- fprintf(stderr, "cfdisk (%s)\n", PACKAGE_STRING);
+ case 'V':
+ printf(UTIL_LINUX_VERSION);
copyright();
- exit(0);
+ return EXIT_SUCCESS;
case 'z':
zero_table = TRUE;
break;
@@ -2821,21 +2837,20 @@ main(int argc, char **argv)
print_only |= PRINT_PARTITION_TABLE;
break;
default:
- usage(argv[0]);
- exit(1);
+ usage(stderr);
}
}
break;
+ case OPT_HELP:
+ usage(stdout);
default:
- usage(argv[0]);
- exit(1);
+ usage(stderr);
}
if (argc-optind == 1)
disk_device = argv[optind];
else if (argc-optind != 0) {
- usage(argv[0]);
- exit(1);
+ usage(stderr);
} else if ((fd = open(DEFAULT_DEVICE, O_RDONLY)) < 0)
disk_device = ALTERNATE_DEVICE;
else close(fd);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (3 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 04/33] cfdisk: add long options to the command Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 21:59 ` Dave Reisner
2013-04-13 19:54 ` [PATCH 06/33] setpriv: allow login and group name option arguments Sami Kerola
` (28 subsequent siblings)
33 siblings, 1 reply; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
The '< <' syntax is bash 2.x trick, and <<< does the same job when bash
3.x is in use. For some unknown reason my bash 4.2.45(2)-release became
allergic to old syntax today(?).
Reference: http://linuxshellaccount.blogspot.co.uk/2008/08/using-bash-to-feed-command-output-to.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
bash-completion/addpart | 2 +-
bash-completion/blkdiscard | 2 +-
bash-completion/blkid | 2 +-
bash-completion/blockdev | 2 +-
bash-completion/delpart | 2 +-
bash-completion/fdisk | 4 ++--
bash-completion/findmnt | 2 +-
bash-completion/fsck | 2 +-
bash-completion/fsck.minix | 2 +-
bash-completion/lsblk | 2 +-
bash-completion/mkfs | 2 +-
bash-completion/mkfs.bfs | 2 +-
bash-completion/mkfs.minix | 2 +-
bash-completion/partx | 2 +-
bash-completion/resizepart | 2 +-
bash-completion/sfdisk | 2 +-
bash-completion/wipefs | 2 +-
17 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/bash-completion/addpart b/bash-completion/addpart
index 2b1e6bb..3b4e603 100644
--- a/bash-completion/addpart
+++ b/bash-completion/addpart
@@ -6,7 +6,7 @@ _addpart_module()
case $COMP_CWORD in
1)
local DEVS=''
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
OPTS="--help --version $DEVS"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
;;
diff --git a/bash-completion/blkdiscard b/bash-completion/blkdiscard
index 310cdfb..9e2e262 100644
--- a/bash-completion/blkdiscard
+++ b/bash-completion/blkdiscard
@@ -21,7 +21,7 @@ _blkdiscard_module()
;;
esac
local DEVS
- DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
diff --git a/bash-completion/blkid b/bash-completion/blkid
index b439328..de8b8ce 100644
--- a/bash-completion/blkid
+++ b/bash-completion/blkid
@@ -60,7 +60,7 @@ _blkid_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'part' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
}
diff --git a/bash-completion/blockdev b/bash-completion/blockdev
index ce986cb..4c86cda 100644
--- a/bash-completion/blockdev
+++ b/bash-completion/blockdev
@@ -4,7 +4,7 @@ _blockdev_module()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
OPTS="-h -V -q
--report
--getsz
diff --git a/bash-completion/delpart b/bash-completion/delpart
index a4b20c8..6fa7006 100644
--- a/bash-completion/delpart
+++ b/bash-completion/delpart
@@ -14,7 +14,7 @@ _delpart_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
OPTS="--help --version $DEVICES"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
;;
diff --git a/bash-completion/fdisk b/bash-completion/fdisk
index b800f8d..4a59070 100644
--- a/bash-completion/fdisk
+++ b/bash-completion/fdisk
@@ -9,7 +9,7 @@ _fdisk_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'part' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
;;
@@ -43,7 +43,7 @@ _fdisk_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
}
diff --git a/bash-completion/findmnt b/bash-completion/findmnt
index 9386d8f..4cb0be8 100644
--- a/bash-completion/findmnt
+++ b/bash-completion/findmnt
@@ -37,7 +37,7 @@ _findmnt_module()
for I in ${TMP_ARR[@]}; do
MNT_OPTS[$I]='1'
done
- done < <(findmnt -rno OPTIONS)
+ done <<<"$(findmnt -rno OPTIONS)"
COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) )
return 0
;;
diff --git a/bash-completion/fsck b/bash-completion/fsck
index 04899a0..448b6b7 100644
--- a/bash-completion/fsck
+++ b/bash-completion/fsck
@@ -32,7 +32,7 @@ _fsck_module()
return 0
;;
esac
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
diff --git a/bash-completion/fsck.minix b/bash-completion/fsck.minix
index 1ec9a78..b9ff739 100644
--- a/bash-completion/fsck.minix
+++ b/bash-completion/fsck.minix
@@ -9,7 +9,7 @@ _fsck.minix_module()
return 0
;;
esac
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
OPTS="-l -a -r -v -s -m -f --version"
COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
return 0
diff --git a/bash-completion/lsblk b/bash-completion/lsblk
index 07e9368..2beb8a5 100644
--- a/bash-completion/lsblk
+++ b/bash-completion/lsblk
@@ -61,7 +61,7 @@ _lsblk_module()
;;
esac
local DEVS
- DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
diff --git a/bash-completion/mkfs b/bash-completion/mkfs
index 4e6e175..daa9ea5 100644
--- a/bash-completion/mkfs
+++ b/bash-completion/mkfs
@@ -21,7 +21,7 @@ _mkfs_module()
return 0
;;
esac
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
return 0
}
diff --git a/bash-completion/mkfs.bfs b/bash-completion/mkfs.bfs
index 8adbc60..4f56403 100644
--- a/bash-completion/mkfs.bfs
+++ b/bash-completion/mkfs.bfs
@@ -24,7 +24,7 @@ _bfs_module()
return 0
;;
esac
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
return 0
}
diff --git a/bash-completion/mkfs.minix b/bash-completion/mkfs.minix
index 78c986f..e7b60a3 100644
--- a/bash-completion/mkfs.minix
+++ b/bash-completion/mkfs.minix
@@ -29,7 +29,7 @@ _mkfs.minix_module()
;;
esac
local DEVS
- while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
diff --git a/bash-completion/partx b/bash-completion/partx
index 7b08fa8..9b382fd 100644
--- a/bash-completion/partx
+++ b/bash-completion/partx
@@ -34,7 +34,7 @@ _partx_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
}
diff --git a/bash-completion/resizepart b/bash-completion/resizepart
index c78af15..08a95f0 100644
--- a/bash-completion/resizepart
+++ b/bash-completion/resizepart
@@ -14,7 +14,7 @@ _resizepart_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
OPTS="--help --version $DEVICES"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
;;
diff --git a/bash-completion/sfdisk b/bash-completion/sfdisk
index 0226b04..d39e2ba 100644
--- a/bash-completion/sfdisk
+++ b/bash-completion/sfdisk
@@ -75,7 +75,7 @@ _sfdisk_module()
local DEV TYPE DEVICES=''
while read DEV TYPE; do
[ $TYPE = 'disk' ] && DEVICES+="$DEV "
- done < <(lsblk -pnro name,type)
+ done <<<"$(lsblk -pnro name,type)"
COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
return 0
}
diff --git a/bash-completion/wipefs b/bash-completion/wipefs
index e0e3286..f0a3ba6 100644
--- a/bash-completion/wipefs
+++ b/bash-completion/wipefs
@@ -27,7 +27,7 @@ _wipefs_module()
;;
esac
local DEVS
- DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax
2013-04-13 19:54 ` [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax Sami Kerola
@ 2013-04-13 21:59 ` Dave Reisner
2013-04-26 11:38 ` Karel Zak
0 siblings, 1 reply; 40+ messages in thread
From: Dave Reisner @ 2013-04-13 21:59 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Sat, Apr 13, 2013 at 08:54:33PM +0100, Sami Kerola wrote:
> The '< <' syntax is bash 2.x trick, and <<< does the same job when bash
> 3.x is in use. For some unknown reason my bash 4.2.45(2)-release became
> allergic to old syntax today(?).
I don't follow this. The syntax is <(commands), which is a process
substitution. It creates a temporary file descriptor which can be
redirected via <. It still very much works, and I don't expect this to
break any time soon. It's likely more memory efficient since there's no
need to expand the output in place -- it can just be read off of the
file descriptor.
I think you should figure out what's wrong with your shell instead of
doing this.
> Reference: http://linuxshellaccount.blogspot.co.uk/2008/08/using-bash-to-feed-command-output-to.html
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
> bash-completion/addpart | 2 +-
> bash-completion/blkdiscard | 2 +-
> bash-completion/blkid | 2 +-
> bash-completion/blockdev | 2 +-
> bash-completion/delpart | 2 +-
> bash-completion/fdisk | 4 ++--
> bash-completion/findmnt | 2 +-
> bash-completion/fsck | 2 +-
> bash-completion/fsck.minix | 2 +-
> bash-completion/lsblk | 2 +-
> bash-completion/mkfs | 2 +-
> bash-completion/mkfs.bfs | 2 +-
> bash-completion/mkfs.minix | 2 +-
> bash-completion/partx | 2 +-
> bash-completion/resizepart | 2 +-
> bash-completion/sfdisk | 2 +-
> bash-completion/wipefs | 2 +-
> 17 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/bash-completion/addpart b/bash-completion/addpart
> index 2b1e6bb..3b4e603 100644
> --- a/bash-completion/addpart
> +++ b/bash-completion/addpart
> @@ -6,7 +6,7 @@ _addpart_module()
> case $COMP_CWORD in
> 1)
> local DEVS=''
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> OPTS="--help --version $DEVS"
> COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> ;;
> diff --git a/bash-completion/blkdiscard b/bash-completion/blkdiscard
> index 310cdfb..9e2e262 100644
> --- a/bash-completion/blkdiscard
> +++ b/bash-completion/blkdiscard
> @@ -21,7 +21,7 @@ _blkdiscard_module()
> ;;
> esac
> local DEVS
> - DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/blkid b/bash-completion/blkid
> index b439328..de8b8ce 100644
> --- a/bash-completion/blkid
> +++ b/bash-completion/blkid
> @@ -60,7 +60,7 @@ _blkid_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'part' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/blockdev b/bash-completion/blockdev
> index ce986cb..4c86cda 100644
> --- a/bash-completion/blockdev
> +++ b/bash-completion/blockdev
> @@ -4,7 +4,7 @@ _blockdev_module()
> COMPREPLY=()
> cur="${COMP_WORDS[COMP_CWORD]}"
> prev="${COMP_WORDS[COMP_CWORD-1]}"
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> OPTS="-h -V -q
> --report
> --getsz
> diff --git a/bash-completion/delpart b/bash-completion/delpart
> index a4b20c8..6fa7006 100644
> --- a/bash-completion/delpart
> +++ b/bash-completion/delpart
> @@ -14,7 +14,7 @@ _delpart_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'disk' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> OPTS="--help --version $DEVICES"
> COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> ;;
> diff --git a/bash-completion/fdisk b/bash-completion/fdisk
> index b800f8d..4a59070 100644
> --- a/bash-completion/fdisk
> +++ b/bash-completion/fdisk
> @@ -9,7 +9,7 @@ _fdisk_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'part' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
> return 0
> ;;
> @@ -43,7 +43,7 @@ _fdisk_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'disk' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/findmnt b/bash-completion/findmnt
> index 9386d8f..4cb0be8 100644
> --- a/bash-completion/findmnt
> +++ b/bash-completion/findmnt
> @@ -37,7 +37,7 @@ _findmnt_module()
> for I in ${TMP_ARR[@]}; do
> MNT_OPTS[$I]='1'
> done
> - done < <(findmnt -rno OPTIONS)
> + done <<<"$(findmnt -rno OPTIONS)"
> COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) )
> return 0
> ;;
> diff --git a/bash-completion/fsck b/bash-completion/fsck
> index 04899a0..448b6b7 100644
> --- a/bash-completion/fsck
> +++ b/bash-completion/fsck
> @@ -32,7 +32,7 @@ _fsck_module()
> return 0
> ;;
> esac
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/fsck.minix b/bash-completion/fsck.minix
> index 1ec9a78..b9ff739 100644
> --- a/bash-completion/fsck.minix
> +++ b/bash-completion/fsck.minix
> @@ -9,7 +9,7 @@ _fsck.minix_module()
> return 0
> ;;
> esac
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> OPTS="-l -a -r -v -s -m -f --version"
> COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
> return 0
> diff --git a/bash-completion/lsblk b/bash-completion/lsblk
> index 07e9368..2beb8a5 100644
> --- a/bash-completion/lsblk
> +++ b/bash-completion/lsblk
> @@ -61,7 +61,7 @@ _lsblk_module()
> ;;
> esac
> local DEVS
> - DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/mkfs b/bash-completion/mkfs
> index 4e6e175..daa9ea5 100644
> --- a/bash-completion/mkfs
> +++ b/bash-completion/mkfs
> @@ -21,7 +21,7 @@ _mkfs_module()
> return 0
> ;;
> esac
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/mkfs.bfs b/bash-completion/mkfs.bfs
> index 8adbc60..4f56403 100644
> --- a/bash-completion/mkfs.bfs
> +++ b/bash-completion/mkfs.bfs
> @@ -24,7 +24,7 @@ _bfs_module()
> return 0
> ;;
> esac
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/mkfs.minix b/bash-completion/mkfs.minix
> index 78c986f..e7b60a3 100644
> --- a/bash-completion/mkfs.minix
> +++ b/bash-completion/mkfs.minix
> @@ -29,7 +29,7 @@ _mkfs.minix_module()
> ;;
> esac
> local DEVS
> - while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/partx b/bash-completion/partx
> index 7b08fa8..9b382fd 100644
> --- a/bash-completion/partx
> +++ b/bash-completion/partx
> @@ -34,7 +34,7 @@ _partx_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'disk' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/resizepart b/bash-completion/resizepart
> index c78af15..08a95f0 100644
> --- a/bash-completion/resizepart
> +++ b/bash-completion/resizepart
> @@ -14,7 +14,7 @@ _resizepart_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'disk' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> OPTS="--help --version $DEVICES"
> COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> ;;
> diff --git a/bash-completion/sfdisk b/bash-completion/sfdisk
> index 0226b04..d39e2ba 100644
> --- a/bash-completion/sfdisk
> +++ b/bash-completion/sfdisk
> @@ -75,7 +75,7 @@ _sfdisk_module()
> local DEV TYPE DEVICES=''
> while read DEV TYPE; do
> [ $TYPE = 'disk' ] && DEVICES+="$DEV "
> - done < <(lsblk -pnro name,type)
> + done <<<"$(lsblk -pnro name,type)"
> COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
> return 0
> }
> diff --git a/bash-completion/wipefs b/bash-completion/wipefs
> index e0e3286..f0a3ba6 100644
> --- a/bash-completion/wipefs
> +++ b/bash-completion/wipefs
> @@ -27,7 +27,7 @@ _wipefs_module()
> ;;
> esac
> local DEVS
> - DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
> + DEVS=''; while read dev; do DEVS+="$dev " ; done <<<"$(lsblk -pnro name)"
> COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> return 0
> }
> --
> 1.8.2.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax
2013-04-13 21:59 ` Dave Reisner
@ 2013-04-26 11:38 ` Karel Zak
2013-04-26 12:29 ` Sami Kerola
0 siblings, 1 reply; 40+ messages in thread
From: Karel Zak @ 2013-04-26 11:38 UTC (permalink / raw)
To: Sami Kerola, util-linux
On Sat, Apr 13, 2013 at 05:59:13PM -0400, Dave Reisner wrote:
> On Sat, Apr 13, 2013 at 08:54:33PM +0100, Sami Kerola wrote:
> > The '< <' syntax is bash 2.x trick, and <<< does the same job when bash
> > 3.x is in use. For some unknown reason my bash 4.2.45(2)-release became
> > allergic to old syntax today(?).
>
> I don't follow this. The syntax is <(commands), which is a process
> substitution. It creates a temporary file descriptor which can be
> redirected via <. It still very much works, and I don't expect this to
> break any time soon. It's likely more memory efficient since there's no
> need to expand the output in place -- it can just be read off of the
> file descriptor.
>
> I think you should figure out what's wrong with your shell instead of
> doing this.
Sami?
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax
2013-04-26 11:38 ` Karel Zak
@ 2013-04-26 12:29 ` Sami Kerola
0 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-26 12:29 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On 26 April 2013 12:38, Karel Zak <kzak@redhat.com> wrote:
> On Sat, Apr 13, 2013 at 05:59:13PM -0400, Dave Reisner wrote:
>> On Sat, Apr 13, 2013 at 08:54:33PM +0100, Sami Kerola wrote:
>> > The '< <' syntax is bash 2.x trick, and <<< does the same job when bash
>> > 3.x is in use. For some unknown reason my bash 4.2.45(2)-release became
>> > allergic to old syntax today(?).
>>
>> I don't follow this. The syntax is <(commands), which is a process
>> substitution. It creates a temporary file descriptor which can be
>> redirected via <. It still very much works, and I don't expect this to
>> break any time soon. It's likely more memory efficient since there's no
>> need to expand the output in place -- it can just be read off of the
>> file descriptor.
>>
>> I think you should figure out what's wrong with your shell instead of
>> doing this.
>
> Sami?
Hi Dave & Karel,
Sorry, I have forgot to have look of this. It is best to drop the
patch for now, as I am not sure why old syntax did not work for me
expected way.
--
Sami Kerola
http://www.iki.fi/kerolasa/
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH 06/33] setpriv: allow login and group name option arguments
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (4 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 05/33] bash-completion: prefer bash 3.x 'here string' syntax Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 07/33] build-sys: add --disable-setterm to ./configure Sami Kerola
` (27 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
For an average user names are easier to use than uid and gid numbers.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/setpriv.1 | 6 ++++--
sys-utils/setpriv.c | 42 ++++++++++++++++++++++++++++++------------
2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/sys-utils/setpriv.1 b/sys-utils/setpriv.1
index c56d89f..c05473c 100644
--- a/sys-utils/setpriv.1
+++ b/sys-utils/setpriv.1
@@ -55,7 +55,8 @@ inheritable set, you are likely to become confused. Do not do that.
Lists all known capabilities. Must be specified alone.
.TP
\fB\-\-ruid\fR \fIuid\fR, \fB\-\-euid\fR \fIuid\fR, \fB\-\-reuid\fR \fIuid\fR
-Sets the real, effective, or both \fIuid\fRs.
+Sets the real, effective, or both \fIuid\fRs. The uid argument can be
+given as textual login name.
.IP
Setting
.I uid
@@ -68,7 +69,8 @@ something like:
\-\-reuid=1000 \-\-\:regid=1000 \-\-\:caps=\-\:all
.TP
\fB\-\-rgid\fR \fIgid\fR, \fB\-\-egid\fR \fIgid\fR, \fB\-\-regid\fR \fIgid\fR
-Sets the real, effective, or both \fIgid\fRs.
+Sets the real, effective, or both \fIgid\fRs. The gid argument can be
+given as textual group name.
.IP
For safety, you must specify one of \-\-\:keep\-\:groups,
\-\-\:clear\-\:groups, or \-\-\:groups if you set any primary
diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index a547fd7..7fa5f82 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -23,10 +23,12 @@
#include <getopt.h>
#include <grp.h>
#include <linux/securebits.h>
+#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
+#include <sys/types.h>
#include <unistd.h>
#include "c.h"
@@ -545,6 +547,28 @@ static void do_apparmor_profile(const char *label)
_("write failed: %s"), _PATH_PROC_ATTR_EXEC);
}
+static uid_t get_user(const char *s, const char *err)
+{
+ struct passwd *pw;
+ long tmp;
+ pw = getpwnam(s);
+ if (pw)
+ return pw->pw_uid;
+ tmp = strtol_or_err(s, err);
+ return tmp;
+}
+
+static gid_t get_group(const char *s, const char *err)
+{
+ struct group *gr;
+ long tmp;
+ gr = getgrnam(s);
+ if (gr)
+ return gr->gr_gid;
+ tmp = strtol_or_err(s, err);
+ return tmp;
+}
+
int main(int argc, char **argv)
{
enum {
@@ -627,43 +651,37 @@ int main(int argc, char **argv)
if (opts.have_ruid)
errx(EXIT_FAILURE, _("duplicate ruid"));
opts.have_ruid = 1;
- opts.ruid = strtol_or_err(optarg,
- _("failed to parse ruid"));
+ opts.ruid = get_user(optarg, _("failed to parse ruid"));
break;
case EUID:
if (opts.have_euid)
errx(EXIT_FAILURE, _("duplicate euid"));
opts.have_euid = 1;
- opts.euid = strtol_or_err(optarg,
- _("failed to parse euid"));
+ opts.euid = get_user(optarg, _("failed to parse euid"));
break;
case REUID:
if (opts.have_ruid || opts.have_euid)
errx(EXIT_FAILURE, _("duplicate ruid or euid"));
opts.have_ruid = opts.have_euid = 1;
- opts.ruid = opts.euid = strtol_or_err(optarg,
- _("failed to parse reuid"));
+ opts.ruid = opts.euid = get_user(optarg, _("failed to parse reuid"));
break;
case RGID:
if (opts.have_rgid)
errx(EXIT_FAILURE, _("duplicate rgid"));
opts.have_rgid = 1;
- opts.rgid = strtol_or_err(optarg,
- _("failed to parse rgid"));
+ opts.rgid = get_group(optarg, _("failed to parse rgid"));
break;
case EGID:
if (opts.have_egid)
errx(EXIT_FAILURE, _("duplicate egid"));
opts.have_egid = 1;
- opts.egid = strtol_or_err(optarg,
- _("failed to parse egid"));
+ opts.egid = get_group(optarg, _("failed to parse egid"));
break;
case REGID:
if (opts.have_rgid || opts.have_egid)
errx(EXIT_FAILURE, _("duplicate rgid or egid"));
opts.have_rgid = opts.have_egid = 1;
- opts.rgid = opts.egid = strtol_or_err(optarg,
- _("failed to parse regid"));
+ opts.rgid = opts.egid = get_group(optarg, _("failed to parse regid"));
break;
case CLEAR_GROUPS:
if (opts.clear_groups)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 07/33] build-sys: add --disable-setterm to ./configure
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (5 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 06/33] setpriv: allow login and group name option arguments Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-26 11:53 ` Karel Zak
2013-04-13 19:54 ` [PATCH 08/33] hexdump: add long options to the command Sami Kerola
` (26 subsequent siblings)
33 siblings, 1 reply; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
configure.ac | 6 ++++++
term-utils/Makemodule.am | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index dd5d3e1..497850c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1290,6 +1290,12 @@ UL_BUILD_INIT([pg])
UL_REQUIRES_HAVE([pg], [ncurses], [ncurses or ncursesw library])
AM_CONDITIONAL(BUILD_PG, test "x$build_pg" = xyes)
+AC_ARG_ENABLE([setterm],
+ AS_HELP_STRING([--disable-setterm], [do not build setterm]),
+ [], enable_setterm=yes
+)
+UL_BUILD_INIT([setterm])
+AM_CONDITIONAL(BUILD_SETTERM, test "x$build_setterm" = xyes)
AC_ARG_ENABLE([schedutils],
AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, teskset]),
diff --git a/term-utils/Makemodule.am b/term-utils/Makemodule.am
index f4fa92d..fdf4d98 100644
--- a/term-utils/Makemodule.am
+++ b/term-utils/Makemodule.am
@@ -24,7 +24,7 @@ agetty_LDADD = $(LDADD) libcommon.la
endif # BUILD_AGETTY
-# TODO: add BUILD_SETTERM to configure.am
+if BUILD_SETTERM
if HAVE_NCURSES
if LINUX
usrbin_exec_PROGRAMS += setterm
@@ -37,6 +37,7 @@ else
setterm_LDADD = $(LDADD) @NCURSES_LIBS@
endif
endif
+endif
if BUILD_RESET
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH 07/33] build-sys: add --disable-setterm to ./configure
2013-04-13 19:54 ` [PATCH 07/33] build-sys: add --disable-setterm to ./configure Sami Kerola
@ 2013-04-26 11:53 ` Karel Zak
0 siblings, 0 replies; 40+ messages in thread
From: Karel Zak @ 2013-04-26 11:53 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Sat, Apr 13, 2013 at 08:54:35PM +0100, Sami Kerola wrote:
> +AC_ARG_ENABLE([setterm],
> + AS_HELP_STRING([--disable-setterm], [do not build setterm]),
> + [], enable_setterm=yes
> +)
> +UL_BUILD_INIT([setterm])
> +AM_CONDITIONAL(BUILD_SETTERM, test "x$build_setterm" = xyes)
>
> AC_ARG_ENABLE([schedutils],
> AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, teskset]),
> diff --git a/term-utils/Makemodule.am b/term-utils/Makemodule.am
> index f4fa92d..fdf4d98 100644
> --- a/term-utils/Makemodule.am
> +++ b/term-utils/Makemodule.am
> @@ -24,7 +24,7 @@ agetty_LDADD = $(LDADD) libcommon.la
> endif # BUILD_AGETTY
>
>
> -# TODO: add BUILD_SETTERM to configure.am
> +if BUILD_SETTERM
> if HAVE_NCURSES
> if LINUX
> usrbin_exec_PROGRAMS += setterm
> @@ -37,6 +37,7 @@ else
> setterm_LDADD = $(LDADD) @NCURSES_LIBS@
> endif
> endif
> +endif
I have applied a little different version.
The reason for BUILD_* is to describe and evaluate dependencies
in ./configure rather than in makefiles. So if you have
BUILD_SETTERM than "if LINUX" or "if HAVE_NCURSES" is usually
unwanted, because you can use
UL_BUILD_INIT([setterm])
UL_REQUIRES_LINUX([setterm])
UL_REQUIRES_HAVE([setterm], [ncurses], [ncurses library])
AM_CONDITIONAL(BUILD_SETTERM, test "x$build_setterm" = xyes)
in the configure file.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH 08/33] hexdump: add long options to the command
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (6 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 07/33] build-sys: add --disable-setterm to ./configure Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 09/33] setsid: exit when control terminal cannot be set Sami Kerola
` (25 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Includes update to bash completion, and manual as well.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
bash-completion/hexdump | 22 ++++++++++++++----
text-utils/hexdump.1 | 24 +++++++++----------
text-utils/hexsyntax.c | 61 ++++++++++++++++++++++++++++++++-----------------
3 files changed, 69 insertions(+), 38 deletions(-)
diff --git a/bash-completion/hexdump b/bash-completion/hexdump
index 0c91187..aa6f8ce 100644
--- a/bash-completion/hexdump
+++ b/bash-completion/hexdump
@@ -5,25 +5,37 @@ _hexdump_module()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
- '-e')
+ '-e'|'--format')
COMPREPLY=( $(compgen -W "format" -- $cur) )
return 0
;;
- '-n')
+ '-n'|'--length')
COMPREPLY=( $(compgen -W "length" -- $cur) )
return 0
;;
- '-s')
+ '-s'|'--skip')
COMPREPLY=( $(compgen -W "offset" -- $cur) )
return 0
;;
- '-V')
+ '-V'|'--version'|'-h'|'--help')
return 0
;;
esac
case $cur in
-*)
- OPTS="-b -c -C -d -o -x -e -f -n -s -v -V"
+ OPTS=" --one-byte-octal
+ --one-byte-char
+ --canonical
+ --two-bytes-decimal
+ --two-bytes-octal
+ --two-bytes-hex
+ --format
+ --format-file
+ --length
+ --skip
+ --no-squeezing
+ --version
+ --help"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index 903100d..e8afdba 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -31,7 +31,7 @@
.\"
.\" from: @(#)hexdump.1 8.2 (Berkeley) 4/18/94
.\"
-.TH HEXDUMP "1" "September 2011" "util-linux" "User Commands"
+.TH HEXDUMP "1" "April 2013" "util-linux" "User Commands"
.SH NAME
hexdump \- display file contents in ascii, decimal, hexadecimal, or octal
.SH SYNOPSIS
@@ -49,17 +49,17 @@ suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes
KB=1000, MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB.
.TP
-.B \-b
+\fB\-b\fR, \fB\-\-one\-byte\-octal\fR
\fIOne-byte octal display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, three-column, zero-filled bytes of input
data, in octal, per line.
.TP
-.B \-c
+\fB\-c\fR, \fB\-\-one\-byte\-char\fR
\fIOne-byte character display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, three-column, space-filled characters of
input data per line.
.TP
-.B \-C
+\fB\-C\fR, \fB\-\-canonical\fR
\fICanonical hex+ASCII display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, two-column, hexadecimal bytes, followed
by the same sixteen bytes in
@@ -68,35 +68,35 @@ format enclosed in
.RB ' | '
characters.
.TP
-.B \-d
+\fB\-d\fR, \fB\-\-two\-bytes\-decimal\fR
\fITwo-byte decimal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, five-column, zero-filled, two-byte units
of input data, in unsigned decimal, per line.
.TP
-.BI \-e \ format_string
+\fB\-e\fR, \fB\-\-format\fR \fIformat_string\fR
Specify a format string to be used for displaying data.
.TP
-.BI \-f \ format_file
+\fB\-r\fR, \fB\-\-format\-file\fR \fIfile\fR
Specify a file that contains one or more newline separated format strings.
Empty lines and lines whose first non-blank character is a hash mark (\&#)
are ignored.
.TP
-.BI \-n \ length
+\fB\-n\fR, \fB\-\-length\fR \fIlength\fR
Interpret only
.I length
bytes of input.
.TP
-.B \-o
+\fB\-o\fR, \fB\-\-two\-bytes\-octal\fR
\fITwo-byte octal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, six-column, zero-filled, two-byte
quantities of input data, in octal, per line.
.TP
-.BI \-s \ offset
+\fB\-s\fR, \fB\-\-skip\fR \fIoffset\fR
Skip
.I offset
bytes from the beginning of the input.
.TP
-.B \-v
+\fB\-v\fR, \fB\-\-no\-squeezing\fR
The
.B \-v
option causes
@@ -107,7 +107,7 @@ option, any number of groups of output lines which would be identical to the
immediately preceding group of output lines (except for the input offsets),
are replaced with a line comprised of a single asterisk.
.TP
-.B \-x
+\fB\-x\fR, \fB\-\-two\-bytes\-hex\fR
\fITwo-byte hexadecimal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, four-column, zero-filled, two-byte
quantities of input data, in hexadecimal, per line.
diff --git a/text-utils/hexsyntax.c b/text-utils/hexsyntax.c
index b0e4fb7..2910ca5 100644
--- a/text-utils/hexsyntax.c
+++ b/text-utils/hexsyntax.c
@@ -42,6 +42,7 @@
#include <errno.h>
#include <err.h>
#include <limits.h>
+#include <getopt.h>
#include "hexdump.h"
#include "nls.h"
#include "strutils.h"
@@ -56,8 +57,25 @@ newsyntax(int argc, char ***argvp)
int ch;
char **argv;
+ static const struct option longopts[] = {
+ {"one-byte-octal", no_argument, NULL, 'b'},
+ {"one-byte-char", required_argument, NULL, 'c'},
+ {"canonical", required_argument, NULL, 'C'},
+ {"two-bytes-decimal", no_argument, NULL, 'd'},
+ {"two-bytes-octal", required_argument, NULL, 'o'},
+ {"two-bytes-hex", no_argument, NULL, 'x'},
+ {"format", required_argument, NULL, 'e'},
+ {"format-file", required_argument, NULL, 'f'},
+ {"length", required_argument, NULL, 'n'},
+ {"skip", required_argument, NULL, 's'},
+ {"no-squeezing", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, no_argument, NULL, 0}
+ };
+
argv = *argvp;
- while ((ch = getopt(argc, argv, "bcCde:f:n:os:vxV")) != -1) {
+ while ((ch = getopt_long(argc, argv, "bcCde:f:n:os:vxhV", longopts, NULL)) != -1) {
switch (ch) {
case 'b':
add("\"%07.7_Ax\n\"");
@@ -99,10 +117,10 @@ newsyntax(int argc, char ***argvp)
add("\"%07.7_Ax\n\"");
add("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"");
break;
+ case 'h':
+ usage(stdout);
case 'V':
- printf(_("%s from %s\n"),
- program_invocation_short_name,
- PACKAGE_STRING);
+ printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
break;
default:
@@ -120,23 +138,24 @@ newsyntax(int argc, char ***argvp)
void __attribute__((__noreturn__)) usage(FILE *out)
{
- fprintf(out, _("\nUsage:\n"
- " %s [options] file...\n"),
- program_invocation_short_name);
- fprintf(out, _(
- "\nOptions:\n"
- " -b one-byte octal display\n"
- " -c one-byte character display\n"
- " -C canonical hex+ASCII display\n"
- " -d two-byte decimal display\n"
- " -o two-byte octal display\n"
- " -x two-byte hexadecimal display\n"
- " -e format format string to be used for displaying data\n"
- " -f format_file file that contains format strings\n"
- " -n length interpret only length bytes of input\n"
- " -s offset skip offset bytes from the beginning\n"
- " -v display without squeezing similar lines\n"
- " -V output version information and exit\n\n"));
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options] file...\n"), program_invocation_short_name);
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -b, --one-byte-octal one-byte octal display\n"), out);
+ fputs(_(" -c, --one-byte-char one-byte character display\n"), out);
+ fputs(_(" -C, --canonical canonical hex+ASCII display\n"), out);
+ fputs(_(" -d, --two-bytes-decimal two-byte decimal display\n"), out);
+ fputs(_(" -o, --two-bytes-octal two-byte octal display\n"), out);
+ fputs(_(" -x, --two-bytes-hex two-byte hexadecimal display\n"), out);
+ fputs(_(" -e, --format format format string to be used for displaying data\n"), out);
+ fputs(_(" -f, --format-file <file> file that contains format strings\n"), out);
+ fputs(_(" -n, --length <length> interpret only length bytes of input\n"), out);
+ fputs(_(" -s, --skip <offset> skip offset bytes from the beginning\n"), out);
+ fputs(_(" -v, --no-squeezing output identical lines\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+ fprintf(out, USAGE_MAN_TAIL("hexdump(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 09/33] setsid: exit when control terminal cannot be set
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (7 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 08/33] hexdump: add long options to the command Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 10/33] cfdisk: check writing to a file was successful Sami Kerola
` (24 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/setsid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/setsid.c b/sys-utils/setsid.c
index b3e6ebf..756a520 100644
--- a/sys-utils/setsid.c
+++ b/sys-utils/setsid.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
if (ctty) {
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1))
- warn(_("failed to set the controlling terminal"));
+ err(EXIT_FAILURE, _("failed to set the controlling terminal"));
}
execvp(argv[optind], argv + optind);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 10/33] cfdisk: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (8 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 09/33] setsid: exit when control terminal cannot be set Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 11/33] setpriv: " Sami Kerola
` (23 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisks/cfdisk.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index db9e233..dcaa05d 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -1849,7 +1849,11 @@ print_raw_table(void) {
if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
@@ -1966,7 +1970,11 @@ print_p_info(void) {
if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
@@ -2060,7 +2068,11 @@ print_part_table(void) {
if (to_file) {
if (!print_only)
- fclose(fp);
+ if (close_stream(fp) != 0) {
+ char errstr[LINE_LENGTH];
+ snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+ print_warning(errstr);
+ }
} else {
menuContinue();
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 11/33] setpriv: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (9 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 10/33] cfdisk: check writing to a file was successful Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 12/33] agetty: " Sami Kerola
` (22 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/setpriv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index 7fa5f82..18810c5 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -541,8 +541,9 @@ static void do_apparmor_profile(const char *label)
err(SETPRIV_EXIT_PRIVERR,
_("cannot open %s"), _PATH_PROC_ATTR_EXEC);
- if (fprintf(f, "changeprofile %s", label) < 0 || fflush(f) != 0
- || fclose(f) != 0)
+ fprintf(f, "changeprofile %s", label);
+
+ if (close_stream(f) != 0)
err(SETPRIV_EXIT_PRIVERR,
_("write failed: %s"), _PATH_PROC_ATTR_EXEC);
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 12/33] agetty: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (10 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 11/33] setpriv: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 13/33] pg: " Sami Kerola
` (21 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
term-utils/agetty.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index a23cf6d..dd52f70 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -235,6 +235,9 @@ static void login_options_to_argv(char *argv[], int *argc, char *str, char *user
static char *fakehost;
#ifdef DEBUGGING
+#ifndef
+# define DEBUG_OUTPUT "/dev/ttyp0"
+#endif
#define debug(s) do { fprintf(dbf,s); fflush(dbf); } while (0)
FILE *dbf;
#else
@@ -270,7 +273,7 @@ int main(int argc, char **argv)
sigaction(SIGINT, &sa, &sa_int);
#ifdef DEBUGGING
- dbf = fopen("/dev/ttyp0", "w");
+ dbf = fopen(DEBUG_OUTPUT, "w");
for (int i = 1; i < argc; i++)
debug(argv[i]);
#endif /* DEBUGGING */
@@ -420,6 +423,12 @@ int main(int argc, char **argv)
options.tty);
}
+#ifdef DEBUGGING
+ fprintf(dbf, "read %c\n", ch);
+ if (close_stream(dbf) != 0)
+ log_err("write failed: %s", DEBUG_OUTPUT);
+#endif
+
/* Let the login program take care of password validation. */
execv(options.login, login_argv);
log_err(_("%s: can't exec %s: %m"), options.tty, login_argv[0]);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 13/33] pg: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (11 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 12/33] agetty: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 14/33] libblkid: " Sami Kerola
` (20 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
text-utils/pg.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/text-utils/pg.c b/text-utils/pg.c
index c00b737..7ddf96b 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -1228,7 +1228,14 @@ static void pgfile(FILE *f, const char *name)
/* No error check for compat. */
fwrite_all(b, sizeof *b, sz, save);
}
- fclose(save);
+ if (close_stream(save) != 0) {
+ cmd.count = errno;
+ mesg(_("write failed"));
+ mesg(": ");
+ mesg(p);
+ mesg(strerror(cmd.count));
+ goto newcmd;
+ }
fseeko(fbuf, (off_t)0, SEEK_END);
mesg(_("saved"));
goto newcmd;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 14/33] libblkid: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (12 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 13/33] pg: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 15/33] libmount: " Sami Kerola
` (19 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
libblkid/src/evaluate.c | 4 +++-
libblkid/src/save.c | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/evaluate.c b/libblkid/src/evaluate.c
index 8853009..8ef9277 100644
--- a/libblkid/src/evaluate.c
+++ b/libblkid/src/evaluate.c
@@ -24,6 +24,7 @@
#include "pathnames.h"
#include "canonicalize.h"
+#include "closestream.h"
#include "blkidP.h"
@@ -123,7 +124,8 @@ int blkid_send_uevent(const char *devname, const char *action)
rc = 0;
if (fputs(action, f) >= 0)
rc = 0;
- fclose(f);
+ if (close_stream(f) != 0)
+ DBG(EVALUATE, blkid_debug("write failed: %s", uevent));
}
DBG(EVALUATE, blkid_debug("%s: send uevent %s",
uevent, rc == 0 ? "SUCCES" : "FAILED"));
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 86eda6c..424017a 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -21,6 +21,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+
+#include "closestream.h"
+
#include "blkidP.h"
static int save_dev(blkid_dev dev, FILE *file)
@@ -148,7 +151,9 @@ int blkid_flush_cache(blkid_cache cache)
ret = 1;
}
- fclose(file);
+ if (close_stream(file) != 0)
+ DBG(SAVE, blkid_debug("write failed: %s", filename));
+
if (opened != filename) {
if (ret < 0) {
unlink(opened);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 15/33] libmount: check writing to a file was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (13 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 14/33] libblkid: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 16/33] include: add close_fd() for noticing write errors before close() Sami Kerola
` (18 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
libmount/src/lock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index e73edf5..f381e42 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -21,6 +21,7 @@
#include <limits.h>
#include <sys/file.h>
+#include "closestream.h"
#include "pathnames.h"
#include "mountP.h"
@@ -573,7 +574,9 @@ void increment_data(const char *filename, int verbose, int loopno)
err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename);
fprintf(f, "%ld", num);
- fclose(f);
+
+ if (close_stream(f) != 0)
+ err(EXIT_FAILURE, "write failed: %s", filename);
if (verbose)
fprintf(stderr, "%d: %s: %ld --> %ld (loop=%d)\n", getpid(),
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 16/33] include: add close_fd() for noticing write errors before close()
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (14 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 15/33] libmount: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 17/33] fdformat: check writing to a file descriptor was successful Sami Kerola
` (17 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Essentially this helper function is similar to close_stream(), but for
file descriptors.
When a file descriptors are close()'d status of write is often
overlooked. The close_fd() will try to determine what happen to writes
with fsync() before closing the file descriptor.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
include/closestream.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/closestream.h b/include/closestream.h
index d61b83b..2535c8b 100644
--- a/include/closestream.h
+++ b/include/closestream.h
@@ -48,4 +48,23 @@ close_stdout(void)
_exit(EXIT_FAILURE);
}
+#ifndef HAVE_FSYNC
+static inline int
+fsync(int fd __attribute__((__unused__)))
+{
+ return 0;
+}
+#endif
+
+static inline int
+close_fd(int fd)
+{
+ const int fsync_fail = (fsync(fd) != 0);
+ const int close_fail = (close(fd) != 0);
+
+ if (fsync_fail || close_fail)
+ return EOF;
+ return 0;
+}
+
#endif /* UTIL_LINUX_CLOSESTREAM_H */
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 17/33] fdformat: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (15 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 16/33] include: add close_fd() for noticing write errors before close() Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 18/33] partx: " Sami Kerola
` (16 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/fdformat.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c
index 509a605..b50ba30 100644
--- a/disk-utils/fdformat.c
+++ b/disk-utils/fdformat.c
@@ -159,7 +159,8 @@ int main(int argc, char **argv)
(param.head == 2) ? _("Double") : _("Single"),
param.track, param.sect, param.size >> 1);
format_disk(ctrl);
- close(ctrl);
+ if (close_fd(ctrl) != 0)
+ err(EXIT_FAILURE, _("write failed"));
if (verify)
verify_disk(argv[0]);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 18/33] partx: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (16 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 17/33] fdformat: check writing to a file descriptor was successful Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 19/33] resizepart: " Sami Kerola
` (15 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/partx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/disk-utils/partx.c b/disk-utils/partx.c
index 49ef1dc..b93ddf3 100644
--- a/disk-utils/partx.c
+++ b/disk-utils/partx.c
@@ -987,6 +987,8 @@ int main(int argc, char **argv)
if (loopdev)
loopcxt_deinit(&lc);
- close(fd);
+ if (close_fd(fd) != 0)
+ err(EXIT_FAILURE, _("write failed"));
+
return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 19/33] resizepart: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (17 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 18/33] partx: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 20/33] cfdisk: " Sami Kerola
` (14 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/resizepart.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/disk-utils/resizepart.c b/disk-utils/resizepart.c
index 5517c4f..765e3a4 100644
--- a/disk-utils/resizepart.c
+++ b/disk-utils/resizepart.c
@@ -11,6 +11,7 @@
#include "partx.h"
#include "sysfs.h"
#include "strutils.h"
+#include "closestream.h"
static void __attribute__ ((__noreturn__)) usage(FILE * out)
{
@@ -73,6 +74,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
switch (c) {
@@ -102,5 +104,8 @@ int main(int argc, char **argv)
strtou64_or_err(argv[3], _("invalid length argument"))))
err(EXIT_FAILURE, _("failed to resize partition"));
+ if (close_fd(fd) != 0)
+ err(EXIT_FAILURE, _("write failed"));
+
return 0;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 20/33] cfdisk: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (18 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 19/33] resizepart: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 21/33] sfdisk: " Sami Kerola
` (13 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisks/cfdisk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index dcaa05d..e685f71 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -406,8 +406,12 @@ static void
fdexit(int ret) {
if (opened) {
if (changed)
- fsync(fd);
- close(fd);
+ if (close_fd(fd) != 0) {
+ fprintf(stderr, _("write failed\n"));
+ exit(2);
+ }
+ else
+ close(fd);
}
if (changed) {
fprintf(stderr, _("Disk has been changed.\n"));
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 21/33] sfdisk: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (19 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 20/33] cfdisk: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 22/33] wdctl: " Sami Kerola
` (12 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisks/sfdisk.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
index 3206a6b..27f62d8 100644
--- a/fdisks/sfdisk.c
+++ b/fdisks/sfdisk.c
@@ -284,12 +284,16 @@ save_sectors(char *dev, int fdin) {
}
}
- close(fdout);
+ if (close_fd(fdout) != 0) {
+ warn(_("write failed: %s"), save_sector_file);
+ return 0;
+ }
return 1;
err:
if (fdout >= 0)
- close(fdout);
+ if (close_fd(fdout) != 0)
+ warn(_("write failed: %s"), save_sector_file);
return 0;
}
@@ -355,7 +359,10 @@ restore_sectors(char *dev) {
if (!reread_disk_partition(dev, fdout)) /* closes fdout */
goto err;
close(fdin);
-
+ if (close_fd(fdout) != 0) {
+ error(_("write failed: %s"), dev);
+ return 0;
+ }
return 1;
err:
@@ -791,7 +798,7 @@ reread_disk_partition(char *dev, int fd) {
return 0;
}
- if (fsync(fd) || close(fd)) {
+ if (close_fd(fd) != 0) {
perror(dev);
warnx(_("Error closing %s\n"), dev);
return 0;
@@ -3026,7 +3033,10 @@ do_activate(char **av, int ac, char *arg) {
"but the DOS MBR will only boot a disk with 1 active partition.\n"),
i);
- close(fd);
+ if (close_fd(fd) != 0) {
+ my_warn(_("write failed"));
+ exit_status = 1;
+ }
}
static void
@@ -3074,7 +3084,10 @@ do_unhide(char **av, int ac, char *arg) {
else
exit_status = 1;
- close(fd);
+ if (close_fd(fd) != 0) {
+ my_warn(_("write failed"));
+ exit_status = 1;
+ }
}
static void
@@ -3108,7 +3121,10 @@ do_change_id(char *dev, char *pnam, char *id) {
exit_status = 1;
done:
- close(fd);
+ if (close_fd(fd) != 0) {
+ my_warn(_("write failed"));
+ exit_status = 1;
+ }
}
static void
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 22/33] wdctl: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (20 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 21/33] sfdisk: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 23/33] fsck.cramfs: " Sami Kerola
` (11 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/wdctl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
index 24ec770..af9a393 100644
--- a/sys-utils/wdctl.c
+++ b/sys-utils/wdctl.c
@@ -330,7 +330,8 @@ static int set_watchdog(struct wdinfo *wd, int timeout)
warn(_("cannot set timeout for %s"), wd->device);
}
- close(fd);
+ if (close_fd(fd))
+ warn(_("write failed"));
sigprocmask(SIG_SETMASK, &oldsigs, NULL);
printf("Set timeout to %d seconds\n", timeout);
@@ -393,7 +394,8 @@ static int read_watchdog(struct wdinfo *wd)
* the machine might end up rebooting. */
}
- close(fd);
+ if (close_fd(fd))
+ warn(_("write failed"));
sigprocmask(SIG_SETMASK, &oldsigs, NULL);
return 0;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 23/33] fsck.cramfs: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (21 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 22/33] wdctl: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 24/33] fsck.minix: " Sami Kerola
` (10 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/fsck.cramfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 5c4b8c4..3c861d5 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -513,7 +513,8 @@ static void do_file(char *path, struct cramfs_inode *i)
if (i->size)
do_uncompress(path, fd, offset, i->size);
if (opt_extract) {
- close(fd);
+ if (close_fd(fd) != 0)
+ err(FSCK_EX_ERROR, _("write failed: %s"), path);
change_file_status(path, i);
}
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 24/33] fsck.minix: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (22 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 23/33] fsck.cramfs: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 25/33] mkfs.bfs: " Sami Kerola
` (9 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/fsck.minix.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 89e96fc..c0ed017 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -1385,6 +1385,8 @@ main(int argc, char **argv) {
if (repair && !automatic)
tcsetattr(STDIN_FILENO, TCSANOW, &termios);
+ if (close_fd(IN) != 0)
+ err(FSCK_EX_ERROR, _("write failed"));
if (changed)
retcode += 3;
if (errors_uncorrected)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 25/33] mkfs.bfs: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (23 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 24/33] fsck.minix: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 26/33] mkfs.cramfs: unify write check to a file descriptor Sami Kerola
` (8 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/mkfs.bfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index 0a296f3..6f11bf7 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -289,7 +289,7 @@ int main(int argc, char **argv)
if (write(fd, &de, sizeof(de)) != sizeof(de))
err(EXIT_FAILURE, _("error writing .. entry"));
- if (close(fd) < 0)
+ if (close_fd(fd) != 0)
err(EXIT_FAILURE, _("error closing %s"), device);
return EXIT_SUCCESS;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 26/33] mkfs.cramfs: unify write check to a file descriptor
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (24 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 25/33] mkfs.bfs: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 27/33] mkfs.minix: check writing to a file descriptor was successful Sami Kerola
` (7 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/mkfs.cramfs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index b5edb7a..cb3e657 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -879,12 +879,11 @@ int main(int argc, char **argv)
(long long) fslen_ub, offset);
written = write(fd, rom_image, offset);
- close(fd);
- if (written < 0)
- err(MKFS_EX_ERROR, _("ROM image"));
if (offset != written)
errx(MKFS_EX_ERROR, _("ROM image write failed (%zd %zd)"),
written, offset);
+ if (close_fd(fd) != 0)
+ err(MKFS_EX_ERROR, _("ROM image"));
/*
* (These warnings used to come at the start, but they scroll off
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 27/33] mkfs.minix: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (25 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 26/33] mkfs.cramfs: unify write check to a file descriptor Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 28/33] mkswap: unify write check to a file descriptor Sami Kerola
` (6 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/mkfs.minix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index e80d1d6..3a1617b 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -804,7 +804,8 @@ int main(int argc, char ** argv) {
mark_good_blocks();
write_tables();
- close(DEV);
+ if (close_fd(DEV) != 0)
+ err(MKFS_EX_ERROR, _("write failed"));
return MKFS_EX_OK;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 28/33] mkswap: unify write check to a file descriptor
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (26 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 27/33] mkfs.minix: check writing to a file descriptor was successful Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 29/33] swaplabel: check writing to a file descriptor was successful Sami Kerola
` (5 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/mkswap.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index ec6fc5f..71503f4 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -625,15 +625,6 @@ main(int argc, char **argv) {
_("%s: unable to write signature page"),
device_name);
- /*
- * A subsequent swapon() will fail if the signature
- * is not actually on disk. (This is a kernel bug.)
- */
-#ifdef HAVE_FSYNC
- if (fsync(DEV))
- errx(EXIT_FAILURE, _("fsync failed"));
-#endif
-
#ifdef HAVE_LIBSELINUX
if (S_ISREG(statbuf.st_mode) && is_selinux_enabled() > 0) {
security_context_t context_string;
@@ -664,5 +655,12 @@ main(int argc, char **argv) {
freecon(oldcontext);
}
#endif
+ /*
+ * A subsequent swapon() will fail if the signature
+ * is not actually on disk. (This is a kernel bug.)
+ * The fsync() in close_fd() will take care of writing.
+ */
+ if (close_fd(DEV) != 0)
+ err(EXIT_FAILURE, _("write failed"));
return EXIT_SUCCESS;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 29/33] swaplabel: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (27 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 28/33] mkswap: unify write check to a file descriptor Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 30/33] fallocate: " Sami Kerola
` (4 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/swaplabel.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c
index 3e3e78b..a5ccb7e 100644
--- a/disk-utils/swaplabel.c
+++ b/disk-utils/swaplabel.c
@@ -145,7 +145,10 @@ static int change_info(const char *devname, const char *label, const char *uuid)
}
}
- close(fd);
+ if (close_fd(fd) != 0) {
+ warn(_("write failed: %s"), devname);
+ return -1;
+ }
return 0;
err:
if (fd >= 0)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 30/33] fallocate: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (28 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 29/33] swaplabel: check writing to a file descriptor was successful Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:54 ` [PATCH 31/33] setpriv: " Sami Kerola
` (3 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/fallocate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
index ff0f9e6..6a87673 100644
--- a/sys-utils/fallocate.c
+++ b/sys-utils/fallocate.c
@@ -168,6 +168,7 @@ int main(int argc, char **argv)
err(EXIT_FAILURE, _("%s: fallocate failed"), fname);
}
- close(fd);
+ if (close_fd(fd) != 0)
+ err(EXIT_FAILURE, _("write failed: %s"), fname);
return EXIT_SUCCESS;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 31/33] setpriv: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (29 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 30/33] fallocate: " Sami Kerola
@ 2013-04-13 19:54 ` Sami Kerola
2013-04-13 19:55 ` [PATCH 32/33] swapon: " Sami Kerola
` (2 subsequent siblings)
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:54 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/setpriv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index 18810c5..4a44106 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -526,7 +526,9 @@ static void do_selinux_label(const char *label)
err(SETPRIV_EXIT_PRIVERR,
_("write failed: %s"), _PATH_PROC_ATTR_EXEC);
- close(fd);
+ if (close_fd(fd) != 0)
+ err(SETPRIV_EXIT_PRIVERR,
+ _("write failed: %s"), _PATH_PROC_ATTR_EXEC);
}
static void do_apparmor_profile(const char *label)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 32/33] swapon: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (30 preceding siblings ...)
2013-04-13 19:54 ` [PATCH 31/33] setpriv: " Sami Kerola
@ 2013-04-13 19:55 ` Sami Kerola
2013-04-13 19:55 ` [PATCH 33/33] wall: " Sami Kerola
2013-04-17 13:31 ` [PATCH 00/33] pull: bash completions, help screens, and file writing Karel Zak
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:55 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/swapon.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index d5b7e37..f1e2433 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -323,7 +323,10 @@ static int swap_rewrite_signature(const char *devname, unsigned int pagesize)
rc = 0;
err:
- close(fd);
+ if (close_fd(fd) != 0) {
+ warn(_("write failed: %s"), devname);
+ rc = -1;
+ }
return rc;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH 33/33] wall: check writing to a file descriptor was successful
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (31 preceding siblings ...)
2013-04-13 19:55 ` [PATCH 32/33] swapon: " Sami Kerola
@ 2013-04-13 19:55 ` Sami Kerola
2013-04-17 13:31 ` [PATCH 00/33] pull: bash completions, help screens, and file writing Karel Zak
33 siblings, 0 replies; 40+ messages in thread
From: Sami Kerola @ 2013-04-13 19:55 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
term-utils/ttymsg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index 66b61b4..d610826 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -169,7 +169,8 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
*/
if (errno == ENODEV || errno == EIO)
break;
- (void) close(fd);
+ if (close_fd(fd) != 0)
+ warn(_("write failed: %s"), device);
if (forked)
_exit(EXIT_FAILURE);
if (strlen(strerror(errno)) > 1000)
@@ -184,7 +185,6 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
return (errbuf);
}
- (void) close(fd);
if (forked)
_exit(EXIT_SUCCESS);
return (NULL);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH 00/33] pull: bash completions, help screens, and file writing
2013-04-13 19:54 [PATCH 00/33] pull: bash completions, help screens, and file writing Sami Kerola
` (32 preceding siblings ...)
2013-04-13 19:55 ` [PATCH 33/33] wall: " Sami Kerola
@ 2013-04-17 13:31 ` Karel Zak
33 siblings, 0 replies; 40+ messages in thread
From: Karel Zak @ 2013-04-17 13:31 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Sat, Apr 13, 2013 at 08:54:28PM +0100, Sami Kerola wrote:
> I feel a bit like traitor. Earlier the week I mentioned in irc I would
No problem, mailing list is the best archive for patches :-)
> not send (much) changes before next release. Then things changed.
>
> There is the {u,}mount bash completion, which I promised to cover if
See the original version from bash-completion package. It also
supports filesystem specific mount options. (But I have doubts that
maintain another place where we have the option is a good idea...)
I'm going to apply the patches after 2.23 release.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 40+ messages in thread