2 Copyright © 1995-2011, 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
20 #include "errstrings.h"
23 void showPtrArgsText(struct AFSBase
*afsbase
, const char *const string
, va_list args
)
25 vprintf(string
, args
);
29 void showText(struct AFSBase
*afsbase
, const char *const string
, ...)
34 showPtrArgsText(afsbase
, string
, ap
);
38 LONG
showError(struct AFSBase
*afsbase
, ULONG error
, ...) {
39 if (error
==ERR_ALREADY_PRINTED
)
41 if (error
>=ERR_UNKNOWN
)
43 showText(afsbase
, texts
[ERR_UNKNOWN
].text
, error
);
49 showPtrArgsText(afsbase
, texts
[error
].text
, ap
);
57 struct AFSBase
*afsbase
,
58 struct Volume
*volume
,
59 ULONG start
, ULONG count
, APTR mem
65 if (fseek(ioh
->fh
, start
*512, SEEK_SET
) == 0)
67 if (fread(mem
, 512, count
, ioh
->fh
) == count
)
77 struct AFSBase
*afsbase
,
78 struct Volume
*volume
,
79 ULONG start
, ULONG count
, APTR mem
85 if (fseek(ioh
->fh
, start
*512, SEEK_SET
) == 0)
87 if (fwrite(mem
, 512, count
, ioh
->fh
) == count
)
95 UBYTE
diskPresent(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
96 return ioh
->fh
? 1 : 0;
99 BOOL
diskWritable(struct AFSBase
*afsbase
, struct IOHandle
*ioh
)
101 return ioh
->fh
? 1 : 0;
104 ULONG
sectorSize(struct AFSBase
*afsbase
, struct IOHandle
*ioh
)
109 void check64BitSupport(struct AFSBase
*afsbase
, struct Volume
*volume
) {
110 printf("%s: We just support 64Bit (or not ...)\n", __FUNCTION__
);
113 struct IOHandle
*openBlockDevice(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
114 ioh
->fh
= fopen(ioh
->blockdevice
, "r+");
117 ioh
->ioflags
|= IOHF_DISK_IN
;
121 showError(afsbase
, ERR_DEVICE
, ioh
->blockdevice
);
125 void closeBlockDevice(struct AFSBase
*afsbase
, struct IOHandle
*ioh
) {
128 ioh
->ioflags
&= ~IOHF_DISK_IN
;
131 BOOL
flush(struct AFSBase
*afsbase
, struct Volume
*volume
) {
132 flushCache(afsbase
, volume
);
133 clearCache(afsbase
, volume
->blockcache
);
137 LONG
attemptAddDosVolume(struct AFSBase
*afsbase
, struct Volume
*volume
) {
138 printf("%s: Don't know what to do here\n", __FUNCTION__
);
142 LONG
osMediumInit(struct AFSBase
*afsbase
, struct Volume
*volume
, struct BlockCache
*blockbuffer
) {
143 printf("%s: Don't know what to do here\n", __FUNCTION__
);
147 void osMediumFree(struct AFSBase
*afsbase
, struct Volume
*volume
, LONG all
) {
148 printf("%s: Don't know what to do here\n", __FUNCTION__
);
151 void remDosNode(struct AFSBase
*afsbase
, struct DosList
*dl
)
153 printf("%s: Don't know what to do here\n", __FUNCTION__
);
156 /********************************* OS Functions *****************************/
158 void *AllocMem(ULONG size
, ULONG flags
) {
161 if (flags
& MEMF_CLEAR
)
162 mem
= calloc(1, size
);
168 void *AllocVec(ULONG size
, ULONG flags
) {
169 return AllocMem(size
, flags
);
172 void FreeMem(APTR mem
, ULONG size
) {
176 void FreeVec(APTR mem
) {
180 void CopyMem(const void *src
, APTR dst
, ULONG size
) {
181 memcpy(dst
, src
, size
);
185 struct DateStamp
*DateStamp(struct DateStamp
*ds
) {
188 struct tm as
={0, 0, 0, 1, 0, 78, -1, -1, -1};
192 current
-= diff
; /* time since 00:00:00, Jan 1, 1978 */
193 ds
->ds_Days
= current
/60/60/24;
194 current
-= (ds
->ds_Days
*60*60*24);
195 ds
->ds_Minute
= current
/60;
196 current
-= (ds
->ds_Minute
*60);
197 ds
->ds_Tick
= current
*50;
201 CONST_STRPTR
PathPart(CONST_STRPTR path
)
205 /* '/' at the beginning of the string really is part of the path */
215 else if (*ptr
== ':')