2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
7 * -date------ -name------------------- -description-----------------------------
8 * 02-jan-2008 [Tomasz Wiszkowski] added disk check option for broken disks
9 * 04-jan-2008 [Tomasz Wiszkowski] corrected tabulation
21 void showPtrArgsText(struct AFSBase
*afsbase
, char *string
, va_list args
) {
22 vprintf(string
, args
);
26 void showText(struct AFSBase
*afsbase
, char *string
, ...) {
30 showPtrArgsText(afsbase
, string
, ap
);
34 LONG
showError(struct AFSBase
*afsbase
, ULONG error
, ...) {
37 "Couldn't open device %s",
38 "Couldn't add disk as dosentry",
39 "Disk is not validated!\n",
40 "Wrong data block %ld",
41 "Wrong checksum on block %ld",
42 "Missing some more bitmap blocks",
43 "Wrong blocktype on block %ld",
44 "Read/Write Error (%ld)",
45 "*** This may be a non-AFS disk. ***\n"
46 "Any attempt to fix it in this case may render the original\n"
47 "file system invalid, and its contents unrecoverable.\n\n"
48 "Please select what to do.",
49 "Block %lu used twice",
50 "Block %lu is located outside volume scope\nand will be removed.",
51 "Repairing disk structure will lead to data loss.\n"
52 "It's best to make a backup before proceeding.\n\n"
53 "Please select what to do.",
58 if (error
==ERR_ALREADY_PRINTED
)
60 if (error
>=ERR_UNKNOWN
)
62 showText(afsbase
, texts
[ERR_UNKNOWN
], error
);
68 showPtrArgsText(afsbase
, texts
[error
], ap
);
76 struct AFSBase
*afsbase
,
77 struct Volume
*volume
,
78 ULONG start
, ULONG count
, APTR mem
84 if (fseek(ioh
->fh
, start
*512, SEEK_SET
) == 0)
86 if (fread(mem
, 512, count
, ioh
->fh
) == count
)
96 struct AFSBase
*afsbase
,
97 struct Volume
*volume
,
98 ULONG start
, ULONG count
, APTR mem
101 struct IOHandle
*ioh
;
104 if (fseek(ioh
->fh
, start
*512, SEEK_SET
) == 0)
106 if (fwrite(mem
, 512, count
, ioh
->fh
) == count
)
114 UBYTE
diskPresent(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
115 return ioh
->fh
? 1 : 0;
118 void check64BitSupport(struct AFSBase
*afsbase
, struct Volume
*volume
) {
119 printf("%s: We just support 64Bit (or not ...)\n", __FUNCTION__
);
122 struct IOHandle
*openBlockDevice(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
123 ioh
->fh
= fopen(ioh
->blockdevice
, "r+");
126 ioh
->ioflags
|= IOHF_DISK_IN
;
130 showError(afsbase
, ERR_DEVICE
, ioh
->blockdevice
);
134 void closeBlockDevice(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
137 ioh
->ioflags
&= ~IOHF_DISK_IN
;
140 BOOL
flush(struct AFSBase
*afsbase
, struct Volume
*volume
) {
141 flushCache(afsbase
, volume
);
142 clearCache(afsbase
, volume
->blockcache
);
146 LONG
osMediumInit(struct AFSBase
*afsbase
, struct Volume
*volume
, struct BlockCache
*blockbuffer
) {
147 printf("%s: Don't know what to do here\n", __FUNCTION__
);
151 void osMediumFree(struct AFSBase
*afsbase
, struct Volume
*volume
, LONG all
) {
152 printf("%s: Don't know what to do here\n", __FUNCTION__
);
155 void remDosNode(struct AFSBase
*afsbase
, struct DosList
*dl
)
157 printf("%s: Don't know what to do here\n", __FUNCTION__
);
160 /********************************* OS Functions *****************************/
162 void *AllocMem(ULONG size
, ULONG flags
) {
165 if (flags
& MEMF_CLEAR
)
166 mem
= calloc(1, size
);
172 void *AllocVec(ULONG size
, ULONG flags
) {
173 return AllocMem(size
, flags
);
176 void FreeMem(APTR mem
, ULONG size
) {
180 void FreeVec(APTR mem
) {
184 void CopyMem(APTR src
, APTR dst
, ULONG size
) {
185 memcpy(dst
, src
, size
);
189 struct DateStamp
*DateStamp(struct DateStamp
*ds
) {
192 struct tm as
={0, 0, 0, 1, 0, 78, -1, -1, -1};
196 current
-= diff
; /* time since 00:00:00, Jan 1, 1978 */
197 ds
->ds_Days
= current
/60/60/24;
198 current
-= (ds
->ds_Days
*60*60*24);
199 ds
->ds_Minute
= current
/60;
200 current
-= (ds
->ds_Minute
*60);
201 ds
->ds_Tick
= current
*50;
205 STRPTR
PathPart(STRPTR path
) {
208 /* '/' at the begining of the string really is part of the path */
222 else if (*ptr
== ':')