summaryrefslogtreecommitdiffstats
path: root/misc-utils/mcookie.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:37 +0100
committerKarel Zak2006-12-07 00:25:37 +0100
commit5c36a0eb7cdb0360f9afd5d747c321f423b35984 (patch)
tree147599a77eaff2b5fbc0d389e89d2b51602326c0 /misc-utils/mcookie.c
parentImported from util-linux-2.8 tarball. (diff)
downloadkernel-qcow2-util-linux-5c36a0eb7cdb0360f9afd5d747c321f423b35984.tar.gz
kernel-qcow2-util-linux-5c36a0eb7cdb0360f9afd5d747c321f423b35984.tar.xz
kernel-qcow2-util-linux-5c36a0eb7cdb0360f9afd5d747c321f423b35984.zip
Imported from util-linux-2.9i tarball.
Diffstat (limited to 'misc-utils/mcookie.c')
-rw-r--r--misc-utils/mcookie.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index 05136190f..33ae7630e 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -101,9 +101,12 @@ int main( int argc, char **argv )
}
for (i = 0; i < RNGS; i++) {
- if ((fd = open( rngs[i].path, O_RDONLY )) >= 0) {
+ if ((fd = open( rngs[i].path, O_RDONLY|O_NONBLOCK )) >= 0) {
r = read( fd, buf, sizeof( buf ) );
- MD5Update( &ctx, buf, r );
+ if (r > 0)
+ MD5Update( &ctx, buf, r );
+ else
+ r = 0;
close( fd );
if (Verbose)
fprintf( stderr, "Got %d bytes from %s\n", r, rngs[i].path );