]>
git.proxmox.com Git - qemu-server.git/blob - utils.c
2 Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
4 Copyright: vzdump is under GNU GPL, the GNU General Public License.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 dated June, 1991.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 Author: Dietmar Maurer <dietmar@proxmox.com>
26 #include <sys/types.h>
36 /* Set a signal handler */
38 setsig (struct sigaction
*sa
, int sig
, void (*fun
)(int), int flags
)
42 sigemptyset(&sa
->sa_mask
);
43 sigaction(sig
, sa
, NULL
);
47 block_is_zero (char const *buffer
, size_t size
)
57 safe_read(int fd
, char *buf
, size_t count
)
62 n
= read(fd
, buf
, count
);
63 } while (n
< 0 && errno
== EINTR
);
69 full_read(int fd
, char *buf
, size_t len
)
77 n
= safe_read(fd
, buf
, len
);
91 fprintf (stderr
, "ERROR: incomplete read detected\n");
99 safe_write(int fd
, char *buf
, size_t count
)
104 n
= write(fd
, buf
, count
);
105 } while (n
< 0 && errno
== EINTR
);
111 full_write(int fd
, char *buf
, size_t len
)
119 n
= safe_write(fd
, buf
, len
);
130 fprintf (stderr
, "ERROR: incomplete write detected\n");