Displaying 11 results from an estimated 11 matches for "tmpdisk_open".
2020 Apr 09
0
[PATCH nbdkit v2 3/3] tmpdisk: Implement this plugin using fileops.
...urn 0;
}
-/* For block devices, stat->st_size is not the true size. */
-static int64_t
-block_device_size (int fd)
-{
- off_t size;
-
- size = lseek (fd, 0, SEEK_END);
- if (size == -1) {
- nbdkit_error ("lseek: %m");
- return -1;
- }
-
- return size;
-}
-
static void *
tmpdisk_open (int readonly)
{
- struct handle *h;
+ struct fileops *fops;
CLEANUP_FREE char *dir = NULL, *disk = NULL;
- int flags;
- struct stat statbuf;
+ int fd, flags;
- h = malloc (sizeof *h);
- if (h == NULL) {
+ fops = malloc (sizeof *fops);
+ if (fops == NULL) {
nbdkit_error ("m...
2020 Mar 17
1
Re: [PATCH nbdkit v2] New tmpdisk plugin.
On Tue, Mar 17, 2020 at 06:16:49AM -0500, Eric Blake wrote:
> >+static void *
> >+tmpdisk_open (int readonly)
> >+{
> >+ struct handle *h;
> >+ CLEANUP_FREE char *disk = NULL;
> >+ const char *tmpdir;
> >+
> >+ tmpdir = getenv ("TMPDIR");
> >+ if (!tmpdir)
> >+ tmpdir = "/var/tmp";
>
> Rather than calling gete...
2020 Apr 07
2
[PATCH nbdkit v2] tmpdisk: Generalize the tmpdisk plugin
An evolution of v1 here:
https://www.redhat.com/archives/libguestfs/2020-April/msg00035.html
I want to generalize the tmpdisk plugin, particularly so you can use
commands like ‘qemu-img create’ or even ‘virt-builder’.
(Actually virt-builder really works - I tested it - but of course it
causes a 30+ second delay when connecting to the server.)
You can now use commands such as:
nbdkit tmpdisk
2020 Apr 07
0
[PATCH nbdkit v2] tmpdisk: Pass any parameters as shell variables to the command.
..."size=%" PRIi64 "\n", size);
- fprintf (fp, "type=");
- shell_quote (type, fp);
putc ('\n', fp);
- putc ('\n', fp);
+ /* The command. */
fprintf (fp, "%s", command);
if (fclose (fp) == EOF) {
@@ -220,7 +254,9 @@ static void *
tmpdisk_open (int readonly)
{
struct handle *h;
- CLEANUP_FREE char *disk = NULL;
+ CLEANUP_FREE char *dir = NULL, *disk = NULL;
+ int flags;
+ struct stat statbuf;
h = malloc (sizeof *h);
if (h == NULL) {
@@ -228,36 +264,25 @@ tmpdisk_open (int readonly)
goto error;
}
h->fd = -1;...
2020 Apr 09
6
[PATCH nbdkit v2 0/3] Implement fileops.
Needs some work still, see in particular the commit message
for patch 3.
Rich.
2020 Apr 08
0
[PATCH nbdkit v3] tmpdisk: Pass any parameters as shell variables to the command.
...urn 0;
}
+/* For block devices, stat->st_size is not the true size. */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek: %m");
+ return -1;
+ }
+
+ return size;
+}
+
static void *
tmpdisk_open (int readonly)
{
struct handle *h;
- CLEANUP_FREE char *disk = NULL;
+ CLEANUP_FREE char *dir = NULL, *disk = NULL;
+ int flags;
+ struct stat statbuf;
h = malloc (sizeof *h);
if (h == NULL) {
@@ -228,36 +292,25 @@ tmpdisk_open (int readonly)
goto error;
}
h->fd = -1;...
2020 Mar 17
2
[PATCH nbdkit v2] New tmpdisk plugin.
...-1;
+ }
+ else if (WIFSIGNALED (r)) {
+ nbdkit_error ("command killed by signal %d", WTERMSIG (r));
+ return -1;
+ }
+ else if (WIFSTOPPED (r)) {
+ nbdkit_error ("command stopped by signal %d", WSTOPSIG (r));
+ return -1;
+ }
+
+ return 0;
+}
+
+static void *
+tmpdisk_open (int readonly)
+{
+ struct handle *h;
+ CLEANUP_FREE char *disk = NULL;
+ const char *tmpdir;
+
+ tmpdir = getenv ("TMPDIR");
+ if (!tmpdir)
+ tmpdir = "/var/tmp";
+
+ h = malloc (sizeof *h);
+ if (h == NULL) {
+ nbdkit_error ("malloc: %m");
+ goto erro...
2020 Mar 17
0
Re: [PATCH nbdkit v2] New tmpdisk plugin.
...ignal %d", WSTOPSIG (r));
> + return -1;
> + }
Generally, WIFSTOPPED() should be unreachable for the result of
system(). I don't mind if you leave it for ease of copy/paste, but it
doesn't hurt to drop it.
> +
> + return 0;
> +}
> +
> +static void *
> +tmpdisk_open (int readonly)
> +{
> + struct handle *h;
> + CLEANUP_FREE char *disk = NULL;
> + const char *tmpdir;
> +
> + tmpdir = getenv ("TMPDIR");
> + if (!tmpdir)
> + tmpdir = "/var/tmp";
Rather than calling getenv() for every client, should we pre-popul...
2020 Apr 08
2
[PATCH nbdkit v3] tmpdisk: Generalize the tmpdisk plugin.
v2 was here:
https://www.redhat.com/archives/libguestfs/2020-April/msg00075.html
In v3:
- Add [VAR=VALUE ...] to manual.
- Various minor improvements to the manual.
- Work (at least, in theory - not tested) with block devices or
symlinks. I didn't document this because it's hard to ensure these
files or block devices would be cleaned up, so here be dragons.
- Remove O_NOCTTY.
-
2020 Mar 16
1
[PATCH nbdkit] New tmpdisk plugin.
Unfinished (needs tests). This is my attempt to make a
"remote tmpfs" plugin as outlined in this prior email:
https://www.redhat.com/archives/libguestfs/2020-March/msg00134.html
Although it would be possible to construct something a bit like this
using existing plugins and filters (perhaps with some new features in
those filters) I think it may be nicer to have a dedicated plugin for
2020 Mar 17
2
[PATCH nbdkit v3] New tmpdisk plugin.
v2 was here:
https://www.redhat.com/archives/libguestfs/2020-March/msg00154.html
v3:
- Micro-optimize tmpdir.
- Quote $disk in default command shell fragment.
- Don't redirect mkfs output to /dev/null. Instead use
exec </dev/null >/dev/null before the shell fragment.
We may want to do this in other places where we run
external shell scripts, or more generally for all