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.h 1421 2007-07-07 01:56:53Z radad $
25 #include <sys/fcntl.h>
32 #include "pfs_types.h"
35 #define min(a, b) ((a) < (b) ? (a) : (b))
41 ///////////////////////////////////////////////////////////////////////////////
44 typedef int (*deviceTransfer_p
)(int fd
, void *buffer
, /*u16*/u32 sub
, u32 sector
, u32 size
, u32 mode
);
45 typedef u32 (*deviceGetSubNumber_p
)(int fd
);
46 typedef u32 (*deviceGetSize_p
)(int fd
, /*u16*/u32 sub
/*0=main 1+=subs*/);
47 typedef void (*deviceSetPartError_p
)(int fd
);
48 typedef int/*0 only :P*/ (*deviceFlushCache_p
)(int fd
);
52 deviceTransfer_p transfer
; //
53 deviceGetSubNumber_p getSubNumber
; //
54 deviceGetSize_p getSize
; //
55 deviceSetPartError_p setPartitionError
; // set open partition as haveing a error
56 deviceFlushCache_p flushCache
; //
62 block_device
*blockDev
; // call table for hdd(hddCallTable)
64 u32 flags
; // rename to attr ones checked
65 u32 total_sector
; // number of sectors in the filesystem
66 u32 zfree
; // zone free
69 u32 zsize
; // zone size
70 u32 num_subs
; // number of sub partitions in the filesystem
71 pfs_blockinfo root_dir
; // block info for root directory
72 pfs_blockinfo log
; // block info for the log
73 pfs_blockinfo current_dir
; // block info for current directory
74 u32 lastError
; // 0 if no error :)
77 u32 free_zone
[65]; // free zones in each partition (1 main + 64 possible subs)
80 typedef struct pfs_cache_s
{
81 struct pfs_cache_s
*next
; //
82 struct pfs_cache_s
*prev
; //
85 pfs_mount_t
*pfsMount
; //
86 u32 sub
; // main(0)/sub(+1) partition
87 u32 sector
; // block/sector for partition
93 pfs_super_block
*superblock
;
101 u16 sub
; // Sub/main partition
102 u32 sector
; // Sector
114 u32 block_segment
; // index into data array in inode structure for current zone segment
115 u32 block_offset
; // block offset from start of current zone segment
116 u32 byte_offset
; // byte offset into current zone
121 pfs_cache_t
*clink
; //
122 u32 aentryOffset
; // used for read offset
124 pfs_blockpos_t block_pos
; // current position into file
125 pfs_restsInfo_t restsInfo
; //
126 u8 restsBuffer
[512]; // used for reading mis-aligned/remainder data
134 ///////////////////////////////////////////////////////////////////////////////
138 #define FIO_ATTR_READABLE 0x0001
139 #define FIO_ATTR_WRITEABLE 0x0002
140 #define FIO_ATTR_EXECUTABLE 0x0004
141 #define FIO_ATTR_COPYPROTECT 0x0008
142 #define FIO_ATTR_UNK0010 0x0010
143 #define FIO_ATTR_SUBDIR 0x0020
144 #define FIO_ATTR_UNK0040 0x0040
145 #define FIO_ATTR_CLOSED 0x0080
146 #define FIO_ATTR_UNK0100 0x0100
147 #define FIO_ATTR_UNK0200 0x0200
148 #define FIO_ATTR_UNK0400 0x0400
149 #define FIO_ATTR_PDA 0x0800
150 #define FIO_ATTR_PSX 0x1000
151 #define FIO_ATTR_UNK2000 0x2000
152 #define FIO_ATTR_HIDDEN 0x4000
154 // cache flags(status)
155 #define CACHE_FLAG_DIRTY 0x01
156 #define CACHE_FLAG_NOLOAD 0x02
157 #define CACHE_FLAG_MASKSTATUS 0x0F
159 // cache flags(types)
160 #define CACHE_FLAG_NOTHING 0x00
161 #define CACHE_FLAG_SEGD 0x10
162 #define CACHE_FLAG_SEGI 0x20
163 #define CACHE_FLAG_BITMAP 0x40
164 #define CACHE_FLAG_MASKTYPE 0xF0
167 #define FSCK_STAT_OK 0x00
168 #define FSCK_STAT_WRITE_ERROR 0x01
169 #define FSCK_STAT_ERROR_0x02 0x02
172 #define MODE_SET_FLAG 0x00
173 #define MODE_REMOVE_FLAG 0x01
174 #define MODE_CHECK_FLAG 0x02
177 #define MOUNT_BUSY 0x8000
179 ///////////////////////////////////////////////////////////////////////////////
182 extern pfs_file_slot_t
*fileSlots
;
183 extern pfs_config_t pfsConfig
;
184 extern pfs_cache_t
*cacheBuf
;
185 extern u32 numBuffers
;
187 extern int blockSize
;
188 extern pfs_mount_t
*pfsMountBuf
;
189 extern int symbolicLinks
;
190 extern int pfsFioSema
;
192 ///////////////////////////////////////////////////////////////////////////////
193 // Function declerations
195 pfs_mount_t
* getMountedUnit(u32 unit
);
196 void clearMount(pfs_mount_t
*pfsMount
);
200 ///////////////////////////////////////////////////////////////////////////////
203 #define DEBUG_CALL_LOG
204 #define DEBUG_VERBOSE_LOG
206 #ifdef DEBUG_VERBOSE_LOG
207 #define dprintf if(pfsDebug) printf
209 #define dprintf(format, args...)
212 #ifdef DEBUG_CALL_LOG
213 #define dprintf2 if(pfsDebug) printf
215 #define dprintf2(format, args...)
227 #include "pfs_fioctl.h"