search for: init_fileop

Displaying 5 results from an estimated 5 matches for "init_fileop".

Did you mean: init_fileops
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 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...e and use NBDKIT_API_VERSION == 2 + * + * - your plugin per-connection handle must either have type ‘struct + * fileops *’, or include ‘struct fileops’ as the first member + * + * - add FILEOPS_READ_WRITE_CALLBACKS or + * FILEOPS_READ_ONLY_CALLBACKS to your ‘struct nbdkit_plugin’ + * + * - call init_fileops from your .open callback, and close_fileops + * from your .close callback + * + * - optionally call fileops_dump_plugin from your .dump_plugin + * callback if you have one + * + * - the fileops mini-library is linked statically into the plugin + * + * This mini-library is safe to use from any...
2020 Apr 09
1
[PATCH nbdkit PRELIMINARY] file: Move file operators to a new fileops mini-library
...file callbacks (like file.pread, file.pwrite, file.zero etc) to a new mini-library. They can then be consumed by other plugins fairly easily by doing: static void * foo_open (int readonly) { struct fileops *fops; int fd, flags; /* Allocate *fops */ /* Set up fd however you want */ if (init_fileops (fd, fops) == -1) { free (fops); return NULL; } return fops; } static struct nbdkit_plugin plugin = { .name = "foo", .open = foo_open, .close = foo_close, FILEOPS_CALLBACKS }; If we did this then it would only work for plugins...
2020 Apr 09
0
[PATCH nbdkit v2 2/3] iso: Implement this plugin using fileops (read-only).
...+ if (fops == NULL) { + nbdkit_error ("malloc: %m"); + return NULL; + } + + /* Copy the fd because fileops needs to have its own file descriptor. */ + fd = dup (iso_fd); + if (fd == -1) { + nbdkit_error ("dup: %m"); + free (fops); + return NULL; + } + + if (init_fileops (fd, fops) == -1) { + free (fops); + return NULL; + } + + return fops; +} + +/* Free up the per-connection handle. */ +static void +iso_close (void *handle) +{ + struct fileops *fops = handle; + + close_fileops (fops); + free (fops); } #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALL...
2020 Apr 09
0
[PATCH nbdkit v2 3/3] tmpdisk: Implement this plugin using fileops.
...(h->fd); - if (h->size == -1) - goto error; - } - else /* Regular file. */ - h->size = statbuf.st_size; - nbdkit_debug ("tmpdisk: requested_size = %" PRIi64 ", size = %" PRIi64, - requested_size, h->size); + if (init_fileops (fd, fops) == -1) + goto error3; /* We don't need the disk to appear in the filesystem since we hold * a file descriptor and access it through that, so unlink the disk. @@ -357,139 +290,26 @@ tmpdisk_open (int readonly) rmdir (dir); /* Return the handle. */ - return h; +...