From 4507e94c3ba68dbf455a9399de5f4ac1732eb5b7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 16 Nov 2018 20:42:20 +0000 Subject: [PATCH] Final running order for 2019 FOSDEM talk. --- 2019-fosdem/.gitignore | 1 + 2019-fosdem/6000-plugins.html | 42 ++++++ 2019-fosdem/6100-plugins-c.html | 155 +++++++++++++++++++ 2019-fosdem/6200-plugin-langs.html | 51 +++++++ 2019-fosdem/6300-plugins-shell.html | 6 + 2019-fosdem/6400-plugins-shell-2.html | 23 +++ 2019-fosdem/6450-cd.svg | 71 +++++++++ 2019-fosdem/6450-plugins-shell-what.html | 9 ++ 2019-fosdem/6450-tarfile.svg | 251 +++++++++++++++++++++++++++++++ 2019-fosdem/6500-shell-next | 21 +++ 2019-fosdem/6500-shell.d/.stamp | 0 2019-fosdem/6500-shell.sh | 4 + 2019-fosdem/9000-final.html | 17 +++ 2019-fosdem/style.css | 7 + 2019-fosdem/tar2iso.sh | 16 ++ 15 files changed, 674 insertions(+) create mode 100644 2019-fosdem/6000-plugins.html create mode 100644 2019-fosdem/6100-plugins-c.html create mode 100644 2019-fosdem/6200-plugin-langs.html create mode 100644 2019-fosdem/6300-plugins-shell.html create mode 100644 2019-fosdem/6400-plugins-shell-2.html create mode 100644 2019-fosdem/6450-cd.svg create mode 100644 2019-fosdem/6450-plugins-shell-what.html create mode 100644 2019-fosdem/6450-tarfile.svg create mode 100755 2019-fosdem/6500-shell-next create mode 100644 2019-fosdem/6500-shell.d/.stamp create mode 100755 2019-fosdem/6500-shell.sh create mode 100644 2019-fosdem/9000-final.html create mode 100755 2019-fosdem/tar2iso.sh diff --git a/2019-fosdem/.gitignore b/2019-fosdem/.gitignore index 349864b..aa996d7 100644 --- a/2019-fosdem/.gitignore +++ b/2019-fosdem/.gitignore @@ -6,6 +6,7 @@ /2200-partitioning.d/.root.img /2200-partitioning.d/root.img /2200-partitioning.d/swap.img +/6500-shell.d/tar2iso.sh /nbdview/error? /nbdview/log? /nbdview/sock? \ No newline at end of file diff --git a/2019-fosdem/6000-plugins.html b/2019-fosdem/6000-plugins.html new file mode 100644 index 0000000..acd95ba --- /dev/null +++ b/2019-fosdem/6000-plugins.html @@ -0,0 +1,42 @@ + + + + +

Writing plugins

+ + +
+ curl + data + ext2 + file + floppy + guestfs + gzip + iso + libvirt + + lua + memory + nbd + null + ocaml + partitioning + pattern + perl + python + + random + ruby + sh + split + streaming + tar + tcl + vddk + xz + zero +
diff --git a/2019-fosdem/6100-plugins-c.html b/2019-fosdem/6100-plugins-c.html new file mode 100644 index 0000000..d2685e5 --- /dev/null +++ b/2019-fosdem/6100-plugins-c.html @@ -0,0 +1,155 @@ + + + + +

Writing plugins in C?

