Sleuth Kit Java Bindings (JNI)  4.9.0
Java bindings for using The Sleuth Kit
VolumeSystem.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2011-2017 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 
100  protected synchronized long getVolumeSystemHandle() throws TskCoreException {
101  if (volumeSystemHandle == 0) {
102  Content dataSource = getDataSource();
103  if ((dataSource != null) && (dataSource instanceof Image)) {
104  Image image = (Image) dataSource;
105  volumeSystemHandle = SleuthkitJNI.openVs(image.getImageHandle(), imgOffset);
106  } else {
107  throw new TskCoreException("Volume System data source is not an image");
108  }
109  }
110 
111  return volumeSystemHandle;
112  }
113 
114  @Override
115  public void close() {
116  if (volumeSystemHandle != 0) {
117  synchronized (this) {
118  if (volumeSystemHandle != 0) {
119  // SleuthkitJNI.closeVs(volumeSystemHandle); // closeVs is currently a no-op
120  volumeSystemHandle = 0;
121  }
122  }
123  }
124  }
125 
126  @Override
127  public void finalize() throws Throwable {
128  try {
129  close();
130  } finally {
131  super.finalize();
132  }
133  }
134 
135  @Override
136  public <T> T accept(SleuthkitItemVisitor<T> v) {
137  return v.visit(this);
138  }
139 
140  @Override
141  public <T> T accept(ContentVisitor<T> v) {
142  return v.visit(this);
143  }
144 
145  @Override
146  public List<Content> getChildren() throws TskCoreException {
147  return getSleuthkitCase().getVolumeSystemChildren(this);
148  }
149 
150  @Override
151  public List<Long> getChildrenIds() throws TskCoreException {
152  return getSleuthkitCase().getVolumeSystemChildrenIds(this);
153  }
154 
160  public List<Volume> getVolumes() throws TskCoreException {
161  List<Volume> volumes = new ArrayList<Volume>();
162  for (Content child : getChildren()) {
163  if (child instanceof Volume) {
164  volumes.add((Volume) child);
165  }
166  }
167  return volumes;
168  }
169 
170  @Override
171  public String toString(boolean preserveState) {
172  return super.toString(preserveState) + "VolumeSystem [\t" + "blockSize " + blockSize + "\t" + "imgOffset " + imgOffset + "\t" + "type " + type + "]\t"; //NON-NLS
173  }
174 }
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)
int read(byte[] readBuffer, long offset, long len)
String toString(boolean preserveState)
static TSK_VS_TYPE_ENUM valueOf(long vsType)
Definition: TskData.java:593
synchronized long getImageHandle()
Definition: Image.java:121

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