Displaying 20 results from an estimated 113 matches for "nbdkit_parse_size".
2019 Feb 07
1
[PATCH nbdkit] server: utils: Fix nbdkit_parse_size to correctly handle negative values
From: Nikolay Ivanets <stenavin@gmail.com>
nbdkit_parse_size() uses strtoumax() function to parse input strings
which states:
"if there was a leading minus sign, the negation of the result of the
conversion represented as an unsigned value, unless the original
(nonnegated) value would overflow."
Later validation doesn't catch the situation wh...
2019 Feb 08
2
[PATCH nbdkit v2] server: utils: Make nbdkit_parse_size to reject negative values
From: Nikolay Ivanets <stenavin@gmail.com>
nbdkit_parse_size() uses strtoumax() function to parse input strings
which states:
"if there was a leading minus sign, the negation of the result of the
conversion represented as an unsigned value, unless the original
(nonnegated) value would overflow."
Later validation doesn't catch the situation wh...
2018 Feb 07
0
[nbdkit PATCH v2 2/2] utils: Revamp nbdkit_parse_size
...20 ++++++------
src/utils.c | 95 ++++++++++++++++++++++++++++++++++++--------------------
2 files changed, 72 insertions(+), 43 deletions(-)
diff --git a/src/test-utils.c b/src/test-utils.c
index e26a6f3..80bef2e 100644
--- a/src/test-utils.c
+++ b/src/test-utils.c
@@ -61,19 +61,19 @@ test_nbdkit_parse_size (void)
{ "", -1 },
{ "0x0", -1 },
{ "garbage", -1 },
- /* { "0garbage", -1 }, */
- /* { "-1", -1 }, */
- /* { "-2", -1 }, */
- /* { "9223372036854775808", -1 }, */
- /* { "-9223372036854775808&q...
2018 Feb 07
3
[nbdkit PATCH v2 0/2] Improve nbdkit_parse_size
...ing src/ files directly in src/, and
automake is a lot happier with this than with my v1 attempt
that tried to compile .c files across directories.
It's still enough of a change that I'm not pushing it right
away.
Eric Blake (2):
build: Add unit-testing of internal files
utils: Revamp nbdkit_parse_size
src/test-utils.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/utils.c | 95 +++++++++++++++++++++++++++--------------
.gitignore | 1 +
src/Makefile.am | 15 ++++++-
4 files changed, 205 insertions(+), 34 deletions(-)
create mode 100644 src/test-utils.c
--...
2023 Sep 03
1
[PATCH nbdkit] server: Move size parsing code (nbdkit_parse_size) to common/include
This is the first part of a pair of patch series which aim to let us
use nbdkit_parse_size (or rather, an equivalent common function) in
nbdcopy, so we can write:
nbdcopy --request-size=32M ...
We can't do that now which was annoying me earlier in the week.
This commit creates a new function called human_size_parse which is
basically nbdkit_parse_size, and turns nbdkit_parse_siz...
2018 Feb 02
0
[RFC nbdkit PATCH] utils: Revamp nbdkit_parse_size
...-80,49 +80,78 @@ nbdkit_absolute_path (const char *path)
return ret;
}
-/* XXX Multiple problems with this function. Really we should use the
- * 'human*' functions from gnulib.
+/* Parse a string with possible scaling suffix, or return -1 after reporting
+ * the error.
*/
int64_t
nbdkit_parse_size (const char *str)
{
uint64_t size;
- char t;
+ char *end;
+ uint64_t scale = 1;
- if (sscanf (str, "%" SCNu64 "%c", &size, &t) == 2) {
- switch (t) {
- case 'b': case 'B':
- return (int64_t) size;
- case 'k': case 'K'...
2023 Sep 05
1
[PATCH nbdkit] server: Move size parsing code (nbdkit_parse_size) to common/include
On Tue, Sep 05, 2023 at 11:09:02AM +0100, Richard W.M. Jones wrote:
> > > +static inline int64_t
> > > +human_size_parse (const char *str,
> > > + const char **error, const char **pstr)
> > > +{
> > > + int64_t size;
> > > + char *end;
> > > + uint64_t scale = 1;
> > > +
> > > + /* XXX Should we
2018 Feb 01
1
Re: [nbdkit PATCH v2 3/3] filters: Add blocksize filter
On Wed, Jan 31, 2018 at 09:26:39PM -0600, Eric Blake wrote:
> +static int
> +blocksize_parse (const char *name, const char *s, unsigned int *v)
Maybe use nbdkit_parse_size?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http:...
2018 Jul 01
2
[nbdkit] Plan for nbdkit 1.4?
...vely released in January this year
(although I didn't actually implement the stable/development branch
policy until April).
There has been a lot of development since then:
- Switch to defaulting to newstyle protocol.
- On-demand ramping of thread pool.
- TRIM support in the file plugin.
- nbdkit_parse_size rewritten.
- Test IPv6 connections.
- Reworked error handling.
- New log filter.
- New blocksize filter.
- New nozero filter.
- New fua filter.
- New can_zero, can_fua methods and better handling of FUA.
- New nbdkit_realpath function.
- Better handling of shutdown.
- New ext2 plugin.
-...
2020 May 22
1
Re: [PATCH nbdkit] DDRESCUE: MISC FIXES
...canf (line, "%" SCNi64 "\t%" SCNi64 "\t%c",
> + &offset, &length, &status) == 3) {
sscanf() cannot detect integer overflow. If you care about detecting
overflow, you'll have to rewrite this into an open-coded loop using
things like nbdkit_parse_size().
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
2018 Jan 19
1
Re: [PATCH nbdkit filters-v2 2/5] Introduce filters.
...am | 4 +-
> include/nbdkit-filter.h | 149 +++++++++++
> include/nbdkit-plugin.h | 2 +
> +++ b/include/nbdkit-filter.h
> +
> +#ifndef NBDKIT_FILTER_H
> +#define NBDKIT_FILTER_H
> +
> +/* This header also defines some useful functions like nbdkit_debug
> + * and nbdkit_parse_size which are appropriate for filters to use.
> + */
> +#include <nbdkit-plugin.h>
Should we stick the useful functions in a new header <nbdkit-common.h>
that both nbdkit-plugin.h and nbdkit-filter.h include? I'm worried that
the games we play with NBDKIT_API_VERSION in nbdkit-p...
2018 Jul 31
0
[PATCH nbdkit 1/4] Add truncate filter for truncating or extending the size of plugins.
...ng the parameters. */
+static int64_t size;
+
+/* Called for each key=value passed on the command line. */
+static int
+truncate_config (nbdkit_next_config *next, void *nxdata,
+ const char *key, const char *value)
+{
+ if (strcmp (key, "truncate") == 0) {
+ truncate = nbdkit_parse_size (value);
+ if (truncate == -1)
+ return -1;
+ return 0;
+ }
+ else if (strcmp (key, "round-up") == 0) {
+ round_up = nbdkit_parse_size (value);
+ if (round_up == -1)
+ return -1;
+ if (round_up == 0) {
+ nbdkit_error ("if set, the round-up parameter mu...
2020 Aug 18
0
[PATCH nbdkit 8/9] include: Prefix all exports with NBDKIT_DLLEXPORT.
...va_list args)
+extern NBDKIT_DLLEXPORT void nbdkit_debug (const char *msg, ...)
+ ATTRIBUTE_FORMAT_PRINTF (1, 2);
+extern NBDKIT_DLLEXPORT void nbdkit_vdebug (const char *msg, va_list args)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
-extern char *nbdkit_absolute_path (const char *path);
-extern int64_t nbdkit_parse_size (const char *str);
-extern int nbdkit_parse_bool (const char *str);
-extern int nbdkit_parse_int (const char *what, const char *str,
- int *r);
-extern int nbdkit_parse_unsigned (const char *what, const char *str,
- unsigned *r);
-extern...
2018 Jul 31
0
[PATCH nbdkit 3/4] Add map filter.
...ace, &saveptr);
+ if (p == NULL) {
+ /* AFAIK this can never happen. */
+ nbdkit_error ("%s:%d: could not read token", filename, lineno);
+ goto err;
+ }
+ if ((q = strchr (p, ',')) != NULL) { /* start,length */
+ *q = '\0'; q++;
+ i = nbdkit_parse_size (p);
+ if (i == -1)
+ goto err;
+ mapping.plugin_start = i;
+ i = nbdkit_parse_size (q);
+ if (i == -1)
+ goto err;
+ length = i;
+ }
+ else if ((q = strchr (p, '-')) != NULL) { /* start-end or start- */
+ *q = '\0'; q++;
+ i =...
2019 Aug 03
0
[nbdkit PATCH 3/3] server: Add and use nbdkit_nanosleep
..._dir_name \
mkostemp \
pipe2 \
+ ppoll \
posix_fadvise])
dnl Check whether printf("%m") works
diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h
index 5257d992..e004aa18 100644
--- a/include/nbdkit-common.h
+++ b/include/nbdkit-common.h
@@ -82,6 +82,7 @@ extern int64_t nbdkit_parse_size (const char *str);
extern int nbdkit_parse_bool (const char *str);
extern int nbdkit_read_password (const char *value, char **password);
extern char *nbdkit_realpath (const char *path);
+extern int nbdkit_nanosleep (unsigned sec, unsigned nsec);
struct nbdkit_extents;
extern int nbdkit_add_ex...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 2/5] lib: Move code for parsing, passwords and paths into libnbdkit.so.
...it_export_name;
- nbdkit_extents_count;
- nbdkit_extents_free;
- nbdkit_extents_new;
- nbdkit_get_extent;
nbdkit_nanosleep;
- nbdkit_parse_bool;
- nbdkit_parse_int8_t;
- nbdkit_parse_int16_t;
- nbdkit_parse_int32_t;
- nbdkit_parse_int64_t;
- nbdkit_parse_int;
- nbdkit_parse_size;
- nbdkit_parse_uint8_t;
- nbdkit_parse_uint16_t;
- nbdkit_parse_uint32_t;
- nbdkit_parse_uint64_t;
- nbdkit_parse_unsigned;
nbdkit_peer_name;
- nbdkit_read_password;
- nbdkit_realpath;
nbdkit_set_error;
nbdkit_shutdown;
nbdkit_vdebug;
nbdkit_verror;
-...
2018 Jan 19
0
[PATCH nbdkit filters-v2 3/5] filters: Add nbdkit-offset-filter.
...er.h>
+
+static int64_t offset = -1, range = -1;
+
+/* Called for each key=value passed on the command line. */
+static int
+offset_config (nbdkit_next_config *next, void *nxdata,
+ const char *key, const char *value)
+{
+ if (strcmp (key, "offset") == 0) {
+ offset = nbdkit_parse_size (value);
+ if (offset == -1)
+ return -1;
+ return 0;
+ }
+ else if (strcmp (key, "range") == 0) {
+ range = nbdkit_parse_size (value);
+ if (range == -1)
+ return -1;
+ return 0;
+ }
+ else
+ return next (nxdata, key, value);
+}
+
+/* Check the user did pa...
2017 Nov 14
0
[PATCH 3/3] docs: Add a section about what happens to the plugin when nbdkit shuts down.
...ny currently running
+plugin callbacks to finish and also call the C<.unload> callback
+before unloading the plugin.
+
+Note that it's not guaranteed this can always happen (eg. the server
+might be killed by C<SIGKILL> or segfault).
+
=head1 PARSING SIZE PARAMETERS
Use the C<nbdkit_parse_size> utility function to parse human-readable
--
2.13.2
2018 Jul 05
0
Re: [nbdkit] Plan for nbdkit 1.4?
...I didn't actually implement the stable/development branch
> policy until April).
>
> There has been a lot of development since then:
>
> - Switch to defaulting to newstyle protocol.
> - On-demand ramping of thread pool.
> - TRIM support in the file plugin.
> - nbdkit_parse_size rewritten.
> - Test IPv6 connections.
> - Reworked error handling.
> - New log filter.
> - New blocksize filter.
> - New nozero filter.
> - New fua filter.
> - New can_zero, can_fua methods and better handling of FUA.
I proposed python plugin implementations of t...
2018 Jul 06
0
ANNOUNCE: nbdkit 1.4.0 - an NBD server toolkit with stable plugin ABI and permissive license
...red Keys (PSK) authentication.
* We now default to the newstyle protocol, use -o to select oldstyle.
* On-demand ramping of thread pool.
* TRIM support in the file plugin.
* Reworked error handling.
* New can_zero, can_fua methods and better handling of FUA.
* New nbdkit_realpath function.
* nbdkit_parse_size rewritten.
* Better handling of shutdown path to ensure plugins can do long cleanups.
* New PKG_CHECK_VAR variables.
* Regression test for IPv6 connections.
* Of course numerous smaller bug fixes and improvements.
Thanks in particular to Eric Blake and Pino Toscano.
Rich.
--
Richard Jones,...