+ + + +
+/* The size of disk in bytes (initialized by
+   size=<SIZE> parameter). */
+static int64_t size = 0;
+
+/* Debug directory operations
+   (-D memory.dir=1). */
+int memory_debug_dir;
+
+static struct sparse_array *sa;
+
+static void
+memory_load (void)
+{
+  sa = alloc_sparse_array (memory_debug_dir);
+  if (sa == NULL) {
+    perror ("malloc");
+    exit (EXIT_FAILURE);
+  }
+}
+
+static void
+memory_unload (void)
+{
+  free_sparse_array (sa);
+}
+
+static int
+memory_config (const char *key,
+               const char *value)
+{
+  if (strcmp (key, "size") == 0) {
+    size = nbdkit_parse_size (value);
+    if (size == -1)
+      return -1;
+  }
+  else {
+    nbdkit_error
+      ("unknown parameter '%s'", key);
+    return -1;
+  }
+
+  return 0;
+}
+
+static int
+memory_config_complete (void)
+{
+  if (size == 0) {
+    nbdkit_error ("you must specify "
+      "size=<SIZE> on the "
+      "command line");
+    return -1;
+  }
+  return 0;
+}
+
+#define memory_config_help \
+  "size=<SIZE>  (required)"
+  " Size of the backing disk"
+
+/* Create the per-connection handle. */
+static void *
+memory_open (int readonly)
+{
+  /* Used only as a handle pointer. */
+  static int mh;
+
+  return &mh;
+}
+
+#define THREAD_MODEL \
+NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS
+
+/* Get the disk size. */
+static int64_t
+memory_get_size (void *handle)
+{
+  return (int64_t) size;
+}
+
+/* Read data. */
+static int
+memory_pread (void *handle, void *buf,
+              uint32_t count, uint64_t offset)
+{
+  sparse_array_read (sa, buf, count, offset);
+  return 0;
+}
+
+/* Write data. */
+static int
+memory_pwrite (void *handle,
+               const void *buf,
+               uint32_t count, uint64_t offset)
+{
+  return sparse_array_write (sa,
+    buf, count, offset);
+}
+
+/* Zero. */
+static int
+memory_zero (void *handle,
+             uint32_t count,
+             uint64_t offset, int may_trim)
+{
+  sparse_array_zero (sa, count, offset);
+  return 0;
+}
+
+/* Trim (same as zero). */
+static int
+memory_trim (void *handle,
+             uint32_t count, uint64_t offset)
+{
+  sparse_array_zero (sa, count, offset);
+  return 0;
+}
+
+static struct nbdkit_plugin plugin = {
+  .name              = "memory",
+  .version           = PACKAGE_VERSION,
+  .load              = memory_load,
+  .unload            = memory_unload,
+  .config            = memory_config,
+  .config_complete   = memory_config_complete,
+  .config_help       = memory_config_help,
+  .open              = memory_open,
+  .get_size          = memory_get_size,
+  .pread             = memory_pread,
+  .pwrite            = memory_pwrite,
+  .zero              = memory_zero,
+  .trim              = memory_trim,
+  /* In this plugin, errno is preserved
+   * properly along error return
+   * paths from failed system calls.
+   */
+  .errno_is_preserved = 1,
+};
+
+NBDKIT_REGISTER_PLUGIN(plugin)
+
diff --git a/2019-fosdem/6200-plugin-langs.html b/2019-fosdem/6200-plugin-langs.html new file mode 100644 index 0000000..97a7799 --- /dev/null +++ b/2019-fosdem/6200-plugin-langs.html @@ -0,0 +1,51 @@ + + + + +

Writing plugins in other languages

+ + + + +
+ curl + data + ext2 + file + floppy + guestfs + gzip + iso + libvirt + + lua + memory + nbd + null + ocaml + partitioning + pattern + perl + python + + random + ruby + sh + split + streaming + tar + tcl + vddk + xz + zero +
diff --git a/2019-fosdem/6300-plugins-shell.html b/2019-fosdem/6300-plugins-shell.html new file mode 100644 index 0000000..eb384a7 --- /dev/null +++ b/2019-fosdem/6300-plugins-shell.html @@ -0,0 +1,6 @@ + + + + +

Writing plugins in shell script

+ diff --git a/2019-fosdem/6400-plugins-shell-2.html b/2019-fosdem/6400-plugins-shell-2.html new file mode 100644 index 0000000..5c2e981 --- /dev/null +++ b/2019-fosdem/6400-plugins-shell-2.html @@ -0,0 +1,23 @@ + + + + +

