New port: cloop-utils.

cloop-utils are tools for creating and extracting cloop V2.0 compressed
read-only filesystem images.
This commit is contained in:
Max Khon 2004-01-25 12:56:50 +00:00
parent 1411fb6abc
commit bdb407082f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=99063
8 changed files with 142 additions and 0 deletions

View File

@ -53,6 +53,7 @@
SUBDIR += clean
SUBDIR += clockspeed
SUBDIR += clockspeed-conf
SUBDIR += cloop-utils
SUBDIR += cmdwatch
SUBDIR += colorize
SUBDIR += comconsole

View File

@ -0,0 +1,28 @@
# New ports collection makefile for: cloop-utils
# Date created: 19 Jan 2004
# Whom: Max Khon <fjoe@FreeBSD.org>
#
# $FreeBSD$
#
PORTNAME= cloop-utils
PORTVERSION= 2.00
CATEGORIES= sysutils
MASTER_SITES= http://developer.linuxtag.net/knoppix/sources/
DISTNAME= cloop_${PORTVERSION}-1
MAINTAINER= fjoe@freebsd.org
COMMENT= Compressed loop FS utils
WRKSRC= ${WRKDIR}/cloop-${PORTVERSION}
USE_GMAKE= yes
MAKE_ENV= APPSONLY=yes
PORTDOCS= README
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/create_compressed_fs ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/extract_compressed_fs ${PREFIX}/bin
${MKDIR} ${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
.include <bsd.port.mk>

View File

@ -0,0 +1 @@
MD5 (cloop_2.00-1.tar.gz) = a18f5d97bae863b823c42cf6722ef769

View File

@ -0,0 +1,16 @@
--- Makefile.orig Thu Jan 15 10:34:31 2004
+++ Makefile Thu Jan 15 10:34:31 2004
@@ -23,8 +23,12 @@
endif
KERNOBJ:=compressed_loop.o
+ALL_TARGETS = create_compressed_fs extract_compressed_fs
+ifndef APPSONLY
+ALL_TARGETS += cloop.o
+endif
-all: cloop.o create_compressed_fs extract_compressed_fs
+all: $(ALL_TARGETS)
cloop.o: compressed_loop.o
$(LD) -r -o $@ $^

View File

@ -0,0 +1,57 @@
--- create_compressed_fs.c.orig Sun Oct 26 05:15:22 2003
+++ create_compressed_fs.c Tue Jan 20 03:37:34 2004
@@ -18,7 +18,30 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#if defined(__FreeBSD__)
+#include <sys/endian.h>
+#include <netinet/in.h>
+typedef uint64_t loff_t;
+#ifndef htobe64
+static __inline __uint64_t
+__bswap64(__uint64_t _x)
+{
+
+ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
+ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
+ ((_x << 24) & ((__uint64_t)0xff << 40)) |
+ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+}
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define htobe64(x) __bswap64(x)
+#else
+#define htobe64(x)
+#endif
+#endif
+#define __cpu_to_be64 htobe64
+#else
#include <asm/byteorder.h>
+#endif
#include <fcntl.h>
#include <zlib.h>
#include "compressed_loop.h"
@@ -195,6 +218,23 @@
cbp=cbp->next;
free(compressed_blocks); compressed_blocks=cbp;
}
+#if defined(__FreeBSD__)
+ /*
+ * FreeBSD requires padding to 512 byte boundary
+ */
+ bytes_so_far = lseek(STDOUT_FILENO, 0, SEEK_END);
+ if (bytes_so_far % 512)
+ {
+ static char padding[512];
+ off_t len = 512 - bytes_so_far % 512;
+
+ if (write(STDOUT_FILENO, padding, len) != len)
+ {
+ perror("writing padding block");
+ return 1;
+ }
+ }
+#endif
fprintf(stderr,"Done.\n");
return 0;
}

View File

@ -0,0 +1,33 @@
--- extract_compressed_fs.c.orig Sun Oct 26 04:57:09 2003
+++ extract_compressed_fs.c Mon Jan 19 05:28:47 2004
@@ -8,7 +8,30 @@
#include <errno.h>
#include <string.h>
#include <zlib.h>
+#if defined(__FreeBSD__)
+#include <sys/endian.h>
+#include <netinet/in.h>
+typedef uint64_t loff_t;
+#ifndef be64toh
+static __inline __uint64_t
+__bswap64(__uint64_t _x)
+{
+
+ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
+ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
+ ((_x << 24) & ((__uint64_t)0xff << 40)) |
+ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+}
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define be64toh(x) __bswap64(x)
+#else
+#define be64toh(x)
+#endif
+#endif
+#define __be64_to_cpu be64toh
+#else
#include <asm/byteorder.h>
+#endif
#include "compressed_loop.h"
struct compressed_block

View File

@ -0,0 +1,4 @@
Tools for creating and extracting read-only compressed filesystem images
in cloop V2.0 format.
WWW: http://developer.linuxtag.net/knoppix/sources/

View File

@ -0,0 +1,2 @@
bin/create_compressed_fs
bin/extract_compressed_fs