sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
super.c
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
#
10
# PFS superblock manipulation routines
11
*/
12
13
#include <errno.h>
14
#include <
stdio.h
>
15
#ifdef _IOP
16
#include <
sysclib.h
>
17
#else
18
#include <
string.h
>
19
#endif
20
#include <
hdd-ioctl.h
>
21
22
#include "
libpfs.h
"
23
24
u32 pfsBlockSize = 1;
// block size scale in sectors (512). Note that 0 = 1x
25
u32 pfsMetaSize = 1024;
// size of each metadata structure
26
27
int
pfsCheckZoneSize(u32 zone_size)
28
{
29
if
((zone_size & (zone_size - 1)) || (zone_size < (2 * 1024)) || (zone_size > (128 * 1024)))
30
{
31
PFS_PRINTF(PFS_DRV_NAME
": Error: Invalid zone size\n"
);
32
return
0;
33
}
34
35
return
1;
36
}
37
38
#ifdef PFS_SUPPORT_BHDD
39
int
pfsCheckExtendedZoneSize(u32 zone_size)
40
{
41
// Note: in XOSD pfs IRX (compared to DVRP firmware), zone size upper bound is 1024 * 1024
42
if
((zone_size & (zone_size - 1)) || (zone_size < (2 * 1024)) || (zone_size > (16384 * 1024)))
43
{
44
PFS_PRINTF(PFS_DRV_NAME
": error: invalid extended zone size %d,%d\n"
, (zone_size & (zone_size - 1)) == 0, zone_size);
45
return
0;
46
}
47
48
return
1;
49
}
50
#endif
51
52
// Returns the number of sectors (512 byte units) which will be used
53
// for bitmaps, given the zone size and partition size
54
u32 pfsGetBitmapSizeSectors(
int
zoneScale, u32 partSize)
55
{
56
int
w, zones = partSize / (1 << zoneScale);
57
58
w = (zones & 7);
59
zones = zones / 8 + w;
60
61
w = (zones & 511);
62
return
zones / 512 + w;
63
}
64
65
// Returns the number of blocks/zones which will be used for bitmaps
66
u32 pfsGetBitmapSizeBlocks(
int
scale, u32 mainsize)
67
{
68
u32 a=pfsGetBitmapSizeSectors(scale, mainsize);
69
return
a / (1<<scale) + ((a % (1<<scale))>0);
70
}
hdd-ioctl.h
libpfs.h
stdio.h
string.h
sysclib.h
core
fs
src
super.c
Generated by
1.18.0