19 package org.sleuthkit.datamodel;
 
   21 import java.util.List;
 
   23 import org.apache.commons.lang3.ArrayUtils;
 
   24 import org.apache.commons.lang3.StringUtils;
 
   25 import com.google.gson.Gson;
 
   26 import com.google.gson.JsonSyntaxException;
 
   38         private long imgOffset, blockSize, blockCount, rootInum,
 
   42         private volatile long filesystemHandle = 0;
 
   60                         long first_inum, 
long last_inum) {
 
   61                 super(db, obj_id, name);
 
   62                 this.imgOffset = img_offset;
 
   63                 this.fsType = fs_type;
 
   64                 this.blockSize = block_size;
 
   65                 this.blockCount = block_count;
 
   66                 this.rootInum = root_inum;
 
   67                 this.firstInum = first_inum;
 
   68                 this.lastInum = last_inum;
 
   79                 if (dataSource instanceof 
Image && ArrayUtils.isEmpty(((
Image) dataSource).getPaths())) {
 
   87                 return blockSize * blockCount;
 
  100                 if (filesystemHandle == 0) {
 
  101                         synchronized (
this) {
 
  102                                 if (filesystemHandle == 0) {
 
  104                                         if ((dataSource == null) || ( !(dataSource instanceof 
Image))) {
 
  105                                                 throw new TskCoreException(
"Data Source of File System is not an image");
 
  108                                         Image image = (Image) dataSource;
 
  111                                         if (isPoolContent()) {
 
  112                                                 Pool pool = getPool();
 
  114                                                         throw new TskCoreException(
"Error finding pool for file system");
 
  117                                                 Volume poolVolume = getPoolVolume();
 
  118                                                 if (poolVolume == null) {
 
  119                                                         throw new TskCoreException(
"File system is in a pool but has no volume");
 
  121                                                 filesystemHandle = SleuthkitJNI.openFsPool(image.getImageHandle(), imgOffset, pool.getPoolHandle(), poolVolume.getStart(), 
getSleuthkitCase());
 
  123                                                 String password = getImagePasswordFromSettings(image.getAcquisitionToolSettings());
 
  124                                                 filesystemHandle = SleuthkitJNI.openFs(image.getImageHandle(), imgOffset, password, 
getSleuthkitCase());
 
  129                 return this.filesystemHandle;
 
  139         private String getImagePasswordFromSettings(String settingsStr) {
 
  141                 if(StringUtils.isBlank(settingsStr)){
 
  146                         Map<String, Object> settingsMap = (
new Gson()).fromJson(settingsStr, Map.class);
 
  147                         return (String)settingsMap.getOrDefault(IMAGE_PASSWORD_KEY, 
"");
 
  148                 } 
catch (JsonSyntaxException ex) {
 
  157                 if (children.size() != 1) {
 
  158                         throw new TskCoreException(
"FileSystem must have only one child.");
 
  161                 if (!(children.get(0) instanceof 
Directory)) {
 
  162                         throw new TskCoreException(
"Child of FileSystem must be a Directory.");
 
  231         @SuppressWarnings(
"deprecation")
 
  235                         if (filesystemHandle != 0) {
 
  237                                 filesystemHandle = 0;
 
  246                 return v.
visit(
this);
 
  250         public <T> T accept(ContentVisitor<T> v) {
 
  251                 return v.visit(
this);
 
  256                 return super.toString(preserveState) + 
"FileSystem [\t" + 
" blockCount " + blockCount + 
"\t" + 
"blockSize " + blockSize + 
"\t" + 
"firstInum " + firstInum + 
"\t" + 
"fsType " + fsType + 
"\t" + 
"imgOffset " + imgOffset + 
"\t" + 
"lastInum " + lastInum + 
"\t" + 
"rootInum " + rootInum + 
"\t" + 
"]"; 
 
String toString(boolean preserveState)
 
List< Content > getChildren()
 
Directory getRootDirectory()
 
int read(byte[] buf, long offset, long len)
 
SleuthkitCase getSleuthkitCase()
 
FileSystem(SleuthkitCase db, long obj_id, String name, long img_offset, TskData.TSK_FS_TYPE_ENUM fs_type, long block_size, long block_count, long root_inum, long first_inum, long last_inum)
 
TskData.TSK_FS_TYPE_ENUM getFsType()
 
static int readFs(long fsHandle, byte[] readBuffer, long offset, long len)