* [PATCH 00/12] another BSD/OSX related patch-set
@ 2016-03-07 23:11 Ruediger Meier
2016-03-07 23:11 ` [PATCH 01/12] wipefs, sfdisk: include libgen.h for basename(3p) Ruediger Meier
` (12 more replies)
0 siblings, 13 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
This is github pull request #299
https://github.com/karelzak/util-linux/pull/299
Again some arbitrary BSD, OSX and musl related fixes and clean-up
patches. Most of them are nice to have for our major target too, most
notable "tests: don't skip case output undefined".
openBSD build runs fine now like this:
$ ./configure --enable-all-programs \
--disable-ipcrm --disable-ipcs --disable-uuidd
make check survives most tests.
For OSX one should additionally disable all utmp.h related programs.
Almost no interesting compiler warnings left. Xcode/clang warnings are
a bit over the top anyways.
Ruediger Meier (12):
wipefs, sfdisk: include libgen.h for basename(3p)
misc: again fixing many printf format strings
lib: include sys/stat.h for struct stat
fdisk: sun, undef HAVE_QSORT_R for non-Linux
libfdisk: remove ifdef HDIO_GETGEO
misc: never cast void* from malloc(3) and friends
libmount: don't include libio.h
tests: cramfs, fix root group
tests: don't skip case "output undefined"
tests: getopt2, add function gnu_getopt_clean()
tests: improve getopt loop error case
getopt: fix -n name for BSD
disk-utils/fdisk.c | 25 +++++----
disk-utils/fsck.minix.c | 5 +-
disk-utils/mkfs.minix.c | 5 +-
disk-utils/mkswap.c | 6 +--
disk-utils/sfdisk.c | 18 ++++---
include/blkdev.h | 1 +
lib/setproctitle.c | 2 +-
lib/strutils.c | 2 +-
libblkid/samples/partitions.c | 4 +-
libblkid/src/cache.c | 2 +-
libblkid/src/config.c | 2 +-
libblkid/src/dev.c | 2 +-
libblkid/src/partitions/partitions.c | 6 +--
libblkid/src/probe.c | 28 +++++-----
libblkid/src/superblocks/drbdproxy_datalog.c | 2 +-
libblkid/src/superblocks/ntfs.c | 8 +--
libblkid/src/superblocks/vfat.c | 3 +-
libblkid/src/tag.c | 2 +-
libfdisk/src/alignment.c | 2 +-
libfdisk/src/ask.c | 4 +-
libfdisk/src/dos.c | 2 +-
libfdisk/src/gpt.c | 26 ++++-----
libfdisk/src/partition.c | 31 ++++++-----
libfdisk/src/script.c | 20 +++----
libfdisk/src/sgi.c | 3 +-
libfdisk/src/sun.c | 7 ++-
libfdisk/src/table.c | 12 +++--
libmount/src/btrfs.c | 2 +-
login-utils/last.c | 2 +-
login-utils/login.c | 2 +-
misc-utils/getopt.c | 11 +++-
misc-utils/test_uuidd.c | 4 +-
misc-utils/wipefs.c | 18 ++++---
sys-utils/swapon-common.c | 4 +-
term-utils/agetty.c | 2 +-
tests/expected/build-sys/config | 0
tests/expected/colcrt/functional | 0
tests/expected/colcrt/regressions | 0
tests/expected/cramfs/mkfs-endianness | 80 +++++++++++++++++++++++++++-
tests/expected/eject/umount | 0
tests/expected/libmount/context-utab | 3 +-
tests/expected/libmount/context-utab-py | 3 +-
tests/expected/libmount/tabdiff | 0
tests/expected/logger/errors | 0
tests/expected/logger/formats | 0
tests/expected/logger/options | 0
tests/expected/losetup/losetup | 0
tests/expected/minix/mkfs | 0
tests/expected/misc/getopt2 | 19 -------
tests/expected/misc/getopt3 | 0
tests/expected/mount/fstab-btrfs | 1 -
tests/expected/mount/umount-alltargets | 1 -
tests/expected/script/options | 0
tests/expected/sfdisk/dos | 0
tests/expected/sfdisk/gpt | 0
tests/expected/sfdisk/resize | 0
tests/functions.sh | 48 +++++++----------
tests/ts/cramfs/mkfs | 19 ++++---
tests/ts/cramfs/mkfs-endianness | 5 +-
tests/ts/libmount/context-utab | 47 ++++++++--------
tests/ts/libmount/context-utab-py | 58 ++++++++++----------
tests/ts/losetup/losetup | 1 -
tests/ts/misc/getopt | 13 ++---
tests/ts/misc/getopt2 | 55 ++++++++++++-------
text-utils/col.c | 4 +-
65 files changed, 364 insertions(+), 268 deletions(-)
delete mode 100644 tests/expected/build-sys/config
delete mode 100644 tests/expected/colcrt/functional
delete mode 100644 tests/expected/colcrt/regressions
delete mode 100644 tests/expected/eject/umount
delete mode 100644 tests/expected/libmount/tabdiff
delete mode 100644 tests/expected/logger/errors
delete mode 100644 tests/expected/logger/formats
delete mode 100644 tests/expected/logger/options
delete mode 100644 tests/expected/losetup/losetup
delete mode 100644 tests/expected/minix/mkfs
delete mode 100644 tests/expected/misc/getopt2
delete mode 100644 tests/expected/misc/getopt3
delete mode 100644 tests/expected/mount/fstab-btrfs
delete mode 100644 tests/expected/script/options
delete mode 100644 tests/expected/sfdisk/dos
delete mode 100644 tests/expected/sfdisk/gpt
delete mode 100644 tests/expected/sfdisk/resize
--
1.9.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/12] wipefs, sfdisk: include libgen.h for basename(3p)
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 02/12] misc: again fixing many printf format strings Ruediger Meier
` (11 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
disk-utils/sfdisk.c | 1 +
misc-utils/wipefs.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 81371eb..14c7cc0 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -35,6 +35,7 @@
#ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
#endif
+#include <libgen.h>
#include "c.h"
#include "xalloc.h"
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index 5948944..abcf5eb 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -29,6 +29,7 @@
#include <getopt.h>
#include <string.h>
#include <limits.h>
+#include <libgen.h>
#include <blkid.h>
@@ -378,9 +379,12 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags)
if (zap && (flags & WP_FL_BACKUP)) {
const char *home = getenv ("HOME");
+ char *tmp = xstrdup(devname);
+
if (!home)
errx(EXIT_FAILURE, _("failed to create a signature backup, $HOME undefined"));
- xasprintf (&backup, "%s/wipefs-%s-", home, basename(devname));
+ xasprintf (&backup, "%s/wipefs-%s-", home, basename(tmp));
+ free(tmp);
}
wp0 = clone_offset(wp);
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/12] misc: again fixing many printf format strings
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
2016-03-07 23:11 ` [PATCH 01/12] wipefs, sfdisk: include libgen.h for basename(3p) Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 03/12] lib: include sys/stat.h for struct stat Ruediger Meier
` (10 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
This is again a huge patch regarding printf format strings to
fix compiler warnings seen on clang/OSX.
I'm trying to follow these rules strictly:
#type #format #cast
uintmax_t %ju -
intmax_t %jd -
uint64_t PRIu64 -
int64_t PRId64 -
size_t %zu -
ssize_t %zd -
ino_t %ju (uintmax_t)
off_t %jd (intmax_t)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
disk-utils/fdisk.c | 25 +++++++++++++---------
disk-utils/fsck.minix.c | 5 +++--
disk-utils/mkfs.minix.c | 5 +++--
disk-utils/mkswap.c | 4 ++--
disk-utils/sfdisk.c | 17 ++++++++-------
libblkid/samples/partitions.c | 4 ++--
libblkid/src/partitions/partitions.c | 6 +++---
libblkid/src/probe.c | 28 +++++++++++++------------
libblkid/src/superblocks/drbdproxy_datalog.c | 2 +-
libblkid/src/superblocks/ntfs.c | 8 +++----
libblkid/src/superblocks/vfat.c | 3 ++-
libfdisk/src/alignment.c | 2 +-
libfdisk/src/ask.c | 4 ++--
libfdisk/src/dos.c | 2 +-
libfdisk/src/gpt.c | 26 ++++++++++++-----------
libfdisk/src/partition.c | 31 +++++++++++++++-------------
libfdisk/src/script.c | 20 +++++++++---------
libfdisk/src/table.c | 12 +++++++----
misc-utils/wipefs.c | 12 +++++------
19 files changed, 119 insertions(+), 97 deletions(-)
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index 304eccc..3aa915b 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -194,7 +194,7 @@ static int ask_number(struct fdisk_context *cxt,
assert(q);
DBG(ASK, ul_debug("asking for number "
- "['%s', <%ju,%ju>, default=%ju, range: %s]",
+ "['%s', <%"PRIu64",%"PRIu64">, default=%"PRIu64", range: %s]",
q, low, high, dflt, range));
if (range && dflt >= low && dflt <= high) {
@@ -202,7 +202,7 @@ static int ask_number(struct fdisk_context *cxt,
snprintf(prompt, sizeof(prompt), _("%s (%s, default %c): "),
q, range, tochar(dflt));
else
- snprintf(prompt, sizeof(prompt), _("%s (%s, default %ju): "),
+ snprintf(prompt, sizeof(prompt), _("%s (%s, default %"PRIu64"): "),
q, range, dflt);
} else if (dflt >= low && dflt <= high) {
@@ -210,13 +210,14 @@ static int ask_number(struct fdisk_context *cxt,
snprintf(prompt, sizeof(prompt), _("%s (%c-%c, default %c): "),
q, tochar(low), tochar(high), tochar(dflt));
else
- snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju, default %ju): "),
+ snprintf(prompt, sizeof(prompt),
+ _("%s (%"PRIu64"-%"PRIu64", default %"PRIu64"): "),
q, low, high, dflt);
} else if (inchar)
snprintf(prompt, sizeof(prompt), _("%s (%c-%c): "),
q, tochar(low), tochar(high));
else
- snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju): "),
+ snprintf(prompt, sizeof(prompt), _("%s (%"PRIu64"-%"PRIu64"): "),
q, low, high);
do {
@@ -264,15 +265,19 @@ static int ask_offset(struct fdisk_context *cxt,
assert(q);
- DBG(ASK, ul_debug("asking for offset ['%s', <%ju,%ju>, base=%ju, default=%ju, range: %s]",
+ DBG(ASK, ul_debug("asking for offset ['%s', <%"PRIu64",%"PRIu64">, base=%"PRIu64", default=%"PRIu64", range: %s]",
q, low, high, base, dflt, range));
if (range && dflt >= low && dflt <= high)
- snprintf(prompt, sizeof(prompt), _("%s (%s, default %ju): "), q, range, dflt);
+ snprintf(prompt, sizeof(prompt), _("%s (%s, default %"PRIu64"): "),
+ q, range, dflt);
else if (dflt >= low && dflt <= high)
- snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju, default %ju): "), q, low, high, dflt);
+ snprintf(prompt, sizeof(prompt),
+ _("%s (%"PRIu64"-%"PRIu64", default %"PRIu64"): "),
+ q, low, high, dflt);
else
- snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju): "), q, low, high);
+ snprintf(prompt, sizeof(prompt), _("%s (%"PRIu64"-%"PRIu64"): "),
+ q, low, high);
do {
uintmax_t num = 0;
@@ -629,7 +634,7 @@ static void dump_buffer(off_t base, unsigned char *buf, size_t sz, int all)
if (l == 0) {
if (all == 0 && !next)
next = skip_empty(buf, i, sz);
- printf("%08jx ", base + i);
+ printf("%08jx ", (intmax_t)base + i);
}
printf(" %02x", buf[i]);
if (l == 7) /* words separator */
@@ -653,7 +658,7 @@ static void dump_blkdev(struct fdisk_context *cxt, const char *name,
{
int fd = fdisk_get_devfd(cxt);
- fdisk_info(cxt, _("\n%s: offset = %ju, size = %zu bytes."),
+ fdisk_info(cxt, _("\n%s: offset = %"PRIu64", size = %zu bytes."),
name, offset, size);
assert(fd >= 0);
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index a040cf5..aa64569 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -626,7 +626,8 @@ read_tables(void) {
if (show) {
printf(_("%ld inodes\n"), inodes);
printf(_("%ld blocks\n"), zones);
- printf(_("Firstdatazone=%jd (%jd)\n"), first_zone, norm_first_zone);
+ printf(_("Firstdatazone=%jd (%jd)\n"),
+ (intmax_t)first_zone, (intmax_t)norm_first_zone);
printf(_("Zonesize=%d\n"), MINIX_BLOCK_SIZE << get_zone_size());
printf(_("Maxsize=%zu\n"), get_max_size());
if (fs_version < 3)
@@ -1053,7 +1054,7 @@ check_file2(struct minix2_inode *dir, unsigned int offset) {
name_depth++;
if (list) {
if (verbose)
- printf("%6ju %07o %3d ", ino, inode->i_mode,
+ printf("%6ju %07o %3d ", (uintmax_t)ino, inode->i_mode,
inode->i_nlinks);
get_current_name();
printf("%s", current_name);
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 24e6188..a4118f1 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -543,7 +543,7 @@ static void setup_tables(const struct fs_control *ctl) {
errx(MKFS_EX_ERROR,
_("First data block at %jd, which is too far (max %d).\n"
"Try specifying fewer inodes by passing --inodes <num>"),
- first_zone_data(),
+ (intmax_t)first_zone_data(),
MINIX_MAX_INODES);
imaps = get_nimaps();
zmaps = get_nzmaps();
@@ -563,7 +563,8 @@ static void setup_tables(const struct fs_control *ctl) {
printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes);
printf(P_("%lu block\n", "%lu blocks\n", zones), zones);
- printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data());
+ printf(_("Firstdatazone=%jd (%jd)\n"),
+ (intmax_t)get_first_zone(), (intmax_t)first_zone_data());
printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size());
printf(_("Maxsize=%zu\n\n"),get_max_size());
}
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index ae02de5..52ee8c6 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -443,7 +443,7 @@ int main(int argc, char **argv)
else if (ctl.npages > sz && !ctl.force)
errx(EXIT_FAILURE,
_("error: "
- "size %llu KiB is larger than device size %ju KiB"),
+ "size %llu KiB is larger than device size %"PRIu64" KiB"),
ctl.npages * (ctl.pagesize / 1024), sz * (ctl.pagesize / 1024));
if (ctl.npages < MIN_GOODPAGES)
@@ -489,7 +489,7 @@ int main(int argc, char **argv)
sz = (ctl.npages - ctl.nbadpages - 1) * ctl.pagesize;
strsz = size_to_human_string(SIZE_SUFFIX_SPACE | SIZE_SUFFIX_3LETTER, sz);
- printf(_("Setting up swapspace version %d, size = %s (%ju bytes)\n"),
+ printf(_("Setting up swapspace version %d, size = %s (%"PRIu64" bytes)\n"),
version, strsz, sz);
free(strsz);
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 14c7cc0..3dfdd9e 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -278,7 +278,7 @@ static void backup_sectors(struct sfdisk *sf,
devfd = fdisk_get_devfd(sf->cxt);
assert(devfd >= 0);
- xasprintf(&fname, "%s0x%08jx.bak", tpl, offset);
+ xasprintf(&fname, "%s0x%08"PRIx64".bak", tpl, offset);
fd = open(fname, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
if (fd < 0)
@@ -421,7 +421,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
step--;
step_bytes = step * ss;
- DBG(MISC, ul_debug(" step: %ju (%ju bytes)", step, step_bytes));
+ DBG(MISC, ul_debug(" step: %ju (%zu bytes)", (uintmax_t)step, step_bytes));
#if defined(POSIX_FADV_SEQUENTIAL) && defined(HAVE_POSIX_FADVISE)
if (!backward)
@@ -437,7 +437,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
color_disable();
fdisk_info(sf->cxt, _(" typescript file: %s"), typescript);
printf(_(" old start: %ju, new start: %ju (move %ju sectors)\n"),
- (uintmax_t) from, (uintmax_t) to, nsectors);
+ (uintmax_t) from, (uintmax_t) to, (uintmax_t) nsectors);
fflush(stdout);
}
@@ -459,12 +459,15 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
fprintf(f, "# Disk: %s\n", devname);
fprintf(f, "# Partition: %zu\n", partno + 1);
fprintf(f, "# Operation: move data\n");
- fprintf(f, "# Original start offset (sectors/bytes): %ju/%ju\n", from, from * ss);
- fprintf(f, "# New start offset (sectors/bytes): %ju/%ju\n", to, to * ss);
- fprintf(f, "# Area size (sectors/bytes): %ju/%ju\n", nsectors, nsectors * ss);
+ fprintf(f, "# Original start offset (sectors/bytes): %ju/%ju\n",
+ (uintmax_t)from, (uintmax_t)from * ss);
+ fprintf(f, "# New start offset (sectors/bytes): %ju/%ju\n",
+ (uintmax_t)to, (uintmax_t)to * ss);
+ fprintf(f, "# Area size (sectors/bytes): %ju/%ju\n",
+ (uintmax_t)nsectors, (uintmax_t)nsectors * ss);
fprintf(f, "# Sector size: %zu\n", ss);
fprintf(f, "# Step size (in bytes): %zu\n", step_bytes);
- fprintf(f, "# Steps: %zu\n", nsectors / step);
+ fprintf(f, "# Steps: %ju\n", (uintmax_t)(nsectors / step));
fprintf(f, "#\n");
fprintf(f, "# <step>: <from> <to> (step offsets in bytes)\n");
diff --git a/libblkid/samples/partitions.c b/libblkid/samples/partitions.c
index fe0ad48..318e9db 100644
--- a/libblkid/samples/partitions.c
+++ b/libblkid/samples/partitions.c
@@ -49,10 +49,10 @@ int main(int argc, char *argv[])
"known partition table\n", devname);
printf("size: %jd, sector size: %u, PT: %s, offset: %jd, id=%s\n---\n",
- blkid_probe_get_size(pr),
+ (intmax_t)blkid_probe_get_size(pr),
blkid_probe_get_sectorsize(pr),
blkid_parttable_get_type(root_tab),
- blkid_parttable_get_offset(root_tab),
+ (intmax_t)blkid_parttable_get_offset(root_tab),
blkid_parttable_get_id(root_tab));
/*
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
index c8e0bfe..bc67e80 100644
--- a/libblkid/src/partitions/partitions.c
+++ b/libblkid/src/partitions/partitions.c
@@ -789,9 +789,9 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
"%d", blkid_partition_get_partno(par));
blkid_probe_sprintf_value(pr, "PART_ENTRY_OFFSET", "%jd",
- blkid_partition_get_start(par));
+ (intmax_t)blkid_partition_get_start(par));
blkid_probe_sprintf_value(pr, "PART_ENTRY_SIZE", "%jd",
- blkid_partition_get_size(par));
+ (intmax_t)blkid_partition_get_size(par));
blkid_probe_sprintf_value(pr, "PART_ENTRY_DISK", "%u:%u",
major(disk), minor(disk));
@@ -820,7 +820,7 @@ int blkid_probe_is_covered_by_pt(blkid_probe pr,
int nparts, i, rc = 0;
DBG(LOWPROBE, ul_debug(
- "=> checking if off=%jd size=%jd covered by PT",
+ "=> checking if off=%"PRIu64" size=%"PRIu64" covered by PT",
offset, size));
if (pr->flags & BLKID_FL_NOSCAN_DEV)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index cc4586b..9c48462 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -607,7 +607,7 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr, uint64_t real_off, uint
/* begin of the device */
if (real_off == 0 || real_off + len < PROBE_MMAP_BEGINSIZ) {
- DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %ju)", pr->size));
+ DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %"PRIu64")", pr->size));
map_off = 0;
map_len = PROBE_MMAP_BEGINSIZ > pr->size ? pr->size : PROBE_MMAP_BEGINSIZ;
@@ -615,7 +615,7 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr, uint64_t real_off, uint
/* end of the device */
} else if (real_off > pr->off + pr->size - PROBE_MMAP_ENDSIZ) {
DBG(BUFFER, ul_debug("\tmapping end of the device (probing area: "
- "off=%ju, size=%ju)", pr->off, pr->size));
+ "off=%"PRIu64", size=%"PRIu64")", pr->off, pr->size));
map_off = PROBE_ALIGN_OFF(pr, pr->off + pr->size - PROBE_MMAP_ENDSIZ);
map_len = pr->off + pr->size - map_off;
@@ -655,7 +655,7 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr, uint64_t real_off, uint
bf->len = map_len;
INIT_LIST_HEAD(&bf->bufs);
- DBG(BUFFER, ul_debug("\tmmap %p: off=%ju, len=%ju (%ju pages)",
+ DBG(BUFFER, ul_debug("\tmmap %p: off=%"PRIu64", len=%"PRIu64" (%"PRIu64" pages)",
bf->data, map_off, map_len, map_len / pr->mmap_granularity));
return bf;
}
@@ -688,7 +688,8 @@ static struct blkid_bufinfo *read_buffer(blkid_probe pr, uint64_t real_off, uint
bf->off = real_off;
INIT_LIST_HEAD(&bf->bufs);
- DBG(LOWPROBE, ul_debug("\tread %p: off=%ju len=%ju", bf->data, real_off, len));
+ DBG(LOWPROBE, ul_debug("\tread %p: off=%"PRIu64" len=%"PRIu64"",
+ bf->data, real_off, len));
ret = read(pr->fd, bf->data, len);
if (ret != (ssize_t) len) {
@@ -749,7 +750,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len
list_entry(p, struct blkid_bufinfo, bufs);
if (real_off >= x->off && real_off + len <= x->off + x->len) {
- DBG(BUFFER, ul_debug("\treuse %p: off=%ju len=%ju (for off=%ju len=%ju)",
+ DBG(BUFFER, ul_debug("\treuse %p: off=%"PRIu64" len=%"PRIu64" (for off=%"PRIu64" len=%"PRIu64")",
x->data, x->off, x->len, real_off, len));
bf = x;
break;
@@ -791,14 +792,15 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
len += bf->len;
list_del(&bf->bufs);
- DBG(BUFFER, ul_debug(" remove buffer: %p [off=%ju, len=%ju]", bf->data, bf->off, bf->len));
+ DBG(BUFFER, ul_debug(" remove buffer: %p [off=%"PRIu64", len=%"PRIu64"]",
+ bf->data, bf->off, bf->len));
if (probe_is_mmap_wanted(pr))
munmap(bf->data, bf->len);
free(bf);
}
- DBG(LOWPROBE, ul_debug(" buffers summary: %ju bytes by %ju read/mmap() calls",
+ DBG(LOWPROBE, ul_debug(" buffers summary: %"PRIu64" bytes by %"PRIu64" read/mmap() calls",
len, ct));
INIT_LIST_HEAD(&pr->buffers);
@@ -932,7 +934,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->flags |= BLKID_FL_CDROM_DEV;
#endif
- DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%ju, size=%ju",
+ DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%"PRIu64", size=%"PRIu64"",
pr->off, pr->size));
DBG(LOWPROBE, ul_debug("whole-disk: %s, regfile: %s",
blkid_probe_is_wholedisk(pr) ?"YES" : "NO",
@@ -961,8 +963,8 @@ int blkid_probe_set_dimension(blkid_probe pr, uint64_t off, uint64_t size)
return -1;
DBG(LOWPROBE, ul_debug(
- "changing probing area pr=%p: size=%ju, off=%ju "
- "-to-> size=%ju, off=%ju",
+ "changing probing area pr=%p: size=%"PRIu64", off=%"PRIu64" "
+ "-to-> size=%"PRIu64", off=%"PRIu64"",
pr, pr->size, pr->off, size, off));
pr->off = off;
@@ -1214,7 +1216,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
len = sizeof(buf);
DBG(LOWPROBE, ul_debug(
- "do_wipe [offset=0x%jx (%ju), len=%zd, chain=%s, idx=%d, dryrun=%s]\n",
+ "do_wipe [offset=0x%"PRIx64" (%"PRIu64"), len=%zu, chain=%s, idx=%d, dryrun=%s]\n",
offset, offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
l = blkid_llseek(fd, offset, SEEK_SET);
@@ -1577,7 +1579,7 @@ int blkid_probe_verify_csum(blkid_probe pr, uint64_t csum, uint64_t expected)
DBG(LOWPROBE, ul_debug(
"incorrect checksum for type %s,"
- " got %jX, expected %jX",
+ " got %"PRIX64", expected %"PRIX64"",
blkid_probe_get_probername(pr),
csum, expected));
/*
@@ -1996,7 +1998,7 @@ void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, uint64_t size)
pr->wipe_chain = chn;
DBG(LOWPROBE,
- ul_debug("wiper set to %s::%s off=%jd size=%jd",
+ ul_debug("wiper set to %s::%s off=%"PRIu64" size=%"PRIu64"",
chn->driver->name,
chn->driver->idinfos[chn->idx]->name,
pr->wipe_off, pr->wipe_size));
diff --git a/libblkid/src/superblocks/drbdproxy_datalog.c b/libblkid/src/superblocks/drbdproxy_datalog.c
index af59722..9a4c7db 100644
--- a/libblkid/src/superblocks/drbdproxy_datalog.c
+++ b/libblkid/src/superblocks/drbdproxy_datalog.c
@@ -36,7 +36,7 @@ static int probe_drbdproxy_datalog(blkid_probe pr,
return errno ? -errno : 1;
blkid_probe_set_uuid(pr, lh->uuid);
- blkid_probe_sprintf_version(pr, "v%jd", le64_to_cpu(lh->version));
+ blkid_probe_sprintf_version(pr, "v%"PRIu64, le64_to_cpu(lh->version));
return 0;
}
diff --git a/libblkid/src/superblocks/ntfs.c b/libblkid/src/superblocks/ntfs.c
index 8ff9ccd..7515811 100644
--- a/libblkid/src/superblocks/ntfs.c
+++ b/libblkid/src/superblocks/ntfs.c
@@ -149,10 +149,10 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag)
off = le64_to_cpu(ns->mft_cluster_location) * sector_size *
sectors_per_cluster;
- DBG(LOWPROBE, ul_debug("NTFS: sector_size=%d, mft_record_size=%d, "
- "sectors_per_cluster=%d, nr_clusters=%ju "
- "cluster_offset=%jd",
- (int) sector_size, mft_record_size,
+ DBG(LOWPROBE, ul_debug("NTFS: sector_size=%"PRIu16", mft_record_size=%"PRIu32", "
+ "sectors_per_cluster=%"PRIu32", nr_clusters=%"PRIu64" "
+ "cluster_offset=%"PRIu64"",
+ sector_size, mft_record_size,
sectors_per_cluster, nr_clusters,
off));
diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c
index a4f598d..cb86560 100644
--- a/libblkid/src/superblocks/vfat.c
+++ b/libblkid/src/superblocks/vfat.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include <ctype.h>
#include <stdint.h>
+#include <inttypes.h>
#include "pt-mbr.h"
#include "superblocks.h"
@@ -125,7 +126,7 @@ static unsigned char *search_fat_label(blkid_probe pr,
uint32_t i;
DBG(LOWPROBE, ul_debug("\tlook for label in root-dir "
- "(entries: %d, offset: %jd)", entries, offset));
+ "(entries: %"PRIu32", offset: %"PRIu64")", entries, offset));
if (!blkid_probe_is_tiny(pr)) {
/* large disk, read whole root directory */
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index 1e1d07c..24f1db9 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -119,7 +119,7 @@ fdisk_sector_t fdisk_align_lba(struct fdisk_context *cxt, fdisk_sector_t lba, in
(uintmax_t) res,
cxt->grain / cxt->sector_size));
else
- DBG(CXT, ul_debugobj(cxt, "LBA %ju -unchanged-", lba));
+ DBG(CXT, ul_debugobj(cxt, "LBA %ju -unchanged-", (uintmax_t)lba));
return res;
}
diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c
index 225957f..fd0555e 100644
--- a/libfdisk/src/ask.c
+++ b/libfdisk/src/ask.c
@@ -462,7 +462,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew)
}
}
- DBG(ASK, ul_debugobj(ask, "ask limits: low: %ju, high: %ju, default: %ju",
+ DBG(ASK, ul_debugobj(ask, "ask limits: low: %"PRIu64", high: %"PRIu64", default: %"PRIu64"",
num->low, num->hig, num->dfl));
if (!rc && !wantnew && num->low == num->hig) {
@@ -504,7 +504,7 @@ dont_ask:
if (*partnum)
*partnum -= 1;
}
- DBG(ASK, ul_debugobj(ask, "result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
+ DBG(ASK, ul_debugobj(ask, "result: %"PRIu64" [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
fdisk_unref_ask(ask);
return rc;
}
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index b199225..68cadcd 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -1201,7 +1201,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
if (stop > start)
stop -= 1;
DBG(LABEL, ul_debug("DOS: don't align end os tiny partition [start=%ju, stop=%ju, grain=%lu]",
- start, stop, cxt->grain));
+ (uintmax_t)start, (uintmax_t)stop, cxt->grain));
}
if (stop < limit) {
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index cd88df0..2b2f519 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -621,7 +621,8 @@ static int count_first_last_lba(struct fdisk_context *cxt,
if (rc < 0)
return rc;
- DBG(LABEL, ul_debug("FirstLBA: script=%ju, uefi=%ju, topology=%ju.", *first, flba, cxt->first_lba));
+ DBG(LABEL, ul_debug("FirstLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
+ *first, flba, (uintmax_t)cxt->first_lba));
if (rc == 0 && (*first < flba || *first > llba)) {
fdisk_warnx(cxt, _("First LBA specified by script is out of range."));
@@ -632,7 +633,8 @@ static int count_first_last_lba(struct fdisk_context *cxt,
if (rc < 0)
return rc;
- DBG(LABEL, ul_debug("LastLBA: script=%ju, uefi=%ju, topology=%ju.", *last, llba, cxt->last_lba));
+ DBG(LABEL, ul_debug("LastLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
+ *last, llba, (uintmax_t)cxt->last_lba));
if (rc == 0 && (*last > llba || *last < flba)) {
fdisk_warnx(cxt, _("Last LBA specified by script is out of range."));
@@ -799,7 +801,7 @@ static uint64_t last_lba(struct fdisk_context *cxt)
else
fdisk_warnx(cxt, _("gpt: cannot handle files with mode %o"), s.st_mode);
- DBG(LABEL, ul_debug("GPT last LBA: %ju", sectors));
+ DBG(LABEL, ul_debug("GPT last LBA: %"PRIu64"", sectors));
return sectors;
}
@@ -1024,13 +1026,13 @@ static struct gpt_header *gpt_read_header(struct fdisk_context *cxt,
else
free(ents);
- DBG(LABEL, ul_debug("found valid GPT Header on LBA %ju", lba));
+ DBG(LABEL, ul_debug("found valid GPT Header on LBA %"PRIu64"", lba));
return header;
invalid:
free(header);
free(ents);
- DBG(LABEL, ul_debug("read GPT Header on LBA %ju failed", lba));
+ DBG(LABEL, ul_debug("read GPT Header on LBA %"PRIu64" failed", lba));
return NULL;
}
@@ -2141,14 +2143,14 @@ static int gpt_add_partition(
do {
uint64_t x;
- DBG(LABEL, ul_debug("testing first sector %ju", disk_f));
+ DBG(LABEL, ul_debug("testing first sector %"PRIu64"", disk_f));
disk_f = find_first_available(pheader, ents, disk_f);
if (!disk_f)
break;
x = find_last_free(pheader, ents, disk_f);
if (x - disk_f >= cxt->grain / cxt->sector_size)
break;
- DBG(LABEL, ul_debug("first sector %ju addresses to small space, continue...", disk_f));
+ DBG(LABEL, ul_debug("first sector %"PRIu64" addresses to small space, continue...", disk_f));
disk_f = x + 1;
} while(1);
@@ -2170,9 +2172,9 @@ static int gpt_add_partition(
user_f = dflt_f;
} else if (pa && fdisk_partition_has_start(pa)) {
- DBG(LABEL, ul_debug("first sector defined: %ju", pa->start));
+ DBG(LABEL, ul_debug("first sector defined: %ju", (uintmax_t)pa->start));
if (pa->start != find_first_available(pheader, ents, pa->start)) {
- fdisk_warnx(cxt, _("Sector %ju already used."), pa->start);
+ fdisk_warnx(cxt, _("Sector %ju already used."), (uintmax_t)pa->start);
return -ERANGE;
}
user_f = pa->start;
@@ -2213,8 +2215,8 @@ static int gpt_add_partition(
} else if (pa && fdisk_partition_has_size(pa)) {
user_l = user_f + pa->size - 1;
- DBG(LABEL, ul_debug("size defined: %ju, end: %ju (last possible: %ju)",
- pa->size, user_l, dflt_l));
+ DBG(LABEL, ul_debug("size defined: %ju, end: %"PRIu64" (last possible: %"PRIu64")",
+ (uintmax_t)pa->size, user_l, dflt_l));
if (user_l != dflt_l && !pa->size_explicit
&& user_l - user_f > (cxt->grain / fdisk_get_sector_size(cxt))) {
user_l = fdisk_align_lba_in_range(cxt, user_l, user_f, dflt_l);
@@ -2308,7 +2310,7 @@ static int gpt_add_partition(
if (pa && pa->attrs)
gpt_entry_attrs_from_string(cxt, e, pa->attrs);
- DBG(LABEL, ul_debug("GPT new partition: partno=%zu, start=%ju, end=%ju, size=%ju",
+ DBG(LABEL, ul_debug("GPT new partition: partno=%zu, start=%"PRIu64", end=%"PRIu64", size=%"PRIu64"",
partnum,
gpt_partition_start(e),
gpt_partition_end(e),
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 2031e33..5e41eed 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -780,16 +780,16 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
if (fdisk_partition_has_start(pa)) {
x = fdisk_cround(cxt, pa->start);
rc = pa->start_post ?
- asprintf(&p, "%ju%c", x, pa->start_post) :
- asprintf(&p, "%ju", x);
+ asprintf(&p, "%"PRIu64"%c", x, pa->start_post) :
+ asprintf(&p, "%"PRIu64, x);
}
break;
case FDISK_FIELD_END:
if (fdisk_partition_has_end(pa)) {
x = fdisk_cround(cxt, fdisk_partition_get_end(pa));
rc = pa->end_post ?
- asprintf(&p, "%ju%c", x, pa->end_post) :
- asprintf(&p, "%ju", x);
+ asprintf(&p, "%"PRIu64"%c", x, pa->end_post) :
+ asprintf(&p, "%"PRIu64, x);
}
break;
case FDISK_FIELD_SIZE:
@@ -798,13 +798,13 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
switch (cxt->sizeunit) {
case FDISK_SIZEUNIT_BYTES:
- rc = asprintf(&p, "%ju", sz);
+ rc = asprintf(&p, "%"PRIu64"", sz);
break;
case FDISK_SIZEUNIT_HUMAN:
if (fdisk_is_details(cxt))
rc = pa->size_post ?
- asprintf(&p, "%ju%c", sz, pa->size_post) :
- asprintf(&p, "%ju", sz);
+ asprintf(&p, "%"PRIu64"%c", sz, pa->size_post) :
+ asprintf(&p, "%"PRIu64, sz);
else {
p = size_to_human_string(SIZE_SUFFIX_1LETTER, sz);
if (!p)
@@ -818,7 +818,8 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
{
uintmax_t sz = fdisk_partition_has_size(pa) ? pa->size : 0;
if (sz)
- rc = asprintf(&p, "%ju", (sz / (cxt->geom.heads * cxt->geom.sectors)) + 1);
+ /* Why we need to cast that to uintmax_t? */
+ rc = asprintf(&p, "%ju", (uintmax_t)(sz / (cxt->geom.heads * cxt->geom.sectors)) + 1);
break;
}
case FDISK_FIELD_SECTORS:
@@ -826,13 +827,13 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
fdisk_partition_has_size(pa) ? (uintmax_t) pa->size : 0);
break;
case FDISK_FIELD_BSIZE:
- rc = asprintf(&p, "%ju", pa->bsize);
+ rc = asprintf(&p, "%"PRIu64, pa->bsize);
break;
case FDISK_FIELD_FSIZE:
- rc = asprintf(&p, "%ju", pa->fsize);
+ rc = asprintf(&p, "%"PRIu64, pa->fsize);
break;
case FDISK_FIELD_CPG:
- rc = asprintf(&p, "%ju", pa->cpg);
+ rc = asprintf(&p, "%"PRIu64, pa->cpg);
break;
case FDISK_FIELD_TYPE:
p = pa->type && pa->type->name ? strdup(_(pa->type->name)) : NULL;
@@ -971,7 +972,8 @@ static int resize_get_last_possible(
fdisk_partition_is_container(pa))
continue;
- DBG(PART, ul_debugobj(pa, "checking start=%ju, size=%ju", pa->start, pa->size));
+ DBG(PART, ul_debugobj(pa, "checking start=%ju, size=%ju",
+ (uintmax_t)pa->start, (uintmax_t)pa->size));
if (!last) {
if (start >= pa->start && start < pa->start + pa->size) {
@@ -1039,12 +1041,13 @@ static int recount_resize(
start += fdisk_partition_get_start(tpl);
DBG(PART, ul_debugobj(tpl, "resize: moving start %s relative, new start: %ju",
- tpl->movestart == FDISK_MOVE_DOWN ? "DOWN" : "UP", start));
+ tpl->movestart == FDISK_MOVE_DOWN ? "DOWN" : "UP", (uintmax_t)start));
/* 1b) set new start - absolute number */
} else if (fdisk_partition_has_start(tpl)) {
start = fdisk_partition_get_start(tpl);
- DBG(PART, ul_debugobj(tpl, "resize: moving start to absolute offset: %ju", start));
+ DBG(PART, ul_debugobj(tpl, "resize: moving start to absolute offset: %ju",
+ (uintmax_t)start));
}
/* 2) verify that start is within the current partition or any freespace area */
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
index 3ca3f59..dceb75a 100644
--- a/libfdisk/src/script.c
+++ b/libfdisk/src/script.c
@@ -405,7 +405,7 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
rc = fdisk_get_disklabel_item(cxt, GPT_LABELITEM_FIRSTLBA, &item);
if (rc == 0) {
- snprintf(buf, sizeof(buf), "%ju", item.data.num64);
+ snprintf(buf, sizeof(buf), "%"PRIu64, item.data.num64);
rc = fdisk_script_set_header(dp, "first-lba", buf);
}
if (rc < 0)
@@ -413,7 +413,7 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
rc = fdisk_get_disklabel_item(cxt, GPT_LABELITEM_LASTLBA, &item);
if (rc == 0) {
- snprintf(buf, sizeof(buf), "%ju", item.data.num64);
+ snprintf(buf, sizeof(buf), "%"PRIu64, item.data.num64);
rc = fdisk_script_set_header(dp, "last-lba", buf);
}
if (rc < 0)
@@ -528,9 +528,9 @@ static int write_file_json(struct fdisk_script *dp, FILE *f)
}
if (fdisk_partition_has_start(pa))
- fprintf(f, ", \"start\": %ju", pa->start);
+ fprintf(f, ", \"start\": %ju", (uintmax_t)pa->start);
if (fdisk_partition_has_size(pa))
- fprintf(f, ", \"size\": %ju", pa->size);
+ fprintf(f, ", \"size\": %ju", (uintmax_t)pa->size);
if (pa->type && fdisk_parttype_get_string(pa->type))
fprintf(f, ", \"type\": \"%s\"", fdisk_parttype_get_string(pa->type));
@@ -614,9 +614,9 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
fprintf(f, "%zu :", pa->partno + 1);
if (fdisk_partition_has_start(pa))
- fprintf(f, " start=%12ju", pa->start);
+ fprintf(f, " start=%12ju", (uintmax_t)pa->start);
if (fdisk_partition_has_size(pa))
- fprintf(f, ", size=%12ju", pa->size);
+ fprintf(f, ", size=%12ju", (uintmax_t)pa->size);
if (pa->type && fdisk_parttype_get_string(pa->type))
fprintf(f, ", type=%s", fdisk_parttype_get_string(pa->type));
@@ -1437,8 +1437,8 @@ static int test_stdin(struct fdisk_test *ts, int argc, char *argv[])
if (rc == 0) {
pa = fdisk_table_get_partition(dp->table, n);
printf(" #%zu %12ju %12ju\n", n + 1,
- fdisk_partition_get_start(pa),
- fdisk_partition_get_size(pa));
+ (uintmax_t)fdisk_partition_get_start(pa),
+ (uintmax_t)fdisk_partition_get_size(pa));
}
} while (rc == 0);
@@ -1479,8 +1479,8 @@ static int test_apply(struct fdisk_test *ts, int argc, char *argv[])
itr = fdisk_new_iter(FDISK_ITER_FORWARD);
while (fdisk_table_next_partition(tb, itr, &pa) == 0) {
printf(" #%zu %12ju %12ju\n", fdisk_partition_get_partno(pa),
- fdisk_partition_get_start(pa),
- fdisk_partition_get_size(pa));
+ (uintmax_t)fdisk_partition_get_start(pa),
+ (uintmax_t)fdisk_partition_get_size(pa));
}
done:
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c
index 1a3d47a..9be5713 100644
--- a/libfdisk/src/table.c
+++ b/libfdisk/src/table.c
@@ -508,11 +508,13 @@ static int check_container_freespace(struct fdisk_context *cxt,
grain = cxt->grain > cxt->sector_size ? cxt->grain / cxt->sector_size : 1;
fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
- DBG(CXT, ul_debugobj(cxt, "initialized: last=%ju, grain=%ju", last, grain));
+ DBG(CXT, ul_debugobj(cxt, "initialized: last=%ju, grain=%ju",
+ (uintmax_t)last, (uintmax_t)grain));
while (fdisk_table_next_partition(parts, &itr, &pa) == 0) {
- DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju", pa->partno, pa->start));
+ DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju",
+ pa->partno, (uintmax_t)pa->start));
if (!pa->used || !fdisk_partition_is_nested(pa)
|| !fdisk_partition_has_start(pa))
@@ -583,12 +585,14 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
last = cxt->first_lba;
grain = cxt->grain > cxt->sector_size ? cxt->grain / cxt->sector_size : 1;
- DBG(CXT, ul_debugobj(cxt, "initialized: last=%ju, grain=%ju", last, grain));
+ DBG(CXT, ul_debugobj(cxt, "initialized: last=%ju, grain=%ju",
+ (uintmax_t)last, (uintmax_t)grain));
/* analyze gaps between partitions */
while (rc == 0 && fdisk_table_next_partition(parts, &itr, &pa) == 0) {
- DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju", pa->partno, pa->start));
+ DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju",
+ pa->partno, (uintmax_t)pa->start));
if (!pa->used || pa->wholedisk || fdisk_partition_is_nested(pa)
|| !fdisk_partition_has_start(pa))
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index abcf5eb..9cd29ad 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -84,7 +84,7 @@ print_pretty(struct wipe_desc *wp, int line)
printf("----------------------------------------------------------------\n");
}
- printf("0x%-17jx %s [%s]", wp->offset, wp->type, _(wp->usage));
+ printf("0x%-17jx %s [%s]", (intmax_t)wp->offset, wp->type, _(wp->usage));
if (wp->label && *wp->label)
printf("\n%27s %s", "LABEL:", wp->label);
@@ -101,7 +101,7 @@ print_parsable(struct wipe_desc *wp, int line)
if (!line)
printf("# offset,uuid,label,type\n");
- printf("0x%jx,", wp->offset);
+ printf("0x%jx,", (intmax_t)wp->offset);
if (wp->uuid) {
blkid_encode_string(wp->uuid, enc, sizeof(enc));
@@ -311,7 +311,7 @@ static void do_wipe_real(blkid_probe pr, const char *devname,
if (blkid_do_wipe(pr, (flags & WP_FL_NOACT) != 0))
warn(_("%s: failed to erase %s magic string at offset 0x%08jx"),
- devname, w->type, w->offset);
+ devname, w->type, (intmax_t)w->offset);
if (flags & WP_FL_QUIET)
return;
@@ -319,7 +319,7 @@ static void do_wipe_real(blkid_probe pr, const char *devname,
printf(P_("%s: %zd byte was erased at offset 0x%08jx (%s): ",
"%s: %zd bytes were erased at offset 0x%08jx (%s): ",
w->len),
- devname, w->len, w->offset, w->type);
+ devname, w->len, (intmax_t)w->offset, w->type);
for (i = 0; i < w->len; i++) {
printf("%02x", w->magic[i]);
@@ -334,7 +334,7 @@ static void do_backup(struct wipe_desc *wp, const char *base)
char *fname = NULL;
int fd;
- xasprintf(&fname, "%s0x%08jx.bak", base, wp->offset);
+ xasprintf(&fname, "%s0x%08jx.bak", base, (intmax_t)wp->offset);
fd = open(fname, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
if (fd < 0)
@@ -428,7 +428,7 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags)
for (w = wp0; w != NULL; w = w->next) {
if (!w->on_disk && !(flags & WP_FL_QUIET))
- warnx(_("%s: offset 0x%jx not found"), devname, w->offset);
+ warnx(_("%s: offset 0x%jx not found"), devname, (uintmax_t)w->offset);
}
if (need_force)
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 03/12] lib: include sys/stat.h for struct stat
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
2016-03-07 23:11 ` [PATCH 01/12] wipefs, sfdisk: include libgen.h for basename(3p) Ruediger Meier
2016-03-07 23:11 ` [PATCH 02/12] misc: again fixing many printf format strings Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 04/12] fdisk: sun, undef HAVE_QSORT_R for non-Linux Ruediger Meier
` (9 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Compiler warning:
'struct stat' will not be visible outside of this function [-Wvisibility]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
include/blkdev.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/blkdev.h b/include/blkdev.h
index 46fb2ce..62eda82 100644
--- a/include/blkdev.h
+++ b/include/blkdev.h
@@ -14,6 +14,7 @@
#endif
#include <fcntl.h>
#include <unistd.h>
+#include <sys/stat.h>
#ifdef HAVE_SYS_MKDEV_H
# include <sys/mkdev.h> /* major and minor on Solaris */
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/12] fdisk: sun, undef HAVE_QSORT_R for non-Linux
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (2 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 03/12] lib: include sys/stat.h for struct stat Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 05/12] libfdisk: remove ifdef HDIO_GETGEO Ruediger Meier
` (8 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Linux/glibc's qsort_r(3) has differently ordered arguments than BSD
implementations. For now we undef that quick and dirty.
The real fix would be to make configure check for qsort_r more
carefully (AC_CHECK_FUNCS with AC_LANG_WERROR). Moreover one could
add a wrapper to swap arguments, see
https://github.com/noporpoise/sort_r/blob/master/sort_r.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
libfdisk/src/sun.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index d5c76ae..a50076a 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -378,6 +378,11 @@ static void fetch_sun(struct fdisk_context *cxt,
}
}
+/* non-Linux qsort_r(3) has usually differently ordered arguments */
+#if !defined (__linux__) || !defined (__GLIBC__)
+# undef HAVE_QSORT_R
+#endif
+
#ifdef HAVE_QSORT_R
static int verify_sun_cmp(int *a, int *b, void *data)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 05/12] libfdisk: remove ifdef HDIO_GETGEO
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (3 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 04/12] fdisk: sun, undef HAVE_QSORT_R for non-Linux Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 06/12] misc: never cast void* from malloc(3) and friends Ruediger Meier
` (7 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
We don't use HDIO_GETGEO since e5b5a349.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
libfdisk/src/sgi.c | 3 +--
libfdisk/src/sun.c | 2 --
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c
index 6228cf8..c77724a 100644
--- a/libfdisk/src/sgi.c
+++ b/libfdisk/src/sgi.c
@@ -968,7 +968,6 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
assert(cxt->label);
assert(fdisk_is_label(cxt, SGI));
-#ifdef HDIO_GETGEO
if (cxt->geom.heads && cxt->geom.sectors) {
fdisk_sector_t llsectors;
@@ -990,7 +989,7 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
"> 33.8 GB."), cxt->dev_path, cxt->geom.cylinders);
}
}
-#endif
+
rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index a50076a..a97ecac 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -225,7 +225,6 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
sunlabel->vtoc.sanity = cpu_to_be32(SUN_VTOC_SANITY);
sunlabel->vtoc.nparts = cpu_to_be16(SUN_MAXPARTITIONS);
-#ifdef HDIO_GETGEO
if (cxt->geom.heads && cxt->geom.sectors) {
fdisk_sector_t llsectors;
@@ -246,7 +245,6 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
cxt->dev_path, cxt->geom.cylinders);
}
} else
-#endif
ask_geom(cxt);
sunlabel->acyl = cpu_to_be16(0);
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 06/12] misc: never cast void* from malloc(3) and friends
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (4 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 05/12] libfdisk: remove ifdef HDIO_GETGEO Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 07/12] libmount: don't include libio.h Ruediger Meier
` (6 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Such cast could hide serious compiler warnings in case we are
missing includes (e.g. <stdlib.h> or "xalloc.h").
See
http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
disk-utils/mkswap.c | 2 +-
lib/setproctitle.c | 2 +-
lib/strutils.c | 2 +-
libblkid/src/cache.c | 2 +-
libblkid/src/config.c | 2 +-
libblkid/src/dev.c | 2 +-
libblkid/src/tag.c | 2 +-
login-utils/login.c | 2 +-
misc-utils/test_uuidd.c | 4 ++--
sys-utils/swapon-common.c | 4 ++--
term-utils/agetty.c | 2 +-
text-utils/col.c | 4 ++--
12 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 52ee8c6..a7c6a70 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -87,7 +87,7 @@ static void init_signature_page(struct mkswap_control *ctl)
} else
ctl->pagesize = kernel_pagesize;
- ctl->signature_page = (unsigned long *) xcalloc(1, ctl->pagesize);
+ ctl->signature_page = xcalloc(1, ctl->pagesize);
ctl->hdr = (struct swap_header_v1_2 *) ctl->signature_page;
}
diff --git a/lib/setproctitle.c b/lib/setproctitle.c
index 4bcf8c8..93bc82e 100644
--- a/lib/setproctitle.c
+++ b/lib/setproctitle.c
@@ -33,7 +33,7 @@ void initproctitle (int argc, char **argv)
for (i = 0; envp[i] != NULL; i++)
continue;
- environ = (char **) malloc(sizeof(char *) * (i + 1));
+ environ = malloc(sizeof(char *) * (i + 1));
if (environ == NULL)
return;
diff --git a/lib/strutils.c b/lib/strutils.c
index 64a6b99..2d7cb59 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -247,7 +247,7 @@ char *strnchr(const char *s, size_t maxlen, int c)
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
- char *new = (char *) malloc((len + 1) * sizeof(char));
+ char *new = malloc((len + 1) * sizeof(char));
if (!new)
return NULL;
new[len] = '\0';
diff --git a/libblkid/src/cache.c b/libblkid/src/cache.c
index b576df8..c6d02a4 100644
--- a/libblkid/src/cache.c
+++ b/libblkid/src/cache.c
@@ -102,7 +102,7 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
DBG(CACHE, ul_debug("creating blkid cache (using %s)",
filename ? filename : "default cache"));
- if (!(cache = (blkid_cache) calloc(1, sizeof(struct blkid_struct_cache))))
+ if (!(cache = calloc(1, sizeof(struct blkid_struct_cache))))
return -BLKID_ERR_MEM;
INIT_LIST_HEAD(&cache->bic_devs);
diff --git a/libblkid/src/config.c b/libblkid/src/config.c
index 3c7f312..1822f1c 100644
--- a/libblkid/src/config.c
+++ b/libblkid/src/config.c
@@ -120,7 +120,7 @@ struct blkid_config *blkid_read_config(const char *filename)
if (!filename)
filename = BLKID_CONFIG_FILE;
- conf = (struct blkid_config *) calloc(1, sizeof(*conf));
+ conf = calloc(1, sizeof(*conf));
if (!conf)
return NULL;
conf->uevent = -1;
diff --git a/libblkid/src/dev.c b/libblkid/src/dev.c
index 99b70b6..8e5516b 100644
--- a/libblkid/src/dev.c
+++ b/libblkid/src/dev.c
@@ -34,7 +34,7 @@ blkid_dev blkid_new_dev(void)
{
blkid_dev dev;
- if (!(dev = (blkid_dev) calloc(1, sizeof(struct blkid_struct_dev))))
+ if (!(dev = calloc(1, sizeof(struct blkid_struct_dev))))
return NULL;
INIT_LIST_HEAD(&dev->bid_devs);
diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c
index bfc7bb7..4dc7da1 100644
--- a/libblkid/src/tag.c
+++ b/libblkid/src/tag.c
@@ -21,7 +21,7 @@ static blkid_tag blkid_new_tag(void)
{
blkid_tag tag;
- if (!(tag = (blkid_tag) calloc(1, sizeof(struct blkid_struct_tag))))
+ if (!(tag = calloc(1, sizeof(struct blkid_struct_tag))))
return NULL;
INIT_LIST_HEAD(&tag->bit_tags);
diff --git a/login-utils/login.c b/login-utils/login.c
index ac76f65..236da9b 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1039,7 +1039,7 @@ static void init_environ(struct login_context *cxt)
/* destroy environment unless user has requested preservation (-p) */
if (!cxt->keep_env) {
- environ = (char **) xmalloc(sizeof(char *));
+ environ = xmalloc(sizeof(char *));
memset(environ, 0, sizeof(char *));
}
diff --git a/misc-utils/test_uuidd.c b/misc-utils/test_uuidd.c
index 78399b9..36f3b3d 100644
--- a/misc-utils/test_uuidd.c
+++ b/misc-utils/test_uuidd.c
@@ -161,7 +161,7 @@ static void create_nthreads(process_t *proc, size_t index)
size_t i, ncreated = 0;
int rc;
- threads = (thread_t *) xcalloc(nthreads, sizeof(thread_t));
+ threads = xcalloc(nthreads, sizeof(thread_t));
for (i = 0; i < nthreads; i++) {
thread_t *th = &threads[i];
@@ -209,7 +209,7 @@ static void create_nprocesses(void)
process_t *process;
size_t i;
- process = (process_t *) xcalloc(nprocesses, sizeof(process_t));
+ process = xcalloc(nprocesses, sizeof(process_t));
for (i = 0; i < nprocesses; i++) {
process_t *proc = &process[i];
diff --git a/sys-utils/swapon-common.c b/sys-utils/swapon-common.c
index 75466a0..8b686c0 100644
--- a/sys-utils/swapon-common.c
+++ b/sys-utils/swapon-common.c
@@ -86,7 +86,7 @@ static size_t ulct;
void add_label(const char *label)
{
- llist = (const char **) xrealloc(llist, (++llct) * sizeof(char *));
+ llist = xrealloc(llist, (++llct) * sizeof(char *));
llist[llct - 1] = label;
}
@@ -102,7 +102,7 @@ size_t numof_labels(void)
void add_uuid(const char *uuid)
{
- ulist = (const char **) xrealloc(ulist, (++ulct) * sizeof(char *));
+ ulist = xrealloc(ulist, (++ulct) * sizeof(char *));
ulist[ulct - 1] = uuid;
}
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 55a00e1..1df1bc8 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1970,7 +1970,7 @@ static char *get_logname(struct options *op, struct termios *tp, struct chardata
if (len < 0)
log_err(_("%s: invalid character conversion for login name"), op->tty);
- wcs = (wchar_t *) malloc((len + 1) * sizeof(wchar_t));
+ wcs = malloc((len + 1) * sizeof(wchar_t));
if (!wcs)
log_err(_("failed to allocate memory: %m"));
diff --git a/text-utils/col.c b/text-utils/col.c
index 53f0556..0823573 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
int need;
need = l->l_lsize ? l->l_lsize * 2 : 90;
- l->l_line = (CHAR *)xrealloc((void *) l->l_line,
+ l->l_line = xrealloc((void *) l->l_line,
(unsigned) need * sizeof(CHAR));
l->l_lsize = need;
}
@@ -472,7 +472,7 @@ void flush_line(LINE *l)
*/
if (l->l_lsize > sorted_size) {
sorted_size = l->l_lsize;
- sorted = (CHAR *)xrealloc((void *)sorted,
+ sorted = xrealloc((void *)sorted,
(unsigned)sizeof(CHAR) * sorted_size);
}
if (l->l_max_col >= count_size) {
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 07/12] libmount: don't include libio.h
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (5 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 06/12] misc: never cast void* from malloc(3) and friends Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 08/12] tests: cramfs, fix root group Ruediger Meier
` (5 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
This include was added just one month ago in 5a971329 but I don't see
what it was good for. It's missing in musl libc.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
libmount/src/btrfs.c | 2 +-
login-utils/last.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmount/src/btrfs.c b/libmount/src/btrfs.c
index edcabf3..9f48bf4 100644
--- a/libmount/src/btrfs.c
+++ b/libmount/src/btrfs.c
@@ -9,7 +9,7 @@
*/
#include <dirent.h>
#include <sys/ioctl.h>
-#include <libio.h>
+#include <stdlib.h>
#include <stdint.h>
#include <linux/btrfs.h>
diff --git a/login-utils/last.c b/login-utils/last.c
index 38b92ef..b8c4b83 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -26,7 +26,7 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <ctype.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/12] tests: cramfs, fix root group
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (6 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 07/12] libmount: don't include libio.h Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:11 ` [PATCH 09/12] tests: don't skip case "output undefined" Ruediger Meier
` (4 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Sudo may login as group wheel or may use user's original group.
Note that group 0 is not named "root" on all Unix systems.
We have some more tests with similar issues but they are Linux-only
(losetup, scsi_debug). We don't fix them unless somebody complains.
BTW we use hexdump instead of md5sum.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
tests/expected/cramfs/mkfs-endianness | 80 ++++++++++++++++++++++++++++++++++-
tests/ts/cramfs/mkfs | 19 ++++-----
tests/ts/cramfs/mkfs-endianness | 5 ++-
3 files changed, 91 insertions(+), 13 deletions(-)
diff --git a/tests/expected/cramfs/mkfs-endianness b/tests/expected/cramfs/mkfs-endianness
index ef935a7..9cf394b 100644
--- a/tests/expected/cramfs/mkfs-endianness
+++ b/tests/expected/cramfs/mkfs-endianness
@@ -1,4 +1,80 @@
create little endian
-4666f0d2b661f9f3962877edabadb210
+00000000 45 3d cd 28 00 10 00 00 03 00 00 00 00 00 00 00 |E=.(............|
+00000010 43 6f 6d 70 72 65 73 73 65 64 20 52 4f 4d 46 53 |Compressed ROMFS|
+00000020 9b d3 39 ca 00 00 00 00 05 00 00 00 05 00 00 00 |..9.............|
+00000030 43 6f 6d 70 72 65 73 73 65 64 00 00 00 00 00 00 |Compressed......|
+00000040 ed 41 00 00 10 00 00 00 c0 04 00 00 ed 41 00 00 |.A...........A..|
+00000050 10 00 00 00 c1 05 00 00 64 69 72 41 ed 41 00 00 |........dirA.A..|
+00000060 20 00 00 00 c1 06 00 00 64 69 72 42 a4 81 00 00 | .......dirB....|
+00000070 00 02 00 00 c1 08 00 00 61 00 00 00 a4 81 00 00 |........a.......|
+00000080 00 3c 00 00 c1 0c 00 00 62 00 00 00 cb 00 00 00 |.<......b.......|
+00000090 78 9c 0b 49 2d 2e c9 cc 4b 57 48 2e 4a cc 4d 2b |x..I-...KWH.J.M+|
+000000a0 56 30 34 32 36 31 35 33 b7 b0 34 50 70 cd 4b c9 |V0426153..4Pp.K.|
+000000b0 4c cc cb 4b 2d 2e 56 48 ce 48 4d ce c6 27 c7 15 |L..K-.VH.HM..'..|
+000000c0 32 6a cc d0 34 06 00 37 c8 a2 81 00 33 01 00 00 |2j..4..7....3...|
+000000d0 8d 01 00 00 e7 01 00 00 38 02 00 00 78 9c ed cc |........8...x...|
+000000e0 bb 0d 80 30 0c 40 c1 9e 29 3c 02 ff cf 00 6c 90 |...0.@..)<....l.|
+000000f0 05 22 27 40 84 70 81 d9 5f 6c 40 4d f1 ea 93 2e |."'@.p.._l@M....|
+00000100 64 7f 8a ed a2 77 bc 36 97 a6 ed fa 61 9c e6 a5 |d....w.6....a...|
+00000110 96 d5 52 89 66 d9 5d f4 c8 7a 7e 59 15 68 68 68 |..R.f.]..z~Y.hhh|
+00000120 68 68 68 68 68 68 68 68 68 68 68 68 fe db bc 1f |hhhhhhhhhhhh....|
+00000130 dd 0d 28 78 9c ed cc bb 0d 80 30 0c 00 d1 9e 29 |..(x......0....)|
+00000140 3c 02 ff c0 00 6c c0 02 51 30 10 21 5c 60 f6 17 |<....l..Q0.!\`..|
+00000150 0b 20 6a 8a ab ef f4 c2 30 96 32 d9 92 a3 99 ba |. j.....0.2.....|
+00000160 4b da 35 1d c5 ac 7e 67 db 24 5d f1 5c 5d aa ba |K.5...~g.$].\]..|
+00000170 69 bb 3e bc ad 5f 0d 06 06 06 06 06 06 06 06 06 |i.>.._..........|
+00000180 06 06 06 06 06 e6 1f cc 03 76 3d 0d 1a 78 9c ed |.........v=..x..|
+00000190 cc bb 0d 80 30 0c 00 d1 9e 29 3c 02 ff cf 00 6c |....0....)<....l|
+000001a0 c0 02 91 09 10 21 5c 60 f6 17 35 0d 75 8a ab ef |.....!\`..5.u...|
+000001b0 f4 6c 4d c1 2c ba 8b 1e 51 4f a9 ea a6 ed fa 61 |.lM.,...QO.....a|
+000001c0 9c 4a 99 ed db 8a 25 fa 93 6c 17 bd c3 b5 f9 df |.J....%..l......|
+000001d0 0a 03 03 03 03 03 03 03 03 03 03 03 03 03 03 93 |................|
+000001e0 13 f3 02 b1 b2 0e 4d 78 9c cb 4b 57 48 2e 4a cc |......Mx..KWH.J.|
+000001f0 4d 2b 56 30 34 32 36 31 35 33 b7 b0 34 50 70 cd |M+V0426153..4Pp.|
+00000200 4b c9 4c cc cb 4b 2d 2e 56 48 ce 48 4d ce c6 27 |K.L..K-.VH.HM..'|
+00000210 c7 15 92 5a 5c 92 99 37 6a cc a8 31 a3 c6 8c 1a |...Z\..7j..1....|
+00000220 33 6a cc a8 31 a3 c6 8c 1a 33 6a cc a8 31 a3 c6 |3j..1....3j..1..|
+00000230 0c 7e 63 00 d1 5c c9 6a 00 00 00 00 00 00 00 00 |.~c..\.j........|
+00000240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+*
+00001000
create big endian
-bc0b7bbef02765d32e07faa735d2e0c6
+00000000 28 cd 3d 45 00 00 10 00 00 00 00 03 00 00 00 00 |(.=E............|
+00000010 43 6f 6d 70 72 65 73 73 65 64 20 52 4f 4d 46 53 |Compressed ROMFS|
+00000020 d3 50 cc 02 00 00 00 00 00 00 00 05 00 00 00 05 |.P..............|
+00000030 43 6f 6d 70 72 65 73 73 65 64 00 00 00 00 00 00 |Compressed......|
+00000040 41 ed 00 00 00 00 10 00 00 00 00 13 41 ed 00 00 |A...........A...|
+00000050 00 00 10 00 04 00 00 17 64 69 72 41 41 ed 00 00 |........dirAA...|
+00000060 00 00 20 00 04 00 00 1b 64 69 72 42 81 a4 00 00 |.. .....dirB....|
+00000070 00 02 00 00 04 00 00 23 61 00 00 00 81 a4 00 00 |.......#a.......|
+00000080 00 3c 00 00 04 00 00 33 62 00 00 00 00 00 00 cb |.<.....3b.......|
+00000090 78 9c 0b 49 2d 2e c9 cc 4b 57 48 2e 4a cc 4d 2b |x..I-...KWH.J.M+|
+000000a0 56 30 34 32 36 31 35 33 b7 b0 34 50 70 cd 4b c9 |V0426153..4Pp.K.|
+000000b0 4c cc cb 4b 2d 2e 56 48 ce 48 4d ce c6 27 c7 15 |L..K-.VH.HM..'..|
+000000c0 32 6a cc d0 34 06 00 37 c8 a2 81 00 00 00 01 33 |2j..4..7.......3|
+000000d0 00 00 01 8d 00 00 01 e7 00 00 02 38 78 9c ed cc |...........8x...|
+000000e0 bb 0d 80 30 0c 40 c1 9e 29 3c 02 ff cf 00 6c 90 |...0.@..)<....l.|
+000000f0 05 22 27 40 84 70 81 d9 5f 6c 40 4d f1 ea 93 2e |."'@.p.._l@M....|
+00000100 64 7f 8a ed a2 77 bc 36 97 a6 ed fa 61 9c e6 a5 |d....w.6....a...|
+00000110 96 d5 52 89 66 d9 5d f4 c8 7a 7e 59 15 68 68 68 |..R.f.]..z~Y.hhh|
+00000120 68 68 68 68 68 68 68 68 68 68 68 68 fe db bc 1f |hhhhhhhhhhhh....|
+00000130 dd 0d 28 78 9c ed cc bb 0d 80 30 0c 00 d1 9e 29 |..(x......0....)|
+00000140 3c 02 ff c0 00 6c c0 02 51 30 10 21 5c 60 f6 17 |<....l..Q0.!\`..|
+00000150 0b 20 6a 8a ab ef f4 c2 30 96 32 d9 92 a3 99 ba |. j.....0.2.....|
+00000160 4b da 35 1d c5 ac 7e 67 db 24 5d f1 5c 5d aa ba |K.5...~g.$].\]..|
+00000170 69 bb 3e bc ad 5f 0d 06 06 06 06 06 06 06 06 06 |i.>.._..........|
+00000180 06 06 06 06 06 e6 1f cc 03 76 3d 0d 1a 78 9c ed |.........v=..x..|
+00000190 cc bb 0d 80 30 0c 00 d1 9e 29 3c 02 ff cf 00 6c |....0....)<....l|
+000001a0 c0 02 91 09 10 21 5c 60 f6 17 35 0d 75 8a ab ef |.....!\`..5.u...|
+000001b0 f4 6c 4d c1 2c ba 8b 1e 51 4f a9 ea a6 ed fa 61 |.lM.,...QO.....a|
+000001c0 9c 4a 99 ed db 8a 25 fa 93 6c 17 bd c3 b5 f9 df |.J....%..l......|
+000001d0 0a 03 03 03 03 03 03 03 03 03 03 03 03 03 03 93 |................|
+000001e0 13 f3 02 b1 b2 0e 4d 78 9c cb 4b 57 48 2e 4a cc |......Mx..KWH.J.|
+000001f0 4d 2b 56 30 34 32 36 31 35 33 b7 b0 34 50 70 cd |M+V0426153..4Pp.|
+00000200 4b c9 4c cc cb 4b 2d 2e 56 48 ce 48 4d ce c6 27 |K.L..K-.VH.HM..'|
+00000210 c7 15 92 5a 5c 92 99 37 6a cc a8 31 a3 c6 8c 1a |...Z\..7j..1....|
+00000220 33 6a cc a8 31 a3 c6 8c 1a 33 6a cc a8 31 a3 c6 |3j..1....3j..1..|
+00000230 0c 7e 63 00 d1 5c c9 6a 00 00 00 00 00 00 00 00 |.~c..\.j........|
+00000240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+*
+00001000
diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs
index 07f703f..cf6bcd6 100755
--- a/tests/ts/cramfs/mkfs
+++ b/tests/ts/cramfs/mkfs
@@ -51,17 +51,16 @@ ts_log "create mountpoint dir"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_log "generate data"
-if [ ! -d "$IMAGE_SRC" ]; then
- mkdir -p $IMAGE_SRC
- for d in `seq 0 110`; do
- DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)"
- mkdir -p $DIRNAME
- for f in `seq 0 10`; do
- FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
- printf "data in %03d-%03d" $d $f >> $FILENAME
- done
+rm -rf "$IMAGE_SRC"
+mkdir -p $IMAGE_SRC
+for d in `seq 0 110`; do
+ DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)"
+ mkdir -p $DIRNAME
+ for f in `seq 0 10`; do
+ FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
+ printf "data in %03d-%03d" $d $f >> $FILENAME
done
-fi
+done
ts_cd "$IMAGE_SRC"
diff --git a/tests/ts/cramfs/mkfs-endianness b/tests/ts/cramfs/mkfs-endianness
index e6707ca..c511086 100755
--- a/tests/ts/cramfs/mkfs-endianness
+++ b/tests/ts/cramfs/mkfs-endianness
@@ -22,6 +22,7 @@ TS_DESC="mkfs endianness"
ts_init "$*"
ts_check_test_command "$TS_CMD_MKCRAMFS"
+ts_check_test_command "$TS_CMD_HEXDUMP"
ts_skip_nonroot
@@ -35,7 +36,7 @@ test_image() {
$TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \
"$IMAGE_CREATED" >> $TS_OUTPUT 2>&1
- md5sum $IMAGE_CREATED | cut -d" " -f1 >> $TS_OUTPUT
+ $TS_CMD_HEXDUMP -C $IMAGE_CREATED >> $TS_OUTPUT
rm "$IMAGE_CREATED"
}
@@ -47,6 +48,8 @@ yes "Testing cramfs 1234567890 Endianness check 1234567890 Endianness check" \
| dd of=$IMAGE_DATA/dirA/dirB/a bs=512 count=1 &> /dev/null
yes "Testing cramfs 1234567890 Endianness check 1234567890 Endianness check" \
| dd of=$IMAGE_DATA/dirA/dirB/b bs=512 count=30 &> /dev/null
+# sudo may use whatever group
+chgrp -R 0 $IMAGE_DATA
#perform tests for both endians
test_image "little"
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/12] tests: don't skip case "output undefined"
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (7 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 08/12] tests: cramfs, fix root group Ruediger Meier
@ 2016-03-07 23:11 ` Ruediger Meier
2016-03-07 23:12 ` [PATCH 10/12] tests: getopt2, add function gnu_getopt_clean() Ruediger Meier
` (3 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:11 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Treat missing expected files as empty and let the test fail if
there is non-empty output.
Expected output may be missing in these cases:
1. forgot to commit the file after changing/adding a (sub)test
2. a bug in a test where we do tricks with TS_EXPECTED
3. and most notable if ts_die() is called before a subtest is
initialized, e.g. in ts_scsi_debug_init()
I always wondered why we don't treat this as FAILED. Now we do
so, ts_finalize and ts_gen_diff looks much cleaner now.
The change discovers that tests with subtest were ignoring the
"non-sub" expected files which had to be fixed. BTW we removed
any zero sized files.
Moreover now we respect diff's return value. In past all test
succeeded when diff was not able to write to diffdir, e.g. when
running tests as normal user after they run as root.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
tests/expected/build-sys/config | 0
tests/expected/colcrt/functional | 0
tests/expected/colcrt/regressions | 0
tests/expected/eject/umount | 0
tests/expected/libmount/context-utab | 3 +-
tests/expected/libmount/context-utab-py | 3 +-
tests/expected/libmount/tabdiff | 0
tests/expected/logger/errors | 0
tests/expected/logger/formats | 0
tests/expected/logger/options | 0
tests/expected/losetup/losetup | 0
tests/expected/minix/mkfs | 0
tests/expected/misc/getopt2 | 19 -----------
tests/expected/misc/getopt3 | 0
tests/expected/mount/fstab-btrfs | 1 -
tests/expected/mount/umount-alltargets | 1 -
tests/expected/script/options | 0
tests/expected/sfdisk/dos | 0
tests/expected/sfdisk/gpt | 0
tests/expected/sfdisk/resize | 0
tests/functions.sh | 48 ++++++++++-----------------
tests/ts/libmount/context-utab | 47 +++++++++++++-------------
tests/ts/libmount/context-utab-py | 58 ++++++++++++++++-----------------
tests/ts/losetup/losetup | 1 -
tests/ts/misc/getopt2 | 19 -----------
25 files changed, 72 insertions(+), 128 deletions(-)
delete mode 100644 tests/expected/build-sys/config
delete mode 100644 tests/expected/colcrt/functional
delete mode 100644 tests/expected/colcrt/regressions
delete mode 100644 tests/expected/eject/umount
delete mode 100644 tests/expected/libmount/tabdiff
delete mode 100644 tests/expected/logger/errors
delete mode 100644 tests/expected/logger/formats
delete mode 100644 tests/expected/logger/options
delete mode 100644 tests/expected/losetup/losetup
delete mode 100644 tests/expected/minix/mkfs
delete mode 100644 tests/expected/misc/getopt2
delete mode 100644 tests/expected/misc/getopt3
delete mode 100644 tests/expected/mount/fstab-btrfs
delete mode 100644 tests/expected/script/options
delete mode 100644 tests/expected/sfdisk/dos
delete mode 100644 tests/expected/sfdisk/gpt
delete mode 100644 tests/expected/sfdisk/resize
diff --git a/tests/expected/build-sys/config b/tests/expected/build-sys/config
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/colcrt/functional b/tests/expected/colcrt/functional
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/colcrt/regressions b/tests/expected/colcrt/regressions
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/eject/umount b/tests/expected/eject/umount
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/libmount/context-utab b/tests/expected/libmount/context-utab
index cde2e3f..2149373 100644
--- a/tests/expected/libmount/context-utab
+++ b/tests/expected/libmount/context-utab
@@ -1,9 +1,8 @@
-Init device
Create partitions
Create filesystem
Do tests...
Create filesystem [btrfs]
All mount options (btrfs subvolume + utab) ---
-rw,relatime,ssd,uhelper=foo
+rw,relatime,ssd,space_cache,uhelper=foo
---
...done.
diff --git a/tests/expected/libmount/context-utab-py b/tests/expected/libmount/context-utab-py
index cde2e3f..2149373 100644
--- a/tests/expected/libmount/context-utab-py
+++ b/tests/expected/libmount/context-utab-py
@@ -1,9 +1,8 @@
-Init device
Create partitions
Create filesystem
Do tests...
Create filesystem [btrfs]
All mount options (btrfs subvolume + utab) ---
-rw,relatime,ssd,uhelper=foo
+rw,relatime,ssd,space_cache,uhelper=foo
---
...done.
diff --git a/tests/expected/libmount/tabdiff b/tests/expected/libmount/tabdiff
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/logger/errors b/tests/expected/logger/errors
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/logger/formats b/tests/expected/logger/formats
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/logger/options b/tests/expected/logger/options
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/losetup/losetup b/tests/expected/losetup/losetup
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/minix/mkfs b/tests/expected/minix/mkfs
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/misc/getopt2 b/tests/expected/misc/getopt2
deleted file mode 100644
index 59ec59b..0000000
--- a/tests/expected/misc/getopt2
+++ /dev/null
@@ -1,19 +0,0 @@
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 1
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 1
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 0
-exit value: 1
-exit value: 1
-exit value: 0
-exit value: 0
-exit value: 1
diff --git a/tests/expected/misc/getopt3 b/tests/expected/misc/getopt3
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/mount/fstab-btrfs b/tests/expected/mount/fstab-btrfs
deleted file mode 100644
index 3582111..0000000
--- a/tests/expected/mount/fstab-btrfs
+++ /dev/null
@@ -1 +0,0 @@
-Success
diff --git a/tests/expected/mount/umount-alltargets b/tests/expected/mount/umount-alltargets
index 53514d1..a0e4679 100644
--- a/tests/expected/mount/umount-alltargets
+++ b/tests/expected/mount/umount-alltargets
@@ -1,4 +1,3 @@
-Init device
Create partitions
Create filesystem A
Create filesystem B
diff --git a/tests/expected/script/options b/tests/expected/script/options
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/sfdisk/dos b/tests/expected/sfdisk/dos
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/sfdisk/gpt b/tests/expected/sfdisk/gpt
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/expected/sfdisk/resize b/tests/expected/sfdisk/resize
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/functions.sh b/tests/functions.sh
index 9e5d243..5d54efd 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -378,22 +378,21 @@ function ts_valgrind {
function ts_gen_diff {
local res=0
- if [ -s "$TS_OUTPUT" ]; then
+ [ -f "$TS_OUTPUT" ] || return 1
+ [ -f "$TS_EXPECTED" ] || TS_EXPECTED=/dev/null
- # remove libtool lt- prefixes
- sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_OUTPUT
+ # remove libtool lt- prefixes
+ sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_OUTPUT
- [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR"
- diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF
+ [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR"
+ diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF
- if [ -s $TS_DIFF ]; then
- res=1
- else
- rm -f $TS_DIFF;
- fi
- else
+ if [ $? -ne 0 ] || [ -s $TS_DIFF ]; then
res=1
+ else
+ rm -f $TS_DIFF;
fi
+
return $res
}
@@ -409,16 +408,12 @@ function tt_gen_mem_report {
function ts_finalize_subtest {
local res=0
- if [ -s "$TS_EXPECTED" ]; then
- ts_gen_diff
- if [ $? -eq 1 ]; then
- ts_failed_subtest "$1"
- res=1
- else
- ts_ok_subtest "$(tt_gen_mem_report "$1")"
- fi
+ ts_gen_diff
+ if [ $? -eq 1 ]; then
+ ts_failed_subtest "$1"
+ res=1
else
- ts_skip_subtest "output undefined"
+ ts_ok_subtest "$(tt_gen_mem_report "$1")"
fi
[ $res -ne 0 ] && TS_NSUBFAILED=$(( $TS_NSUBFAILED + 1 ))
@@ -433,22 +428,15 @@ function ts_finalize {
ts_cleanup_on_exit
if [ $TS_NSUBTESTS -ne 0 ]; then
- if [ $TS_NSUBFAILED -ne 0 ]; then
+ if ! ts_gen_diff || [ $TS_NSUBFAILED -ne 0 ]; then
ts_failed "$TS_NSUBFAILED from $TS_NSUBTESTS sub-tests"
else
ts_ok "all $TS_NSUBTESTS sub-tests PASSED"
fi
fi
- if [ -s $TS_EXPECTED ]; then
- ts_gen_diff
- if [ $? -eq 1 ]; then
- ts_failed "$1"
- fi
- ts_ok "$1"
- fi
-
- ts_skip "output undefined"
+ ts_gen_diff || ts_failed "$1"
+ ts_ok "$1"
}
function ts_die {
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
index 8b93fe9..38bc170 100755
--- a/tests/ts/libmount/context-utab
+++ b/tests/ts/libmount/context-utab
@@ -15,6 +15,7 @@ ts_check_test_command "$TS_CMD_UUIDGEN"
ts_skip_nonroot
ts_check_prog "mkfs.ext4"
+ts_check_prog "mkfs.btrfs"
TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
LABEL=libmount-test
@@ -93,35 +94,33 @@ grep -q $DEVICE $LIBMOUNT_UTAB && \
ts_finalize_subtest
-if [ -x "/sbin/mkfs.btrfs" ]; then
- $TS_CMD_WIPEFS -a $DEVICE &> /dev/null
- ts_log "Create filesystem [btrfs]"
- mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
- udevadm settle
+$TS_CMD_WIPEFS -a $DEVICE &> /dev/null
+ts_log "Create filesystem [btrfs]"
+mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
+udevadm settle
- mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
- btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
- umount $MOUNTPOINT &> /dev/null
+mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
+btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
+umount $MOUNTPOINT &> /dev/null
- udevadm settle
+udevadm settle
- ts_init_subtest "mount-uhelper-subvol"
- mkdir -p $MOUNTPOINT &> /dev/null
- ts_valgrind $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB || \
- echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
- ts_finalize_subtest
+ts_init_subtest "mount-uhelper-subvol"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_valgrind $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB || \
+ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
- ts_log "All mount options (btrfs subvolume + utab) ---"
- $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
- ts_log "---"
+ts_log "All mount options (btrfs subvolume + utab) ---"
+$TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
+ts_log "---"
- ts_init_subtest "umount-subvol"
- ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB && \
- echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
- ts_finalize_subtest
-fi
+ts_init_subtest "umount-subvol"
+ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
ts_log "...done."
rmmod scsi_debug
diff --git a/tests/ts/libmount/context-utab-py b/tests/ts/libmount/context-utab-py
index 5337d10..fdde63a 100755
--- a/tests/ts/libmount/context-utab-py
+++ b/tests/ts/libmount/context-utab-py
@@ -14,6 +14,7 @@ ts_check_test_command "$TS_CMD_UUIDGEN"
ts_skip_nonroot
ts_check_prog "mkfs.ext4"
+ts_check_prog "mkfs.btrfs"
ts_init_py libmount
@@ -93,35 +94,34 @@ grep -q $DEVICE $LIBMOUNT_UTAB && \
echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
-if [ -x "/sbin/mkfs.btrfs" ]; then
- $TS_CMD_WIPEFS -a $DEVICE &> /dev/null
- ts_log "Create filesystem [btrfs]"
- mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
- udevadm settle
-
- mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
- btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
- umount $MOUNTPOINT &> /dev/null
-
- udevadm settle
-
- ts_init_subtest "mount-uhelper-subvol"
- mkdir -p $MOUNTPOINT &> /dev/null
- $PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB || \
- echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
- ts_finalize_subtest
-
- ts_log "All mount options (btrfs subvolume + utab) ---"
- $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
- ts_log "---"
-
- ts_init_subtest "umount-subvol"
- $PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB && \
- echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
- ts_finalize_subtest
-fi
+
+$TS_CMD_WIPEFS -a $DEVICE &> /dev/null
+ts_log "Create filesystem [btrfs]"
+mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
+udevadm settle
+
+mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
+btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
+umount $MOUNTPOINT &> /dev/null
+
+udevadm settle
+
+ts_init_subtest "mount-uhelper-subvol"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB || \
+ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_log "All mount options (btrfs subvolume + utab) ---"
+$TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
+ts_log "---"
+
+ts_init_subtest "umount-subvol"
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
ts_log "...done."
rmmod scsi_debug
diff --git a/tests/ts/losetup/losetup b/tests/ts/losetup/losetup
index a50d2eb..1fec0dd 100755
--- a/tests/ts/losetup/losetup
+++ b/tests/ts/losetup/losetup
@@ -30,7 +30,6 @@ ts_check_test_command "$TS_CMD_LSBLK"
$TS_CMD_LOSETUP --version >/dev/null 2>$TS_OUTPUT || ts_failed
$TS_CMD_LOSETUP --unknownopt >>$TS_OUTPUT 2>/dev/null && ts_failed
test -s $TS_OUTPUT && ts_failed
-rm -f $TS_OUTPUT
ts_skip_nonroot
ts_check_losetup
diff --git a/tests/ts/misc/getopt2 b/tests/ts/misc/getopt2
index 677131f..779d15b 100755
--- a/tests/ts/misc/getopt2
+++ b/tests/ts/misc/getopt2
@@ -27,120 +27,101 @@ $TS_CMD_GETOPT -a -o abcde -l abcde -- -a -ab -abc -ac >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest alternative_option_long
$TS_CMD_GETOPT --alternative -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest alternative_option_short
$TS_CMD_GETOPT -a -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest invalid_getopt_option
$TS_CMD_GETOPT -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i '1,1s/.*\///' $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest invocation_model_one
$TS_CMD_GETOPT abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest invocation_model_three_as_one
$TS_CMD_GETOPT -o abc:d::e::f::g: -- ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest invocation_model_two_as_one
$TS_CMD_GETOPT -- abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest invocation_without_parameters
$TS_CMD_GETOPT >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest long_option_ambiguous_1
$TS_CMD_GETOPT -o a -l long1,long2 -- --long >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,1s/.*\///' -e "1s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest longopts
$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbriviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest name_option_long
$TS_CMD_GETOPT -n THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest name_option_short
$TS_CMD_GETOPT --name THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest quiet_option_long
$TS_CMD_GETOPT --quiet -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest quiet_option_short
$TS_CMD_GETOPT -q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest quiet_output_option_long
$TS_CMD_GETOPT --quiet-output -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest quiet_output_option_short
$TS_CMD_GETOPT -Q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest same_long_short_options
$TS_CMD_GETOPT -o a -l a -- -a --a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest test_for_enhanced_getopt
$TS_CMD_GETOPT -T >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest unknown_options
$TS_CMD_GETOPT -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i '1,2s/.*\///' $TS_OUTPUT
ts_finalize_subtest
-echo "exit value: $?" >> $TS_OUTPUT
ts_init_subtest unquoted_option_bash
$TS_CMD_GETOPT -s bash -u -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More
than
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/12] tests: getopt2, add function gnu_getopt_clean()
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (8 preceding siblings ...)
2016-03-07 23:11 ` [PATCH 09/12] tests: don't skip case "output undefined" Ruediger Meier
@ 2016-03-07 23:12 ` Ruediger Meier
2016-03-07 23:12 ` [PATCH 11/12] tests: improve getopt loop error case Ruediger Meier
` (2 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:12 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
This makes the test compatible to OpenBSD, OSX and musl libc.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
tests/ts/misc/getopt2 | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tests/ts/misc/getopt2 b/tests/ts/misc/getopt2
index 779d15b..8ca2d55 100755
--- a/tests/ts/misc/getopt2
+++ b/tests/ts/misc/getopt2
@@ -22,104 +22,136 @@ ts_check_test_command "$TS_CMD_GETOPT"
export LANG=C
+function gnu_getopt_clean() {
+ sed --in-place \
+ -e "s/: \(.*\) -- \(.\)$/: \1 -- '\2'/" \
+ -e "s/ ['\`]\(--[a-zA-Z0-9]\{1,\}\)'/ '\1'/g" \
+ -e "s/unrecognized option: \(.\)$/invalid option -- '\1'/" \
+ -e "s/option requires an argument: \(.\)$/option requires an argument -- '\1'/" \
+ -e "s/unrecognized option: \([^'-].\{1,\}\)$/unrecognized option '--\1'/" \
+ "$TS_OUTPUT"
+}
+
ts_init_subtest alternative_option_clash
$TS_CMD_GETOPT -a -o abcde -l abcde -- -a -ab -abc -ac >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest alternative_option_long
$TS_CMD_GETOPT --alternative -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest alternative_option_short
$TS_CMD_GETOPT -a -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest invalid_getopt_option
$TS_CMD_GETOPT -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i '1,1s/.*\///' $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest invocation_model_one
$TS_CMD_GETOPT abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest invocation_model_three_as_one
$TS_CMD_GETOPT -o abc:d::e::f::g: -- ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest invocation_model_two_as_one
$TS_CMD_GETOPT -- abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest invocation_without_parameters
$TS_CMD_GETOPT >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest long_option_ambiguous_1
$TS_CMD_GETOPT -o a -l long1,long2 -- --long >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,1s/.*\///' -e "1s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+sed -i -e "1s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest longopts
$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbriviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest name_option_long
$TS_CMD_GETOPT -n THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest name_option_short
$TS_CMD_GETOPT --name THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest quiet_option_long
$TS_CMD_GETOPT --quiet -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest quiet_option_short
$TS_CMD_GETOPT -q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest quiet_output_option_long
$TS_CMD_GETOPT --quiet-output -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+sed -i -e "3s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest quiet_output_option_short
$TS_CMD_GETOPT -Q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i -e '1,4s/.*\///' -e "3s/ambiguous$/ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+sed -i "3s/is ambiguous: long$/'--long' is ambiguous; possibilities: '--long1' '--long2'/" $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest same_long_short_options
$TS_CMD_GETOPT -o a -l a -- -a --a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest test_for_enhanced_getopt
$TS_CMD_GETOPT -T >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest unknown_options
$TS_CMD_GETOPT -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
sed -i '1,2s/.*\///' $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest unquoted_option_bash
@@ -128,6 +160,7 @@ $TS_CMD_GETOPT -s bash -u -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More
one
line' >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest unquoted_option_tcsh
@@ -136,6 +169,7 @@ $TS_CMD_GETOPT -s tcsh --unquoted -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'M
one
line' >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest weird_quoting_bash
@@ -144,6 +178,7 @@ $TS_CMD_GETOPT -s bash -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More
one
line' >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_init_subtest weird_quoting_tcsh
@@ -152,6 +187,7 @@ $TS_CMD_GETOPT --shell tcsh -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More
one
line' >> $TS_OUTPUT 2>&1
echo "exit value: $?" >> $TS_OUTPUT
+gnu_getopt_clean
ts_finalize_subtest
ts_finalize
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/12] tests: improve getopt loop error case
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (9 preceding siblings ...)
2016-03-07 23:12 ` [PATCH 10/12] tests: getopt2, add function gnu_getopt_clean() Ruediger Meier
@ 2016-03-07 23:12 ` Ruediger Meier
2016-03-07 23:12 ` [PATCH 12/12] getopt: fix -n name for BSD Ruediger Meier
2016-03-08 1:28 ` [PATCH 00/12] another BSD/OSX related patch-set Isaac Dunham
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:12 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Avoid exit 1 in test scripts. Simplify and complete redirection
to TS_OUPUT.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
tests/ts/misc/getopt | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tests/ts/misc/getopt b/tests/ts/misc/getopt
index 715ec36..460f8a8 100755
--- a/tests/ts/misc/getopt
+++ b/tests/ts/misc/getopt
@@ -31,17 +31,18 @@ eval set -- "$TEMP"
while true ; do
case "$1" in
- -a|--a-long) echo "Option a" >> $TS_OUTPUT 2>&1; shift ;;
- -b|--b-long) echo "Option b, argument \`$2'" >> $TS_OUTPUT 2>&1; shift 2 ;;
+ -a|--a-long) echo "Option a"; shift ;;
+ -b|--b-long) echo "Option b, argument \`$2'"; shift 2 ;;
-c|--c-long)
case "$2" in
- "") echo "Option c, no argument" >> $TS_OUTPUT 2>&1; shift 2 ;;
- *) echo "Option c, argument \`$2'" >> $TS_OUTPUT 2>&1; shift 2 ;;
+ "") echo "Option c, no argument"; shift 2 ;;
+ *) echo "Option c, argument \`$2'"; shift 2 ;;
esac ;;
--) shift ; break ;;
- *) echo "Internal error!" >> $TS_OUTPUT 2>&1; exit 1 ;;
+ *) echo "Internal error!"; break;;
esac
-done
+done >> $TS_OUTPUT 2>&1
+
echo "Remaining arguments:" >> $TS_OUTPUT 2>&1
for arg do echo '--> '"\`$arg'" >> $TS_OUTPUT 2>&1; done
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 12/12] getopt: fix -n name for BSD
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (10 preceding siblings ...)
2016-03-07 23:12 ` [PATCH 11/12] tests: improve getopt loop error case Ruediger Meier
@ 2016-03-07 23:12 ` Ruediger Meier
2016-03-08 1:28 ` [PATCH 00/12] another BSD/OSX related patch-set Isaac Dunham
12 siblings, 0 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-07 23:12 UTC (permalink / raw)
To: util-linux
From: Ruediger Meier <ruediger.meier@ga-group.nl>
BSD gets the program name for warnings from getprogname() and not
from argv. Thus we use setprogname() there.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
misc-utils/getopt.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c
index c166fd7..c4144f6 100644
--- a/misc-utils/getopt.c
+++ b/misc-utils/getopt.c
@@ -62,6 +62,9 @@
#include <unistd.h>
#include <ctype.h>
#include <getopt.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h> /* BSD */
+#endif
#include "closestream.h"
#include "nls.h"
@@ -447,9 +450,13 @@ int main(int argc, char *argv[])
optind++;
}
}
- if (name)
+
+ if (name) {
argv[optind - 1] = name;
- else
+#if defined (BSD) || defined (__APPLE__)
+ setprogname(name);
+#endif
+ } else
argv[optind - 1] = argv[0];
return generate_output(&ctl, argv + optind - 1, argc - optind + 1);
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 00/12] another BSD/OSX related patch-set
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
` (11 preceding siblings ...)
2016-03-07 23:12 ` [PATCH 12/12] getopt: fix -n name for BSD Ruediger Meier
@ 2016-03-08 1:28 ` Isaac Dunham
2016-03-14 1:43 ` Ruediger Meier
12 siblings, 1 reply; 18+ messages in thread
From: Isaac Dunham @ 2016-03-08 1:28 UTC (permalink / raw)
To: Ruediger Meier; +Cc: util-linux
On Tue, Mar 08, 2016 at 12:11:50AM +0100, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>
> This is github pull request #299
> https://github.com/karelzak/util-linux/pull/299
>
> Again some arbitrary BSD, OSX and musl related fixes and clean-up
<snip>
> For OSX one should additionally disable all utmp.h related programs.
FYI:
With musl, utmpx is stubbed out and utmp is wrappers for utmpx, so
users should disable utmp(x)-related programs and code.
(The point is to let things build, but not use utmp because the maintainer
considers it a fundamentally flawed idea.)
Additionally, systemd is working on allowing disabling of utmp(x).
This seems to imply that --disable-utmp/--disable-utmpx options would be
helpful.
> Almost no interesting compiler warnings left. Xcode/clang warnings are
> a bit over the top anyways.
>
>
> Ruediger Meier (12):
> wipefs, sfdisk: include libgen.h for basename(3p)
I'm glad to see use of POSIX basename(), which is the only version that
musl implements.
The way musl implements basename, strdup() is not needed, but following
POSIX is better than relying on implementation-specific details.
Thanks,
Isaac Dunham
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/12] another BSD/OSX related patch-set
2016-03-08 1:28 ` [PATCH 00/12] another BSD/OSX related patch-set Isaac Dunham
@ 2016-03-14 1:43 ` Ruediger Meier
2016-03-14 15:10 ` Karel Zak
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Ruediger Meier @ 2016-03-14 1:43 UTC (permalink / raw)
To: Isaac Dunham; +Cc: util-linux
On Tuesday 08 March 2016, Isaac Dunham wrote:
> On Tue, Mar 08, 2016 at 12:11:50AM +0100, Ruediger Meier wrote:
> > From: Ruediger Meier <ruediger.meier@ga-group.nl>
> >
> > This is github pull request #299
> > https://github.com/karelzak/util-linux/pull/299
> >
> > Again some arbitrary BSD, OSX and musl related fixes and clean-up
>
> <snip>
>
> > For OSX one should additionally disable all utmp.h related
> > programs.
>
> FYI:
> With musl, utmpx is stubbed out and utmp is wrappers for utmpx, so
> users should disable utmp(x)-related programs and code.
> (The point is to let things build, but not use utmp because the
> maintainer considers it a fundamentally flawed idea.)
>
> Additionally, systemd is working on allowing disabling of utmp(x).
Will there be another interface to be used by last(1)?
> This seems to imply that --disable-utmp/--disable-utmpx options would
> be helpful.
Do you mean --without-utmp to build our progs without utmp or really
disabling the build of all progs which are using utmp right now?
Actually I thought the next step could be to remove utmp and use utmpx
only because it's POSIX and more portable. See commit d00c10ed.
> > Almost no interesting compiler warnings left. Xcode/clang warnings
> > are a bit over the top anyways.
> >
> >
> > Ruediger Meier (12):
> > wipefs, sfdisk: include libgen.h for basename(3p)
>
> I'm glad to see use of POSIX basename(), which is the only version
> that musl implements.
There are still two files to be fixed
login-utils/last.c
login-utils/su-common.c
On the other hand I thought we could also completely avoid basename(3p)
and use something like our stripoff_last_component() from
lib/fileutils.c.
> The way musl implements basename, strdup() is not needed, but
> following POSIX is better than relying on implementation-specific
> details.
>
> Thanks,
> Isaac Dunham
> --
> 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] 18+ messages in thread
* Re: [PATCH 00/12] another BSD/OSX related patch-set
2016-03-14 1:43 ` Ruediger Meier
@ 2016-03-14 15:10 ` Karel Zak
2016-03-15 2:10 ` Isaac Dunham
2016-03-15 11:24 ` Karel Zak
2 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2016-03-14 15:10 UTC (permalink / raw)
To: Ruediger Meier; +Cc: Isaac Dunham, util-linux
On Mon, Mar 14, 2016 at 02:43:40AM +0100, Ruediger Meier wrote:
> > > Ruediger Meier (12):
> > > wipefs, sfdisk: include libgen.h for basename(3p)
> >
> > I'm glad to see use of POSIX basename(), which is the only version
> > that musl implements.
>
> There are still two files to be fixed
> login-utils/last.c
> login-utils/su-common.c
>
> On the other hand I thought we could also completely avoid basename(3p)
> and use something like our stripoff_last_component() from
> lib/fileutils.c.
Yep, and maybe also introduce strdup_last_component() in case we
don't want to modify the original path.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/12] another BSD/OSX related patch-set
2016-03-14 1:43 ` Ruediger Meier
2016-03-14 15:10 ` Karel Zak
@ 2016-03-15 2:10 ` Isaac Dunham
2016-03-15 11:24 ` Karel Zak
2 siblings, 0 replies; 18+ messages in thread
From: Isaac Dunham @ 2016-03-15 2:10 UTC (permalink / raw)
To: Ruediger Meier; +Cc: util-linux
On Mon, Mar 14, 2016 at 02:43:40AM +0100, Ruediger Meier wrote:
> On Tuesday 08 March 2016, Isaac Dunham wrote:
> > On Tue, Mar 08, 2016 at 12:11:50AM +0100, Ruediger Meier wrote:
> > > From: Ruediger Meier <ruediger.meier@ga-group.nl>
> > >
> > > This is github pull request #299
> > > https://github.com/karelzak/util-linux/pull/299
> > >
> > > Again some arbitrary BSD, OSX and musl related fixes and clean-up
> >
> > <snip>
> >
> > > For OSX one should additionally disable all utmp.h related
> > > programs.
> >
> > FYI:
> > With musl, utmpx is stubbed out and utmp is wrappers for utmpx, so
> > users should disable utmp(x)-related programs and code.
>
> > (The point is to let things build, but not use utmp because the
> > maintainer considers it a fundamentally flawed idea.)
> >
> > Additionally, systemd is working on allowing disabling of utmp(x).
>
> Will there be another interface to be used by last(1)?
As far as I know, the only option for that on no-utmp(x) systems would be
PAM.
> > This seems to imply that --disable-utmp/--disable-utmpx options would
> > be helpful.
>
> Do you mean --without-utmp to build our progs without utmp or really
> disabling the build of all progs which are using utmp right now?
Ideally, it would be build progs without utmp(x), and disable build of
anything that's a stub after that.
For example:
uptime would either drop the '<n> users' field, or change it to
'?? users' (the latter would keep the right number of fields).
wall would disappear, since it enumerates active ttys based on utmp.
last would disappear, since it gets login records from utmp(x).
> Actually I thought the next step could be to remove utmp and use utmpx
> only because it's POSIX and more portable. See commit d00c10ed.
That doesn't address what I'm concerned about, though it's a nice thought.
(In fact, OpenBSD is utmp only.)
I'm saying that it would be *nice* to be able to turn off *everything* that
relies on utmp or utmpx, all at once.
Is that, at least in theory, acceptable?
Thanks,
Isaac Dunham
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/12] another BSD/OSX related patch-set
2016-03-14 1:43 ` Ruediger Meier
2016-03-14 15:10 ` Karel Zak
2016-03-15 2:10 ` Isaac Dunham
@ 2016-03-15 11:24 ` Karel Zak
2 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2016-03-15 11:24 UTC (permalink / raw)
To: Ruediger Meier; +Cc: Isaac Dunham, util-linux
On Mon, Mar 14, 2016 at 02:43:40AM +0100, Ruediger Meier wrote:
> On Tuesday 08 March 2016, Isaac Dunham wrote:
> > On Tue, Mar 08, 2016 at 12:11:50AM +0100, Ruediger Meier wrote:
> > > From: Ruediger Meier <ruediger.meier@ga-group.nl>
> > >
> > > This is github pull request #299
> > > https://github.com/karelzak/util-linux/pull/299
> > >
> > > Again some arbitrary BSD, OSX and musl related fixes and clean-up
> >
> > <snip>
> >
> > > For OSX one should additionally disable all utmp.h related
> > > programs.
> >
> > FYI:
> > With musl, utmpx is stubbed out and utmp is wrappers for utmpx, so
> > users should disable utmp(x)-related programs and code.
>
> > (The point is to let things build, but not use utmp because the
> > maintainer considers it a fundamentally flawed idea.)
> >
> > Additionally, systemd is working on allowing disabling of utmp(x).
>
> Will there be another interface to be used by last(1)?
>
> > This seems to imply that --disable-utmp/--disable-utmpx options would
> > be helpful.
>
> Do you mean --without-utmp to build our progs without utmp or really
> disabling the build of all progs which are using utmp right now?
>
> Actually I thought the next step could be to remove utmp and use utmpx
> only because it's POSIX and more portable. See commit d00c10ed.
>
> There are still two files to be fixed
> login-utils/last.c
> login-utils/su-common.c
Well, programs like login(1) and su(1) use btmp to log failed login
attempts, it should be enough to check if _PATH_BTMP exists,
otherwise ignore the file.
If we want to use --without-utmp then only for portability (libc
does not provide relevant headers).
I guess we want to support work with (archived) utmp files, so
programs like utmpdump makes sense everywhere (if possible).
The last(1) or lslogins(1) have to be smart enough to ignore missing
files by default. So again, --without-utmp should be about
portability only.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-03-15 11:24 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07 23:11 [PATCH 00/12] another BSD/OSX related patch-set Ruediger Meier
2016-03-07 23:11 ` [PATCH 01/12] wipefs, sfdisk: include libgen.h for basename(3p) Ruediger Meier
2016-03-07 23:11 ` [PATCH 02/12] misc: again fixing many printf format strings Ruediger Meier
2016-03-07 23:11 ` [PATCH 03/12] lib: include sys/stat.h for struct stat Ruediger Meier
2016-03-07 23:11 ` [PATCH 04/12] fdisk: sun, undef HAVE_QSORT_R for non-Linux Ruediger Meier
2016-03-07 23:11 ` [PATCH 05/12] libfdisk: remove ifdef HDIO_GETGEO Ruediger Meier
2016-03-07 23:11 ` [PATCH 06/12] misc: never cast void* from malloc(3) and friends Ruediger Meier
2016-03-07 23:11 ` [PATCH 07/12] libmount: don't include libio.h Ruediger Meier
2016-03-07 23:11 ` [PATCH 08/12] tests: cramfs, fix root group Ruediger Meier
2016-03-07 23:11 ` [PATCH 09/12] tests: don't skip case "output undefined" Ruediger Meier
2016-03-07 23:12 ` [PATCH 10/12] tests: getopt2, add function gnu_getopt_clean() Ruediger Meier
2016-03-07 23:12 ` [PATCH 11/12] tests: improve getopt loop error case Ruediger Meier
2016-03-07 23:12 ` [PATCH 12/12] getopt: fix -n name for BSD Ruediger Meier
2016-03-08 1:28 ` [PATCH 00/12] another BSD/OSX related patch-set Isaac Dunham
2016-03-14 1:43 ` Ruediger Meier
2016-03-14 15:10 ` Karel Zak
2016-03-15 2:10 ` Isaac Dunham
2016-03-15 11:24 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox