-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupDescriptor.java
More file actions
41 lines (32 loc) · 1.5 KB
/
Copy pathGroupDescriptor.java
File metadata and controls
41 lines (32 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class GroupDescriptor {
private ByteBuffer byteBuffer;
private int inodeTablePointers[];
private int inodeTablePointersLocations[];
public GroupDescriptor(Ext2File file, int blocksCount) throws IOException {
byteBuffer = ByteBuffer.wrap(file.read(2048, 1024)).order(ByteOrder.LITTLE_ENDIAN);
inodeTablePointers = new int[blocksCount];
inodeTablePointersLocations = new int[blocksCount];
for (int i = 0; i < blocksCount; i++) {
inodeTablePointers[i] = byteBuffer.getInt((i * Constants.GROUP_DESCRIPTOR_LENGTH) + Constants.INODE_TABLE_POINTER_OFFSET);
inodeTablePointersLocations[i] = 2048 + (i * Constants.GROUP_DESCRIPTOR_LENGTH) + Constants.INODE_TABLE_POINTER_OFFSET;
}
System.out.println(this);
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("\n====================GROUP DESCRIPTOR CONTENT====================");
for (int i = 0; i < inodeTablePointers.length; i++)
sb.append("\nInode Table Pointer " + i + ": " + inodeTablePointers[i]);
sb.append("\n================================================================");
return sb.toString();
}
public int[] getInodeTablePointers() {
return inodeTablePointers;
}
public int[] getInodeTablePointersLocations() {
return inodeTablePointersLocations;
}
}