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.List;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
25
30
31 private static final Logger logger = Logger.getLogger(
Pool.class.
getName());
32 private volatile long poolHandle = 0;
33 private final long type;
34
44 super(db, obj_id, name);
45 this.type = type;
46 }
47
48 @Override
50 synchronized (this) {
51 if (poolHandle == 0) {
52 getPoolHandle();
53 }
54 }
55 return SleuthkitJNI.readPool(poolHandle, readBuffer, offset, len);
56 }
57
58 @Override
60 try {
63 logger.log(Level.SEVERE,
"Error getting parent of pool with obj ID {0}",
getId());
64 return 0;
65 }
66 }
67
75 }
76
87 // Note that once poolHandle is set, it will never be changed or reset to zero
88 if (poolHandle == 0) {
89 synchronized (this) {
90 if (poolHandle == 0) {
92 if ((dataSource != null) && (dataSource instanceof
Image)) {
93 Image image = (Image) dataSource;
95 } else {
96 throw new TskCoreException("Data Source of pool is not an image");
97 }
98 }
99 }
100 }
101 return this.poolHandle;
102 }
103
110 private long getPoolOffset(Image image) throws TskCoreException {
112 // If the parent is an image, then the pool starts at offset zero
113 return 0;
114 }
else if (this.
getParent() instanceof Volume) {
115 // If the parent is a volume, then the pool starts at the volume offset
116 Volume parent = (Volume)this.
getParent();
117 if (parent.getParent() instanceof VolumeSystem) {
118 // uses block size from parent volume system
119 return parent.getStart() * ((VolumeSystem) parent.getParent()).getBlockSize(); // Offset needs to be in bytes
120 } else {
121 // uses sector size from parent image (old behavior fallback)
122 return parent.getStart() * image.getSsize(); // Offset needs to be in bytes
123 }
124 }
125 throw new TskCoreException(
"Pool with object ID " + this.
getId() +
" does not have Image or Volume parent");
126 }
127
128 @Override
130 // Pools will be closed during case closing by the JNI code.
131 }
132
133 @SuppressWarnings("deprecation")
134 @Override
136 try {
138 } finally {
139 super.finalize();
140 }
141 }
142
143 @Override
145 return v.
visit(
this);
146 }
147
148 @Override
149 public <T> T accept(ContentVisitor<T> v) {
150 return v.visit(this);
151 }
152
153 @Override
156 }
157
158 @Override
161 }
162
163
164 @Override
166 return super.toString(preserveState) + "Pool [\t" + "type " + type + "]\t"; //NON-NLS
167 }
168 }
int read(byte[] readBuffer, long offset, long len)
String toString(boolean preserveState)
static TSK_POOL_TYPE_ENUM valueOf(long poolType)
SleuthkitCase getSleuthkitCase()
List< Content > getChildren()
TSK_POOL_TYPE_ENUM getType()
List< Long > getChildrenIds()
Pool(SleuthkitCase db, long obj_id, String name, long type)
synchronized long getImageHandle()