bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public CipherInputStream(InputStream in, Cipher cipher) { this(in); this.cipher = cipher; if (!(isStream = cipher.getBlockSize() == 1)) { inBuffer = new byte[2][]; inBuffer[0] = new byte[cipher.getBlockSize()]; inBuffer[1] = new byte[cipher.getBlockSize()]; inLength = 0; outBuffer = new byte[cipher.getBlockSize()]; outOffset = outLength = 0; state = VIRGIN; } }
|
public CipherInputStream(InputStream in, Cipher cipher) { super (in); this.cipher = cipher; if (!(isStream = cipher.getBlockSize() == 1)) { inBuffer = new byte[2][]; inBuffer[0] = new byte[cipher.getBlockSize()]; inBuffer[1] = new byte[cipher.getBlockSize()]; inLength = 0; outBuffer = new byte[cipher.getBlockSize()]; outOffset = outLength = 0; state = VIRGIN; } }
| 13,504
|
public CipherInputStream(InputStream in, Cipher cipher) { this(in); this.cipher = cipher; if (!(isStream = cipher.getBlockSize() == 1)) { inBuffer = new byte[2][]; inBuffer[0] = new byte[cipher.getBlockSize()]; inBuffer[1] = new byte[cipher.getBlockSize()]; inLength = 0; outBuffer = new byte[cipher.getBlockSize()]; outOffset = outLength = 0; state = VIRGIN; } }
|
public CipherInputStream(InputStream in, Cipher cipher) { this(in); this.cipher = cipher; if (!(isStream = cipher.getBlockSize() == 1)) { inBuffer = new byte[2][]; inBuffer[0] = new byte[cipher.getBlockSize()]; inBuffer[1] = new byte[cipher.getBlockSize()]; inLength = 0; outBuffer = new byte[cipher.getBlockSize()]; outOffset = outLength = 0; state = VIRGIN; } }
| 13,505
|
public int available() throws IOException { if (isStream) return super.available(); return outLength - outOffset; }
|
public int available() throws IOException { if (isStream) return super.available(); if (outBuffer == null || outOffset >= outBuffer.length) nextBlock (); return outBuffer.length - outOffset; }
| 13,506
|
public void close() throws IOException { super.close(); }
|
public synchronized void close() throws IOException { super.close(); }
| 13,507
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,508
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,509
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { outBuffer = null; outOffset = 0; while (outBuffer == null) { int l = in.read (buf); if (Configuration.DEBUG) logger.log (Component.CRYPTO, "we read {0} bytes", Integer.valueOf (l)); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,510
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,511
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,512
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,513
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { IOException ioe = new IOException ("bad padding"); ioe.initCause (bpe); throw ioe; } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
| 13,514
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { IOException ioe = new IOException ("illegal block size"); ioe.initCause (ibse); throw ioe; } inLength = count; }
| 13,515
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } inLength = count; }
|
private void nextBlock() throws IOException { byte[] temp = inBuffer[0]; inBuffer[0] = inBuffer[1]; inBuffer[1] = temp; int count = 0; boolean eof = false; if (state == VIRGIN || state == LIVING) { do { int l = in.read(inBuffer[1], count, inBuffer[1].length - count); if (l == -1) { eof = true; break; } count += l; } while (count < inBuffer[1].length); } try { switch (state) { case VIRGIN: state = LIVING; nextBlock(); break; case LIVING: if (eof) { if (count > 0) { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); state = DYING; } else { outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; } } else { outOffset = cipher.update(inBuffer[0], 0, inLength, outBuffer, 0); } break; case DYING: outOffset = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer, 0); state = DEAD; break; case DEAD: } } catch (ShortBufferException sbe) { throw new IOException(sbe.toString()); } catch (BadPaddingException bpe) { throw new IOException(bpe.toString()); } catch (IllegalBlockSizeException ibse) { throw new IOException(ibse.toString()); } finally { if (Configuration.DEBUG) logger.log (Component.CRYPTO, "decrypted {0} bytes for reading", Integer.valueOf (outBuffer.length)); } }
| 13,516
|
public int read() throws IOException { if (isStream) { byte[] buf = new byte[1]; int in = super.read(); if (in == -1) return -1; buf[0] = (byte) in; try { cipher.update(buf, 0, 1, buf, 0); } catch (ShortBufferException shouldNotHappen) { throw new IOException(shouldNotHappen.getMessage()); } return buf[0] & 0xFF; } if (state == DEAD) return -1; if (available() == 0) nextBlock(); if (state == DEAD) return -1; return outBuffer[outOffset++] & 0xFF; }
|
public synchronized int read() throws IOException { if (isStream) { byte[] buf = new byte[1]; int in = super.read(); if (in == -1) return -1; buf[0] = (byte) in; try { cipher.update(buf, 0, 1, buf, 0); } catch (ShortBufferException shouldNotHappen) { throw new IOException(shouldNotHappen.getMessage()); } return buf[0] & 0xFF; } if (state == DEAD) return -1; if (available() == 0) nextBlock(); if (state == DEAD) return -1; return outBuffer[outOffset++] & 0xFF; }
| 13,517
|
public int read() throws IOException { if (isStream) { byte[] buf = new byte[1]; int in = super.read(); if (in == -1) return -1; buf[0] = (byte) in; try { cipher.update(buf, 0, 1, buf, 0); } catch (ShortBufferException shouldNotHappen) { throw new IOException(shouldNotHappen.getMessage()); } return buf[0] & 0xFF; } if (state == DEAD) return -1; if (available() == 0) nextBlock(); if (state == DEAD) return -1; return outBuffer[outOffset++] & 0xFF; }
|
public int read() throws IOException { if (isStream) { byte[] buf = new byte[1]; int in = super.read(); if (in == -1) return -1; buf[0] = (byte) in; try { cipher.update(buf, 0, 1, buf, 0); } catch (ShortBufferException shouldNotHappen) { throw new IOException(shouldNotHappen.getMessage()); } return buf[0] & 0xFF; } if (state == DEAD) return -1; if (available() == 0) nextBlock(); if (state == DEAD) return -1; return outBuffer[outOffset++] & 0xFF; }
| 13,518
|
public long skip(long bytes) throws IOException { if (isStream) { return super.skip(bytes); } long ret = 0; if (bytes > 0 && available() > 0) { ret = available(); outOffset = outLength = 0; } return ret; }
|
public long skip(long bytes) throws IOException { if (isStream) { return super.skip(bytes); } long ret = 0; if (bytes > 0 && outBuffer != null && outOffset >= outBuffer.length) { ret = available(); outOffset = outLength = 0; } return ret; }
| 13,519
|
public long skip(long bytes) throws IOException { if (isStream) { return super.skip(bytes); } long ret = 0; if (bytes > 0 && available() > 0) { ret = available(); outOffset = outLength = 0; } return ret; }
|
public long skip(long bytes) throws IOException { if (isStream) { return super.skip(bytes); } long ret = 0; if (bytes > 0 && available() > 0) { ret = available(); outOffset = outLength = 0; } return ret; }
| 13,520
|
public Object evaluate(Node context, int pos, int len) { Object val = (arg == null) ? null : arg.evaluate(context, pos, len); return _local_name(context, (Collection) val); }
|
public Object evaluate(Node context, int pos, int len) { Object val = (arg == null) ? Collections.singleton(context) : arg.evaluate(context, pos, len); return _local_name(context, (Collection) val); }
| 13,521
|
public synchronized void fireEvent(KeyboardEvent event) { if (event != null) { for (Iterator i = listeners.iterator(); i.hasNext();) { KeyboardListener l = (KeyboardListener) i.next(); if (event.isKeyPressed()) { l.keyPressed(event); } else if (event.isKeyReleased()) { l.keyReleased(event); } if (event.isConsumed()) { break; } } } }
|
public synchronized void fireEvent(KeyboardEvent event) { if (event != null) { for (Iterator i = listeners.iterator(); i.hasNext();) { KeyboardListener l = (KeyboardListener) i.next(); if (event.isKeyPressed()) { l.keyPressed(event); } else if (event.isKeyReleased()) { l.keyReleased(event); } if (event.isConsumed()) { break; } } } }
| 13,523
|
public String readLine() throws IOException { if (eof) { return null; } do { if (blockReads) { // Use mark and reset to read chunks of bytes final int MIN_LENGTH = 1024; int len, pos; len = in.available(); len = (len < MIN_LENGTH) ? MIN_LENGTH : len; byte[] b = new byte[len]; in.mark(len); // Read into buffer b len = in.read(b, 0, len); // Handle EOF if (len == -1) { eof = true; if (buf.size() == 0) { return null; } else { // We don't care about resetting buf return buf.toString(encoding); } } // Get index of LF in b pos = indexOf(b, len, (byte) 0x0a); if (pos != -1) { // Write pos bytes to buf buf.write(b, 0, pos); // Reset stream, and read pos + 1 bytes in.reset(); pos += 1; while (pos > 0) { len = in.read(b, 0, pos); pos = (len == -1) ? -1 : pos - len; } // Return line String ret = buf.toString(encoding); buf.reset(); return ret; } else { // Append everything to buf and fall through to re-read. buf.write(b, 0, len); } } else { // We must use character reads in order not to read too much // from the underlying stream. int c = in.read(); switch (c) { case -1: eof = true; if (buf.size() == 0) { return null; } // Fall through and return contents of buffer. case 0x0a: // LF String ret = buf.toString(encoding); buf.reset(); return ret; default: buf.write(c); } } } while (true); }
|
public String readLine() throws IOException { if (eof) { return null; } do { if (blockReads) { // Use mark and reset to read chunks of bytes final int MAX_LENGTH = 1024; int len, pos; len = in.available(); len = (len < MIN_LENGTH) ? MIN_LENGTH : len; byte[] b = new byte[len]; in.mark(len); // Read into buffer b len = in.read(b, 0, len); // Handle EOF if (len == -1) { eof = true; if (buf.size() == 0) { return null; } else { // We don't care about resetting buf return buf.toString(encoding); } } // Get index of LF in b pos = indexOf(b, len, (byte) 0x0a); if (pos != -1) { // Write pos bytes to buf buf.write(b, 0, pos); // Reset stream, and read pos + 1 bytes in.reset(); pos += 1; while (pos > 0) { len = in.read(b, 0, pos); pos = (len == -1) ? -1 : pos - len; } // Return line String ret = buf.toString(encoding); buf.reset(); return ret; } else { // Append everything to buf and fall through to re-read. buf.write(b, 0, len); } } else { // We must use character reads in order not to read too much // from the underlying stream. int c = in.read(); switch (c) { case -1: eof = true; if (buf.size() == 0) { return null; } // Fall through and return contents of buffer. case 0x0a: // LF String ret = buf.toString(encoding); buf.reset(); return ret; default: buf.write(c); } } } while (true); }
| 13,525
|
public String readLine() throws IOException { if (eof) { return null; } do { if (blockReads) { // Use mark and reset to read chunks of bytes final int MIN_LENGTH = 1024; int len, pos; len = in.available(); len = (len < MIN_LENGTH) ? MIN_LENGTH : len; byte[] b = new byte[len]; in.mark(len); // Read into buffer b len = in.read(b, 0, len); // Handle EOF if (len == -1) { eof = true; if (buf.size() == 0) { return null; } else { // We don't care about resetting buf return buf.toString(encoding); } } // Get index of LF in b pos = indexOf(b, len, (byte) 0x0a); if (pos != -1) { // Write pos bytes to buf buf.write(b, 0, pos); // Reset stream, and read pos + 1 bytes in.reset(); pos += 1; while (pos > 0) { len = in.read(b, 0, pos); pos = (len == -1) ? -1 : pos - len; } // Return line String ret = buf.toString(encoding); buf.reset(); return ret; } else { // Append everything to buf and fall through to re-read. buf.write(b, 0, len); } } else { // We must use character reads in order not to read too much // from the underlying stream. int c = in.read(); switch (c) { case -1: eof = true; if (buf.size() == 0) { return null; } // Fall through and return contents of buffer. case 0x0a: // LF String ret = buf.toString(encoding); buf.reset(); return ret; default: buf.write(c); } } } while (true); }
|
public String readLine() throws IOException { if (eof) { return null; } do { if (blockReads) { // Use mark and reset to read chunks of bytes final int MIN_LENGTH = 1024; int len, pos; len = in.available(); if (len == 0 || len > MAX_LENGTH) len = MAX_LENGTH; byte[] b = new byte[len]; in.mark(len); // Read into buffer b len = in.read(b, 0, len); // Handle EOF if (len == -1) { eof = true; if (buf.size() == 0) { return null; } else { // We don't care about resetting buf return buf.toString(encoding); } } // Get index of LF in b pos = indexOf(b, len, (byte) 0x0a); if (pos != -1) { // Write pos bytes to buf buf.write(b, 0, pos); // Reset stream, and read pos + 1 bytes in.reset(); pos += 1; while (pos > 0) { len = in.read(b, 0, pos); pos = (len == -1) ? -1 : pos - len; } // Return line String ret = buf.toString(encoding); buf.reset(); return ret; } else { // Append everything to buf and fall through to re-read. buf.write(b, 0, len); } } else { // We must use character reads in order not to read too much // from the underlying stream. int c = in.read(); switch (c) { case -1: eof = true; if (buf.size() == 0) { return null; } // Fall through and return contents of buffer. case 0x0a: // LF String ret = buf.toString(encoding); buf.reset(); return ret; default: buf.write(c); } } } while (true); }
| 13,526
|
public static String[] read(InputStream input) { StringSeqHolder h = new StringSeqHolder(); h._read(input); return h.value; }
|
public static String[] read(InputStream input) { StringSeqHolder h = new StringSeqHolder(); h._read(input); return h.value; }
| 13,527
|
public static void write(OutputStream output, String[] value) { StringSeqHolder h = new StringSeqHolder(value); h._write(output); }
|
public static void write(OutputStream output, String[] value) { StringSeqHolder h = new StringSeqHolder(value); h._write(output); }
| 13,528
|
public Object clone() { try { return super.clone(); } catch (Exception e) { System.err.println("Huuuhhh, this class implements cloneable !!!!!!"); System.err.println("I think there is a bug in this JVM somewhere"); } return null; }
|
public Object clone() { try { return super.clone(); } catch (Exception e) { System.err.println("Huuuhhh, this class implements cloneable !!!!!!"); System.err.println("I think there is a bug in this JVM somewhere"); } return null; }
| 13,529
|
public Ext2FileSystem(Device device, boolean readOnly) throws FileSystemException { super(device, readOnly); log.setLevel(Level.INFO); blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75); //groupDescriptorLock = new Object(); //superblockLock = new Object(); }
|
public Ext2FileSystem(Device device, boolean readOnly) throws FileSystemException { super(device, readOnly); log.setLevel(Level.INFO); blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75); //groupDescriptorLock = new Object(); //superblockLock = new Object(); }
| 13,531
|
public Ext2FileSystem(Device device, boolean readOnly) throws FileSystemException { super(device, readOnly); log.setLevel(Level.INFO); blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75); //groupDescriptorLock = new Object(); //superblockLock = new Object(); }
|
public Ext2FileSystem(Device device, boolean readOnly) throws FileSystemException { super(device, readOnly); log.setLevel(Level.INFO); blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75); //groupDescriptorLock = new Object(); //superblockLock = new Object(); blockCache = new BlockCache(50, (float) 0.75); inodeCache = new INodeCache(50, (float) 0.75); }
| 13,532
|
protected FSEntry buildRootEntry() throws IOException { //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[0]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = Ext2Constants.EXT2_ROOT_INO; INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, 0, iNodeNr-1)); int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); iNode.create( Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); //trigger a write to disk iNode.update(); //add the inode to the inode cache synchronized(inodeCache) { inodeCache.put(new Integer(Ext2Constants.EXT2_ROOT_INO), iNode); } modifyUsedDirsCount(0, 1); Ext2Entry rootEntry = new Ext2Entry(iNode,"/",Ext2Constants.EXT2_FT_DIR, this, null); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, ".", Ext2Constants.EXT2_FT_DIR); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, "..", Ext2Constants.EXT2_FT_DIR); rootEntry.getDirectory().addDirectory("lost+found"); return rootEntry; }
|
protected FSEntry buildRootEntry() throws IOException { //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[0]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = Ext2Constants.EXT2_ROOT_INO; INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, 0, iNodeNr-1)); int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); iNode.create( Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); //trigger a write to disk iNode.update(); //add the inode to the inode cache synchronized(inodeCache) { inodeCache.put(new Integer(Ext2Constants.EXT2_ROOT_INO), iNode); } modifyUsedDirsCount(0, 1); Ext2Entry rootEntry = new Ext2Entry(iNode,"/",Ext2Constants.EXT2_FT_DIR, this, null); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, ".", Ext2Constants.EXT2_FT_DIR); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, "..", Ext2Constants.EXT2_FT_DIR); rootEntry.getDirectory().addDirectory("lost+found"); return rootEntry; }
| 13,533
|
protected FSEntry buildRootEntry() throws IOException { //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[0]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = Ext2Constants.EXT2_ROOT_INO; INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, 0, iNodeNr-1)); int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); iNode.create( Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); //trigger a write to disk iNode.update(); //add the inode to the inode cache synchronized(inodeCache) { inodeCache.put(new Integer(Ext2Constants.EXT2_ROOT_INO), iNode); } modifyUsedDirsCount(0, 1); Ext2Entry rootEntry = new Ext2Entry(iNode,"/",Ext2Constants.EXT2_FT_DIR, this, null); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, ".", Ext2Constants.EXT2_FT_DIR); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, "..", Ext2Constants.EXT2_FT_DIR); rootEntry.getDirectory().addDirectory("lost+found"); return rootEntry; }
|
protected FSEntry buildRootEntry() throws IOException { //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[0]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = Ext2Constants.EXT2_ROOT_INO; INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, 0, iNodeNr-1)); int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); iNode.create( Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); //trigger a write to disk iNode.update(); //add the inode to the inode cache synchronized(inodeCache) { inodeCache.put(new Integer(Ext2Constants.EXT2_ROOT_INO), iNode); } modifyUsedDirsCount(0, 1); Ext2Entry rootEntry = new Ext2Entry(iNode,"/",Ext2Constants.EXT2_FT_DIR, this, null); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, ".", Ext2Constants.EXT2_FT_DIR); ((Ext2Directory)rootEntry.getDirectory()).addINode(Ext2Constants.EXT2_ROOT_INO, "..", Ext2Constants.EXT2_FT_DIR); rootEntry.getDirectory().addDirectory("lost+found"); return rootEntry; }
| 13,534
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
| 13,535
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
| 13,536
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
| 13,537
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
| 13,538
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
|
public void create(int blockSize) throws FileSystemException { try{ //create the superblock superblock = new Superblock(); superblock.create(blockSize, this); //create the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].create(i, this); } //create each block group: // create the block bitmap // create the inode bitmap // fill the inode table with zeroes for(int i=0; i<groupCount; i++) { log.debug("creating gropup "+i); byte[] blockBitmap = new byte[blockSize]; byte[] inodeBitmap = new byte[blockSize]; //update the block bitmap: mark the metadata blocks allocated long iNodeTableBlock = groupDescriptors[i].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + i*superblock.getBlocksPerGroup())); for(int j=0; j<metadataLength; j++) BlockBitmap.setBit(blockBitmap, j); //set the padding at the end of the last block group if(i == groupCount-1) { for(long k=superblock.getBlocksCount(); k<groupCount*superblock.getBlocksPerGroup(); k++) BlockBitmap.setBit(blockBitmap,(int) (k % superblock.getBlocksPerGroup())); } //update the inode bitmap: mark the special inodes allocated in the first block group if(i==0) for(int j=0; j<superblock.getFirstInode()-1; j++) INodeBitmap.setBit(inodeBitmap, j); //create an empty inode table byte[] emptyBlock = new byte[blockSize]; for(long j=iNodeTableBlock; j<firstNonMetadataBlock; j++) writeBlock(j, emptyBlock, false); iNodeTables[i] = new INodeTable(this, (int)iNodeTableBlock); writeBlock(groupDescriptors[i].getBlockBitmap(), blockBitmap, false); writeBlock(groupDescriptors[i].getInodeBitmap(), inodeBitmap, false); } log.info("superblock.getBlockSize(): "+superblock.getBlockSize()); buildRootEntry(); //write everything to disk flush(); }catch (IOException ioe) { throw new FileSystemException("Unable to create filesystem", ioe); } }
| 13,539
|
protected INode createINode(int preferredBlockBroup, int fileFormat, int accessRights, int uid, int gid) throws FileSystemException, IOException { if(preferredBlockBroup >= superblock.getBlocksCount()) throw new FileSystemException("Block group "+preferredBlockBroup+" does not exist"); int groupNr = preferredBlockBroup; //first check the preferred block group, if it has any free inodes INodeReservation res = findFreeINode( groupNr ); //if no free inode has been found in the preferred block group, then try the others if(!res.isSuccessful()) { for(groupNr=0; groupNr<superblock.getBlockGroupNr(); groupNr++) { res = findFreeINode( groupNr ); if(res.isSuccessful()){ break; } } } if(!res.isSuccessful()) throw new FileSystemException("No free inodes found!"); //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[preferredBlockBroup]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = res.getINodeNr((int)superblock.getINodesPerGroup()); INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, groupNr, res.getIndex())); iNode.create( fileFormat, accessRights, uid, gid); //trigger a write to disk iNode.update(); log.debug("** NEW INODE ALLOCATED: inode number: "+iNode.getINodeNr()); //put the inode into the cache synchronized(inodeCache) { Integer key = new Integer(iNodeNr); if(inodeCache.containsKey(key)) throw new FileSystemException("Newly allocated inode is already in the inode cache!?"); else inodeCache.put(key, iNode); } return iNode; }
|
protected INode createINode(int preferredBlockBroup, int fileFormat, int accessRights, int uid, int gid) throws FileSystemException, IOException { if(preferredBlockBroup >= superblock.getBlocksCount()) throw new FileSystemException("Block group "+preferredBlockBroup+" does not exist"); int groupNr = preferredBlockBroup; //first check the preferred block group, if it has any free inodes INodeReservation res = findFreeINode( groupNr ); //if no free inode has been found in the preferred block group, then try the others if(!res.isSuccessful()) { for(groupNr=0; groupNr<superblock.getBlockGroupNr(); groupNr++) { res = findFreeINode( groupNr ); if(res.isSuccessful()){ break; } } } if(!res.isSuccessful()) throw new FileSystemException("No free inodes found!"); //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[preferredBlockBroup]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = res.getINodeNr((int)superblock.getINodesPerGroup()); INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, groupNr, res.getIndex())); iNode.create( fileFormat, accessRights, uid, gid); //trigger a write to disk iNode.update(); log.debug("** NEW INODE ALLOCATED: inode number: "+iNode.getINodeNr()); //put the inode into the cache synchronized(inodeCache) { Integer key = new Integer(iNodeNr); if(inodeCache.containsKey(key)) throw new FileSystemException("Newly allocated inode is already in the inode cache!?"); else inodeCache.put(key, iNode); } return iNode; }
| 13,540
|
protected INode createINode(int preferredBlockBroup, int fileFormat, int accessRights, int uid, int gid) throws FileSystemException, IOException { if(preferredBlockBroup >= superblock.getBlocksCount()) throw new FileSystemException("Block group "+preferredBlockBroup+" does not exist"); int groupNr = preferredBlockBroup; //first check the preferred block group, if it has any free inodes INodeReservation res = findFreeINode( groupNr ); //if no free inode has been found in the preferred block group, then try the others if(!res.isSuccessful()) { for(groupNr=0; groupNr<superblock.getBlockGroupNr(); groupNr++) { res = findFreeINode( groupNr ); if(res.isSuccessful()){ break; } } } if(!res.isSuccessful()) throw new FileSystemException("No free inodes found!"); //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[preferredBlockBroup]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = res.getINodeNr((int)superblock.getINodesPerGroup()); INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, groupNr, res.getIndex())); iNode.create( fileFormat, accessRights, uid, gid); //trigger a write to disk iNode.update(); log.debug("** NEW INODE ALLOCATED: inode number: "+iNode.getINodeNr()); //put the inode into the cache synchronized(inodeCache) { Integer key = new Integer(iNodeNr); if(inodeCache.containsKey(key)) throw new FileSystemException("Newly allocated inode is already in the inode cache!?"); else inodeCache.put(key, iNode); } return iNode; }
|
protected INode createINode(int preferredBlockBroup, int fileFormat, int accessRights, int uid, int gid) throws FileSystemException, IOException { if(preferredBlockBroup >= superblock.getBlocksCount()) throw new FileSystemException("Block group "+preferredBlockBroup+" does not exist"); int groupNr = preferredBlockBroup; //first check the preferred block group, if it has any free inodes INodeReservation res = findFreeINode( groupNr ); //if no free inode has been found in the preferred block group, then try the others if(!res.isSuccessful()) { for(groupNr=0; groupNr<superblock.getBlockGroupNr(); groupNr++) { res = findFreeINode( groupNr ); if(res.isSuccessful()){ break; } } } if(!res.isSuccessful()) throw new FileSystemException("No free inodes found!"); //a free inode has been found: create the inode and write it into the inode table INodeTable iNodeTable = iNodeTables[preferredBlockBroup]; //byte[] iNodeData = new byte[INode.INODE_LENGTH]; int iNodeNr = res.getINodeNr((int)superblock.getINodesPerGroup()); INode iNode = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, groupNr, res.getIndex())); iNode.create( fileFormat, accessRights, uid, gid); //trigger a write to disk iNode.update(); log.debug("** NEW INODE ALLOCATED: inode number: "+iNode.getINodeNr()); //put the inode into the cache synchronized(inodeCache) { Integer key = new Integer(iNodeNr); if(inodeCache.containsKey(key)) throw new FileSystemException("Newly allocated inode is already in the inode cache!?"); else inodeCache.put(key, iNode); } return iNode; }
| 13,541
|
public FSEntry createRootEntry() throws IOException { try{ return new Ext2Entry( getINode(Ext2Constants.EXT2_ROOT_INO), "/", Ext2Constants.EXT2_FT_DIR, this, null ); }catch(FileSystemException e) { throw new IOException(e); } }
|
public FSEntry createRootEntry() throws IOException { try{ return new Ext2Entry( getINode(Ext2Constants.EXT2_ROOT_INO), "/", Ext2Constants.EXT2_FT_DIR, this, null ); }catch(FileSystemException e) { throw new IOException(e); } }
| 13,542
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); BlockReservation result; //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); BlockReservation result; //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
| 13,543
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); BlockReservation result; //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int) (firstNonMetadataBlock - (superblock .getFirstDataBlock() + group * superblock.getBlocksPerGroup())); log.debug("group[" + group + "].getInodeTable()=" + iNodeTableBlock + ", iNodeTable.getSizeInBlocks()=" + INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group(" + group + "): " + metadataLength); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
| 13,544
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); BlockReservation result; //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
|
public BlockReservation findFreeBlocks(int group, long threshold) throws IOException{ GroupDescriptor gdesc = groupDescriptors[group]; //see if it's worth to check the block group at all if( gdesc.getFreeBlocksCount() < threshold) return new BlockReservation(false, -1, -1, gdesc.getFreeBlocksCount()); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); int metadataLength = (int)(firstNonMetadataBlock - (superblock.getFirstDataBlock() + group*superblock.getBlocksPerGroup())); log.debug("group["+group+"].getInodeTable()="+iNodeTableBlock+", iNodeTable.getSizeInBlocks()="+INodeTable.getSizeInBlocks(this)); log.debug("metadata length for block group("+group+"): "+metadataLength); BlockReservation result; //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmapBlock = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmapBlock ) { result=BlockBitmap.findFreeBlocks( bitmapBlock, metadataLength ); //if the reservation was successful, write the bitmap data to disk //within the same synchronized block if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmapBlock, true); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()-1-result.getPreallocCount()); modifyFreeBlocksCount( group, -1-result.getPreallocCount() ); } } } if(result.isSuccessful()) { result.setBlock( group*getSuperblock().getBlocksPerGroup() + superblock.getFirstDataBlock() + result.getBlock() ); result.setFreeBlocksCount(gdesc.getFreeBlocksCount()); } return result; }
| 13,545
|
public void flush() throws IOException { log.info("Flushing the contents of the filesystem"); //update the inodes synchronized(inodeCache) { try{ log.debug("inodecache size: "+inodeCache.size()); Iterator iterator = inodeCache.values().iterator(); while(iterator.hasNext()) { INode iNode = (INode)iterator.next(); iNode.flush(); log.debug("flush(): inodeCache.values().iterator().hasNext() "+iterator.hasNext()); } }catch(FileSystemException fse) { throw new IOException(fse); } } //update the group descriptors and the superblock copies updateFS(); //flush the blocks synchronized(blockCache) { Iterator iterator = blockCache.values().iterator(); while(iterator.hasNext()) { Block block = (Block)iterator.next(); block.flush(); } } log.info("Filesystem flushed"); }
|
public void flush() throws IOException { log.info("Flushing the contents of the filesystem"); //update the inodes synchronized(inodeCache) { try{ log.debug("inodecache size: "+inodeCache.size()); Iterator iterator = inodeCache.values().iterator(); while(iterator.hasNext()) { INode iNode = (INode)iterator.next(); iNode.flush(); log.debug("flush(): inodeCache.values().iterator().hasNext() "+iterator.hasNext()); } }catch(FileSystemException fse) { throw new IOException(fse); } } //update the group descriptors and the superblock copies updateFS(); //flush the blocks synchronized(blockCache) { Iterator iterator = blockCache.values().iterator(); while(iterator.hasNext()) { Block block = (Block)iterator.next(); block.flush(); } } log.info("Filesystem flushed"); }
| 13,546
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
| 13,547
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
| 13,548
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
|
public void freeBlock(long blockNr) throws FileSystemException, IOException{ if(blockNr<0 || blockNr>=superblock.getBlocksCount()) throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")"); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); GroupDescriptor gdesc = groupDescriptors[group]; /* Throw an exception if an attempt is made to free up a filesystem metadata * block (the beginning of each block group is filesystem metadata): * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) throw new FileSystemException("Attempt to free a filesystem metadata block!"); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index ); //update the bitmap block writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); //gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1); modifyFreeBlocksCount(group, 1); } } }
| 13,549
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
| 13,550
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
| 13,551
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
|
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer(iNodeNr); log.debug("iNodeCache size: "+inodeCache.size()); synchronized(inodeCache) { //check if the inode is already in the cache if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); } //move the time consuming disk read out of the synchronized block //(see comments at getBlock()) int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode INodeTable iNodeTable = iNodeTables[group]; INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index)); result.read(iNodeTable.getInodeData(index)); synchronized(inodeCache) { //check if the inode is still not in the cache if(!inodeCache.containsKey(key)) { inodeCache.put(key, result); return result; } else return (INode)inodeCache.get(key); } }
| 13,552
|
public void read() throws FileSystemException { byte data[]; try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock //TODO: the superblock should read itself getApi().read(1024, data, 0, Superblock.SUPERBLOCK_LENGTH); //superblock = new Superblock(data, this); superblock = new Superblock(); superblock.read(data, this); //read the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { //groupDescriptors[i]=new GroupDescriptor(i, this); groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].read(i, this); iNodeTables[i] = new INodeTable(this, (int)groupDescriptors[i].getInodeTable()); } } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } //check for unsupported filesystem options //(an unsupported INCOMPAT feature means that the fs may not be mounted at all) if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_COMPRESSION) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (COMPRESSION) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_META_BG) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (META_BG) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (JOURNAL_DEV) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (RECOVER) disallows mounting"); //an unsupported RO_COMPAT feature means that the filesystem can only be mounted readonly if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_LARGE_FILE)) { log.info(getDevice().getId()+" Unsupported filesystem feature (LARGE_FILE) forces readonly mode"); setReadOnly(true); } if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_BTREE_DIR)) { log.info(getDevice().getId()+" Unsupported filesystem feature (BTREE_DIR) forces readonly mode"); setReadOnly(true); } //if the filesystem has not been cleanly unmounted, mount it readonly if(superblock.getState()==Ext2Constants.EXT2_ERROR_FS) { log.info(getDevice().getId()+" Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } //if the filesystem has been mounted R/W, set it to "unclean" if(!isReadOnly()) { log.info(getDevice().getId()+" mounting fs r/w"); superblock.setState(Ext2Constants.EXT2_ERROR_FS); } //log.info( "Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: "+superblock.getBlocksCount()+"\n"+ " #blocks/group: "+superblock.getBlocksPerGroup()+"\n"+ " #block groups: "+groupCount+"\n"+ " block size: "+superblock.getBlockSize()+"\n"+ " #inodes: "+superblock.getINodesCount()+"\n"+ " #inodes/group: "+superblock.getINodesPerGroup()); }
|
public void read() throws FileSystemException { byte data[]; try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock //TODO: the superblock should read itself getApi().read(1024, data, 0, Superblock.SUPERBLOCK_LENGTH); //superblock = new Superblock(data, this); superblock = new Superblock(); superblock.read(data, this); //read the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { //groupDescriptors[i]=new GroupDescriptor(i, this); groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].read(i, this); iNodeTables[i] = new INodeTable(this, (int)groupDescriptors[i].getInodeTable()); } } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } //check for unsupported filesystem options //(an unsupported INCOMPAT feature means that the fs may not be mounted at all) if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_COMPRESSION) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (COMPRESSION) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_META_BG) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (META_BG) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (JOURNAL_DEV) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (RECOVER) disallows mounting"); //an unsupported RO_COMPAT feature means that the filesystem can only be mounted readonly if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_LARGE_FILE)) { log.info(getDevice().getId()+" Unsupported filesystem feature (LARGE_FILE) forces readonly mode"); setReadOnly(true); } if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_BTREE_DIR)) { log.info(getDevice().getId()+" Unsupported filesystem feature (BTREE_DIR) forces readonly mode"); setReadOnly(true); } //if the filesystem has not been cleanly unmounted, mount it readonly if(superblock.getState()==Ext2Constants.EXT2_ERROR_FS) { log.info(getDevice().getId()+" Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } //if the filesystem has been mounted R/W, set it to "unclean" if(!isReadOnly()) { log.info(getDevice().getId()+" mounting fs r/w"); superblock.setState(Ext2Constants.EXT2_ERROR_FS); } //log.info( "Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: "+superblock.getBlocksCount()+"\n"+ " #blocks/group: "+superblock.getBlocksPerGroup()+"\n"+ " #block groups: "+groupCount+"\n"+ " block size: "+superblock.getBlockSize()+"\n"+ " #inodes: "+superblock.getINodesCount()+"\n"+ " #inodes/group: "+superblock.getINodesPerGroup()); }
| 13,553
|
public void read() throws FileSystemException { byte data[]; try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock //TODO: the superblock should read itself getApi().read(1024, data, 0, Superblock.SUPERBLOCK_LENGTH); //superblock = new Superblock(data, this); superblock = new Superblock(); superblock.read(data, this); //read the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { //groupDescriptors[i]=new GroupDescriptor(i, this); groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].read(i, this); iNodeTables[i] = new INodeTable(this, (int)groupDescriptors[i].getInodeTable()); } } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } //check for unsupported filesystem options //(an unsupported INCOMPAT feature means that the fs may not be mounted at all) if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_COMPRESSION) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (COMPRESSION) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_META_BG) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (META_BG) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (JOURNAL_DEV) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (RECOVER) disallows mounting"); //an unsupported RO_COMPAT feature means that the filesystem can only be mounted readonly if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_LARGE_FILE)) { log.info(getDevice().getId()+" Unsupported filesystem feature (LARGE_FILE) forces readonly mode"); setReadOnly(true); } if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_BTREE_DIR)) { log.info(getDevice().getId()+" Unsupported filesystem feature (BTREE_DIR) forces readonly mode"); setReadOnly(true); } //if the filesystem has not been cleanly unmounted, mount it readonly if(superblock.getState()==Ext2Constants.EXT2_ERROR_FS) { log.info(getDevice().getId()+" Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } //if the filesystem has been mounted R/W, set it to "unclean" if(!isReadOnly()) { log.info(getDevice().getId()+" mounting fs r/w"); superblock.setState(Ext2Constants.EXT2_ERROR_FS); } //log.info( "Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: "+superblock.getBlocksCount()+"\n"+ " #blocks/group: "+superblock.getBlocksPerGroup()+"\n"+ " #block groups: "+groupCount+"\n"+ " block size: "+superblock.getBlockSize()+"\n"+ " #inodes: "+superblock.getINodesCount()+"\n"+ " #inodes/group: "+superblock.getINodesPerGroup()); }
|
public void read() throws FileSystemException { byte data[]; try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock //TODO: the superblock should read itself getApi().read(1024, data, 0, Superblock.SUPERBLOCK_LENGTH); //superblock = new Superblock(data, this); superblock = new Superblock(); superblock.read(data, this); //read the group descriptors groupCount = (int)Math.ceil((double)superblock.getBlocksCount() / (double)superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; iNodeTables = new INodeTable[groupCount]; for(int i=0; i<groupCount; i++) { //groupDescriptors[i]=new GroupDescriptor(i, this); groupDescriptors[i]=new GroupDescriptor(); groupDescriptors[i].read(i, this); iNodeTables[i] = new INodeTable(this, (int)groupDescriptors[i].getInodeTable()); } } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } //check for unsupported filesystem options //(an unsupported INCOMPAT feature means that the fs may not be mounted at all) if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_COMPRESSION) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (COMPRESSION) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_META_BG) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (META_BG) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (JOURNAL_DEV) disallows mounting"); if( hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER) ) throw new FileSystemException(getDevice().getId()+" Unsupported filesystem feature (RECOVER) disallows mounting"); //an unsupported RO_COMPAT feature means that the filesystem can only be mounted readonly if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_LARGE_FILE)) { log.info(getDevice().getId()+" Unsupported filesystem feature (LARGE_FILE) forces readonly mode"); setReadOnly(true); } if( hasROFeature(Ext2Constants.EXT2_FEATURE_RO_COMPAT_BTREE_DIR)) { log.info(getDevice().getId()+" Unsupported filesystem feature (BTREE_DIR) forces readonly mode"); setReadOnly(true); } //if the filesystem has not been cleanly unmounted, mount it readonly if(superblock.getState()==Ext2Constants.EXT2_ERROR_FS) { log.info(getDevice().getId()+" Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } //if the filesystem has been mounted R/W, set it to "unclean" if(!isReadOnly()) { log.info(getDevice().getId()+" mounting fs r/w"); superblock.setState(Ext2Constants.EXT2_ERROR_FS); } //log.info( "Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: "+superblock.getBlocksCount()+"\n"+ " #blocks/group: "+superblock.getBlocksPerGroup()+"\n"+ " #block groups: "+groupCount+"\n"+ " block size: "+superblock.getBlockSize()+"\n"+ " #inodes: "+superblock.getINodesCount()+"\n"+ " #inodes/group: "+superblock.getINodesPerGroup()); }
| 13,554
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); } return result; } } }
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); } return result; } } }
| 13,555
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); } return result; } } }
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); } return result; } } }
| 13,556
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); } return result; } } }
|
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); //synchronize to the blockCache to avoid flushing the block between reading it //and synchronizing to it synchronized(blockCache) { byte[] bitmap= getBlock(groupDescriptors[group].getBlockBitmap()); synchronized( bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); //result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); result.setBlock(blockNr); synchronized (blockCache) { byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); synchronized (bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock(bitmap, index); if (result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1 - result.getPreallocCount()); result.setBlock(blockNr); } return result; } } } return result; synchronized (blockCache) { byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); synchronized (bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock(bitmap, index); if (result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1 - result.getPreallocCount()); result.setBlock(blockNr); } return result; } } } synchronized (blockCache) { byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); synchronized (bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock(bitmap, index); if (result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1 - result.getPreallocCount()); result.setBlock(blockNr); } return result; } } } synchronized (blockCache) { byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); synchronized (bitmap) { BlockReservation result = BlockBitmap.testAndSetBlock(bitmap, index); if (result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1 - result.getPreallocCount()); result.setBlock(blockNr); } return result; } } }
| 13,557
|
public void writeBlock(long nr, byte[] data, boolean forceWrite) throws IOException { if(isClosed()) throw new IOException("FS closed"); if(isReadOnly()) throw new ReadOnlyFileSystemException("Filesystem is mounted read-only!"); Block block; Integer key=new Integer((int)nr); int blockSize=superblock.getBlockSize(); //check if the block is in the cache synchronized(blockCache) { if(blockCache.containsKey(key)) { block = (Block)blockCache.get(key); //update the data in the cache block.setData(data); if(forceWrite || SYNC_WRITE) { //write the block to disk getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); block.setDirty(false); log.debug("writing block "+nr+" to disk"); } else block.setDirty(true); } else { //If the block was not in the cache, I see no reason to put it //in the cache when it is written. //It is simply written to disk. getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); } } }
|
public void writeBlock(long nr, byte[] data, boolean forceWrite) throws IOException { if(isClosed()) throw new IOException("FS closed"); if(isReadOnly()) throw new ReadOnlyFileSystemException("Filesystem is mounted read-only!"); Block block; Integer key=new Integer((int)nr); int blockSize=superblock.getBlockSize(); //check if the block is in the cache synchronized(blockCache) { if(blockCache.containsKey(key)) { block = (Block)blockCache.get(key); //update the data in the cache block.setData(data); if(forceWrite || SYNC_WRITE) { //write the block to disk getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); block.setDirty(false); log.debug("writing block "+nr+" to disk"); } else block.setDirty(true); } else { //If the block was not in the cache, I see no reason to put it //in the cache when it is written. //It is simply written to disk. getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); } } }
| 13,558
|
public void writeBlock(long nr, byte[] data, boolean forceWrite) throws IOException { if(isClosed()) throw new IOException("FS closed"); if(isReadOnly()) throw new ReadOnlyFileSystemException("Filesystem is mounted read-only!"); Block block; Integer key=new Integer((int)nr); int blockSize=superblock.getBlockSize(); //check if the block is in the cache synchronized(blockCache) { if(blockCache.containsKey(key)) { block = (Block)blockCache.get(key); //update the data in the cache block.setData(data); if(forceWrite || SYNC_WRITE) { //write the block to disk getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); block.setDirty(false); log.debug("writing block "+nr+" to disk"); } else block.setDirty(true); } else { //If the block was not in the cache, I see no reason to put it //in the cache when it is written. //It is simply written to disk. getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); } } }
|
public void writeBlock(long nr, byte[] data, boolean forceWrite) throws IOException { if(isClosed()) throw new IOException("FS closed"); if(isReadOnly()) throw new ReadOnlyFileSystemException("Filesystem is mounted read-only!"); Block block; Integer key=new Integer((int)nr); int blockSize=superblock.getBlockSize(); //check if the block is in the cache synchronized(blockCache) { if(blockCache.containsKey(key)) { block = (Block)blockCache.get(key); //update the data in the cache block.setData(data); if(forceWrite || SYNC_WRITE) { //write the block to disk getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); block.setDirty(false); log.debug("writing block "+nr+" to disk"); } else block.setDirty(true); } else { //If the block was not in the cache, I see no reason to put it //in the cache when it is written. //It is simply written to disk. getApi().write(nr*blockSize, data, 0, blockSize); //timedWrite(nr, data); } } }
| 13,559
|
ProcessingInstructionNode(TemplateNode children, TemplateNode next, String name) { super(children, next); this.name = name; }
|
ProcessingInstructionNode(TemplateNode children, TemplateNode next, String name) { super(children, next); this.name = name; }
| 13,560
|
ProcessingInstructionNode(TemplateNode children, TemplateNode next, String name) { super(children, next); this.name = name; }
|
ProcessingInstructionNode(TemplateNode children, TemplateNode next, String name) { this.name = name; }
| 13,561
|
TemplateNode clone(Stylesheet stylesheet) { return new ProcessingInstructionNode((children == null) ? null : children.clone(stylesheet), (next == null) ? null : next.clone(stylesheet), name); }
|
TemplateNode clone(Stylesheet stylesheet) { return new ProcessingInstructionNode((children == null) ? null : children.clone(stylesheet), (next == null) ? null : next.clone(stylesheet), name); }
| 13,562
|
public Container getContainer() { View parent = getParent(); if (parent == null) throw new AssertionError("The parent of a View must not be null."); return parent.getContainer(); }
|
public Container getContainer() { View parent = getParent(); if (parent == null) return null; else return parent.getContainer(); }
| 13,564
|
protected final Item clone(EmitterContext ec) { final Item res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
|
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
| 13,565
|
protected final Item clone(EmitterContext ec) { final Item res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
|
protected final Item clone(EmitterContext ec) { final Item res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
| 13,566
|
protected final Item clone(EmitterContext ec) { final Item res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
|
protected final Item clone(EmitterContext ec) { final Item res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: final X86RegisterPool pool = ec.getPool(); final Register lsb = pool.request(JvmType.INT); final Register msb = pool.request(JvmType.INT); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); res = createReg(getType(), lsb, msb); pool.transferOwnerTo(lsb, res); pool.transferOwnerTo(msb, res); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
| 13,567
|
public Class[] getExceptionTypes() { if (exceptionTypes == null) { final VmExceptions exceptions = vmMethod.getExceptions(); final int cnt = exceptions.getLength(); final ArrayList list = new ArrayList(cnt); for (int i = 0; i < cnt; i++) { try { list.add(exceptions.getException(i).getResolvedVmClass().asClass()); } catch (Exception e) { // there is some missing getException(i).getResolvedVmClass() // if one makes a system.out on the methods it fails, looks "java.lang.Exception" is missing // I think I'll look into it, if I can. // 10/03/2005 Martin Husted Hartvig } } exceptionTypes = list; } return (Class[])exceptionTypes.toArray(new Class[exceptionTypes.size()]); }
|
public Class[] getExceptionTypes() { if (exceptionTypes == null) { final VmExceptions exceptions = vmMethod.getExceptions(); final int cnt = exceptions.getLength(); final ArrayList<Class> list = new ArrayList<Class>(cnt); for (int i = 0; i < cnt; i++) { try { list.add(exceptions.getException(i).getResolvedVmClass().asClass()); } catch (Exception e) { // there is some missing getException(i).getResolvedVmClass() // if one makes a system.out on the methods it fails, looks "java.lang.Exception" is missing // I think I'll look into it, if I can. // 10/03/2005 Martin Husted Hartvig } } exceptionTypes = list; } return (Class[])exceptionTypes.toArray(new Class[exceptionTypes.size()]); }
| 13,568
|
public Class[] getParameterTypes() { if (parameterTypes == null) { int cnt = vmMethod.getNoArguments(); ArrayList list = new ArrayList(cnt); for (int i = 0; i < cnt; i++) { list.add(vmMethod.getArgumentType(i).asClass()); } parameterTypes = list; } return (Class[])parameterTypes.toArray(new Class[parameterTypes.size()]); }
|
public Class[] getParameterTypes() { if (parameterTypes == null) { int cnt = vmMethod.getNoArguments(); ArrayList<Class> list = new ArrayList<Class>(cnt); for (int i = 0; i < cnt; i++) { list.add(vmMethod.getArgumentType(i).asClass()); } parameterTypes = list; } return (Class[])parameterTypes.toArray(new Class[parameterTypes.size()]); }
| 13,569
|
public int hashCode() { return getDeclaringClass().getName().hashCode() ^ getName().hashCode(); }
|
public int hashCode() { final Class<?> declClass = getDeclaringClass(); return declClass.getName().hashCode() ^ getName().hashCode(); }
| 13,570
|
public String toString() { // 128 is a reasonable buffer initial size for constructor StringBuffer sb = new StringBuffer(128); Modifier.toString(getModifiers(), sb).append(' '); sb.append(getReturnType().getName()).append(' '); sb.append(getDeclaringClass().getName()).append('.'); sb.append(getName()).append('('); Class[] c = getParameterTypes(); if (c.length > 0) { sb.append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } sb.append(')'); c = getExceptionTypes(); if (c.length > 0) { sb.append(" throws ").append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } return sb.toString(); }
|
public String toString() { // 128 is a reasonable buffer initial size for constructor StringBuffer sb = new StringBuffer(128); Modifier.toString(getModifiers(), sb).append(' '); sb.append(getReturnType().getName()).append(' '); sb.append(getDeclaringClass().getName()).append('.'); sb.append(getName()).append('('); Class[] c = getParameterTypes(); if (c.length > 0) { sb.append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } sb.append(')'); c = getExceptionTypes(); if (c.length > 0) { sb.append(" throws ").append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } return sb.toString(); }
| 13,571
|
public String toString() { // 128 is a reasonable buffer initial size for constructor StringBuffer sb = new StringBuffer(128); Modifier.toString(getModifiers(), sb).append(' '); sb.append(getReturnType().getName()).append(' '); sb.append(getDeclaringClass().getName()).append('.'); sb.append(getName()).append('('); Class[] c = getParameterTypes(); if (c.length > 0) { sb.append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } sb.append(')'); c = getExceptionTypes(); if (c.length > 0) { sb.append(" throws ").append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } return sb.toString(); }
|
public String toString() { // 128 is a reasonable buffer initial size for constructor StringBuffer sb = new StringBuffer(128); Modifier.toString(getModifiers(), sb).append(' '); sb.append(getReturnType().getName()).append(' '); sb.append(getDeclaringClass().getName()).append('.'); sb.append(getName()).append('('); Class<?>[] c = getParameterTypes(); if (c.length > 0) { sb.append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } sb.append(')'); c = getExceptionTypes(); if (c.length > 0) { sb.append(" throws ").append(c[0].getName()); for (int i = 1; i < c.length; i++) sb.append(',').append(c[i].getName()); } return sb.toString(); }
| 13,572
|
public JMenuItem() { // TODO } // JMenuItem()
|
public JMenuItem() { // TODO } // JMenuItem()
| 13,573
|
public void addMenuDragMouseListener(MenuDragMouseListener listener) { // TODO } // addMenuDragMouseListener()
|
public void addMenuDragMouseListener(MenuDragMouseListener listener) { // TODO } // addMenuDragMouseListener()
| 13,574
|
public void addMenuKeyListener(MenuKeyListener listener) { // TODO } // addMenuKeyListener()
|
public void addMenuKeyListener(MenuKeyListener listener) { // TODO } // addMenuKeyListener()
| 13,575
|
protected void configurePropertiesFromAction(Action action) { // TODO } // configurePropertiesFromAction()
|
protected void configurePropertiesFromAction(Action action) { // TODO } // configurePropertiesFromAction()
| 13,576
|
protected PropertyChangeListener createActionPropertyChangeListener(Action action) { return null; // TODO } // createActionPropertyChangeListener()
|
protected PropertyChangeListener createActionPropertyChangeListener(Action action) { return null; // TODO } // createActionPropertyChangeListener()
| 13,577
|
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseDragged()
|
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseDragged()
| 13,578
|
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseEntered()
|
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseEntered()
| 13,579
|
protected void fireMenuDragMouseExited(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseExited()
|
protected void fireMenuDragMouseExited(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseExited()
| 13,580
|
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseReleased()
|
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event) { // TODO } // fireMenuDragMouseReleased()
| 13,581
|
public KeyStroke getAccelerator() { return null; // TODO } // getAccelerator()
|
public KeyStroke getAccelerator() { return null; // TODO } // getAccelerator()
| 13,582
|
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJMenuItem(this); } // if return accessibleContext; } // getAccessibleContext()
|
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJMenuItem(this); } // if return accessibleContext; } // getAccessibleContext()
| 13,583
|
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJMenuItem(this); } // if return accessibleContext; } // getAccessibleContext()
|
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJMenuItem(this); // if return accessibleContext; // getAccessibleContext()
| 13,584
|
public MenuElement[] getSubElements() { return null; // TODO } // getSubElements()
|
public MenuElement[] getSubElements() { return null; // TODO } // getSubElements()
| 13,585
|
public boolean isArmed() { return false; // TODO } // isArmed()
|
public boolean isArmed() { return false; // TODO } // isArmed()
| 13,586
|
public void menuSelectionChanged(boolean changed) { // TODO } // menuSelectionChanged()
|
public void menuSelectionChanged(boolean changed) { // TODO } // menuSelectionChanged()
| 13,587
|
protected String paramString() { return null; // TODO } // paramString()
|
protected String paramString() { return null; // TODO } // paramString()
| 13,588
|
public void processMenuDragMouseEvent(MenuDragMouseEvent event) { // TODO } // processMenuDragMouseEvent()
|
public void processMenuDragMouseEvent(MenuDragMouseEvent event) { // TODO } // processMenuDragMouseEvent()
| 13,589
|
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager) { // TODO } // processMouseEvent()
|
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager) { // TODO } // processMouseEvent()
| 13,590
|
public void removeMenuDragMouseListener(MenuDragMouseListener listener) { // TODO } // removeMenuDragMouseListener()
|
public void removeMenuDragMouseListener(MenuDragMouseListener listener) { // TODO } // removeMenuDragMouseListener()
| 13,591
|
public void removeMenuKeyListener(MenuKeyListener listener) { // TODO } // removeMenuKeyListener()
|
public void removeMenuKeyListener(MenuKeyListener listener) { // TODO } // removeMenuKeyListener()
| 13,592
|
public void setAccelerator(KeyStroke keystroke) { // TODO } // setAccelerator()
|
public void setAccelerator(KeyStroke keystroke) { // TODO } // setAccelerator()
| 13,593
|
public void setArmed(boolean armed) { // TODO } // setArmed()
|
public void setArmed(boolean armed) { // TODO } // setArmed()
| 13,594
|
public void setEnabled(boolean enabled) { // TODO } // setEnabled()
|
public void setEnabled(boolean enabled) { // TODO } // setEnabled()
| 13,595
|
public void updateUI() { setUI((MenuItemUI) UIManager.get(this)); invalidate(); } // updateUI()
|
public void updateUI() { setUI((MenuItemUI) UIManager.get(this)); invalidate(); } // updateUI()
| 13,596
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // With the OceanTheme the button border is painted entirely different. // However, I couldn't figure out how this is determined besides checking // for instanceof OceanTheme. The button painting is definitely not // influenced by a UI default property and it is definitely performed // by the same Border class. if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) paintOceanButtonBorder(c, g, x, y, w, h); else { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { // draw dark border g.setColor(darkShadow); g.drawRect(x, y, w - 2, h - 2); if (!bmodel.isPressed()) { // draw light border g.setColor(light); g.drawRect(x + 1, y + 1, w - 2, h - 2); // draw crossing pixels of both borders g.setColor(middle); g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1); } else { // draw light border g.setColor(light); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // draw shadow border g.setColor(middle); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // draw crossing pixels of both borders g.setColor(shadow); g.drawRect(x + 1, y + h - 2, 0, 0); g.drawRect(x + w - 2, y + 1, 0, 0); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } } }
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // With the OceanTheme the button border is painted entirely different. // However, I couldn't figure out how this is determined besides checking // for instanceof OceanTheme. The button painting is definitely not // influenced by a UI default property and it is definitely performed // by the same Border class. if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) paintOceanButtonBorder(c, g, x, y, w, h); else { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { // draw dark border g.setColor(darkShadow); g.drawRect(x, y, w - 2, h - 2); if (!bmodel.isPressed()) { // draw light border g.setColor(light); g.drawRect(x + 1, y + 1, w - 2, h - 2); // draw crossing pixels of both borders g.setColor(middle); g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1); } else { // draw light border g.setColor(light); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // draw shadow border g.setColor(middle); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // draw crossing pixels of both borders g.setColor(shadow); g.drawRect(x + 1, y + h - 2, 0, 0); g.drawRect(x + w - 2, y + 1, 0, 0); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } } }
| 13,597
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // With the OceanTheme the button border is painted entirely different. // However, I couldn't figure out how this is determined besides checking // for instanceof OceanTheme. The button painting is definitely not // influenced by a UI default property and it is definitely performed // by the same Border class. if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) paintOceanButtonBorder(c, g, x, y, w, h); else { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { // draw dark border g.setColor(darkShadow); g.drawRect(x, y, w - 2, h - 2); if (!bmodel.isPressed()) { // draw light border g.setColor(light); g.drawRect(x + 1, y + 1, w - 2, h - 2); // draw crossing pixels of both borders g.setColor(middle); g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1); } else { // draw light border g.setColor(light); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // draw shadow border g.setColor(middle); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // draw crossing pixels of both borders g.setColor(shadow); g.drawRect(x + 1, y + h - 2, 0, 0); g.drawRect(x + w - 2, y + 1, 0, 0); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } } }
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // With the OceanTheme the button border is painted entirely different. // However, I couldn't figure out how this is determined besides checking // for instanceof OceanTheme. The button painting is definitely not // influenced by a UI default property and it is definitely performed // by the same Border class. if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) paintOceanButtonBorder(c, g, x, y, w, h); else { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { // draw dark border g.setColor(darkShadow); g.drawRect(x, y, w - 2, h - 2); if (!bmodel.isPressed()) { // draw light border g.setColor(light); g.drawRect(x + 1, y + 1, w - 2, h - 2); // draw crossing pixels of both borders g.setColor(middle); g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1); else { // draw light border g.setColor(light); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // draw shadow border g.setColor(middle); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // draw crossing pixels of both borders g.setColor(shadow); g.drawRect(x + 1, y + h - 2, 0, 0); g.drawRect(x + w - 2, y + 1, 0, 0); else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2);
| 13,598
|
private void paintOceanButtonBorder(Component c, Graphics g, int x, int y, int w, int h) { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { if (bmodel.isPressed()) { // draw fat border g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); } else if (bmodel.isRollover()) { g.setColor(shadow); g.drawRect(x, y, w - 1, h - 1); g.drawRect(x + 2, y + 2, w - 5, h - 5); g.setColor(darkShadow); g.drawRect(x + 1, y + 1, w - 3, h - 3); } else { g.setColor(darkShadow); g.drawRect(x, y, w - 1, h - 1); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } }
|
private void paintOceanButtonBorder(Component c, Graphics g, int x, int y, int w, int h) { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { if (bmodel.isPressed() || ((c instanceof JButton) && ((JButton) c).isDefaultButton())) { // draw fat border g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); } else if (bmodel.isRollover()) { g.setColor(shadow); g.drawRect(x, y, w - 1, h - 1); g.drawRect(x + 2, y + 2, w - 5, h - 5); g.setColor(darkShadow); g.drawRect(x + 1, y + 1, w - 3, h - 3); } else { g.setColor(darkShadow); g.drawRect(x, y, w - 1, h - 1); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } }
| 13,599
|
private void paintOceanButtonBorder(Component c, Graphics g, int x, int y, int w, int h) { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { if (bmodel.isPressed()) { // draw fat border g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); } else if (bmodel.isRollover()) { g.setColor(shadow); g.drawRect(x, y, w - 1, h - 1); g.drawRect(x + 2, y + 2, w - 5, h - 5); g.setColor(darkShadow); g.drawRect(x + 1, y + 1, w - 3, h - 3); } else { g.setColor(darkShadow); g.drawRect(x, y, w - 1, h - 1); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } }
|
private void paintOceanButtonBorder(Component c, Graphics g, int x, int y, int w, int h) { ButtonModel bmodel = null; if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel(); Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl(); if (c.isEnabled()) { if (bmodel.isPressed()) { // draw fat border g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); } else if (bmodel.isRollover()) { g.setColor(shadow); g.drawRect(x, y, w - 1, h - 1); g.drawRect(x + 2, y + 2, w - 5, h - 5); g.setColor(darkShadow); g.drawRect(x + 1, y + 1, w - 3, h - 3); } else { g.setColor(darkShadow); g.drawRect(x, y, w - 1, h - 1); } } else { // draw disabled border g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); } }
| 13,600
|
public CombinedClassLoader(Collection a_loaders) { ArrayList sLoaders = new ArrayList(a_loaders.size()); Iterator iter = a_loaders.iterator(); Object cl; while (iter.hasNext()) { cl = iter.next(); if (!sLoaders.contains(cl)) sLoaders.add(cl); } loaders = new ClassLoader[sLoaders.size()]; for (int i = 0; i < loaders.length; i++) loaders[i] = (ClassLoader) sLoaders.get(i); }
|
public CombinedClassLoader(Collection a_loaders) { ArrayList sLoaders = new ArrayList(a_loaders.size()); Iterator iter = a_loaders.iterator(); Object cl; while (iter.hasNext()) { cl = iter.next(); if (cl!=null && !sLoaders.contains(cl)) sLoaders.add(cl); } loaders = new ClassLoader[sLoaders.size()]; for (int i = 0; i < loaders.length; i++) loaders[i] = (ClassLoader) sLoaders.get(i); }
| 13,601
|
public void read(long fileOffset, byte[] dest, int off, int len) throws IOException { //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } //a single inode may be represented by more than one Ext2Directory instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { try{ if(len+off>getLength()) throw new IOException("Can't read past the file!"); long blockSize = iNode.getExt2FileSystem().getBlockSize(); long bytesRead=0; while( bytesRead < len ) { long blockNr = (fileOffset+bytesRead) / blockSize; long blockOffset = (fileOffset+bytesRead) % blockSize; long copyLength = Math.min(len-bytesRead, blockSize - blockOffset); System.arraycopy( iNode.getDataBlock(blockNr), (int)blockOffset, dest, off+(int)bytesRead, (int)copyLength); bytesRead += copyLength; } //read done, unlock the inode from the cache iNode.decLocked(); return; }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } } }
|
public void read(long fileOffset, byte[] dest, int off, int len) throws IOException { //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } //a single inode may be represented by more than one Ext2Directory instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { try{ if(len+off>getLength()) throw new IOException("Can't read past the file!"); long blockSize = iNode.getExt2FileSystem().getBlockSize(); long bytesRead=0; while( bytesRead < len ) { long blockNr = (fileOffset+bytesRead) / blockSize; long blockOffset = (fileOffset+bytesRead) % blockSize; long copyLength = Math.min(len-bytesRead, blockSize - blockOffset); System.arraycopy( iNode.getDataBlock(blockNr), (int)blockOffset, dest, off+(int)bytesRead, (int)copyLength); bytesRead += copyLength; } //read done, unlock the inode from the cache iNode.decLocked(); return; }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } } }
| 13,602
|
private void rereadInode() throws IOException{ int iNodeNr = iNode.getINodeNr(); try{ iNode = ((Ext2FileSystem)getFileSystem()).getINode(iNodeNr); }catch(FileSystemException fse) { throw new IOException(fse); } }
|
private void rereadInode() throws IOException{ int iNodeNr = iNode.getINodeNr(); try{ iNode = ((Ext2FileSystem)getFileSystem()).getINode(iNodeNr); }catch(FileSystemException fse) { throw new IOException(fse); } }
| 13,603
|
public void setLength(long length) throws IOException { if(!canWrite()) throw new ReadOnlyFileSystemException("FileSystem or File is readonly"); long blockSize = iNode.getExt2FileSystem().getBlockSize(); //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } //a single inode may be represented by more than one Ext2Directory instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { try{ //if length<getLength(), then the file is truncated if(length<getLength()) { long blockNr = length / blockSize; long blockOffset = length % blockSize; long nextBlock; if(blockOffset==0) nextBlock=blockNr; else nextBlock=blockNr+1; for(long i=iNode.getAllocatedBlockCount()-1; i>=nextBlock; i--) { log.debug("setLength(): freeing up block "+i+" of inode"); iNode.freeDataBlock(i); } iNode.setSize(length); iNode.setMtime(System.currentTimeMillis()/1000); //setLength done, unlock the inode from the cache iNode.decLocked(); return; } //if length>getLength(), then new blocks are allocated for the file //The content of the new blocks is undefined (see the setLength(long i) //method of java.io.RandomAccessFile if(length>getLength()) { long len = length - getLength(); long blocksAllocated = getLengthInBlocks(); long bytesAllocated = getLength(); long bytesCovered=0; while( bytesCovered < len ) { long blockIndex = (bytesAllocated+bytesCovered) / blockSize; long blockOffset = (bytesAllocated+bytesCovered) % blockSize; long newSection = Math.min(len-bytesCovered, blockSize - blockOffset); //allocate a new block if needed if(blockIndex >= blocksAllocated) { iNode.allocateDataBlock(blockIndex); blocksAllocated++; } bytesCovered += newSection; } iNode.setSize(length); iNode.setMtime(System.currentTimeMillis()/1000); //setLength done, unlock the inode from the cache iNode.decLocked(); return; } }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } } // synchronized(inode) }
|
public void setLength(long length) throws IOException { if(!canWrite()) throw new ReadOnlyFileSystemException("FileSystem or File is readonly"); long blockSize = iNode.getExt2FileSystem().getBlockSize(); //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } //a single inode may be represented by more than one Ext2Directory instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { try{ //if length<getLength(), then the file is truncated if(length<getLength()) { long blockNr = length / blockSize; long blockOffset = length % blockSize; long nextBlock; if(blockOffset==0) nextBlock=blockNr; else nextBlock=blockNr+1; for(long i=iNode.getAllocatedBlockCount()-1; i>=nextBlock; i--) { log.debug("setLength(): freeing up block "+i+" of inode"); iNode.freeDataBlock(i); } iNode.setSize(length); iNode.setMtime(System.currentTimeMillis()/1000); //setLength done, unlock the inode from the cache iNode.decLocked(); return; } //if length>getLength(), then new blocks are allocated for the file //The content of the new blocks is undefined (see the setLength(long i) //method of java.io.RandomAccessFile if(length>getLength()) { long len = length - getLength(); long blocksAllocated = getLengthInBlocks(); long bytesAllocated = getLength(); long bytesCovered=0; while( bytesCovered < len ) { long blockIndex = (bytesAllocated+bytesCovered) / blockSize; long blockOffset = (bytesAllocated+bytesCovered) % blockSize; long newSection = Math.min(len-bytesCovered, blockSize - blockOffset); //allocate a new block if needed if(blockIndex >= blocksAllocated) { iNode.allocateDataBlock(blockIndex); blocksAllocated++; } bytesCovered += newSection; } iNode.setSize(length); iNode.setMtime(System.currentTimeMillis()/1000); //setLength done, unlock the inode from the cache iNode.decLocked(); return; } }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } } // synchronized(inode) }
| 13,604
|
public void write(long fileOffset, byte[] src, int off, int len) throws IOException { //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } try{ //a single inode may be represented by more than one Ext2File instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { if(fileOffset > getLength()) throw new IOException("Can't write beyond the end of the file! (fileOffset: "+ fileOffset+", getLength()"+getLength()); if(off+len>src.length) throw new IOException("src is shorter than what you want to write"); log.debug("write(fileOffset="+fileOffset+", src, off, len="+len+")"); final long blockSize = iNode.getExt2FileSystem().getBlockSize(); long blocksAllocated = iNode.getAllocatedBlockCount(); long bytesWritten=0; while( bytesWritten < len ) { long blockIndex = (fileOffset+bytesWritten) / blockSize; long blockOffset = (fileOffset+bytesWritten) % blockSize; long copyLength = Math.min(len-bytesWritten, blockSize - blockOffset); //If only a part of the block is written, then read the block //and update its contents with the data in src. If the whole block //is overwritten, then skip reading it. byte[] dest; if( !( (blockOffset==0)&&(copyLength==blockSize) ) && (blockIndex < blocksAllocated)) dest = iNode.getDataBlock(blockIndex); else dest = new byte[(int)blockSize]; System.arraycopy( src, (int)(off+bytesWritten), dest, (int)blockOffset, (int)copyLength); //allocate a new block if needed if(blockIndex >= blocksAllocated) { try{ iNode.allocateDataBlock(blockIndex); }catch(FileSystemException fe) { throw new IOException("Internal filesystem exception",fe); } blocksAllocated++; } //write the block iNode.writeDataBlock(blockIndex, dest); bytesWritten += copyLength; } iNode.setSize( fileOffset+len ); iNode.setMtime(System.currentTimeMillis()/1000); //write done, unlock the inode from the cache iNode.decLocked(); return; } }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } }
|
public void write(long fileOffset, byte[] src, int off, int len) throws IOException { //synchronize to the inode cache to make sure that the inode does not get //flushed between reading it and locking it synchronized(((Ext2FileSystem)getFileSystem()).getInodeCache()) { //reread the inode before synchronizing to it to make sure //all threads use the same instance rereadInode(); //lock the inode into the cache so it is not flushed before synchronizing to it //(otherwise a new instance of INode referring to the same inode could be put //in the cache resulting in the possibility of two threads manipulating the same //inode at the same time because they would synchronize to different INode instances) iNode.incLocked(); } try{ //a single inode may be represented by more than one Ext2File instances, //but each will use the same instance of the underlying inode (see Ext2FileSystem.getINode()), //so synchronize to the inode synchronized(iNode) { if(fileOffset > getLength()) throw new IOException("Can't write beyond the end of the file! (fileOffset: "+ fileOffset+", getLength()"+getLength()); if(off+len>src.length) throw new IOException("src is shorter than what you want to write"); log.debug("write(fileOffset="+fileOffset+", src, off, len="+len+")"); final long blockSize = iNode.getExt2FileSystem().getBlockSize(); long blocksAllocated = iNode.getAllocatedBlockCount(); long bytesWritten=0; while( bytesWritten < len ) { long blockIndex = (fileOffset+bytesWritten) / blockSize; long blockOffset = (fileOffset+bytesWritten) % blockSize; long copyLength = Math.min(len-bytesWritten, blockSize - blockOffset); //If only a part of the block is written, then read the block //and update its contents with the data in src. If the whole block //is overwritten, then skip reading it. byte[] dest; if( !( (blockOffset==0)&&(copyLength==blockSize) ) && (blockIndex < blocksAllocated)) dest = iNode.getDataBlock(blockIndex); else dest = new byte[(int)blockSize]; System.arraycopy( src, (int)(off+bytesWritten), dest, (int)blockOffset, (int)copyLength); //allocate a new block if needed if(blockIndex >= blocksAllocated) { try{ iNode.allocateDataBlock(blockIndex); }catch(FileSystemException fe) { throw new IOException("Internal filesystem exception",fe); } blocksAllocated++; } //write the block iNode.writeDataBlock(blockIndex, dest); bytesWritten += copyLength; } iNode.setSize( fileOffset+len ); iNode.setMtime(System.currentTimeMillis()/1000); //write done, unlock the inode from the cache iNode.decLocked(); return; } }catch(Throwable t) { //could not fininsh the operation, unlock the inode from the cache iNode.decLocked(); throw new IOException(t); } }
| 13,605
|
public static Remote toStub(Remote obj) throws NoSuchObjectException { Class cls = obj.getClass(); String classname = cls.getName(); ClassLoader cl = cls.getClassLoader(); try { Class scls = cl.loadClass(classname + "_Stub"); // JDK 1.2 stubs Class[] stubprototype = new Class[] { RemoteRef.class }; Constructor con = scls.getConstructor(stubprototype); return (Remote)(con.newInstance(new Object[]{obj})); } catch (Exception e) {} throw new NoSuchObjectException(obj.getClass().getName()); }
|
public static Remote toStub(Remote obj) throws NoSuchObjectException { Class cls = obj.getClass(); String classname = cls.getName(); ClassLoader cl = cls.getClassLoader(); try { Class scls = cl.loadClass(classname + "_Stub"); // JDK 1.2 stubs Class[] stubprototype = new Class[] { RemoteRef.class }; Constructor con = scls.getConstructor(stubprototype); return (Remote)(con.newInstance(new Object[]{obj})); } catch (Exception e) {} throw new NoSuchObjectException(obj.getClass().getName()); }
| 13,606
|
public static UserException readUserException(String idl, InputStream input) { try { String holder = toHelperName(idl); Class holderClass = Class.forName(holder); Method read = holderClass.getMethod("read", new Class[] { org.omg.CORBA.portable.InputStream.class } ); return (UserException) read.invoke(null, new Object[] { input }); } catch (MARSHAL mex) { // This one is ok to throw throw mex; } catch (Exception ex) { ex.printStackTrace(); return null; } }
|
public static UserException readUserException(String idl, InputStream input) { try { String holder = toHelperName(idl); Class holderClass = Class.forName(holder); Method read = holderClass.getMethod("read", new Class[] { org.omg.CORBA.portable.InputStream.class } ); return (UserException) read.invoke(null, new Object[] { input }); } catch (MARSHAL mex) { // This one is ok to throw throw mex; } catch (Exception ex) { ex.printStackTrace(); return null; } }
| 13,609
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.