diff options
| author | 2011-04-04 12:15:34 -0700 | |
|---|---|---|
| committer | 2011-04-04 12:15:34 -0700 | |
| commit | 6907891b1f2d706fa2bd6c40b986f73e5666e00e (patch) | |
| tree | 8bf8129f35c161ac4ef0e7807985ec63f8a6f5ff | |
| parent | 7f5a026d255fdcbd600a01b4abbd87eb0b528e37 (diff) | |
You can't fsync(2) /dev/urandom...
...so don't even try. Doing so leads to this:
W/EntropyService( 1586): unable to load initial entropy (first boot?)
W/EntropyService( 1586): java.io.SyncFailedException: fsync failed: EINVAL (Invalid argument)
W/EntropyService( 1586): at java.io.FileDescriptor.sync(FileDescriptor.java:73)
W/EntropyService( 1586): at java.io.RandomAccessFile.write(RandomAccessFile.java:694)
W/EntropyService( 1586): at java.io.RandomAccessFile.write(RandomAccessFile.java:676)
W/EntropyService( 1586): at com.android.server.RandomBlock.toDataOut(RandomBlock.java:88)
W/EntropyService( 1586): at com.android.server.RandomBlock.toFile(RandomBlock.java:70)
W/EntropyService( 1586): at com.android.server.EntropyService.loadInitialEntropy(EntropyService.java:99)
W/EntropyService( 1586): at com.android.server.EntropyService.<init>(EntropyService.java:86)
W/EntropyService( 1586): at com.android.server.EntropyService.<init>(EntropyService.java:76)
W/EntropyService( 1586): at com.android.server.ServerThread.run(SystemServer.java:139)
W/EntropyService( 1586): Caused by: libcore.io.ErrnoException: fsync failed: EINVAL (Invalid argument)
W/EntropyService( 1586): at libcore.io.Posix.fsync(Native Method)
W/EntropyService( 1586): at libcore.io.BlockGuardOs.fsync(BlockGuardOs.java:39)
W/EntropyService( 1586): at java.io.FileDescriptor.sync(FileDescriptor.java:71)
W/EntropyService( 1586): ... 8 more
Change-Id: I598a9456eccec0ca087f1568d47b6b8e531de8a8
| -rw-r--r-- | services/java/com/android/server/EntropyService.java | 4 | ||||
| -rw-r--r-- | services/java/com/android/server/RandomBlock.java | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/services/java/com/android/server/EntropyService.java b/services/java/com/android/server/EntropyService.java index 0f1fc7876a59..788a2f53bbdf 100644 --- a/services/java/com/android/server/EntropyService.java +++ b/services/java/com/android/server/EntropyService.java @@ -96,7 +96,7 @@ public class EntropyService extends Binder { private void loadInitialEntropy() { try { - RandomBlock.fromFile(entropyFile).toFile(randomDevice); + RandomBlock.fromFile(entropyFile).toFile(randomDevice, false); } catch (IOException e) { Slog.w(TAG, "unable to load initial entropy (first boot?)", e); } @@ -104,7 +104,7 @@ public class EntropyService extends Binder { private void writeEntropy() { try { - RandomBlock.fromFile(randomDevice).toFile(entropyFile); + RandomBlock.fromFile(randomDevice).toFile(entropyFile, true); } catch (IOException e) { Slog.w(TAG, "unable to write entropy", e); } diff --git a/services/java/com/android/server/RandomBlock.java b/services/java/com/android/server/RandomBlock.java index cc22bd9b00cb..e5d73015cdfc 100644 --- a/services/java/com/android/server/RandomBlock.java +++ b/services/java/com/android/server/RandomBlock.java @@ -62,11 +62,11 @@ class RandomBlock { return retval; } - void toFile(String filename) throws IOException { + void toFile(String filename, boolean sync) throws IOException { if (DEBUG) Slog.v(TAG, "writing to file " + filename); RandomAccessFile out = null; try { - out = new RandomAccessFile(filename, "rws"); + out = new RandomAccessFile(filename, sync ? "rws" : "rw"); toDataOut(out); truncateIfPossible(out); } finally { |