2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
15 size_t Purify_fread (void *ptr
, size_t size
, size_t nmemb
, FILE *stream
)
17 if (!Purify_CheckMemoryAccess (ptr
, size
*nmemb
, PURIFY_MemAccess_Write
))
19 if (Purify_Error
== NotOwnMemory
)
21 Purify_Error
= IllPointer
;
22 Purify_PrintError ("fread (addr=%p, size=%ld, num=%ld, file=%p)"
23 , ptr
, size
, nmemb
, stream
);
27 Purify_PrintAccessError ("fread()", ptr
, size
);
31 return fread (ptr
, size
, nmemb
, stream
);
34 size_t Purify_read (int fd
, void *ptr
, size_t size
)
36 if (!Purify_CheckMemoryAccess (ptr
, size
, PURIFY_MemAccess_Write
))
38 if (Purify_Error
== NotOwnMemory
)
40 Purify_Error
= IllPointer
;
41 Purify_PrintError ("read (fd=%d, addr=%p, size=%ld)"
46 Purify_PrintAccessError ("read()", ptr
, size
);
50 return read (fd
, ptr
, size
);
53 char * Purify_fgets (char * ptr
, int size
, FILE * stream
)
55 if (!Purify_CheckMemoryAccess (ptr
, size
, PURIFY_MemAccess_Write
))
57 if (Purify_Error
== NotOwnMemory
)
59 Purify_Error
= IllPointer
;
60 Purify_PrintError ("fgets (ptr=%p, size=%d, stream=%p)"
65 Purify_PrintAccessError ("fgets()", ptr
, size
);
69 return fgets (ptr
, size
, stream
);
72 char * Purify_getcwd (char * buf
, size_t size
)
78 if (!Purify_CheckMemoryAccess (buf
, size
, PURIFY_MemAccess_Write
))
80 if (Purify_Error
== NotOwnMemory
)
82 Purify_Error
= IllPointer
;
83 Purify_PrintError ("getcwd (buf=%p, size=%ld)"
88 Purify_PrintAccessError ("getcwd()", buf
, size
);
92 ret
= getcwd (buf
, size
);
98 ptr
= getcwd (NULL
, size
);
105 ret
= Purify_strdup (ptr
);
114 ret
= Purify_malloc (size
);
121 hash
= Purify_FindMemory (ret
);
122 Purify_SetMemoryFlags (hash
, 0, strlen (ptr
) + 1,
123 PURIFY_MemFlag_Readable
|PURIFY_MemFlag_Writable
133 int Purify_stat (char * path
, struct stat
* st
)
137 if (!Purify_CheckMemoryAccess (path
, 1, PURIFY_MemAccess_Read
))
138 Purify_PrintAccessError ("stat (path, ...)", path
, 1);
140 len
= strlen (path
)+1;
142 if (!Purify_CheckMemoryAccess (path
, len
, PURIFY_MemAccess_Read
))
143 Purify_PrintAccessError ("stat (path, ...)", path
, len
);
145 if (!Purify_CheckMemoryAccess (st
, sizeof (struct stat
), PURIFY_MemAccess_Write
))
146 Purify_PrintAccessError ("stat (..., stat)", st
, sizeof (struct stat
));
148 return stat (path
, st
);
151 int Purify_lstat (char * path
, struct stat
* st
)
155 if (!Purify_CheckMemoryAccess (path
, 1, PURIFY_MemAccess_Read
))
156 Purify_PrintAccessError ("lstat (path, ...)", path
, 1);
158 len
= strlen (path
)+1;
160 if (!Purify_CheckMemoryAccess (path
, len
, PURIFY_MemAccess_Read
))
161 Purify_PrintAccessError ("lstat (path, ...)", path
, len
);
163 if (!Purify_CheckMemoryAccess (st
, sizeof (struct stat
), PURIFY_MemAccess_Write
))
164 Purify_PrintAccessError ("lstat (..., stat)", st
, sizeof (struct stat
));
166 return lstat (path
, st
);
169 int Purify_fstat (int fd
, struct stat
* st
)
171 if (!Purify_CheckMemoryAccess (st
, sizeof (struct stat
), PURIFY_MemAccess_Write
))
172 Purify_PrintAccessError ("fstat (..., stat)", st
, sizeof (struct stat
));
174 return fstat (fd
, st
);
177 struct dirent
* Purify_readdir (DIR * dir
)
179 static struct dirent
* last_de
= NULL
;
189 Purify_RemMemory (last_de
);
191 hash
= Purify_AddMemory (de
, sizeof (struct dirent
),
192 PURIFY_MemFlag_Writable
193 | PURIFY_MemFlag_Readable
194 , PURIFY_MemType_Data
197 hash
->data
= "dirent";