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.ResourceBundle;
22 import java.util.ArrayList;
23 import java.util.List;
24
30
32 private long startSector;
//in sectors, relative to volume system start
37 private static ResourceBundle
bundle = ResourceBundle.getBundle(
"org.sleuthkit.datamodel.Bundle");
38
50 protected Volume(
SleuthkitCase db,
long obj_id,
long addr,
long startSector,
long lengthInSectors,
long flags, String desc) {
51 super(db, obj_id, "vol" + Long.toString(addr)); //NON-NLS
56 if (!desc.equals("")) {
58 } else {
59 this.desc = bundle.getString("Volume.desc.text");
60 }
61 }
62
63 @Override
65 synchronized (this) {
68 throw new TskCoreException(bundle.getString(
"Volume.read.exception.msg1.text"));
69 }
70 VolumeSystem parentVs = (VolumeSystem) myParent;
71 // read from the volume
72 if (volumeHandle == 0) {
74 }
75
76 }
78 }
79
80 @Override
82 if (volumeHandle != 0) {
83 synchronized (this) {
84 if (volumeHandle != 0) {
86 volumeHandle = 0;
87 }
88 }
89 }
90 }
91
92 @Override
94 try {
96 } finally {
97 super.finalize();
98 }
99 }
100
101 @Override
103 return lengthInSectors * 512;
104 }
105
106 @Override
110 if (!name.isEmpty()) {
111 uniquePath =
"/vol_" +
name;
//NON-NLS
112 }
113
115 if (myParent != null) {
117 }
119 }
120
121 //methods get exact data from database. could be manipulated to get more
122 //meaningful data.
131 }
132
141 }
142
150 }
151
159 }
160
168 }
169
178 }
179
180 // ----- Here all the methods for vs flags conversion / mapping -----
189
190 String result = "";
191
193 if (flag.getVsFlag() == vsFlag) {
194 result = flag.toString();
195 }
196 }
197 return result;
198 }
199
208
209 long result = 0;
210
212 if (flag.toString().equals(vsFlag)) {
213 result = flag.getVsFlag();
214 }
215 }
216 return result;
217 }
218
227
228 String result = "";
229
232
233 // some variables that might be needed in the future
236
237 if ((vsFlag & allocFlag) == allocFlag) {
238 result = bundle.getString("Volume.vsFlagToString.allocated");
239 }
240 if ((vsFlag & unallocFlag) == unallocFlag) {
241 result = bundle.getString("Volume.vsFlagToString.unallocated");
242 }
243 // ... add more code here if needed
244
245 return result;
246 }
247
248 @Override
250 return v.
visit(
this);
251 }
252
253 @Override
254 public <T> T accept(ContentVisitor<T> v) {
255 return v.visit(this);
256 }
257
258 @Override
261 }
262
263 @Override
266 }
267
274
276 List<FileSystem> fileSystems = new ArrayList<FileSystem>();
277 for (
Content child : children) {
279 fileSystems.add((FileSystem) child);
280 }
281 }
282
283 return fileSystems;
284 }
285
286 @Override
288 return super.toString(preserveState) + "Volume [\t" + "addr " + addr + "\t" + "desc " + desc + "\t" + "flags " + flags + "\t" + "length " + lengthInSectors + "\t" + "start " + startSector + "]\t"; //NON-NLS
289 }
290 }
TSK_VS_PART_FLAG_ALL
Show all sectors in the walk.
synchronized Content getParent()
static long valueToVsFlag(String vsFlag)
TSK_VS_PART_FLAG_ALLOC
Sectors are allocated to a volume in the volume system.
int read(byte[] buf, long offset, long len)
List< FileSystem > getFileSystems()
synchronized long getVolumeSystemHandle()
String toString(boolean preserveState)
TSK_VS_PART_FLAG_META
Sectors contain volume system metadata and could also be ALLOC or UNALLOC.
static ResourceBundle bundle
Volume(SleuthkitCase db, long obj_id, long addr, long startSector, long lengthInSectors, long flags, String desc)
static int readVsPart(long volHandle, byte[] readBuffer, long offset, long len)
List< Long > getChildrenIds()
String getFlagsAsString()
static void closeVs(long vsHandle)
static String vsFlagToValue(long vsFlag)
List< Content > getChildren()
SleuthkitCase getSleuthkitCase()
volatile long volumeHandle
static long openVsPart(long vsHandle, long volId)
TSK_VS_PART_FLAG_UNALLOC
Sectors are not allocated to a volume.
synchronized String getUniquePath()
static String vsFlagToString(long vsFlag)