5 Commits
10 changed files with 386 additions and 152 deletions
+2 -1
View File
@@ -4,7 +4,7 @@ dnl Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023-2024 Andrew Wood
dnl
dnl License GPLv3+: GNU GPL version 3 or later; see `docs/COPYING'.
AC_INIT([pv], [1.8.12], [pv@ivarch.com], [pv], [https://www.ivarch.com/programs/pv.shtml])
AC_INIT([pv], [1.8.13], [pv@ivarch.com], [pv], [https://www.ivarch.com/programs/pv.shtml])
AC_CONFIG_SRCDIR([src/include/config.h.in])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([src/include/config.h])
@@ -37,6 +37,7 @@ AC_CHECK_HEADERS([termios.h])
AC_CHECK_HEADERS([libgen.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([libintl.h locale.h])
AC_CHECK_HEADERS([sys/sysmacros.h])
AC_CHECK_MEMBERS([struct stat.st_blksize])
dnl Libraries that may contain key functions.
+1
View File
@@ -94,5 +94,6 @@ is acknowledged and greatly appreciated:
* [xmort](https://codeberg.org/xmort) - added "`--output`" option ([#90](https://codeberg.org/a-j-wood/pv/pulls/90))
* [bogiord](https://codeberg.org/bogiord) - reported the loss of output block device size detection in 1.8.10, and suggested the fix ([#91](https://codeberg.org/a-j-wood/pv/issues/91))
* [eborisch](https://codeberg.org/eborisch) - provided fix for misbehaviour when used with "`zfs send`" due to treating zero sized writes (generally due to timer interruption) as end of file ([#92](https://codeberg.org/a-j-wood/pv/pulls/92), [#93](https://codeberg.org/a-j-wood/pv/pulls/93))
* [alexanderperlis](https://codeberg.org/alexanderperlis) - provided initial support for block devices with "`--size @FILE`" ([#94](https://codeberg.org/a-j-wood/pv/pulls/94))
---
+4
View File
@@ -1,3 +1,7 @@
### 1.8.13 - 18 August 2024
* feature: when using "`--size @FILE`", _FILE_ can be a block device, and its size will be used (pull request [#94](https://codeberg.org/a-j-wood/pv/pulls/94)) supplied by [alexanderperlis](https://codeberg.org/alexanderperlis)
### 1.8.12 - 18 July 2024
* fix: correct the detection of output block device size that was broken in 1.8.10 ([#91](https://codeberg.org/a-j-wood/pv/issues/91))
+1 -1
View File
@@ -1,4 +1,4 @@
.TH PV 1 "July 2024" Linux "User Manuals"
.TH PV 1 "August 2024" Linux "User Manuals"
.SH NAME
pv \- monitor the progress of data through a pipe
.SH SYNOPSIS
+53 -33
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-07-18 22:11+0100\n"
"POT-Creation-Date: 2024-08-06 23:24+0100\n"
"Language: de\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Date: 1999-06-01 15:18:29+0100\n"
@@ -258,45 +258,65 @@ msgstr "Bitte senden Sie Fehlerberichte an %s"
msgid "state allocation failed"
msgstr "Zustandszuweisung fehlgeschlagen"
#: src/main/options.c:177
msgid "option structure allocation failed"
msgstr "`option' konnte nicht allokiert werden"
#: src/main/options.c:196
msgid "option structure argv allocation failed"
msgstr "`option' (argv) konnte nicht allokiert werden"
#: src/main/options.c:258
msgid "integer argument expected"
msgstr "Ganzzahliges Argument erwartet"
#: src/main/options.c:269
msgid "numeric argument expected"
msgstr "numerisches Argument erwartet"
#: src/main/options.c:280
msgid "process ID or pid:fd pair expected"
msgstr "Prozess-ID oder PID:FD-Paar erwartet"
#: src/main/options.c:287
msgid "invalid process ID"
msgstr "ungültige Prozess-ID"
#: src/main/options.c:391 src/pv/file.c:324
#: src/main/options.c:138 src/pv/file.c:324
msgid "failed to stat file"
msgstr "Dateiinformationen konnten nicht gelesen werden"
#: src/main/options.c:502
#: src/main/options.c:152
msgid "is a directory"
msgstr ""
#: src/main/options.c:181
msgid "failed to generate sysfs filename"
msgstr ""
#: src/main/options.c:203
msgid "failed to read sysfs size file"
msgstr ""
#: src/main/options.c:223
msgid "failed to open block device"
msgstr ""
#: src/main/options.c:233
msgid "failed to determine size of block device"
msgstr ""
#: src/main/options.c:334
msgid "option structure allocation failed"
msgstr "`option' konnte nicht allokiert werden"
#: src/main/options.c:353
msgid "option structure argv allocation failed"
msgstr "`option' (argv) konnte nicht allokiert werden"
#: src/main/options.c:415
msgid "integer argument expected"
msgstr "Ganzzahliges Argument erwartet"
#: src/main/options.c:426
msgid "numeric argument expected"
msgstr "numerisches Argument erwartet"
#: src/main/options.c:437
msgid "process ID or pid:fd pair expected"
msgstr "Prozess-ID oder PID:FD-Paar erwartet"
#: src/main/options.c:444
msgid "invalid process ID"
msgstr "ungültige Prozess-ID"
#: src/main/options.c:647
#, c-format
msgid "Try `%s --help' for more information."
msgstr "`%s --help' zeigt weitere Informationen an."
#: src/main/options.c:504
#: src/main/options.c:649
#, c-format
msgid "Try `%s -h' for more information."
msgstr "`%s -h' zeigt weitere Informationen an."
#: src/main/options.c:535
#: src/main/options.c:680
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
@@ -304,23 +324,23 @@ msgstr ""
"Beim Anzeigen von Dateideskriptoren können keine Optionen für den "
"Zeilenmodus oder den Übertragungsmodifikator verwendet werden"
#: src/main/options.c:544
#: src/main/options.c:689
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"Beim Anzeigen von Dateideskriptoren können keine Zeilenmodus- oder "
"Übertragungsmodifikatoroptionen verwendet werden."
#: src/main/options.c:553
#: src/main/options.c:698
msgid "cannot use remote control when watching file descriptors"
msgstr ""
"kann keine Fernbedienung verwenden, wenn Dateideskriptoren angezeigt werden"
#: src/main/options.c:562
#: src/main/options.c:707
msgid "cannot transfer files when watching file descriptors"
msgstr ""
"Dateien können beim Betrachten von Dateideskriptoren nicht übertragen werden"
#: src/main/options.c:577
#: src/main/options.c:722
msgid "not available on systems without /proc/self/fdinfo"
msgstr "Nicht verfügbar auf Systemen ohne /proc/self/fdinfo"
+53 -33
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-07-18 22:11+0100\n"
"POT-Creation-Date: 2024-08-06 23:24+0100\n"
"Language: fr\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Date: 1999-06-01 15:18:29+0100\n"
@@ -259,45 +259,65 @@ msgstr "SVP rapporter tous bogues à %s"
msgid "state allocation failed"
msgstr "échec de l'allocation de mémoire de condition"
#: src/main/options.c:177
msgid "option structure allocation failed"
msgstr "l'allocation pour la structure d'une option a échoué"
#: src/main/options.c:196
msgid "option structure argv allocation failed"
msgstr "l'allocation pour la structure de l'option argv a échoué"
#: src/main/options.c:258
msgid "integer argument expected"
msgstr "Valeur entière attendue"
#: src/main/options.c:269
msgid "numeric argument expected"
msgstr "Valeur numérique attendue"
#: src/main/options.c:280
msgid "process ID or pid:fd pair expected"
msgstr "ID de processus ou paire pid:fd attendue"
#: src/main/options.c:287
msgid "invalid process ID"
msgstr "ID de processus non valide"
#: src/main/options.c:391 src/pv/file.c:324
#: src/main/options.c:138 src/pv/file.c:324
msgid "failed to stat file"
msgstr "échec à statuer sur le fichier"
#: src/main/options.c:502
#: src/main/options.c:152
msgid "is a directory"
msgstr ""
#: src/main/options.c:181
msgid "failed to generate sysfs filename"
msgstr ""
#: src/main/options.c:203
msgid "failed to read sysfs size file"
msgstr ""
#: src/main/options.c:223
msgid "failed to open block device"
msgstr ""
#: src/main/options.c:233
msgid "failed to determine size of block device"
msgstr ""
#: src/main/options.c:334
msgid "option structure allocation failed"
msgstr "l'allocation pour la structure d'une option a échoué"
#: src/main/options.c:353
msgid "option structure argv allocation failed"
msgstr "l'allocation pour la structure de l'option argv a échoué"
#: src/main/options.c:415
msgid "integer argument expected"
msgstr "Valeur entière attendue"
#: src/main/options.c:426
msgid "numeric argument expected"
msgstr "Valeur numérique attendue"
#: src/main/options.c:437
msgid "process ID or pid:fd pair expected"
msgstr "ID de processus ou paire pid:fd attendue"
#: src/main/options.c:444
msgid "invalid process ID"
msgstr "ID de processus non valide"
#: src/main/options.c:647
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Essayez `%s --help' pour plus d'informations."
#: src/main/options.c:504
#: src/main/options.c:649
#, c-format
msgid "Try `%s -h' for more information."
msgstr "Essayez `%s -h' pour plus d'informations."
#: src/main/options.c:535
#: src/main/options.c:680
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
@@ -305,25 +325,25 @@ msgstr ""
"impossible d'utiliser le mode ligne ou les options de modificateur de "
"transfert lors de la visualisation des descripteurs de fichiers"
#: src/main/options.c:544
#: src/main/options.c:689
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"impossible d'utiliser le positionnement du curseur lors de la visualisation "
"des descripteurs de fichier"
#: src/main/options.c:553
#: src/main/options.c:698
msgid "cannot use remote control when watching file descriptors"
msgstr ""
"impossible d'utiliser la télécommande lors de la visualisation des "
"descripteurs de fichiers"
#: src/main/options.c:562
#: src/main/options.c:707
msgid "cannot transfer files when watching file descriptors"
msgstr ""
"impossible de transférer des fichiers lorsque vous regardez des descripteurs "
"de fichiers"
#: src/main/options.c:577
#: src/main/options.c:722
msgid "not available on systems without /proc/self/fdinfo"
msgstr "non disponible sur les systèmes sans /proc/self/fdinfo"
+53 -33
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-07-18 22:11+0100\n"
"POT-Creation-Date: 2024-08-06 23:24+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -252,63 +252,83 @@ msgstr "Proszę przesyłać zgłoszenia błędów do %s"
msgid "state allocation failed"
msgstr ""
#: src/main/options.c:177
msgid "option structure allocation failed"
msgstr "nie udało się zaalokować struktur opcji"
#: src/main/options.c:196
msgid "option structure argv allocation failed"
msgstr "nie udało się zaalokować struktur opcji argv"
#: src/main/options.c:258
msgid "integer argument expected"
msgstr ""
#: src/main/options.c:269
msgid "numeric argument expected"
msgstr ""
#: src/main/options.c:280
msgid "process ID or pid:fd pair expected"
msgstr ""
#: src/main/options.c:287
msgid "invalid process ID"
msgstr ""
#: src/main/options.c:391 src/pv/file.c:324
#: src/main/options.c:138 src/pv/file.c:324
msgid "failed to stat file"
msgstr "nie udało się wykonać operacji stat na pliku"
#: src/main/options.c:502
#: src/main/options.c:152
msgid "is a directory"
msgstr ""
#: src/main/options.c:181
msgid "failed to generate sysfs filename"
msgstr ""
#: src/main/options.c:203
msgid "failed to read sysfs size file"
msgstr ""
#: src/main/options.c:223
msgid "failed to open block device"
msgstr ""
#: src/main/options.c:233
msgid "failed to determine size of block device"
msgstr ""
#: src/main/options.c:334
msgid "option structure allocation failed"
msgstr "nie udało się zaalokować struktur opcji"
#: src/main/options.c:353
msgid "option structure argv allocation failed"
msgstr "nie udało się zaalokować struktur opcji argv"
#: src/main/options.c:415
msgid "integer argument expected"
msgstr ""
#: src/main/options.c:426
msgid "numeric argument expected"
msgstr ""
#: src/main/options.c:437
msgid "process ID or pid:fd pair expected"
msgstr ""
#: src/main/options.c:444
msgid "invalid process ID"
msgstr ""
#: src/main/options.c:647
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Spróbuj `%s --help' by uzyskać więcej informacji"
#: src/main/options.c:504
#: src/main/options.c:649
#, c-format
msgid "Try `%s -h' for more information."
msgstr "Spróbuj `%s -h' by uzyskać więcej informacji"
#: src/main/options.c:535
#: src/main/options.c:680
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:544
#: src/main/options.c:689
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:553
#: src/main/options.c:698
msgid "cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:562
#: src/main/options.c:707
msgid "cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:577
#: src/main/options.c:722
msgid "not available on systems without /proc/self/fdinfo"
msgstr ""
+53 -33
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-07-18 22:11+0100\n"
"POT-Creation-Date: 2024-08-06 23:24+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -252,45 +252,65 @@ msgstr "Por favor, reporte quaisquer defeitos para %s"
msgid "state allocation failed"
msgstr "alocação de memória de status falhou"
#: src/main/options.c:177
msgid "option structure allocation failed"
msgstr "erro na alocação da estrutura de opções"
#: src/main/options.c:196
msgid "option structure argv allocation failed"
msgstr "erro na alocação da estrutura de opções argv"
#: src/main/options.c:258
msgid "integer argument expected"
msgstr "argumento inteiro esperado"
#: src/main/options.c:269
msgid "numeric argument expected"
msgstr "argumento numérico esperado"
#: src/main/options.c:280
msgid "process ID or pid:fd pair expected"
msgstr "ID do processo ou par pid:fd esperado"
#: src/main/options.c:287
msgid "invalid process ID"
msgstr "ID de processo inválido"
#: src/main/options.c:391 src/pv/file.c:324
#: src/main/options.c:138 src/pv/file.c:324
msgid "failed to stat file"
msgstr "erro obtendo informações do arquivo"
#: src/main/options.c:502
#: src/main/options.c:152
msgid "is a directory"
msgstr ""
#: src/main/options.c:181
msgid "failed to generate sysfs filename"
msgstr ""
#: src/main/options.c:203
msgid "failed to read sysfs size file"
msgstr ""
#: src/main/options.c:223
msgid "failed to open block device"
msgstr ""
#: src/main/options.c:233
msgid "failed to determine size of block device"
msgstr ""
#: src/main/options.c:334
msgid "option structure allocation failed"
msgstr "erro na alocação da estrutura de opções"
#: src/main/options.c:353
msgid "option structure argv allocation failed"
msgstr "erro na alocação da estrutura de opções argv"
#: src/main/options.c:415
msgid "integer argument expected"
msgstr "argumento inteiro esperado"
#: src/main/options.c:426
msgid "numeric argument expected"
msgstr "argumento numérico esperado"
#: src/main/options.c:437
msgid "process ID or pid:fd pair expected"
msgstr "ID do processo ou par pid:fd esperado"
#: src/main/options.c:444
msgid "invalid process ID"
msgstr "ID de processo inválido"
#: src/main/options.c:647
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Tente `%s --help' para maiores informações."
#: src/main/options.c:504
#: src/main/options.c:649
#, c-format
msgid "Try `%s -h' for more information."
msgstr "Tente `%s -h' para maiores informações."
#: src/main/options.c:535
#: src/main/options.c:680
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
@@ -298,21 +318,21 @@ msgstr ""
"não pode usar o modo de linha ou opções de modificador de transferência ao "
"assistir os descritores de arquivo"
#: src/main/options.c:544
#: src/main/options.c:689
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"não pode usar o posicionamento do cursor ao observar os descritores de "
"arquivo"
#: src/main/options.c:553
#: src/main/options.c:698
msgid "cannot use remote control when watching file descriptors"
msgstr "não pode usar o controle remoto ao assistir os descritores de arquivo"
#: src/main/options.c:562
#: src/main/options.c:707
msgid "cannot transfer files when watching file descriptors"
msgstr "não pode transferir arquivos ao assistir descritores de arquivo"
#: src/main/options.c:577
#: src/main/options.c:722
msgid "not available on systems without /proc/self/fdinfo"
msgstr "não disponível em sistemas sem /proc/self/fdinfo"
+3
View File
@@ -169,6 +169,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#undef HAVE_SYS_SYSMACROS_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
+163 -18
View File
@@ -15,6 +15,15 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#ifdef major
#ifdef minor
#define CAN_BUILD_SYSFS_FILENAME 1
#endif
#endif
#endif
#include <fcntl.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@@ -88,6 +97,154 @@ bool opts_add_file(opts_t opts, const char *filename)
}
/*
* Set opts->size from the size of the file whose name is size_file,
* returning false (and reporting the error) if there is a problem.
*
* If size_file points to a block device, the size of the block device is
* used.
*/
static bool opts_use_size_of_file(opts_t opts, const char *size_file)
{
struct stat sb;
int stat_rc;
#ifdef CAN_BUILD_SYSFS_FILENAME
char sysfs_filename[512]; /* flawfinder: ignore */
FILE *sysfs_fptr;
long long sysfs_size;
#endif /* CAN_BUILD_SYSFS_FILENAME */
int device_fd;
off_t device_size;
/*
* flawfinder rationale: sysfs_filename is only used with
* pv_snprintf() which guarantees it will be bounded and zero
* terminated.
*/
stat_rc = 0;
memset(&sb, 0, sizeof(sb));
stat_rc = stat(size_file, &sb);
if (0 != stat_rc) {
/*@-mustfreefresh@ */
/*
* splint note: the gettext calls made by _() cause memory
* leak warnings, but in this case it's unavoidable, and
* mitigated by the fact we only translate each string once.
*/
fprintf(stderr, "%s: %s: %s: %s\n",
opts->program_name, size_file, _("failed to stat file"), strerror(errno));
return false;
/*@+mustfreefresh@ */
}
/* This was a regular file - use its size and return. */
if (S_ISREG((mode_t) (sb.st_mode))) {
opts->size = (off_t) (sb.st_size);
return true;
}
/* This was a directory - report an error. */
if (S_ISDIR((mode_t) (sb.st_mode))) {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s\n", opts->program_name, size_file, _("is a directory"));
return false;
/*@+mustfreefresh@ */
}
/* This was not a block device - just use the size and return. */
if (!S_ISBLK((mode_t) (sb.st_mode))) {
opts->size = (off_t) (sb.st_size);
return true;
}
/*
* Block device - determine its size by looking for
* /sys/dev/block/MAJOR:MINOR/size, and if that fails, try opening
* the file and seeking to the end.
*/
#ifdef CAN_BUILD_SYSFS_FILENAME
/*
* Try the sysfs method - lightest touch and requires no read access
* to the actual block device.
*/
memset(sysfs_filename, 0, sizeof(sysfs_filename));
if (pv_snprintf
(sysfs_filename, sizeof(sysfs_filename), "/sys/dev/block/%u:%u/size", major(sb.st_rdev),
minor(sb.st_rdev)) < 0) {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s: %s\n",
opts->program_name, size_file, _("failed to generate sysfs filename"), strerror(errno));
return false;
/*@+mustfreefresh@ */
}
sysfs_fptr = fopen(sysfs_filename, "r"); /* flawfinder: ignore */
/*
* flawfinder rationale: sysfs is trusted here, the filename is
* predictable, and we are restricted to reading one number.
*/
if (NULL != sysfs_fptr) {
sysfs_size = -1;
if (1 == fscanf(sysfs_fptr, "%lld", &sysfs_size)) {
/* Read successful - use the value (* 512) and return. */
(void) fclose(sysfs_fptr);
opts->size = (off_t) sysfs_size *512;
return true;
}
/* Read not successful - report the error and return. */
/* NB we must fclose() after reporting to retain errno. */
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s: %s\n",
opts->program_name, size_file, _("failed to read sysfs size file"), strerror(errno));
(void) fclose(sysfs_fptr);
return false;
/*@+mustfreefresh@ */
}
#endif /* CAN_BUILD_SYSFS_FILENAME */
/*
* Try opening the block device and seeking to the end.
*/
device_fd = open(size_file, O_RDONLY); /* flawfinder: ignore */
/*
* flawfinder rationale: the filename is under the direct control of
* the operator by its nature, so we can't refuse to open symlinks
* etc as that would be counterintuitive.
*/
if (device_fd < 0) {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s: %s\n",
opts->program_name, size_file, _("failed to open block device"), strerror(errno));
return false;
/*@+mustfreefresh@ */
}
device_size = (off_t) lseek(device_fd, 0, SEEK_END);
if (device_size < 0) {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s: %s\n",
opts->program_name, size_file, _("failed to determine size of block device"), strerror(errno));
/* NB close() after reporting error, to preserve errno. */
(void) close(device_fd);
return false;
/*@+mustfreefresh@ */
}
(void) close(device_fd);
/* Use the size we found. */
opts->size = device_size;
return true;
}
/*
* Parse the given command-line arguments into an opts_t object, handling
* "help" and "version" options internally.
@@ -373,28 +530,16 @@ opts_t opts_parse(unsigned int argc, char **argv)
opts->delay_start = pv_getnum_interval(optarg);
break;
case 's':
/* Permit "@<filename>" as well as just a number. */
if ('@' == *optarg) {
if ('@' != *optarg) {
/* A number was passed, not "@<filename>". */
opts->size = pv_getnum_size(optarg, opts->decimal_units);
} else {
/* Permit "@<filename>". */
const char *size_file = 1 + optarg;
struct stat sb;
int rc;
rc = 0;
memset(&sb, 0, sizeof(sb));
rc = stat(size_file, &sb);
if (0 == rc) {
opts->size = (off_t) (sb.st_size);
} else {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s %s: %s\n",
opts->program_name,
_("failed to stat file"), size_file, strerror(errno));
if (!opts_use_size_of_file(opts, size_file)) {
opts_free(opts);
return NULL;
/*@+mustfreefresh@ */
}
} else {
opts->size = pv_getnum_size(optarg, opts->decimal_units);
}
break;
case 'l':