dinstall: deb
dpkg -i ${DEB}
-sparsecp: sparsecp.c utils.c
- gcc ${CFLAGS} -o sparsecp sparsecp.c
-
qm.bash-completion:
PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qm; PVE::CLI::qm->generate_bash_completions();" >$@.tmp
mv $@.tmp $@
PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qmrestore; PVE::CLI::qmrestore->generate_bash_completions();" >$@.tmp
mv $@.tmp $@
-PKGSOURCES=qm qm.1 qmrestore qmrestore.1 qmextract sparsecp qm.conf.5 qm.bash-completion qmrestore.bash-completion
+PKGSOURCES=qm qm.1 qmrestore qmrestore.1 qmextract qm.conf.5 qm.bash-completion qmrestore.bash-completion
.PHONY: install
install: ${PKGSOURCES}
install -m 0755 pve-bridge ${DESTDIR}${VARLIBDIR}/pve-bridge
install -m 0755 pve-bridge-hotplug ${DESTDIR}${VARLIBDIR}/pve-bridge-hotplug
install -m 0755 pve-bridgedown ${DESTDIR}${VARLIBDIR}/pve-bridgedown
- install -s -m 0755 sparsecp ${DESTDIR}${LIBDIR}
install -D -m 0644 modules-load.conf ${DESTDIR}/etc/modules-load.d/qemu-server.conf
install -m 0755 qmextract ${DESTDIR}${LIBDIR}
install -m 0644 qm.1 ${DESTDIR}/${MAN1DIR}
exec 'dd', 'ibs=256K', 'obs=256K', "of=$path";
die "couldn't exec dd: $!\n";
} else {
- exec '/usr/lib/qemu-server/sparsecp', $path;
- die "couldn't exec sparsecp: $!\n";
+ exec '/bin/cp', '--sparse=always', '/dev/stdin', $path;
+ die "couldn't exec cp: $!\n";
}
}
+++ /dev/null
-/*
- Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
-
- Copyright: vzdump is under GNU GPL, the GNU General Public License.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 dated June, 1991.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301, USA.
-
- Author: Dietmar Maurer <dietmar@proxmox.com>
-
-*/
-
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <stdint.h>
-#include <getopt.h>
-#include <signal.h>
-
-#include "utils.c"
-
-#define BLOCKSIZE 512*8
-
-static char *outname;
-
-static void
-cleanup (void)
-{
- if (outname)
- unlink (outname);
-}
-
-void term_handler()
-{
- fprintf (stderr, "received signal - terminate process\n");
- exit(-1);
-}
-
-size_t
-sparse_cp (int infd, int outfd)
-{
- size_t total = 0;
- size_t count;
- char buffer[BLOCKSIZE];
- int last_write_made_hole = 0;
-
- while ((count = safe_read (infd, buffer, sizeof (buffer))) > 0) {
- if (block_is_zero (buffer, count)) {
-
- if (lseek (outfd, count, SEEK_CUR) < 0) {
- perror ("cannot lseek\n");
- exit (-1);
- }
- last_write_made_hole = 1;
- } else {
- full_write (outfd, buffer, count);
- last_write_made_hole = 0;
- }
- total += count;
- }
-
- if (last_write_made_hole) {
- if (ftruncate (outfd, total) < 0) {
- perror ("cannot ftruncate\n");
- exit (-1);
- }
- }
-
- return total;
-}
-
-int
-main (int argc, char **argv)
-{
- struct sigaction sa;
-
- if (argc != 2) {
- fprintf (stderr, "wrong number of arguments\n");
- exit (-1);
- }
-
- time_t starttime = time(NULL);
-
- outname = argv[1];
-
- int outfd;
-
- if ((outfd = open(outname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
- fprintf (stderr, "unable to open file '%s' - %s\n",
- outname, strerror (errno));
- exit (-1);
- }
- atexit(cleanup);
-
- setsig(&sa, SIGINT, term_handler, SA_RESTART);
- setsig(&sa, SIGQUIT, term_handler, SA_RESTART);
- setsig(&sa, SIGTERM, term_handler, SA_RESTART);
- setsig(&sa, SIGPIPE, term_handler, SA_RESTART);
-
- size_t total = sparse_cp (0, outfd);
-
- close (outfd);
-
- time_t delay = time(NULL) - starttime;
- if (delay <= 0) delay = 1;
-
- fprintf (stderr, "%zu bytes copied, %zd s, %.2f MiB/s\n", total, delay,
- (total/(1024*1024))/(float)delay);
-
- outname = NULL;
-
- exit (0);
-}
+++ /dev/null
-/*
- Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
-
- Copyright: vzdump is under GNU GPL, the GNU General Public License.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 dated June, 1991.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301, USA.
-
- Author: Dietmar Maurer <dietmar@proxmox.com>
-
-*/
-
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-
-/* Set a signal handler */
-static void
-setsig (struct sigaction *sa, int sig, void (*fun)(int), int flags)
-{
- sa->sa_handler = fun;
- sa->sa_flags = flags;
- sigemptyset(&sa->sa_mask);
- sigaction(sig, sa, NULL);
-}
-
-int
-block_is_zero (char const *buffer, size_t size)
-{
- while (size--)
- if (*buffer++)
- return 0;
-
- return 1;
-}
-
-ssize_t
-safe_read(int fd, char *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = read(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-int
-full_read(int fd, char *buf, size_t len)
-{
- ssize_t n;
- size_t total;
-
- total = 0;
-
- while (len > 0) {
- n = safe_read(fd, buf, len);
-
- if (n == 0)
- return total;
-
- if (n < 0)
- break;
-
- buf += n;
- total += n;
- len -= n;
- }
-
- if (len) {
- fprintf (stderr, "ERROR: incomplete read detected\n");
- exit (-1);
- }
-
- return total;
-}
-
-ssize_t
-safe_write(int fd, char *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = write(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-int
-full_write(int fd, char *buf, size_t len)
-{
- ssize_t n;
- size_t total;
-
- total = 0;
-
- while (len > 0) {
- n = safe_write(fd, buf, len);
-
- if (n < 0)
- break;
-
- buf += n;
- total += n;
- len -= n;
- }
-
- if (len) {
- fprintf (stderr, "ERROR: incomplete write detected\n");
- exit (-1);
- }
-
- return total;
-}