Sleuth Kit Java Bindings (JNI)  4.12.1
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  @SuppressWarnings("deprecation")
127  @Override
128  public void finalize() throws Throwable {
129  try {
130  close();
131  } finally {
132  super.finalize();
133  }
134  }
135 
136  @Override
137  public <T> T accept(SleuthkitItemVisitor<T> v) {
138  return v.visit(this);
139  }
140 
141  @Override
142  public <T> T accept(ContentVisitor<T> v) {
143  return v.visit(this);
144  }
145 
146  @Override
147  public List<Content> getChildren() throws TskCoreException {
148  return getSleuthkitCase().getVolumeSystemChildren(this);
149  }
150 
151  @Override
152  public List<Long> getChildrenIds() throws TskCoreException {
153  return getSleuthkitCase().getVolumeSystemChildrenIds(this);
154  }
155 
161  public List<Volume> getVolumes() throws TskCoreException {
162  List<Volume> volumes = new ArrayList<Volume>();
163  for (Content child : getChildren()) {
164  if (child instanceof Volume) {
165  volumes.add((Volume) child);
166  }
167  }
168  return volumes;
169  }
170 
171  @Override
172  public String toString(boolean preserveState) {
173  return super.toString(preserveState) + "VolumeSystem [\t" + "blockSize " + blockSize + "\t" + "imgOffset " + imgOffset + "\t" + "type " + type + "]\t"; //NON-NLS
174  }
175 }
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:602
synchronized long getImageHandle()
Definition: Image.java:122

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