fix for corrupted graphics when manipulating config files
[open-ps2-loader.git] / modules / ps2fs / pfs_types.h
blobaf6f47cd6afcaf7fcf0d9f8956667b6bc2803814
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.
10 # $Id: pfs_types.h 577 2004-09-14 14:41:46Z pixel $
13 #ifndef _PFS_TYPES_H
14 #define _PFS_TYPES_H
16 ///////////////////////////////////////////////////////////////////////////////
17 // Pre-processor macros
19 // General constants
20 #define PFS_BLOCKSIZE 0x2000
21 #define PFS_SUPER_MAGIC 0x50465300 // "PFS\0" aka Playstation Filesystem
22 #define PFS_JOUNRNAL_MAGIC 0x5046534C // "PFSL" aka PFS Log
23 #define PFS_SEGD_MAGIC 0x53454744 // "SEGD" aka segment descriptor direct
24 #define PFS_SEGI_MAGIC 0x53454749 // "SEGI" aka segment descriptor indirect
25 #define PFS_MAX_SUBPARTS 64
26 #define PFS_NAME_LEN 255
27 #define PFS_VERSION 4
29 ///////////////////////////////////////////////////////////////////////////////
30 // Structures
32 // jounrnal/log
33 typedef struct {
34 u32 magic; // =PFS_JOUNRNAL_MAGIC
35 u16 num; //
36 u16 checksum; //
37 struct{
38 u32 sector; // block/sector for partition
39 u16 sub; // main(0)/sub(+1) partition
40 u16 logSector; // block/sector offset in journal area
41 } log[127];
42 } pfs_journal_t;
44 typedef struct{
45 u8 kLen; // key len/used for offset in to str for value
46 u8 vLen; // value len
47 u16 aLen; // allocated length == ((kLen+vLen+7) & ~3)
48 char str[3]; // size = 3 so sizeof pfs_aentry_t=7 :P
49 } pfs_aentry_t;
51 typedef struct {
52 u32 inode;
53 u8 sub;
54 u8 pLen; // path length
55 u16 aLen; // allocated length == ((pLen+8+3) & ~3)
56 char path[512-8];
57 } pfs_dentry;
59 // Block number/count pair (used in inodes)
60 typedef struct {
61 u32 number; //
62 u16 subpart; //
63 u16 count; //
64 } pfs_blockinfo;
66 // Date/time descriptor
67 typedef struct {
68 u8 unused; //
69 u8 sec; //
70 u8 min; //
71 u8 hour; //
72 u8 day; //
73 u8 month; //
74 u16 year; //
75 } pfs_datetime;
77 // Superblock structure
78 typedef struct {
79 u32 magic; //
80 u32 version; //
81 u32 unknown1; //
82 u32 fsckStat; //
83 u32 zone_size; //
84 u32 num_subs; // number of subs attached to filesystem
85 pfs_blockinfo log; // block info for metadata log
86 pfs_blockinfo root; // block info for root directory
87 } pfs_super_block;
89 // Inode structure
90 typedef struct {
91 u32 checksum; // Sum of all other words in the inode
92 u32 magic; //
93 pfs_blockinfo inode_block; // start block of inode
94 pfs_blockinfo next_segment; // next segment descriptor inode
95 pfs_blockinfo last_segment; // last segment descriptor inode
96 pfs_blockinfo unused; //
97 pfs_blockinfo data[114]; //
98 u16 mode; // file mode
99 u16 attr; // file attributes
100 u16 uid; //
101 u16 gid; //
102 pfs_datetime atime; //
103 pfs_datetime ctime; //
104 pfs_datetime mtime; //
105 u64 size; //
106 u32 number_blocks; // number of blocks/zones used by file
107 u32 number_data; // number of used entries in data array
108 u32 number_segdesg; // number of "indirect blocks"/next segment descriptor's
109 u32 subpart; // subpart of inode
110 u32 reserved[4]; //
111 } pfs_inode;
113 #endif /* _PFS_TYPES_H */