2
asfs.c -- parted asfs filesystem support
3
Copyright (C) 1998-2000, 2007, 2009-2012 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 3 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include <parted/parted.h>
22
#include <parted/debug.h>
23
#include <parted/endian.h>
30
# define _(String) dgettext (PACKAGE, String)
32
# define _(String) (String)
33
#endif /* ENABLE_NLS */
36
_asfs_probe_root (PedGeometry *geom, uint32_t *block, int blocksize, PedSector root) {
40
if (PED_BE32_TO_CPU (block[0]) != 0x53465300) return 0;
41
for (i = 0, sum = 1; i < 128*blocksize; i++) sum += PED_BE32_TO_CPU (block[i]);
42
if (sum != 0) return 0;
43
if (PED_BE32_TO_CPU (block[2]) * blocksize + geom->start != root) {
46
start = ((((PedSector) PED_BE32_TO_CPU (block[8])) << 32)
47
+ (PedSector) PED_BE32_TO_CPU (block[9])) / 512;
48
end = (((((PedSector) PED_BE32_TO_CPU (block[10])) << 32)
49
+ (PedSector) PED_BE32_TO_CPU (block[11])) / 512) - 1;
50
if (start != geom->start || end != geom->end) return 0;
55
_asfs_probe (PedGeometry* geom)
58
struct PartitionBlock * part;
63
PED_ASSERT (geom != NULL);
64
PED_ASSERT (geom->dev != NULL);
66
/* Finds the blocksize of the partition block */
67
if (!(part = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
68
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
69
_("%s : Failed to allocate partition block\n"), __func__);
72
if (amiga_find_part(geom, part) != NULL) {
73
blocksize = PED_BE32_TO_CPU (part->de_SizeBlock)
74
* PED_BE32_TO_CPU (part->de_SectorPerBlock) / 128;
79
if (!(block = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
80
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
81
_("%s : Failed to allocate block\n"), __func__);
85
if (!ped_device_read (geom->dev, block, root, blocksize)) {
86
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
87
_("%s : Couldn't read root block %llu\n"), __func__, root);
90
if (PED_BE32_TO_CPU (block[0]) != 0x53465300) {
94
/* Find and test the root blocks */
95
if (_asfs_probe_root(geom, block, blocksize, root)) {
98
root = geom->end - blocksize - (geom->length % blocksize) + 1;
99
if (!ped_device_read (geom->dev, block, root, 1)) {
100
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
101
_("%s : Couldn't read root block %llu\n"), __func__, root);
104
if (_asfs_probe_root(geom, block, blocksize, root)) {
109
return ped_geometry_duplicate (geom);
119
static PedFileSystemOps _asfs_ops = {
123
PedFileSystemType _asfs_type = {
127
block_sizes: ((int[2]){512, 0})