git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ruby: Run tests one at a time, instead of in parallel.
[libguestfs.git]
/
daemon
/
zero.c
diff --git
a/daemon/zero.c
b/daemon/zero.c
index
9d793e1
..
4d06505
100644
(file)
--- a/
daemon/zero.c
+++ b/
daemon/zero.c
@@
-1,5
+1,5
@@
/* libguestfs - the guestfsd daemon
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009 Red Hat Inc.
*
* 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
*
* 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
@@
-28,13
+28,11
@@
#include "actions.h"
int
#include "actions.h"
int
-do_zero (char *device)
+do_zero (c
onst c
har *device)
{
int fd, i;
char buf[4096];
{
int fd, i;
char buf[4096];
- IS_DEVICE (device, -1);
-
fd = open (device, O_WRONLY);
if (fd == -1) {
reply_with_perror ("%s", device);
fd = open (device, O_WRONLY);
if (fd == -1) {
reply_with_perror ("%s", device);
@@
-44,9
+42,16
@@
do_zero (char *device)
memset (buf, 0, sizeof buf);
for (i = 0; i < 32; ++i)
memset (buf, 0, sizeof buf);
for (i = 0; i < 32; ++i)
- (void) write (fd, buf, sizeof buf);
-
- close (fd);
+ if (write (fd, buf, sizeof buf) != sizeof buf) {
+ reply_with_perror ("write: %s", device);
+ close (fd);
+ return -1;
+ }
+
+ if (close (fd) == -1) {
+ reply_with_perror ("close: %s", device);
+ return -1;
+ }
return 0;
}
return 0;
}