search for: call_read

Displaying 20 results from an estimated 34 matches for "call_read".

2020 Mar 19
0
[nbdkit PATCH 1/2] sh, eval: Cache .can_zero and .can_flush
...it_export_name () ? : "", NULL }; + struct sh_handle *h = malloc (sizeof *h); + + if (!h) { + nbdkit_error ("malloc: %m"); + return NULL; + } + h->can_flush = -1; + h->can_zero = -1; /* We store the string returned by open in the handle. */ - switch (call_read (&h, &hlen, args)) { + switch (call_read (&h->h, &hlen, args)) { case OK: /* Remove final newline if present. */ - if (hlen > 0 && h[hlen-1] == '\n') { - h[hlen-1] = '\0'; + if (hlen > 0 && h->h[hlen-1] == '\n')...
2023 Aug 30
2
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...**argv) CLEANUP_FREE_STRING string rbuf = empty_vector; CLEANUP_FREE_STRING string ebuf = empty_vector; - r = call3 (NULL, 0, &rbuf, &ebuf, argv); + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); return handle_script_error (argv[0], &ebuf, r); } @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) int r; CLEANUP_FREE_STRING string ebuf = empty_vector; - r = call3 (NULL, 0, rbuf, &ebuf, argv); + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); r = handle_script_error (argv[0], &ebuf, r); if (r == ERROR) string_reset (rbuf); @@ -58...
2020 Aug 25
0
[nbdkit PATCH 5/5] sh, eval: Implement .default_export
...n = p; while ((d = strchr (n, '\n')) != NULL) { @@ -310,13 +312,18 @@ sh_list_exports (int readonly, int default_only, default_only ? "true" : "false", NULL }; CLEANUP_FREE char *s = NULL; size_t slen; + const char *def; switch (call_read (&s, &slen, args)) { case OK: return parse_exports (script, s, slen, exports); case MISSING: - return nbdkit_add_export (exports, "", NULL); + /* Match what is done for a C plugin. */ + def = sh_default_export (readonly, nbdkit_is_tls ()); + if (!def) +...
2023 Aug 31
1
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...uf = empty_vector; > CLEANUP_FREE_STRING string ebuf = empty_vector; > > - r = call3 (NULL, 0, &rbuf, &ebuf, argv); > + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); > return handle_script_error (argv[0], &ebuf, r); > } > > @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) > int r; > CLEANUP_FREE_STRING string ebuf = empty_vector; > > - r = call3 (NULL, 0, rbuf, &ebuf, argv); > + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); > r = handle_script_error (argv[0], &ebuf, r); > if (r == ERRO...
2023 Aug 31
1
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...uf = empty_vector; > CLEANUP_FREE_STRING string ebuf = empty_vector; > > - r = call3 (NULL, 0, &rbuf, &ebuf, argv); > + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); > return handle_script_error (argv[0], &ebuf, r); > } > > @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) > int r; > CLEANUP_FREE_STRING string ebuf = empty_vector; > > - r = call3 (NULL, 0, rbuf, &ebuf, argv); > + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); > r = handle_script_error (argv[0], &ebuf, r); > if (r == ERRO...
2018 Dec 15
1
Re: [PATCH nbdkit v2 3/4] sh: Switch nbdkit-sh-plugin to use API version 2.
...user includes or omits a trailing newline on their output? > +static int > +sh_can_fua (void *handle) > +{ > + char *h = handle; > + const char *args[] = { script, "can_fua", h, NULL }; > + char *s = NULL; > + size_t slen; > + int r; > + > + switch (call_read (&s, &slen, args)) { > + case OK: > + if (slen > 0 && s[slen-1] == '\n') > + s[slen-1] = '\0'; Good - you do ignore trailing newline. Makes it easier for the author to not worry about it either way. > + > + case RET_FALSE: > + fre...
2023 Aug 31
1
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...FREE_STRING string ebuf = empty_vector; > > > > - r = call3 (NULL, 0, &rbuf, &ebuf, argv); > > + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); > > return handle_script_error (argv[0], &ebuf, r); > > } > > > > @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) > > int r; > > CLEANUP_FREE_STRING string ebuf = empty_vector; > > > > - r = call3 (NULL, 0, rbuf, &ebuf, argv); > > + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); > > r = handle_script_error (argv[0], &e...
2023 Aug 31
2
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...CLEANUP_FREE_STRING string ebuf = empty_vector; >> >> - r = call3 (NULL, 0, &rbuf, &ebuf, argv); >> + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); >> return handle_script_error (argv[0], &ebuf, r); >> } >> >> @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) >> int r; >> CLEANUP_FREE_STRING string ebuf = empty_vector; >> >> - r = call3 (NULL, 0, rbuf, &ebuf, argv); >> + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); >> r = handle_script_error (argv[0], &ebuf, r)...
2023 Aug 31
2
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...empty_vector; > >> > >> - r = call3 (NULL, 0, &rbuf, &ebuf, argv); > >> + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); > >> return handle_script_error (argv[0], &ebuf, r); > >> } > >> > >> @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) > >> int r; > >> CLEANUP_FREE_STRING string ebuf = empty_vector; > >> > >> - r = call3 (NULL, 0, rbuf, &ebuf, argv); > >> + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); > >> r = handle_script...
2023 Aug 31
1
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...ebuf = empty_vector; >>> >>> - r = call3 (NULL, 0, &rbuf, &ebuf, argv); >>> + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); >>> return handle_script_error (argv[0], &ebuf, r); >>> } >>> >>> @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) >>> int r; >>> CLEANUP_FREE_STRING string ebuf = empty_vector; >>> >>> - r = call3 (NULL, 0, rbuf, &ebuf, argv); >>> + r = call3 (NULL, 0, NULL, rbuf, &ebuf, argv); >>> r = handle_script_error...
2020 Mar 19
5
[nbdkit PATCH 0/2] More caching of initial setup
When I added .can_FOO caching in 1.16, I missed the case that the sh plugin itself was calling .can_flush twice in some situations (in order to default .can_fua). Then right after, I regressed it to call .can_zero twice (in order to default .can_fast_zero). I also missed that .thread_model could use better caching, because at the time, I did not add testsuite coverage. Fix that now. Eric Blake
2019 May 16
0
[nbdkit PATCH v2 07/24] sh: Implement .cache script callback
...olean method, the method prints "none", "emulate" or "native". */ +static int +sh_can_cache (void *handle) +{ + char *h = handle; + const char *args[] = { script, "can_cache", h, NULL }; + CLEANUP_FREE char *s = NULL; + size_t slen; + int r; + + switch (call_read (&s, &slen, args)) { + case OK: + if (slen > 0 && s[slen-1] == '\n') + s[slen-1] = '\0'; + if (strcasecmp (s, "none") == 0) + r = NBDKIT_CACHE_NONE; + else if (strcasecmp (s, "emulate") == 0) + r = NBDKIT_CACHE_EMULATE;...
2019 Jan 02
0
[PATCH nbdkit v2 1/2] Annotate internal function parameters with attribute((nonnull)).
...sh/call.h b/plugins/sh/call.h index 204a404..b5916b0 100644 --- a/plugins/sh/call.h +++ b/plugins/sh/call.h @@ -42,9 +42,13 @@ typedef enum exit_code { RET_FALSE = 3 /* script exited with code 3 meaning false */ } exit_code; -extern exit_code call (const char **argv); -extern exit_code call_read (char **rbuf, size_t *rbuflen, const char **argv); -extern exit_code call_write (const char *wbuf, size_t wbuflen, const char **argv); +extern exit_code call (const char **argv) + __attribute__((__nonnull__ (1))); +extern exit_code call_read (char **rbuf, size_t *rbuflen, const char **argv) + __a...
2018 Dec 15
5
[PATCH nbdkit v2 0/4] tests: Test export flags (eflags).
v1 was here: https://www.redhat.com/archives/libguestfs/2018-December/thread.html#00123 v2: - Document "-" instead of "script=-" and use it in the test; and verify this also works on FreeBSD; and verify that it doesn't depend on the particular behaviour of our wrapper script and should work with installed nbdkit too. - Fix handling of zero flags parameter. -
2018 Dec 14
0
[PATCH nbdkit 2/3] sh: Switch nbdkit-sh-plugin to use API version 2.
...); +} + +static int +sh_can_zero (void *handle) +{ + return boolean_method (handle, "can_zero"); +} + +static int +sh_can_fua (void *handle) +{ + char *h = handle; + const char *args[] = { script, "can_fua", h, NULL }; + char *s = NULL; + size_t slen; + int r; + + switch (call_read (&s, &slen, args)) { + case OK: + if (slen > 0 && s[slen-1] == '\n') + s[slen-1] = '\0'; + if (strcmp (s, "none") == 0) + r = NBDKIT_FUA_NONE; + else if (strcmp (s, "emulate") == 0) + r = NBDKIT_FUA_EMULATE; + else i...
2018 Dec 15
0
[PATCH nbdkit v2 3/4] sh: Switch nbdkit-sh-plugin to use API version 2.
...); +} + +static int +sh_can_zero (void *handle) +{ + return boolean_method (handle, "can_zero"); +} + +static int +sh_can_fua (void *handle) +{ + char *h = handle; + const char *args[] = { script, "can_fua", h, NULL }; + char *s = NULL; + size_t slen; + int r; + + switch (call_read (&s, &slen, args)) { + case OK: + if (slen > 0 && s[slen-1] == '\n') + s[slen-1] = '\0'; + if (strcmp (s, "none") == 0) + r = NBDKIT_FUA_NONE; + else if (strcmp (s, "emulate") == 0) + r = NBDKIT_FUA_EMULATE; + else i...
2019 Jan 02
4
[PATCH nbdkit v2 0/2] Use of attribute(()).
v1 was here: https://www.redhat.com/archives/libguestfs/2019-January/msg00008.html In v2 I have provided two patches: The first patch extends attribute((nonnull)) to most internal functions, but not to the external API. The second patch uses a macro so that attribute((format)) is only used in the public API on GCC or Clang. At least in theory these headers could be used by a C compiler which
2023 Aug 31
0
[nbdkit PATCH] sh: Allow pwrite to not consume all data
...; - r = call3 (NULL, 0, &rbuf, &ebuf, argv); > >>>> + r = call3 (NULL, 0, NULL, &rbuf, &ebuf, argv); > >>>> return handle_script_error (argv[0], &ebuf, r); > >>>> } > >>>> > >>>> @@ -568,7 +563,7 @@ call_read (string *rbuf, const char **argv) > >>>> int r; > >>>> CLEANUP_FREE_STRING string ebuf = empty_vector; > >>>> > >>>> - r = call3 (NULL, 0, rbuf, &ebuf, argv); > >>>> + r = call3 (NULL, 0, NULL, rbuf, &ebuf, a...
2019 May 20
3
[nbdkit PATCH 0/2] More on .thread_model
Rich pointed out that making thread_model dynamic even for plugins makes some sense, so here is the code for doing it for 'sh'. I'm less confident on how to do it for OCaml and Rust (not to mention that those allow the plugin to already compile in their model, rather than the language binding glue forcing a model). The other languages (lua, perl, python, ruby) still need to be
2020 Jul 31
0
[RFC nbdkit PATCH 4/4] sh, eval: Add .list_exports support
..._exports"; + const char *script = get_script (method); + const char *args[] = { script, method, readonly ? "true" : "false", + default_only ? "true" : "false", NULL }; + CLEANUP_FREE char *s = NULL; + size_t slen; + + switch (call_read (&s, &slen, args)) { + case OK: + return parse_exports (script, s, slen, exports); + + case MISSING: + return nbdkit_add_export (exports, "", NULL); + + case ERROR: + return -1; + + case RET_FALSE: + nbdkit_error ("%s: %s method returned unexpected code (3/fal...