2 * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
10 #include <boot/partitions.h>
11 #include <boot/platform.h>
24 Volume::Volume(boot::Partition
*partition
)
28 if ((fDevice
= open_node(partition
, O_RDONLY
)) < B_OK
)
31 if (read_pos(fDevice
, 0, &fType
, sizeof(int32
)) < B_OK
)
34 fType
= B_BENDIAN_TO_HOST_INT32(fType
);
38 case DT_AMIGA_FFS_INTL
:
39 case DT_AMIGA_FFS_DCACHE
:
43 printf("The Amiga OFS is not yet supported.\n");
46 // unsupported file system
47 //printf("amiga_ffs: unsupported: %08lx\n", fType);
51 char *buffer
= (char *)malloc(4096);
55 int32 blockSize
= partition
->block_size
;
56 if (get_root_block(fDevice
, buffer
, blockSize
, partition
->size
) != B_OK
) {
57 // try to get the root block at different sizes, if the
58 // block size was incorrectly passed from the partitioning
60 for (int32 size
= 512; size
<= 4096; size
<<= 1) {
61 if (get_root_block(fDevice
, buffer
, size
, partition
->size
) == B_OK
) {
64 } else if (size
>= 4096) {
65 puts("Could not find root block\n");
72 char *newBuffer
= (char *)realloc(buffer
, blockSize
);
73 // if reallocation fails, we keep the old buffer
74 if (newBuffer
!= NULL
)
77 fRootNode
.SetTo(buffer
, blockSize
);
78 fRoot
= new(nothrow
) Directory(*this, fRootNode
);
79 // fRoot will free the buffer for us upon destruction
94 return fRootNode
.ValidateCheckSum();
104 amiga_ffs_identify_file_system(boot::Partition
*partition
)
106 Volume
volume(partition
);
108 return volume
.InitCheck() < B_OK
? 0 : 0.8;
113 amiga_ffs_get_file_system(boot::Partition
*partition
, ::Directory
**_root
)
115 Volume
*volume
= new(nothrow
) Volume(partition
);
119 if (volume
->InitCheck() < B_OK
) {
124 *_root
= volume
->Root();
129 file_system_module_info gAmigaFFSFileSystemModule
= {
130 "file_systems/amiga_ffs/v1",
131 kPartitionTypeAmigaFFS
,
132 amiga_ffs_identify_file_system
,
133 amiga_ffs_get_file_system