Alien-Libjio

 view release on metacpan or  search on metacpan

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

}

/** Build the filename of a given transaction. Assumes jtfile can hold at
 * least PATH_MAX bytes. */
void get_jtfile(struct jfs *fs, unsigned int tid, char *jtfile)
{
	snprintf(jtfile, PATH_MAX, "%s/%u", fs->jdir, tid);
}


/* The ntohll() and htonll() functions are not standard, so we define them
 * using an UGLY trick because there is no standard way to check for
 * endianness at runtime. */

/** Convert a 64-bit value between network byte order and host byte order. */
uint64_t ntohll(uint64_t x)
{
	static int endianness = 0;

	/* determine the endianness by checking how htonl() behaves; use -1
	 * for little endian and 1 for big endian */
	if (endianness == 0) {
		if (htonl(1) == 1)
			endianness = 1;
		else
			endianness = -1;

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

	struct autosync_cfg *as_cfg;
};


off_t plockf(int fd, int cmd, off_t offset, off_t len);
ssize_t spread(int fd, void *buf, size_t count, off_t offset);
ssize_t spwrite(int fd, const void *buf, size_t count, off_t offset);
ssize_t swritev(int fd, struct iovec *iov, int iovcnt);
int get_jdir(const char *filename, char *jdir);
void get_jtfile(struct jfs *fs, unsigned int tid, char *jtfile);
uint64_t ntohll(uint64_t x);
uint64_t htonll(uint64_t x);

uint32_t checksum_buf(uint32_t sum, const unsigned char *buf, size_t count);

void autosync_check(struct jfs *fs);

#endif

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


static void ophdr_hton(struct on_disk_ophdr *ophdr)
{
	ophdr->len = htonl(ophdr->len);
	ophdr->offset = htonll(ophdr->offset);
}

static void ophdr_ntoh(struct on_disk_ophdr *ophdr)
{
	ophdr->len = ntohl(ophdr->len);
	ophdr->offset = ntohll(ophdr->offset);
}

static void trailer_hton(struct on_disk_trailer *trailer) {
	trailer->numops = htonl(trailer->numops);
	trailer->checksum = htonl(trailer->checksum);
}

static void trailer_ntoh(struct on_disk_trailer *trailer) {
	trailer->numops = ntohl(trailer->numops);
	trailer->checksum = ntohl(trailer->checksum);



( run in 2.604 seconds using v1.01-cache-2.11-cpan-800906f7e73 )