bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
14,399
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
14,400
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
14,401
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting("Main", "setupSigningParams"); }
private void setupSigningParams() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { log.entering("Main", "setupSigningParams"); if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); if (userHome == null || userHome.trim().length() == 0) throw new SecurityException("Option '-keystore' is not defined or" + " is an empty string, and 'user.home'" + " is unknown"); ksURL = "file:" + userHome.trim() + "/.keystore"; } else { ksURL = ksURL.trim(); if (ksURL.indexOf(":") == -1) ksURL = "file:" + ksURL; } if (ksType == null || ksType.trim().length() == 0) ksType = KeyStore.getDefaultType(); else ksType = ksType.trim(); store = KeyStore.getInstance(ksType); if (ksPassword == null) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter keystore password: ", false); handler.handle(new Callback[] { pcb }); ksPasswordChars = pcb.getPassword(); } else ksPasswordChars = ksPassword.toCharArray(); URL url = new URL(ksURL); InputStream stream = url.openStream(); store.load(stream, ksPasswordChars); if (alias == null) HelpPrinter.printHelpAndExit(HELP_PATH); if (! store.containsAlias(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be known to the key store in use"); if (! store.isKeyEntry(alias)) throw new SecurityException("Designated alias [" + alias + "] MUST be an Alias of a Key Entry"); Key key; if (password == null) { passwordChars = ksPasswordChars; try { key = store.getKey(alias, passwordChars); } catch (UnrecoverableKeyException x) { // ask the user to provide one CallbackHandler handler = new ConsoleCallbackHandler(); PasswordCallback pcb = new PasswordCallback("Enter key password for " + alias + ": ", false); handler.handle(new Callback[] { pcb }); passwordChars = pcb.getPassword(); // take 2 key = store.getKey(alias, passwordChars); } } else { passwordChars = password.toCharArray(); key = store.getKey(alias, passwordChars); } if (! (key instanceof PrivateKey)) throw new SecurityException("Key associated with " + alias + " MUST be a private key"); signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); log.finest(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; sigFileName = sigFileName.toUpperCase(EN_US_LOCALE); if (sigFileName.length() > 8) sigFileName = sigFileName.substring(0, 8); char[] chars = sigFileName.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (! (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-')) chars[i] = '_'; } sigFileName = new String(chars); if (signedJarFileName == null) signedJarFileName = jarFileName; log.exiting(this.getClass().getName(), "setupSigningParams"); }
14,402
private void start() throws Exception { log.entering("Main", "start"); if (verify) { JarVerifier jv = new JarVerifier(this); jv.start(); } else { JarSigner js = new JarSigner(this); js.start(); } log.exiting("Main", "start"); }
private void start() throws Exception { log.entering(this.getClass().getName(), "start"); if (verify) { JarVerifier jv = new JarVerifier(this); jv.start(); } else { JarSigner js = new JarSigner(this); js.start(); } log.exiting("Main", "start"); }
14,403
private void start() throws Exception { log.entering("Main", "start"); if (verify) { JarVerifier jv = new JarVerifier(this); jv.start(); } else { JarSigner js = new JarSigner(this); js.start(); } log.exiting("Main", "start"); }
private void start() throws Exception { log.entering("Main", "start"); if (verify) { JarVerifier jv = new JarVerifier(this); jv.start(); } else { JarSigner js = new JarSigner(this); js.start(); } log.exiting(this.getClass().getName(), "start"); }
14,404
private void teardown() { log.entering("Main", "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting("Main", "teardown"); }
private void teardown() { log.entering(this.getClass().getName(), "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting("Main", "teardown"); }
14,405
private void teardown() { log.entering("Main", "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting("Main", "teardown"); }
private void teardown() { log.entering("Main", "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting("Main", "teardown"); }
14,406
private void teardown() { log.entering("Main", "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting("Main", "teardown"); }
private void teardown() { log.entering("Main", "teardown"); if (providerInstalled) { final String providerName = provider.getName(); log.info("About to remove provider: " + providerName); // remove it. again we need to override security checks AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Security.removeProvider(providerName); return null; } }); } log.exiting(this.getClass().getName(), "teardown"); }
14,407
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering(this.getClass().getName(), "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,408
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.1") + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,409
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.2") + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,410
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.finer("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,411
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.8") + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,412
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.finer("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,413
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.8") + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,414
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.finer("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,415
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
14,416
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting("JarSigner", "start"); }
void start() throws Exception { log.entering("JarSigner", "start"); JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); sfHelper.startSigning(); // 1. compute the digests for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; sfHelper.updateEntry(je); if (main.isVerbose()) System.out.println(" signing: " + jeName); } sfHelper.finishSigning(main.isSectionsOnly()); if (main.isVerbose()) System.out.println(" updating: " + JarFile.MANIFEST_NAME); // 2. write jar entries and manifest File signedJarFile = File.createTempFile("gcp-", ".jar"); FileOutputStream fos = new FileOutputStream(signedJarFile); JarOutputStream outSignedJarFile = new JarOutputStream(fos, sfHelper.getManifest()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry je = (JarEntry) e.nextElement(); String jeName = je.getName(); if (jeName.equals(JarFile.MANIFEST_NAME) || jeName.endsWith(File.separator)) continue; log.finest("Processing " + jeName); JarEntry newEntry = new JarEntry(jeName); newEntry.setTime(je.getTime()); outSignedJarFile.putNextEntry(newEntry); InputStream jeis = jarFile.getInputStream(je); copyFromTo(jeis, outSignedJarFile); } // 3. create the .SF file String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; log.finest("Processing " + sfFileName); JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); log.info("Created .SF file"); if (main.isVerbose()) System.out.println(" adding: " + sfFileName); // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; log.finest("Processing " + dsaFileName); JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); sfHelper.writeDSA(outSignedJarFile, main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); log.info("Created .DSA file"); if (main.isVerbose()) System.out.println(" adding: " + dsaFileName); // cleanup outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); log.info("Renamed signed JAR file"); if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") + "jar signed."); log.exiting(this.getClass().getName(), "start"); }
14,417
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
public ProfileHeader() { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
14,419
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
public ProfileHeader(byte[] data) { creatorSig = 0; intent = 0; modelSig = manufacturerSig = (int) 0x6E6f6E65; magic = icMagicNumber; cmmId = 0; platform = 0; timestamp = new byte[8]; majorVersion = 2; minorVersion = 0x10; flags = 0; // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
14,420
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
14,421
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
public ProfileHeader(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); // Get size (the sign bit shouldn't matter. // A valid profile can never be +2Gb) size = buf.getInt(ICC_Profile.icHdrSize); // CMM ID cmmId = buf.getInt(ICC_Profile.icHdrCmmId); // Version number majorVersion = (int) (data[ICC_Profile.icHdrVersion]); minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); // Profile/Device class int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); profileClass = -1; for (int i = 0; i < classMap.length; i += 2) if (classMap[i] == classSig) { profileClass = classMap[i + 1]; break; } // get the data color space int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); colorSpace = -1; for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == csSig) { colorSpace = csTypeMap[i + 1]; break; } // get the profile color space (PCS), must be xyz or lab except // for device-link-class profiles int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); profileColorSpace = -1; if (profileClass != ICC_Profile.CLASS_DEVICELINK) { if (pcsSig == ICC_Profile.icSigXYZData) profileColorSpace = ColorSpace.TYPE_XYZ; if (pcsSig == ICC_Profile.icSigLabData) profileColorSpace = ColorSpace.TYPE_Lab; } else { for (int i = 0; i < csTypeMap.length; i += 2) if (csTypeMap[i] == pcsSig) { profileColorSpace = csTypeMap[i + 1]; break; } } // creation timestamp timestamp = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); // magic number magic = buf.getInt(ICC_Profile.icHdrMagic); // platform info platform = buf.getInt(ICC_Profile.icHdrPlatform); // get flags flags = buf.getInt(ICC_Profile.icHdrFlags); // get manufacturer sign manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); // get header model modelSig = buf.getInt(ICC_Profile.icHdrModel); // attributes attributes = new byte[8]; System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); // rendering intent intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); // illuminant info illuminant = new byte[12]; System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); // Creator signature creatorSig = buf.getInt(ICC_Profile.icHdrCreator); // The rest of the header (Total size: 128 bytes) is unused.. }
14,422
ICC_ProfileRGB(byte[] data) { super(data); matrix = createMatrix(); whitePoint = getXYZData(icSigMediaWhitePointTag); }
ICC_ProfileRGB(int cspace) { super(data); matrix = createMatrix(); whitePoint = getXYZData(icSigMediaWhitePointTag); }
14,423
ICC_ProfileRGB(byte[] data) { super(data); matrix = createMatrix(); whitePoint = getXYZData(icSigMediaWhitePointTag); }
ICC_ProfileRGB(byte[] data) { super(cspace); matrix = createMatrix(); whitePoint = getXYZData(icSigMediaWhitePointTag); }
14,424
ICC_ProfileGray(byte[] data) { super(data); whitePoint = getXYZData(icSigMediaWhitePointTag); }
ICC_ProfileGray(int cspace) { super(data); whitePoint = getXYZData(icSigMediaWhitePointTag); }
14,425
ICC_ProfileGray(byte[] data) { super(data); whitePoint = getXYZData(icSigMediaWhitePointTag); }
ICC_ProfileGray(byte[] data) { super(cspace); whitePoint = getXYZData(icSigMediaWhitePointTag); }
14,426
protected void startDevice() throws DriverException { final Device device = getDevice(); try { final DeviceManager dm = (DeviceManager)InitialNaming.lookup(DeviceManager.NAME); dm.rename(device, getDevicePrefix(), true); } catch (DeviceAlreadyRegisteredException ex) { log.error("Cannot rename device", ex); } catch (NameNotFoundException ex) { throw new DriverException("Cannot find DeviceManager", ex); } device.registerAPI(NetDeviceAPI.class, this); txThread = new QueueProcessorThread(device.getId() + "-tx", txQueue, this); txThread.start(); }
protected void startDevice() throws DriverException { final Device device = getDevice(); try { final DeviceManager dm = (DeviceManager)InitialNaming.lookup(DeviceManager.NAME); if (renameToDevicePrefixOnly()) { dm.rename(device, getDevicePrefix(), true); } else { dm.rename(device, getDevicePrefix() + "-" + device.getId(), false); } } catch (DeviceAlreadyRegisteredException ex) { log.error("Cannot rename device", ex); } catch (NameNotFoundException ex) { throw new DriverException("Cannot find DeviceManager", ex); } device.registerAPI(NetDeviceAPI.class, this); txThread = new QueueProcessorThread(device.getId() + "-tx", txQueue, this); txThread.start(); }
14,427
public synchronized void allocateDataBlock(long i) throws FileSystemException, IOException { if(i < getAllocatedBlockCount()) throw new IOException(i+" blocks are already allocated for this inode"); if(i > getAllocatedBlockCount()) throw new IOException("Allocate block "+getAllocatedBlockCount()+" first!"); long newBlock = findFreeBlock(i); log.debug("Allocated new block "+newBlock); desc.setLastAllocatedBlockIndex(i); registerBlockIndex(i, newBlock); }
public synchronized void allocateDataBlock(long i) throws FileSystemException, IOException { if(i < getAllocatedBlockCount()) throw new IOException(i+" blocks are already allocated for this inode"); if(i > getAllocatedBlockCount()) throw new IOException("Allocate block "+getAllocatedBlockCount()+" first!"); long newBlock = findFreeBlock(i); log.debug("Allocated new block "+newBlock); desc.setLastAllocatedBlockIndex(i); registerBlockIndex(i, newBlock); }
14,428
public synchronized void allocateDataBlock(long i) throws FileSystemException, IOException { if(i < getAllocatedBlockCount()) throw new IOException(i+" blocks are already allocated for this inode"); if(i > getAllocatedBlockCount()) throw new IOException("Allocate block "+getAllocatedBlockCount()+" first!"); long newBlock = findFreeBlock(i); log.debug("Allocated new block "+newBlock); desc.setLastAllocatedBlockIndex(i); registerBlockIndex(i, newBlock); }
public synchronized void allocateDataBlock(long i) throws FileSystemException, IOException { if(i < getAllocatedBlockCount()) throw new IOException(i+" blocks are already allocated for this inode"); if(i > getAllocatedBlockCount()) throw new IOException("Allocate block "+getAllocatedBlockCount()+" first!"); long newBlock = findFreeBlock(i); log.debug("Allocated new block "+newBlock); desc.setLastAllocatedBlockIndex(i); registerBlockIndex(i, newBlock); }
14,429
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
14,430
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
14,431
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
14,432
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
14,433
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
private long findFreeBlock(long index) throws IOException, FileSystemException{ //long newBlock; long lastBlock = -1; BlockReservation reservation; //first, see if preallocated blocks exist if( desc.getPreallocCount() > 0 ) { return desc.usePreallocBlock(); } //no preallocated blocks: //check around the last allocated block if(index>0) lastBlock = getDataBlockNr(index-1); if( lastBlock!=-1 ) { for(int i=1; i<16; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } for(int i=-15; i<0; i++) { reservation = getExt2FileSystem().testAndSetBlock(lastBlock+i); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return lastBlock+i; } } } //then check the current block group from the beginning //(threshold=1 means: find is successul if at least one free block is found) reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } //then check the other block groups, first those that have "more" free space, //but take a note if a non-full group is found long nonfullBlockGroup = -1; for(int i=0; i<getExt2FileSystem().getGroupCount(); i++) { if(i==desc.getGroup()) continue; long threshold = (long)Math.ceil( getExt2FileSystem().getSuperblock().getBlocksPerGroup() * Ext2Constants.EXT2_BLOCK_THRESHOLD_RATIO ); reservation = getExt2FileSystem().findFreeBlocks( i, threshold); if(reservation.isSuccessful()) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } if(reservation.getFreeBlocksCount()>0) nonfullBlockGroup = i; } //if no block group with at least the threshold number of free blocks is found, //then check if there was any nonfull group if(nonfullBlockGroup!=-1) { reservation = getExt2FileSystem().findFreeBlocks( desc.getGroup(), 1 ); if( reservation.isSuccessful() ) { desc.setPreallocBlock( reservation.getBlock()+1 ); desc.setPreallocCount( reservation.getPreallocCount() ); long prealloc512 = (1+reservation.getPreallocCount()) * (fs.getBlockSize()/512); setBlocks( getBlocks()+prealloc512 ); return reservation.getBlock(); } } throw new IOException("No free blocks: disk full!"); }
14,434
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,435
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,436
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,437
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
protected synchronized void freeDataBlock(long i) throws IOException, FileSystemException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i != blockCount-1) throw new IOException("Only the last block of the inode can be freed." + "You were trying to free block nr. "+i+", while inode contains " + +blockCount+" blocks."); desc.setLastAllocatedBlockIndex(i-1); //preallocated blocks follow the last allocated block: when the last block is freed, //free the preallocated blocks as well freePreallocatedBlocks(); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); setDirty(true); //see the direct blocks (0; 11) if(i<12) { indirectFree(Ext2Utils.get32(data,40+(int)i*4), 0, 0); Ext2Utils.set32(data, 40+(int)i*4, 0); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { //the 12th index points to the indirect block indirectFree( Ext2Utils.get32(data, 40+12*4), i, 1 ); //if this was the last block on the indirect block, then delete the record of //the indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+12*4, 0); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) { //the 13th index points to the double indirect block indirectFree( Ext2Utils.get32(data, 40+13*4), i, 2 ); //if this was the last block on the double indirect block, then delete the record of //the double indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+13*4, 0); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) { //the 14th index points to the triple indirect block indirectFree( Ext2Utils.get32(data, 40+14*4), i, 3 ); //if this was the last block on the triple indirect block, then delete the record of //the triple indirect block from the inode if(i==0) Ext2Utils.set32(data, 40+14*4, 0); return; } //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,438
private long getDataBlockNr(long i) throws IOException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i > blockCount-1) throw new IOException( "Trying to read block "+i+" (counts from 0), while"+ " INode contains only "+blockCount+" blocks"); //get the direct blocks (0; 11) if(i<12) { log.debug("getDataBlockNr(): block nr: "+Ext2Utils.get32(data,40+(int)i*4)); return Ext2Utils.get32(data,40+(int)i*4); } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) //the 12th index points to the indirect block return indirectRead( Ext2Utils.get32(data, 40+12*4), i, 1 ); //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) //the 13th index points to the double indirect block return indirectRead( Ext2Utils.get32(data, 40+13*4), i, 2 ); //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) //the 14th index points to the triple indirect block return indirectRead( Ext2Utils.get32(data, 40+14*4), i, 3 ); //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
private long getDataBlockNr(long i) throws IOException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i > blockCount-1) throw new IOException( "Trying to read block "+i+" (counts from 0), while"+ " INode contains only "+blockCount+" blocks"); //get the direct blocks (0; 11) if(i<12) { log.debug("getDataBlockNr(): block nr: "+Ext2Utils.get32(data,40+(int)i*4)); return Ext2Utils.get32(data,40+(int)i*4); } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) //the 12th index points to the indirect block return indirectRead( Ext2Utils.get32(data, 40+12*4), i, 1 ); //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) //the 13th index points to the double indirect block return indirectRead( Ext2Utils.get32(data, 40+13*4), i, 2 ); //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) //the 14th index points to the triple indirect block return indirectRead( Ext2Utils.get32(data, 40+14*4), i, 3 ); //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,439
private long getDataBlockNr(long i) throws IOException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i > blockCount-1) throw new IOException( "Trying to read block "+i+" (counts from 0), while"+ " INode contains only "+blockCount+" blocks"); //get the direct blocks (0; 11) if(i<12) { log.debug("getDataBlockNr(): block nr: "+Ext2Utils.get32(data,40+(int)i*4)); return Ext2Utils.get32(data,40+(int)i*4); } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) //the 12th index points to the indirect block return indirectRead( Ext2Utils.get32(data, 40+12*4), i, 1 ); //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) //the 13th index points to the double indirect block return indirectRead( Ext2Utils.get32(data, 40+13*4), i, 2 ); //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) //the 14th index points to the triple indirect block return indirectRead( Ext2Utils.get32(data, 40+14*4), i, 3 ); //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
private long getDataBlockNr(long i) throws IOException { final long blockCount = getAllocatedBlockCount(); final int indirectCount = getIndirectCount(); if(i > blockCount-1) throw new IOException( "Trying to read block "+i+" (counts from 0), while"+ " INode contains only "+blockCount+" blocks"); //get the direct blocks (0; 11) if(i<12) { log.debug("getDataBlockNr(): block nr: "+Ext2Utils.get32(data,40+(int)i*4)); return Ext2Utils.get32(data,40+(int)i*4); } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) //the 12th index points to the indirect block return indirectRead( Ext2Utils.get32(data, 40+12*4), i, 1 ); //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; if(i<indirectCount * indirectCount) //the 13th index points to the double indirect block return indirectRead( Ext2Utils.get32(data, 40+13*4), i, 2 ); //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) i-=indirectCount*indirectCount; if(i<indirectCount*indirectCount*indirectCount) //the 14th index points to the triple indirect block return indirectRead( Ext2Utils.get32(data, 40+14*4), i, 3 ); //shouldn't get here throw new IOException(new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")")); }
14,440
private final void indirectFree(long dataBlockNr, long offset, int indirectionLevel) throws IOException, FileSystemException { log.debug("indirectFree(datablockNr="+dataBlockNr+", offset="+offset+", ind="+indirectionLevel+")"); if(indirectionLevel==0) { fs.freeBlock( dataBlockNr ); return; } byte[] data = fs.getBlock( dataBlockNr ); long blockIndex = offset / (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockOffset= offset % (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockNr = Ext2Utils.get32(data, (int)blockIndex*4); indirectFree( blockNr, blockOffset, indirectionLevel-1); if(offset==0) { //block blockNr has been the last block pointer on the indirect block, //so the indirect block can be freed up as well fs.freeBlock( dataBlockNr ); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); } }
private final void indirectFree(long dataBlockNr, long offset, int indirectionLevel) throws IOException, FileSystemException { log.debug("indirectFree(datablockNr="+dataBlockNr+", offset="+offset+", ind="+indirectionLevel+")"); if(indirectionLevel==0) { fs.freeBlock( dataBlockNr ); return; } byte[] data = fs.getBlock( dataBlockNr ); long blockIndex = offset / (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockOffset= offset % (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockNr = Ext2Utils.get32(data, (int)blockIndex*4); indirectFree( blockNr, blockOffset, indirectionLevel-1); if(offset==0) { //block blockNr has been the last block pointer on the indirect block, //so the indirect block can be freed up as well fs.freeBlock( dataBlockNr ); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); } }
14,441
private final void indirectFree(long dataBlockNr, long offset, int indirectionLevel) throws IOException, FileSystemException { log.debug("indirectFree(datablockNr="+dataBlockNr+", offset="+offset+", ind="+indirectionLevel+")"); if(indirectionLevel==0) { fs.freeBlock( dataBlockNr ); return; } byte[] data = fs.getBlock( dataBlockNr ); long blockIndex = offset / (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockOffset= offset % (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockNr = Ext2Utils.get32(data, (int)blockIndex*4); indirectFree( blockNr, blockOffset, indirectionLevel-1); if(offset==0) { //block blockNr has been the last block pointer on the indirect block, //so the indirect block can be freed up as well fs.freeBlock( dataBlockNr ); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); } }
private final void indirectFree(long dataBlockNr, long offset, int indirectionLevel) throws IOException, FileSystemException { log.debug("indirectFree(datablockNr="+dataBlockNr+", offset="+offset+", ind="+indirectionLevel+")"); if(indirectionLevel==0) { fs.freeBlock( dataBlockNr ); return; } byte[] data = fs.getBlock( dataBlockNr ); long blockIndex = offset / (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockOffset= offset % (long)Math.pow(getIndirectCount(), indirectionLevel-1); long blockNr = Ext2Utils.get32(data, (int)blockIndex*4); indirectFree( blockNr, blockOffset, indirectionLevel-1); if(offset==0) { //block blockNr has been the last block pointer on the indirect block, //so the indirect block can be freed up as well fs.freeBlock( dataBlockNr ); long block512 = fs.getBlockSize()/512; setBlocks( getBlocks()-block512 ); } }
14,442
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,443
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,444
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,445
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,447
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,448
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,450
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
private final void registerBlockIndex(long i, long blockNr) throws FileSystemException, IOException{ final long blockCount = getSizeInBlocks(); final int indirectCount = getIndirectCount(); long allocatedBlocks = i; if(i != blockCount) throw new FileSystemException( "Trying to register block "+i+" (counts from 0), when"+ " INode contains only "+blockCount+" blocks"); log.debug("registering block #"+blockNr); setDirty(true); //the direct blocks (0; 11) if(i<12) { Ext2Utils.set32(data, 40+(int)i*4, blockNr); return; } //see the indirect blocks (12; indirectCount-1) i-=12; if(i<indirectCount) { long indirectBlockNr; //the 12th index points to the indirect block if(i==0) { //need to reserve the indirect block itself, as this is the //first time it is used indirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+12*4, indirectBlockNr); //log.debug("reserved indirect block: "+indirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(indirectBlockNr, zeroes, false); } else //the indirect block has already been used indirectBlockNr = Ext2Utils.get32(data,40+12*4); indirectWrite( indirectBlockNr, i, allocatedBlocks, blockNr, 1 ); return; } //see the double indirect blocks (indirectCount; doubleIndirectCount-1) i-=indirectCount; final int doubleIndirectCount = indirectCount * indirectCount; if(i<doubleIndirectCount) { long doubleIndirectBlockNr; //the 13th index points to the double indirect block if(i==0) { //need to reserve the double indirect block itself doubleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, doubleIndirectBlockNr); //log.debug("reserved double indirect block: "+doubleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(doubleIndirectBlockNr, zeroes, false); } else doubleIndirectBlockNr = Ext2Utils.get32(data, 40+13*4); indirectWrite( doubleIndirectBlockNr, i, allocatedBlocks, blockNr, 2 ); return; } //see the triple indirect blocks (doubleIndirectCount; tripleIndirectCount-1) final int tripleIndirectCount = indirectCount * indirectCount * indirectCount; i-=doubleIndirectCount; if(i<tripleIndirectCount) { long tripleIndirectBlockNr; //the 14th index points to the triple indirect block if(i==0) { //need to reserve the triple indirect block itself tripleIndirectBlockNr = findFreeBlock(allocatedBlocks++); Ext2Utils.set32(data, 40+13*4, tripleIndirectBlockNr); //log.debug("reserved triple indirect block: "+tripleIndirectBlockNr); //need to blank the block so that e2fsck does not complain byte[] zeroes=new byte[fs.getBlockSize()]; //blank the block Arrays.fill(zeroes, 0, fs.getBlockSize(), (byte)0); fs.writeBlock(tripleIndirectBlockNr, zeroes, false); } else tripleIndirectBlockNr = Ext2Utils.get32(data, 40+14*4); indirectWrite( tripleIndirectBlockNr, i, allocatedBlocks, blockNr, 3 ); return; } //shouldn't get here throw new FileSystemException("Internal FS exception: getDataBlockIndex(i="+i+")"); }
14,451
protected synchronized void update() throws IOException{ try{ if(dirty) { log.debug(" ** updating inode **"); desc.getINodeTable().writeInodeData( desc.getIndex(), data ); dirty=false; } }catch(FileSystemException fs) { throw new IOException(fs); } }
protected synchronized void update() throws IOException{ try{ if(dirty) { log.debug(" ** updating inode **"); desc.getINodeTable().writeInodeData( desc.getIndex(), data ); dirty=false; } }catch(FileSystemException fs) { throw new IOException(fs); } }
14,452
protected final void handleStartTag(TagElement tag) { htmlAttributeSet attributes = gnu.getAttributes(); if (tag.fictional()) attributes.addAttribute(ParserCallback.IMPLIED, Boolean.TRUE); callBack.handleStartTag(tag.getHTMLTag(), attributes, hTag.where.startPosition ); }
protected final void handleStartTag(TagElement tag) { SimpleAttributeSet attributes = gnu.getAttributes(); if (tag.fictional()) attributes.addAttribute(ParserCallback.IMPLIED, Boolean.TRUE); callBack.handleStartTag(tag.getHTMLTag(), attributes, hTag.where.startPosition ); }
14,453
protected boolean removeEldestEntry(Map.Entry eldest) { if(size()>MAX_SIZE) { ((Block)eldest.getValue()).flush(); return true; } else return false; }
protected boolean removeEldestEntry(Map.Entry eldest) { if(size()>MAX_SIZE) { try{ ((Block)eldest.getValue()).flush(); CacheEvent event = new CacheEvent(eldest.getValue(),CacheEvent.REMOVED); Iterator listeners=cacheListeners.iterator(); while(listeners.hasNext()) { ((CacheListener)listeners.next()).elementRemoved(event); } }catch(IOException e) { log.error("Exception when flushing a block from the cache", e); } return true; } else return false; }
14,454
public Object next() { //log.debug("next: offset=" + offset); if (nextEntry == null) { //log.debug("next: islast"); throw new NoSuchElementException(); } else { final IndexEntry result = nextEntry; final int size = nextEntry.getSize(); //log.debug("next: size=" + size); offset += size; // Now read the next next entry readNext(); return result; } }
public IndexEntry next() { //log.debug("next: offset=" + offset); if (nextEntry == null) { //log.debug("next: islast"); throw new NoSuchElementException(); } else { final IndexEntry result = nextEntry; final int size = nextEntry.getSize(); //log.debug("next: size=" + size); offset += size; // Now read the next next entry readNext(); return result; } }
14,455
public final Class getCategory() { return RequestingUserName.class; }
public Class getCategory() { return RequestingUserName.class; }
14,456
public final String getName() { return "requesting-user-name"; }
public String getName() { return "requesting-user-name"; }
14,457
public void hide() { if (isVisible()) { if (peer != null) peer.setVisible(false); this.visible = false; invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); getToolkit().getSystemEventQueue().postEvent(ce); } }
public void hide() { if (isVisible()) { if (peer != null) peer.setVisible(false); this.visible = false; invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); getToolkit().getSystemEventQueue().postEvent(ce); } }
14,458
public void hide() { if (isVisible()) { if (peer != null) peer.setVisible(false); this.visible = false; invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); getToolkit().getSystemEventQueue().postEvent(ce); } }
public void hide() { if (isVisible()) { if (peer != null) peer.setVisible(false); this.visible = false; Container currentParent = parent; if (currentParent != null) { currentParent.invalidate(); currentParent.repaint(); } ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); getToolkit().getSystemEventQueue().postEvent(ce); } }
14,459
public void show() { // We must set visible before showing the peer. Otherwise the // peer could post paint events before visible is true, in which // case lightweight components are not initially painted -- // Container.paint first calls isShowing () before painting itself // and its children. if(!isVisible()) { this.visible = true; if (peer != null) peer.setVisible(true); invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); getToolkit().getSystemEventQueue().postEvent(ce); } }
public void show() { // We must set visible before showing the peer. Otherwise the // peer could post paint events before visible is true, in which // case lightweight components are not initially painted -- // Container.paint first calls isShowing () before painting itself // and its children. if(!isVisible()) { this.visible = true; if (peer != null) peer.setVisible(true); invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); getToolkit().getSystemEventQueue().postEvent(ce); } }
14,460
protected void fireDragGestureRecognized(int dragAction, Point p) throws NotImplementedException { throw new Error("not implemented"); }
protected void fireDragGestureRecognized(int dragAction, Point p) { throw new Error("not implemented"); }
14,462
protected void fireDragGestureRecognized(int dragAction, Point p) throws NotImplementedException { throw new Error("not implemented"); }
protected void fireDragGestureRecognized(int dragAction, Point p) throws NotImplementedException { if(dragGestureListener != null) dragGestureListener.dragGestureRecognized (new DragGestureEvent(this, dragAction, p, events)); }
14,463
public void resetRecognizer() throws NotImplementedException { throw new Error("not implemented"); }
public void resetRecognizer() throws NotImplementedException { events = new ArrayList(); }
14,464
public JFormattedTextField getTextField() { return null; } /* TODO */
public JFormattedTextField getTextField() { return null; } /* TODO */
14,466
public void layoutContainer(Container parent) { } /* TODO */
public void layoutContainer(Container parent) { Insets insets = getInsets(); Dimension size = getSize(); ftf.setBounds(insets.left, insets.top, size.width - insets.left - insets.right, size.height - insets.top - insets.bottom); } /* TODO */
14,467
public Dimension minimumLayoutSize(Container parent) { return null; } /* TODO */
public Dimension minimumLayoutSize(Container parent) { return null; } /* TODO */
14,468
public Dimension preferredLayoutSize(Container parent) { return null; } /* TODO */
public Dimension preferredLayoutSize(Container parent) { return null; } /* TODO */
14,469
protected JComponent createEditor(SpinnerModel model) { return new StubEditor(this); } /* TODO */}
protected JComponent createEditor(SpinnerModel model) { return new StubEditor(this); } /* TODO */}
14,470
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { // TODO: This implementation is very general and highly inefficient. There // are two possible ways to optimize this: // 1. Special cased implementations for common ColorModels and transfer // types. // 2. Native implementation. int x0 = src.getMinX(); int y0 = src.getMinY(); int width = src.getWidth(); int height = src.getHeight(); int x1 = x0 + width; int y1 = y0 + height; Object srcPixel = null; Object dstPixel = null; // Prepare the array that holds the color and alpha components of the // source pixels. float[] srcComponents; int srcComponentsLength = srcColorModel.getNumComponents(); if (! srcColorModel.hasAlpha()) srcComponentsLength += 1; srcComponents = new float[srcComponentsLength]; // Prepare the array that holds the color and alpha components of the // destination pixels. float[] dstComponents; int dstComponentsLength = dstColorModel.getNumComponents(); if (! dstColorModel.hasAlpha()) dstComponentsLength += 1; dstComponents = new float[dstComponentsLength]; if (srcComponentsLength != dstComponentsLength) throw new AWTError("The color models of the source and destination have" + "incompatible number of color components"); int srcTransferType = srcColorModel.getTransferType(); int dstTransferType = dstColorModel.getTransferType(); for (int y = y0; y < y1; y++) { for (int x = x0; x < x1; x++) { // Fetch source pixel. srcPixel = src.getDataElements(x, y, (int[]) srcPixel); // Fetch destination pixel. dstPixel = dstIn.getDataElements(x, y, dstPixel); // Get normalized components. This is the only type that is // guaranteed to be supported by all ColorModels. srcComponents = srcColorModel.getNormalizedComponents(srcPixel, srcComponents, 0); if (! srcColorModel.hasAlpha()) srcComponents[srcComponentsLength - 1] = 1.0F; dstComponents = dstColorModel.getNormalizedComponents(dstPixel, dstComponents, 0); if (! dstColorModel.hasAlpha()) dstComponents[dstComponentsLength - 1] = 1.0F; // Prepare the input. float compositeAlpha = composite.getAlpha(); srcComponents[srcComponentsLength - 1] *= compositeAlpha; if (srcColorModel.isAlphaPremultiplied()) { for (int i = srcComponentsLength - 2; i >= 0; i--) srcComponents[i] *= compositeAlpha; } else { for (int i = srcComponentsLength - 1; i >= 0; i--) srcComponents[i] *= srcComponents[srcComponentsLength - 1]; } if (! dstColorModel.isAlphaPremultiplied()) { for (int i = dstComponentsLength - 2; i >= 0; i--) dstComponents[i] *= dstComponents[dstComponents.length - 1]; } // Determine the blending factors according to the rule in the // AlphaComposite. For some rules the factors must be determined // dynamically because they depend on the actual pixel value. float srcAlpha = srcComponents[srcComponentsLength - 1]; float dstAlpha = dstComponents[dstComponentsLength - 1]; switch (composite.getRule()) { case AlphaComposite.DST_ATOP: fs = 1.F - dstAlpha; fd = srcAlpha; break; case AlphaComposite.DST_IN: fd = srcAlpha; break; case AlphaComposite.DST_OUT: fd = 1.F - srcAlpha; break; case AlphaComposite.DST_OVER: fs = 1.F - dstAlpha; break; case AlphaComposite.SRC_ATOP: fs = srcAlpha; fd = 1.F - srcAlpha; break; case AlphaComposite.SRC_IN: fs = dstAlpha; break; case AlphaComposite.SRC_OUT: fs = 1.F - dstAlpha; break; case AlphaComposite.SRC_OVER: fd= 1.F - srcAlpha; break; case AlphaComposite.XOR: fs = 1.F - dstAlpha; fd= 1.F - srcAlpha; break; default: // For the other cases the factors have already been determined // in the constructor. } // Apply the blending equation to the pixels. for (int i = 0; i < srcComponentsLength; i++) { dstComponents[i] = srcComponents[i] * fs + dstComponents[i] * fd; } // Convert the result back when the destination is not // alpha-premultiplied. dstAlpha = dstComponents[dstComponentsLength - 1]; if (!dstColorModel.isAlphaPremultiplied() && dstAlpha != 0.F) { for (int i = 0; i < dstComponentsLength - 1; i++) { dstComponents[i] = dstComponents[i] / dstAlpha; } } // Store the result in the destination raster. dstPixel = dstColorModel.getDataElements(dstComponents, 0, dstPixel); dstOut.setDataElements(x, y, dstPixel); } // End X loop. } // End Y loop. }
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { // TODO: This implementation is very general and highly inefficient. There // are two possible ways to optimize this: // 1. Special cased implementations for common ColorModels and transfer // types. // 2. Native implementation. int x0 = src.getMinX(); int y0 = src.getMinY(); int width = src.getWidth(); int height = src.getHeight(); int x1 = x0 + width; int y1 = y0 + height; Object srcPixel = null; Object dstPixel = null; // Prepare the array that holds the color and alpha components of the // source pixels. float[] srcComponents; int srcComponentsLength = srcColorModel.getNumComponents(); if (! srcColorModel.hasAlpha()) srcComponentsLength += 1; srcComponents = new float[srcComponentsLength]; // Prepare the array that holds the color and alpha components of the // destination pixels. float[] dstComponents; int dstComponentsLength = dstColorModel.getNumComponents(); if (! dstColorModel.hasAlpha()) dstComponentsLength += 1; dstComponents = new float[dstComponentsLength]; if (srcComponentsLength != dstComponentsLength) throw new AWTError("The color models of the source and destination have" + "incompatible number of color components"); int srcTransferType = srcColorModel.getTransferType(); int dstTransferType = dstColorModel.getTransferType(); for (int y = y0; y < y1; y++) { for (int x = x0; x < x1; x++) { // Fetch source pixel. srcPixel = src.getDataElements(x, y, (int[]) srcPixel); // Fetch destination pixel. dstPixel = dstIn.getDataElements(x, y, dstPixel); // Get normalized components. This is the only type that is // guaranteed to be supported by all ColorModels. srcComponents = srcColorModel.getNormalizedComponents(srcPixel, srcComponents, 0); if (! srcColorModel.hasAlpha()) srcComponents[srcComponentsLength - 1] = 1.0F; dstComponents = dstColorModel.getNormalizedComponents(dstPixel, dstComponents, 0); if (! dstColorModel.hasAlpha()) dstComponents[dstComponentsLength - 1] = 1.0F; // Prepare the input. float compositeAlpha = composite.getAlpha(); srcComponents[srcComponentsLength - 1] *= compositeAlpha; if (srcColorModel.isAlphaPremultiplied()) { for (int i = srcComponentsLength - 2; i >= 0; i--) srcComponents[i] *= compositeAlpha; } else { for (int i = srcComponentsLength - 2; i >= 0; i--) srcComponents[i] *= srcComponents[srcComponentsLength - 1]; } if (! dstColorModel.isAlphaPremultiplied()) { for (int i = dstComponentsLength - 2; i >= 0; i--) dstComponents[i] *= dstComponents[dstComponents.length - 1]; } // Determine the blending factors according to the rule in the // AlphaComposite. For some rules the factors must be determined // dynamically because they depend on the actual pixel value. float srcAlpha = srcComponents[srcComponentsLength - 1]; float dstAlpha = dstComponents[dstComponentsLength - 1]; switch (composite.getRule()) { case AlphaComposite.DST_ATOP: fs = 1.F - dstAlpha; fd = srcAlpha; break; case AlphaComposite.DST_IN: fd = srcAlpha; break; case AlphaComposite.DST_OUT: fd = 1.F - srcAlpha; break; case AlphaComposite.DST_OVER: fs = 1.F - dstAlpha; break; case AlphaComposite.SRC_ATOP: fs = srcAlpha; fd = 1.F - srcAlpha; break; case AlphaComposite.SRC_IN: fs = dstAlpha; break; case AlphaComposite.SRC_OUT: fs = 1.F - dstAlpha; break; case AlphaComposite.SRC_OVER: fd= 1.F - srcAlpha; break; case AlphaComposite.XOR: fs = 1.F - dstAlpha; fd= 1.F - srcAlpha; break; default: // For the other cases the factors have already been determined // in the constructor. } // Apply the blending equation to the pixels. for (int i = 0; i < srcComponentsLength; i++) { dstComponents[i] = srcComponents[i] * fs + dstComponents[i] * fd; } // Convert the result back when the destination is not // alpha-premultiplied. dstAlpha = dstComponents[dstComponentsLength - 1]; if (!dstColorModel.isAlphaPremultiplied() && dstAlpha != 0.F) { for (int i = 0; i < dstComponentsLength - 1; i++) { dstComponents[i] = dstComponents[i] / dstAlpha; } } // Store the result in the destination raster. dstPixel = dstColorModel.getDataElements(dstComponents, 0, dstPixel); dstOut.setDataElements(x, y, dstPixel); } // End X loop. } // End Y loop. }
14,473
public float[] getNormalizedComponents (Object pixel, float[] normComponents, int normOffset) { // subclasses has to implement this method. throw new UnsupportedOperationException(); }
public float[] getNormalizedComponents (Object pixel, float[] normComponents, int normOffset) { // subclasses has to implement this method. throw new UnsupportedOperationException(); }
14,474
public float[] getNormalizedComponents (Object pixel, float[] normComponents, int normOffset) { // subclasses has to implement this method. throw new UnsupportedOperationException(); }
public float[] getNormalizedComponents (Object pixel, float[] normComponents, int normOffset) { // subclasses has to implement this method. throw new UnsupportedOperationException(); }
14,475
public int hashCode () { // FIXME: Check what SUN calculates here. return super.hashCode (); }
public int hashCode () { // FIXME: Check what SUN calculates here. long hashCode = Double.doubleToLongBits(get(position())) + 31; long multiplier = 1; for (int i = position() + 1; i < limit(); ++i) { multiplier *= 31; hashCode += (Double.doubleToLongBits(get(i)) + 30)*multiplier; } return ((int)hashCode); }
14,476
final public static DoubleBuffer wrap (double[] array, int offset, int length) { return new DoubleBufferImpl (array, 0, array.length, offset + length, offset, -1, false); }
public static final DoubleBuffer wrap (double[] array, int offset, int length) { return new DoubleBufferImpl (array, 0, array.length, offset + length, offset, -1, false); }
14,477
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
private void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
14,478
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
14,479
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{ Ext2File dir = new Ext2File(iNode); //read itself as a file //find the last directory record (if any) Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode); Ext2DirectoryRecord rec=null; while(iterator.hasNext()) { rec = iterator.nextDirectoryRecord(); } Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); if(rec!=null) { long lastPos = rec.getFileOffset(); long lastLen = rec.getRecLen(); //truncate the last record to its minimal size (cut the padding from the end) rec.truncateRecord(); //directoryRecords may not extend over block boundaries: // see if the new record fits in the same block after truncating the last record long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen(); log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen); log.debug("LAST-1 truncated length: "+rec.getRecLen()); log.debug("Remaining length: "+remainingLength); if(remainingLength >= dr.getRecLen()) { //write back the last record truncated dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() ); //pad the end of the new record with zeroes dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength); //append the new record at the end of the list dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+ (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen()); } else { //the new record must go to the next block //(the previously last record (rec) stays padded to the end of the block, so we can // append after that) dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize()); dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() ); log.debug("addDirectoryRecord(): LAST record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen()); } } else { //rec==null, ie. this is the first record in the directory dr.expandRecord(0, fs.getBlockSize()); dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen()); log.debug("addDirectoryRecord(): LAST record: begins at: 0, length: "+dr.getRecLen()); } //dir.flush(); iNode.setMtime(System.currentTimeMillis()/1000); }
14,480
public synchronized FSEntry createDirectoryEntry(String name) throws IOException { if(!canWrite()) throw new IOException("Filesystem or directory is mounted read-only!"); //create a new iNode for the file //TODO: access rights, file type, UID and GID should be passed through the FSDirectory interface INode newINode; Ext2DirectoryRecord dr; Ext2Entry newEntry; Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); try{ int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); newINode = fs.createINode((int)iNode.getGroup(), Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, name); addDirectoryRecord(dr); newINode.setLinksCount( newINode.getLinksCount()+1 ); newEntry = new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_DIR, fs, this); //add "." Ext2Directory newDir = new Ext2Directory(newEntry); Ext2DirectoryRecord drThis = new Ext2DirectoryRecord( fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, "." ); newDir.addDirectoryRecord( drThis ); newINode.setLinksCount( 2 ); //add ".." long parentINodeNr = ((Ext2Directory)entry.getDirectory()).getINode().getINodeNr(); Ext2DirectoryRecord drParent=new Ext2DirectoryRecord( fs, parentINodeNr, Ext2Constants.EXT2_FT_DIR, ".." ); newDir.addDirectoryRecord( drParent ); //increase the reference count for the parent directory INode parentINode = fs.getINode((int)parentINodeNr); parentINode.setLinksCount( parentINode.getLinksCount()+1 ); //update the number of used directories in the block group int group = (int)( (newINode.getINodeNr()-1) / fs.getSuperblock().getINodesPerGroup()) ; fs.modifyUsedDirsCount(group, 1); //update both affected directory inodes iNode.update(); newINode.update(); }catch(FileSystemException fse) { throw new IOException(fse); } return newEntry; }
public FSEntry createDirectoryEntry(String name) throws IOException { if(!canWrite()) throw new IOException("Filesystem or directory is mounted read-only!"); //create a new iNode for the file //TODO: access rights, file type, UID and GID should be passed through the FSDirectory interface INode newINode; Ext2DirectoryRecord dr; Ext2Entry newEntry; Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); try{ int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); newINode = fs.createINode((int)iNode.getGroup(), Ext2Constants.EXT2_S_IFDIR, rights, 0, 0); dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, name); addDirectoryRecord(dr); newINode.setLinksCount( newINode.getLinksCount()+1 ); newEntry = new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_DIR, fs, this); //add "." Ext2Directory newDir = new Ext2Directory(newEntry); Ext2DirectoryRecord drThis = new Ext2DirectoryRecord( fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, "." ); newDir.addDirectoryRecord( drThis ); newINode.setLinksCount( 2 ); //add ".." long parentINodeNr = ((Ext2Directory)entry.getDirectory()).getINode().getINodeNr(); Ext2DirectoryRecord drParent=new Ext2DirectoryRecord( fs, parentINodeNr, Ext2Constants.EXT2_FT_DIR, ".." ); newDir.addDirectoryRecord( drParent ); //increase the reference count for the parent directory INode parentINode = fs.getINode((int)parentINodeNr); parentINode.setLinksCount( parentINode.getLinksCount()+1 ); //update the number of used directories in the block group int group = (int)( (newINode.getINodeNr()-1) / fs.getSuperblock().getINodesPerGroup()) ; fs.modifyUsedDirsCount(group, 1); //update both affected directory inodes iNode.update(); newINode.update(); }catch(FileSystemException fse) { throw new IOException(fse); } return newEntry; }
14,481
public synchronized FSEntry createFileEntry(String name) throws IOException { if(!canWrite()) throw new IOException("Filesystem or directory is mounted read-only!"); //create a new iNode for the file //TODO: access rights, file type, UID and GID should be passed through the FSDirectory interface INode newINode; Ext2DirectoryRecord dr; Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); try{ int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); newINode = fs.createINode((int)iNode.getGroup(), Ext2Constants.EXT2_S_IFREG, rights, 0, 0); dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_REG_FILE, name); addDirectoryRecord(dr); newINode.setLinksCount( newINode.getLinksCount()+1 ); // update the directory inode iNode.update(); }catch(FileSystemException fse) { throw new IOException(fse); } return new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_REG_FILE, fs, this); }
public FSEntry createFileEntry(String name) throws IOException { if(!canWrite()) throw new IOException("Filesystem or directory is mounted read-only!"); //create a new iNode for the file //TODO: access rights, file type, UID and GID should be passed through the FSDirectory interface INode newINode; Ext2DirectoryRecord dr; Ext2FileSystem fs = (Ext2FileSystem) getFileSystem(); try{ int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO); newINode = fs.createINode((int)iNode.getGroup(), Ext2Constants.EXT2_S_IFREG, rights, 0, 0); dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_REG_FILE, name); addDirectoryRecord(dr); newINode.setLinksCount( newINode.getLinksCount()+1 ); // update the directory inode iNode.update(); }catch(FileSystemException fse) { throw new IOException(fse); } return new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_REG_FILE, fs, this); }
14,482
protected Thread getCurrentWriter() { // FIXME: Implement locking! return null; }
protected Thread getCurrentWriter() { // FIXME: Implement locking! return currentWriter; }
14,484
public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { // Just return when no text to insert was given. if (text == null || text.length() == 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, text.length(), DocumentEvent.EventType.INSERT); content.insertString(offset, text); insertUpdate(event, attributes); fireInsertUpdate(event); }
public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { // Just return when no text to insert was given. if (text == null || text.length() == 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, text.length(), DocumentEvent.EventType.INSERT); writeLock(); UndoableEdit temp = content.insertString(offset, text); writeUnlock(); GapContent.UndoInsertString changes = null; if (content instanceof GapContent) changes = (GapContent.UndoInsertString) temp; insertUpdate(event, attributes); fireInsertUpdate(event); }
14,485
public void remove(int offset, int length) throws BadLocationException { DefaultDocumentEvent event = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE); removeUpdate(event); content.remove(offset, length); postRemoveUpdate(event); fireRemoveUpdate(event); }
public void remove(int offset, int length) throws BadLocationException { DefaultDocumentEvent event = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE); removeUpdate(event); Element[] added = new Element[1]; added[0] = root.getElement(start); boolean shouldFire = content.getString(offset, length).length() != 0; writeLock(); UndoableEdit temp = content.remove(offset, length); writeUnlock(); postRemoveUpdate(event); fireRemoveUpdate(event); }
14,489
public Component getTopComponentAt(int x, int y) { Component comp = super.getTopComponentAt(x, y); SwingFrame sfp = (SwingFrame) SwingUtilities.getAncestorOfClass( SwingFrame.class, comp); if (sfp != null) { Rectangle r = sfp.getBounds(); Insets ins = sfp.getSwingPeer().getInsets(); r.x = r.x + ins.left; r.y = r.y + ins.top; r.width = r.width - ins.left - ins.right; r.height = r.height - ins.top - ins.bottom; if (r.contains(x, y)) { Component c = sfp.getAwtFrame().findComponentAt(x, y); if (c != null) { comp = c; } } } return comp; }
public Component getTopComponentAt(int x, int y) { Component comp = super.getTopComponentAt(x, y); SwingFrame sfp = (SwingFrame) SwingUtilities.getAncestorOfClass( SwingFrame.class, comp); if (sfp != null) { Rectangle r = sfp.getBounds(); Insets ins = sfp.getSwingPeer().getInsets(); r.x = r.x + ins.left; r.y = r.y + ins.top; r.width = r.width - ins.left - ins.right; r.height = r.height - ins.top - ins.bottom; if (r.contains(x, y)) { Component c = sfp.getAWTComponent().findComponentAt(x, y); if (c != null) { comp = c; } } } return comp; }
14,494
protected Item cloneConstant() { return createConst(getValue()); }
protected WordItem cloneConstant() { return createConst(getValue()); }
14,495
public static long[] read(InputStream input) { LongLongSeqHolder h = new LongLongSeqHolder(); h._read(input); return h.value; }
public static long[] read(InputStream input) { LongLongSeqHolder h = new LongLongSeqHolder(); h._read(input); return h.value; }
14,496
public static void write(OutputStream output, long[] value) { LongLongSeqHolder h = new LongLongSeqHolder(value); h._write(output); }
public static void write(OutputStream output, long[] value) { LongLongSeqHolder h = new LongLongSeqHolder(value); h._write(output); }
14,497
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding the rootPane (initialization stages) use super.add. // Otherwise pass the add onto the content pane. if (comp==rootPane) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("rootPaneChecking is enabled - adding components " + "disallowed."); getContentPane().add(comp,constraints,index); } }
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding the rootPane (initialization stages) use super.add. // Otherwise pass the add onto the content pane. if (!initStageDone) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("rootPaneChecking is enabled - adding components " + "disallowed."); getContentPane().add(comp,constraints,index); } }
14,498
protected void installDefaults(JSeparator s) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); shadow = defaults.getColor("Separator.shadow"); highlight = defaults.getColor("Separator.highlight"); s.setOpaque(true); }
protected void installDefaults(JSeparator s) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); shadow = defaults.getColor("Separator.shadow"); highlight = defaults.getColor("Separator.highlight"); s.setOpaque(false); }
14,499
public abstract boolean addPermission(Permission permission);
boolean addPermission(Permission permission);
14,502
public abstract boolean checkPermission(Permission permission);
boolean checkPermission(Permission permission);
14,503
public abstract Principal getPrincipal();
Principal getPrincipal();
14,504
public abstract boolean isNegative();
boolean isNegative();
14,505
public abstract Enumeration permissions();
Enumeration permissions();
14,506
public abstract boolean removePermission(Permission perm);
boolean removePermission(Permission perm);
14,507
public abstract void setNegativePermissions();
void setNegativePermissions();
14,508
public abstract boolean setPrincipal(Principal user);
boolean setPrincipal(Principal user);
14,509
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
14,510
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
public Object evaluate(Node context, int pos, int len) Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) p = 0; } int l = s.length() - p; if (l <= 0) return ""; } if (arg3 != null) Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) l = v3; } } return s.substring(p, p + l); }
14,511
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; int l = s.length() - p; if (l <= 0) { return ""; if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; return s.substring(p, p + l);
14,512
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
public Object evaluate(Node context, int pos, int len) { Object val1 = arg1.evaluate(context, pos, len); Object val2 = arg2.evaluate(context, pos, len); String s = _string(context, val1); int p = (val2 instanceof Double) ? ((Double) val2).intValue() : (int) Math.round(_number(context, val2)); p--; if (p < 0) { p = 0; } int l = s.length() - p; if (l <= 0) { return ""; } if (arg3 != null) { Object val3 = arg3.evaluate(context, pos, len); int v3 = (val3 instanceof Double) ? ((Double) val3).intValue() : (int) Math.round(_number(context, val3)); if (v3 < l) { l = v3; } } return s.substring(p, p + l); }
14,513
public BufferCapabilities getBufferCapabilities() throws NotImplementedException { throw new Error("not implemented"); }
public BufferCapabilities getBufferCapabilities() { throw new Error("not implemented"); }
14,514
public BufferCapabilities getBufferCapabilities() throws NotImplementedException { throw new Error("not implemented"); }
public BufferCapabilities getBufferCapabilities() throws NotImplementedException { if (imageCapabilities == null) getImageCapabilities(); if (bufferCapabilities == null) bufferCapabilities = new BufferCapabilities(imageCapabilities, imageCapabilities, null); return bufferCapabilities; }
14,515