Alien-Libjio

 view release on metacpan or  search on metacpan

libjio/libjio/compat.h  view on Meta::CPAN


#ifndef _COMPAT_H
#define _COMPAT_H


/* sync_file_range() is linux-specific, so we provide an internal similar API,
 * with a constant to be able to check for its presence; the implementation is
 * in compat.c.
 *
 * To get its constants we need to temporarily define _GNU_SOURCE, which is
 * not the nicest thing, but is not worth defining globally. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#define _REMOVE_GNU_SOURCE
#endif
#include <fcntl.h>		/* SYNC_FILE_RANGE_WRITE, if available */
#ifdef _REMOVE_GNU_SOURCE
#undef _REMOVE_GNU_SOURCE
#undef _GNU_SOURCE
#endif

libjio/libjio/journal.c  view on Meta::CPAN

/** fsync() a directory */
static int fsync_dir(int fd)
{
	int rv;

	rv = fsync(fd);

	if (rv != 0 && (errno == EINVAL || errno == EBADF)) {
		/* it seems to be legal that fsync() on directories is not
		 * implemented, so if this fails with EINVAL or EBADF, just
		 * call a global sync(); which is awful (and might still
		 * return before metadata is done) but it seems to be the
		 * saner choice; otherwise we just fail */
		sync();
		rv = 0;

		if (!already_warned_about_sync) {
			fprintf(stderr, "libjio warning: falling back on " \
					"sync() for directory syncing\n");
			already_warned_about_sync = 1;
		}

libjio/tests/stress/jiostress  view on Meta::CPAN

	print("support. Please install libfiu and recompile libjio with FI=1.")
	print()
	raise

#
# Auxiliary stuff
#

gbcount = 0
def getbytes(n):
	global gbcount
	gbcount = (gbcount + 1) % 10
	return bytes(str(gbcount) * n, 'ascii')

def randfrange(maxend, maxsize):
	start = random.randint(0, maxend - 1)
	size = random.randint(0, (maxend - 1) - start) % maxsize
	return start, start + size

def randfloat(min, max):
	return min + random.random() % (max - min)



( run in 0.783 second using v1.01-cache-2.11-cpan-49f99fa48dc )