Writing plugins in shell script

+ +

+(Or any language). +We only need to write a few callbacks ... +

+ + + +

+Almost all callbacks are optional. +

diff --git a/2019-fosdem/6450-cd.svg b/2019-fosdem/6450-cd.svg new file mode 100644 index 0000000..881455e --- /dev/null +++ b/2019-fosdem/6450-cd.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2019-fosdem/6450-plugins-shell-what.html b/2019-fosdem/6450-plugins-shell-what.html new file mode 100644 index 0000000..a1ea8ea --- /dev/null +++ b/2019-fosdem/6450-plugins-shell-what.html @@ -0,0 +1,9 @@ + + + + +

What shell script?

+ + + + diff --git a/2019-fosdem/6450-tarfile.svg b/2019-fosdem/6450-tarfile.svg new file mode 100644 index 0000000..ae57d1a --- /dev/null +++ b/2019-fosdem/6450-tarfile.svg @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2019-fosdem/6500-shell-next b/2019-fosdem/6500-shell-next new file mode 100755 index 0000000..0fd1dd0 --- /dev/null +++ b/2019-fosdem/6500-shell-next @@ -0,0 +1,21 @@ +#!/bin/bash - + +source functions + +# Title. +export title="Writing tar2iso.sh" + +# History. +remember 'emacs tar2iso.sh &' +remember 'nbdkit sh ./tar2iso.sh file=~/nbdkit-1.9.0.tar.gz' +remember 'sudo nbd-client -b 512 localhost /dev/nbd0' +remember 'sudo mount /dev/nbd0 /tmp/mnt' + +./restore +pushd 6500-shell.d >/dev/null +rm -f tar2iso.sh +echo '#!/bin/bash' > tar2iso.sh +echo >> tar2iso.sh +chmod +x tar2iso.sh +terminal +popd >/dev/null diff --git a/2019-fosdem/6500-shell.d/.stamp b/2019-fosdem/6500-shell.d/.stamp new file mode 100644 index 0000000..e69de29 diff --git a/2019-fosdem/6500-shell.sh b/2019-fosdem/6500-shell.sh new file mode 100755 index 0000000..9290481 --- /dev/null +++ b/2019-fosdem/6500-shell.sh @@ -0,0 +1,4 @@ +#!/bin/bash - + +xfce4-terminal --disable-server \ + -x ./6500-shell-next diff --git a/2019-fosdem/9000-final.html b/2019-fosdem/9000-final.html new file mode 100644 index 0000000..e4e1c8c --- /dev/null +++ b/2019-fosdem/9000-final.html @@ -0,0 +1,17 @@ + + + + +

In summary

+ + + +

Any Questions?

diff --git a/2019-fosdem/style.css b/2019-fosdem/style.css index aa57add..1f66f13 100644 --- a/2019-fosdem/style.css +++ b/2019-fosdem/style.css @@ -23,6 +23,13 @@ h1 { border-bottom: 2px solid rgb(204,0,0); } +h2 { + color: rgb(204,0,0); + font-size: 32px; + font-style: italic; + border-bottom: 2px solid rgb(204,0,0); +} + b { color: rgb(204,0,0); } diff --git a/2019-fosdem/tar2iso.sh b/2019-fosdem/tar2iso.sh new file mode 100755 index 0000000..dc4a3b4 --- /dev/null +++ b/2019-fosdem/tar2iso.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +case "$1" in + config) + [ "$2" = "file" ] && ln -sf "$3" $tmpdir/tarfile ;; + config_complete) + tar zxf $tmpdir/tarfile -C $tmpdir + rm $tmpdir/tarfile + mkisofs -JrT -o $tmpdir/iso $tmpdir ;; + open) ;; + get_size) + stat -c '%s' $tmpdir/iso ;; + pread) + dd iflag=skip_bytes,count_bytes skip=$4 count=$3 if=$tmpdir/iso ;; + *) exit 2 ;; +esac -- 1.8.3.1