Sleuth Kit Java Bindings (JNI)  4.2
Java bindings for using The Sleuth Kit
VolumeSystem.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.List;
24 
28 public class VolumeSystem extends AbstractContent {
29 
30  private volatile long volumeSystemHandle = 0;
31  private long type, imgOffset, blockSize;
32 
43  protected VolumeSystem(SleuthkitCase db, long obj_id, String name, long type, long imgOffset, long blockSize) {
44  super(db, obj_id, name);
45  this.type = type;
46  this.imgOffset = imgOffset;
47  this.blockSize = blockSize;
48  }
49 
50  @Override
51  public int read(byte[] readBuffer, long offset, long len) throws TskCoreException {
52  synchronized (this) {
53  if (volumeSystemHandle == 0) {
55  }
56  }
57  return SleuthkitJNI.readVs(volumeSystemHandle, readBuffer, offset, len);
58  }
59 
60  @Override
61  public long getSize() {
62  return 0;
63  }
64 
71  return TskData.TSK_VS_TYPE_ENUM.valueOf(type);
72  }
73 
79  public long getOffset() {
80  return imgOffset;
81  }
82 
88  public long getBlockSize() {
89  return blockSize;
90  }
91 
99  protected synchronized long getVolumeSystemHandle() throws TskCoreException {
100  if (volumeSystemHandle == 0) {
101  Content dataSource = getDataSource();
102  if ((dataSource != null) && (dataSource instanceof Image)) {
103  Image image = (Image) dataSource;
104  volumeSystemHandle = SleuthkitJNI.openVs(image.getImageHandle(), imgOffset);
105  } else {
106  throw new TskCoreException("Volume System data source is not an image");
107  }
108  }
109 
110  return volumeSystemHandle;
111  }
112 
113  @Override
114  public void close() {
115  if (volumeSystemHandle != 0) {
116  synchronized (this) {
117  if (volumeSystemHandle != 0) {
118  SleuthkitJNI.closeVs(volumeSystemHandle);
119  volumeSystemHandle = 0;
120  }
121  }
122  }
123  }
124 
125  @Override
126  public void finalize() throws Throwable {
127  try {
128  close();
129  } finally {
130  super.finalize();
131  }
132  }
133 
134  @Override
135  public <T> T accept(SleuthkitItemVisitor<T> v) {
136  return v.visit(this);
137  }
138 
139  @Override
140  public <T> T accept(ContentVisitor<T> v) {
141  return v.visit(this);
142  }
143 
144  @Override
145  public List<Content> getChildren() throws TskCoreException {
146  return getSleuthkitCase().getVolumeSystemChildren(this);
147  }
148 
149  @Override
150  public List<Long> getChildrenIds() throws TskCoreException {
151  return getSleuthkitCase().getVolumeSystemChildrenIds(this);
152  }
153 
158  public List<Volume> getVolumes() throws TskCoreException {
159  List<Volume> volumes = new ArrayList<Volume>();
160  for (Content child : getChildren()) {
161  if (child instanceof Volume) {
162  volumes.add((Volume) child);
163  }
164  }
165  return volumes;
166  }
167 
168  @Override
169  public String toString(boolean preserveState) {
170  return super.toString(preserveState) + "VolumeSystem [\t" + "blockSize " + blockSize + "\t" + "imgOffset " + imgOffset + "\t" + "type " + type + "]\t"; //NON-NLS
171  }
172 }
static int readVs(long vsHandle, byte[] readBuffer, long offset, long len)
VolumeSystem(SleuthkitCase db, long obj_id, String name, long type, long imgOffset, long blockSize)
synchronized long getVolumeSystemHandle()
static long openVs(long imgHandle, long vsOffset)
static void closeVs(long vsHandle)
int read(byte[] readBuffer, long offset, long len)
String toString(boolean preserveState)
static TSK_VS_TYPE_ENUM valueOf(long vsType)
Definition: TskData.java:565
synchronized long getImageHandle()
Definition: Image.java:72

Copyright © 2011-2015 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.