Displaying 15 results from an estimated 15 matches for "xsrandom".
Did you mean:
srandom
2018 Dec 28
2
[PATCH v2 nbdkit] common: Improve pseudo-random number generation.
v2:
- Fix seeding.
- Add a test that nbdkit-random-plugin is producing something
which looks at least somewhat random.
Rich.
2018 Dec 31
1
Re: [PATCH v2 nbdkit] common: Improve pseudo-random number generation.
...yptography or security is
> + * required - use gcrypt if you need those.
> + */
> +
> +/* You can seed ‘struct random_state’ by setting the s[] elements
> + * directly - but not you must NOT set it all to zero. OR if you have
s/not you/note you/
> + * a 64 bit seed, you can use xsrandom below to initialize the state.
> + */
> +struct random_state {
> + uint64_t s[4];
> +};
> +
> +static inline uint64_t
> +snext (uint64_t *seed)
> +{
> + uint64_t z = (*seed += 0x9e3779b97f4a7c15);
> + z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
> + z = (z ^...
2018 Dec 28
0
[PATCH v2 nbdkit] common: Improve pseudo-random number generation.
...mbers
+ * (CSPRNG) and so should not be used when cryptography or security is
+ * required - use gcrypt if you need those.
+ */
+
+/* You can seed ‘struct random_state’ by setting the s[] elements
+ * directly - but not you must NOT set it all to zero. OR if you have
+ * a 64 bit seed, you can use xsrandom below to initialize the state.
+ */
+struct random_state {
+ uint64_t s[4];
+};
+
+static inline uint64_t
+snext (uint64_t *seed)
+{
+ uint64_t z = (*seed += 0x9e3779b97f4a7c15);
+ z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
+ z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
+ return z ^ (z...
2019 Jan 01
3
[PATCH nbdkit] include: Annotate function parameters with attribute((nonnull)).
Should we use attribute((nonnull)) at all? There's a very interesting
history of this in libvirt -- try looking at commit eefb881 plus the
commits referencing eefb881 -- but it does seem to work for me using
recent GCC and Clang.
I only did a few functions because annotating them gets old quickly...
Rich.
2020 Apr 15
0
[PATCH nbdkit 4/9] common/regions: Use new vector type to store the list of regions.
...oot records.
* Secondary PT is only used for GPT. EBR array of sectors is only
@@ -93,7 +93,7 @@ static struct random_state random_state;
static void
partitioning_load (void)
{
- init_regions (®ions);
+ init_regions (&the_regions);
parse_guid (DEFAULT_TYPE_GUID, type_guid);
xsrandom (time (NULL), &random_state);
}
@@ -110,7 +110,7 @@ partitioning_unload (void)
/* We don't need to free regions.regions[].u.data because it points
* to primary, secondary or ebr which we free here.
*/
- free_regions (®ions);
+ free_regions (&the_regions);
free...
2019 Jan 02
0
[PATCH nbdkit v2 1/2] Annotate internal function parameters with attribute((nonnull)).
...lude/random.h b/common/include/random.h
index eb08295..098c6d6 100644
--- a/common/include/random.h
+++ b/common/include/random.h
@@ -67,7 +67,7 @@ snext (uint64_t *seed)
}
/* Seed the random state from a 64 bit seed. */
-static inline void
+static inline void __attribute__((__nonnull__ (2)))
xsrandom (uint64_t seed, struct random_state *state)
{
state->s[0] = snext (&seed);
@@ -83,7 +83,7 @@ rotl (const uint64_t x, int k)
}
/* Returns 64 random bits. Updates the state. */
-static inline uint64_t
+static inline uint64_t __attribute__((__nonnull__ (1)))
xrandom (struct random_sta...
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
2019 Mar 19
0
[PATCH nbdkit 1/9] server: Implement extents/can_extents calls for plugins and filters.
...j, type);
+ dump_extents_map (map);
+ exit (EXIT_FAILURE);
+ }
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ unsigned i;
+ uint64_t offset, length;
+ uint32_t type;
+ size_t j;
+ struct random_state random_state;
+ struct nbdkit_extents_map *map;
+
+ xsrandom (time (NULL), &random_state);
+
+ map = nbdkit_extents_new ();
+ assert (map != NULL);
+
+ for (i = 0; i < 1000; ++i) {
+ type = xrandom (&random_state);
+ type &= 3;
+ offset = xrandom (&random_state);
+ offset &= DISK_SIZE - 1;
+ /* XXX Change the distribu...
2019 Feb 22
0
[PATCH nbdkit v3 4/4] Add linuxdisk plugin.
...;;
+int64_t size;
+bool size_add_estimate; /* if size=+SIZE was used */
+
+/* Virtual disk. */
+static struct virtual_disk disk;
+
+/* Used to create a random GUID for the partition. */
+struct random_state random_state;
+
+static void
+linuxdisk_load (void)
+{
+ init_virtual_disk (&disk);
+ xsrandom (time (NULL), &random_state);
+}
+
+static void
+linuxdisk_unload (void)
+{
+ free_virtual_disk (&disk);
+ free (dir);
+}
+
+static int
+linuxdisk_config (const char *key, const char *value)
+{
+ if (strcmp (key, "dir") == 0) {
+ if (dir != NULL) {
+ /* TODO: Support me...
2019 Feb 19
0
[PATCH nbdkit 4/4] Add linuxdisk plugin.
...size_add_estimate; /* if size=+SIZE was used */
+
+/* Virtual disk. */
+static struct virtual_disk disk;
+
+/* Used to create a random GUID for the partition. */
+struct random_state random_state;
+
+static void
+linuxdisk_load (void)
+{
+ load_filesystem ();
+ init_virtual_disk (&disk);
+ xsrandom (time (NULL), &random_state);
+}
+
+static void
+linuxdisk_unload (void)
+{
+ size_t i;
+
+ free_virtual_disk (&disk);
+
+ for (i = 0; i < nr_dirs; ++i)
+ free (dirs[i]);
+ free (dirs);
+}
+
+static int
+linuxdisk_config (const char *key, const char *value)
+{
+ if (strcmp (key,...
2020 Apr 15
18
[PATCH nbdkit 0/9] Generic vector, and pass $nbdkit_stdio_safe to shell scripts.
This was a rather longer trip around the houses than I anticipated!
The basic purpose of the patch series is to set $nbdkit_stdio_safe to
"0" or "1" in sh and eval plugin scripts.
To do that, I ended up adding a nicer way to manipulate environ lists,
and to do that, I ended up adding a whole generic vector
implementation which is applicable in a lot of different places.
2019 Feb 22
5
[PATCH nbdkit v3 0/4] Add linuxdisk plugin.
For v3 I reimplemented this using mke2fs -d. This obviously makes the
implementation a whole lot simpler, but cannot support multiple
directory merging.
Patches 1-3 are the same as before. I've also reproduced the notes
from v2 below.
v2:
- Fix inconsistent tab/space.
- All 3 plugins now contain a block of text pointing to the
other 2 plugins.
- TMDIR -> TMPDIR
- Unlink the
2019 Mar 19
15
[PATCH nbdkit 0/9] [mainly for discussion and early review] Implement extents.
I want to post this but mainly for discussion and early review. It's
not safe for these patches to all go upstream yet (because not all
filters have been checked/adjusted), but if any patches were to go
upstream then probably 1 & 2 only are safe.
File, VDDK, memory and data plugins all work, although I have only
done minimal testing on them.
The current tests, such as they are, all
2019 Feb 19
6
[PATCH nbdkit v2 0/5] Add linuxdisk plugin.
Another interesting thing you can do with this plugin:
https://rwmj.wordpress.com/2019/02/19/nbdkit-linuxdisk-plugin/
v2:
- Fix inconsistent tab/space.
- All 3 plugins now contain a block of text pointing to the
other 2 plugins.
- TMDIR -> TMPDIR
- Unlink the temporary file and other cleanups along error paths.
- fclose -> pclose, and check the return value for errors.
-
2019 Feb 19
7
[PATCH nbdkit 0/4] New plugin: Add linuxdisk plugin.
Turns out Japanese trains are good for coding!
In supermin we have a bunch of code to create the libguestfs
appliance. It creates it directly using libext2fs (part of
e2fsprogs). We can use the same technique to create ext2 virtual
disks in nbdkit, which is what this new plugin does. Why a new plugin
instead of modifying the floppy plugin? See the 4/4 commit message
for an explanation.
The