|
|
cbc4cf |
From c2b650ebe33a001b3bf19912b136dbbff5495600 Mon Sep 17 00:00:00 2001
|
|
|
cbc4cf |
From: Frank Schaefer <kelledin@gmail.com>
|
|
|
cbc4cf |
Date: Tue, 10 Jul 2018 20:21:02 -0500
|
|
|
cbc4cf |
Subject: [PATCH 11/14] tests: break up large strings for PySys_WriteStdout()
|
|
|
cbc4cf |
|
|
|
cbc4cf |
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1656437
|
|
|
cbc4cf |
Upstream: http://github.com/karelzak/util-linux/commit/8a12ab57755afc36546834f175ef0b9e9376ba59
|
|
|
cbc4cf |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
cbc4cf |
---
|
|
|
cbc4cf |
libmount/python/fs.c | 56 ++++++++++++++++++++++++++++++++++----------
|
|
|
cbc4cf |
1 file changed, 43 insertions(+), 13 deletions(-)
|
|
|
cbc4cf |
|
|
|
cbc4cf |
diff --git a/libmount/python/fs.c b/libmount/python/fs.c
|
|
|
cbc4cf |
index d6490d248..634a914ef 100644
|
|
|
cbc4cf |
--- a/libmount/python/fs.c
|
|
|
cbc4cf |
+++ b/libmount/python/fs.c
|
|
|
cbc4cf |
@@ -63,32 +63,62 @@ static PyObject *Fs_get_devno(FsObject *self)
|
|
|
cbc4cf |
return PyObjectResultInt(mnt_fs_get_devno(self->fs));
|
|
|
cbc4cf |
}
|
|
|
cbc4cf |
|
|
|
cbc4cf |
+static void _dump_debug_string(const char *lead, const char *s, char quote)
|
|
|
cbc4cf |
+{
|
|
|
cbc4cf |
+ /* PySys_WriteStdout() will automatically truncate any '%s' token
|
|
|
cbc4cf |
+ * longer than a certain length (documented as 1000 bytes, but we
|
|
|
cbc4cf |
+ * give ourselves some margin here just in case). The only way I
|
|
|
cbc4cf |
+ * know to get around this is to print such strings in bite-sized
|
|
|
cbc4cf |
+ * chunks.
|
|
|
cbc4cf |
+ */
|
|
|
cbc4cf |
+ static const unsigned int _PY_MAX_LEN = 900;
|
|
|
cbc4cf |
+ static const char *_PY_MAX_LEN_FMT = "%.900s";
|
|
|
cbc4cf |
+ unsigned int len;
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
+ if (lead != NULL)
|
|
|
cbc4cf |
+ PySys_WriteStdout("%s", lead);
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
+ if (quote != 0)
|
|
|
cbc4cf |
+ PySys_WriteStdout("%c", quote);
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
+ for (len = strlen(s); len > _PY_MAX_LEN; len -= _PY_MAX_LEN, s += _PY_MAX_LEN)
|
|
|
cbc4cf |
+ PySys_WriteStdout(_PY_MAX_LEN_FMT, s);
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
+ if (len > 0)
|
|
|
cbc4cf |
+ PySys_WriteStdout(_PY_MAX_LEN_FMT, s);
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
+ if (quote != 0)
|
|
|
cbc4cf |
+ PySys_WriteStdout("%c\n", quote);
|
|
|
cbc4cf |
+ else
|
|
|
cbc4cf |
+ PySys_WriteStdout("\n");
|
|
|
cbc4cf |
+}
|
|
|
cbc4cf |
+
|
|
|
cbc4cf |
#define Fs_print_debug_HELP "print_debug()\n\n"
|
|
|
cbc4cf |
static PyObject *Fs_print_debug(FsObject *self)
|
|
|
cbc4cf |
{
|
|
|
cbc4cf |
PySys_WriteStdout("------ fs: %p\n", self->fs);
|
|
|
cbc4cf |
- PySys_WriteStdout("source: %s\n", mnt_fs_get_source(self->fs));
|
|
|
cbc4cf |
- PySys_WriteStdout("target: %s\n", mnt_fs_get_target(self->fs));
|
|
|
cbc4cf |
- PySys_WriteStdout("fstype: %s\n", mnt_fs_get_fstype(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("source: ", mnt_fs_get_source(self->fs), 0);
|
|
|
cbc4cf |
+ _dump_debug_string("target: ", mnt_fs_get_target(self->fs), 0);
|
|
|
cbc4cf |
+ _dump_debug_string("fstype: ", mnt_fs_get_fstype(self->fs), 0);
|
|
|
cbc4cf |
|
|
|
cbc4cf |
if (mnt_fs_get_options(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("optstr: %s\n", mnt_fs_get_options(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("optstr: ", mnt_fs_get_options(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_vfs_options(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("VFS-optstr: %s\n", mnt_fs_get_vfs_options(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("VFS-optstr: ", mnt_fs_get_vfs_options(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_fs_options(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("FS-opstr: %s\n", mnt_fs_get_fs_options(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("FS-opstr: ", mnt_fs_get_fs_options(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_user_options(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("user-optstr: %s\n", mnt_fs_get_user_options(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("user-optstr: ", mnt_fs_get_user_options(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_optional_fields(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("optional-fields: '%s'\n", mnt_fs_get_optional_fields(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("optional-fields: ", mnt_fs_get_optional_fields(self->fs), '\'');
|
|
|
cbc4cf |
if (mnt_fs_get_attributes(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("attributes: %s\n", mnt_fs_get_attributes(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("attributes: ", mnt_fs_get_attributes(self->fs), 0);
|
|
|
cbc4cf |
|
|
|
cbc4cf |
if (mnt_fs_get_root(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("root: %s\n", mnt_fs_get_root(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("root: ", mnt_fs_get_root(self->fs), 0);
|
|
|
cbc4cf |
|
|
|
cbc4cf |
if (mnt_fs_get_swaptype(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("swaptype: %s\n", mnt_fs_get_swaptype(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("swaptype: ", mnt_fs_get_swaptype(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_size(self->fs))
|
|
|
cbc4cf |
PySys_WriteStdout("size: %jd\n", mnt_fs_get_size(self->fs));
|
|
|
cbc4cf |
if (mnt_fs_get_usedsize(self->fs))
|
|
|
cbc4cf |
@@ -97,7 +127,7 @@ static PyObject *Fs_print_debug(FsObject *self)
|
|
|
cbc4cf |
PySys_WriteStdout("priority: %d\n", mnt_fs_get_priority(self->fs));
|
|
|
cbc4cf |
|
|
|
cbc4cf |
if (mnt_fs_get_bindsrc(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("bindsrc: %s\n", mnt_fs_get_bindsrc(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("bindsrc: ", mnt_fs_get_bindsrc(self->fs), 0);
|
|
|
cbc4cf |
if (mnt_fs_get_freq(self->fs))
|
|
|
cbc4cf |
PySys_WriteStdout("freq: %d\n", mnt_fs_get_freq(self->fs));
|
|
|
cbc4cf |
if (mnt_fs_get_passno(self->fs))
|
|
|
cbc4cf |
@@ -112,7 +142,7 @@ static PyObject *Fs_print_debug(FsObject *self)
|
|
|
cbc4cf |
if (mnt_fs_get_tid(self->fs))
|
|
|
cbc4cf |
PySys_WriteStdout("tid: %d\n", mnt_fs_get_tid(self->fs));
|
|
|
cbc4cf |
if (mnt_fs_get_comment(self->fs))
|
|
|
cbc4cf |
- PySys_WriteStdout("comment: '%s'\n", mnt_fs_get_comment(self->fs));
|
|
|
cbc4cf |
+ _dump_debug_string("comment: ", mnt_fs_get_comment(self->fs), '\'');
|
|
|
cbc4cf |
return UL_IncRef(self);
|
|
|
cbc4cf |
}
|
|
|
cbc4cf |
/*
|
|
|
cbc4cf |
--
|
|
|
cbc4cf |
2.17.2
|
|
|
cbc4cf |
|