#include <fcntl.h>
Go to the source code of this file.
◆ fs_changed()
◆ fs_close()
Definition at line 459 of file io.c.
460{
462 int changed;
463
467 else
473 }
475 pdie(
"closing filesystem");
477}
static unsigned __int64 next
void pdie(const char *msg,...)
static void fs_flush(void)
◆ fs_open()
Definition at line 163 of file io.c.
164{
168 }
171}
void CDECL perror(const char *str)
◆ fs_read()
Read data from the partition, accounting for any pending updates that are queued for writing.
- Parameters
-
| [in] | pos | Byte offset, relative to the beginning of the partition, at which to read |
| [in] | size | Number of bytes to read |
| [out] | data | Where to put the data read |
Definition at line 282 of file io.c.
283{
285 int got;
286
287#ifdef __REACTOS__
288 const size_t readsize_aligned = (
size % 512) ? (
size + (512 - (
size % 512))) :
size;
290 const size_t seek_delta = (
size_t)(
pos - seekpos_aligned);
291#if DBG
292 const size_t readsize = (
size_t)(
pos - seekpos_aligned) + readsize_aligned;
293#endif
294 char* tmpBuf =
alloc(readsize_aligned);
295 if (
lseek(
fd, seekpos_aligned, 0) != seekpos_aligned)
pdie(
"Seek to %lld",
pos);
296 if ((got =
read(
fd, tmpBuf, readsize_aligned)) < 0)
pdie(
"Read %d bytes at %lld",
size,
pos);
302#else
304 pdie(
"Seek to %lld", (
long long)
pos);
306 pdie(
"Read %d bytes at %lld",
size, (
long long)
pos);
307#endif
309 die(
"Got %d bytes instead of %d at %lld", got,
size, (
long long)
pos);
315 else
318 }
319 }
320}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define memcpy(s1, s2, n)
Referenced by add_file(), alloc_rootdir_entry(), check_backup_boot(), find_volume_de(), read_boot(), read_fat(), read_fsinfo(), and write_boot_label().
◆ fs_test()
Definition at line 322 of file io.c.
323{
324 void *scratch;
325 int okay;
326
327#ifdef __REACTOS__
328 const size_t readsize_aligned = (
size % 512) ? (
size + (512 - (
size % 512))) :
size;
330 scratch =
alloc(readsize_aligned);
331 if (
lseek(
fd, seekpos_aligned, 0) != seekpos_aligned)
pdie(
"Seek to %lld",
pos);
332 okay =
read(
fd, scratch, readsize_aligned) == (
int)readsize_aligned;
334#else
336 pdie(
"Seek to %lld", (
long long)
pos);
340#endif
341 return okay;
342}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Referenced by fix_bad(), read_boot(), and test_file().
◆ fs_write()
Definition at line 344 of file io.c.
345{
347 int did;
348
349#ifdef __REACTOS__
350
352 void *scratch;
353 const size_t readsize_aligned = (
size % 512) ? (
size + (512 - (
size % 512))) :
size;
355 const size_t seek_delta = (
size_t)(
pos - seekpos_aligned);
356 BOOLEAN use_read = (seek_delta != 0) || ((readsize_aligned-
size) != 0);
357
359
360
361 if (use_read)
362 scratch =
alloc(readsize_aligned);
363 else
365
367 if (
lseek(
fd, seekpos_aligned, 0) != seekpos_aligned)
pdie(
"Seek to %lld",seekpos_aligned);
368
369 if (use_read)
370 {
371
372 if (
read(
fd, scratch, readsize_aligned) < 0)
pdie(
"Read %d bytes at %lld",
size,
pos);
373
374
376
377
378 if (
lseek(
fd, seekpos_aligned, 0) != seekpos_aligned)
pdie(
"Seek to %lld",seekpos_aligned);
379 }
380
381
382 if ((did =
write(
fd, scratch, readsize_aligned)) == (
int)readsize_aligned)
383 {
384 if (use_read)
free(scratch);
385 return;
386 }
387 if (did < 0)
pdie(
"Write %d bytes at %lld",
size,
pos);
388 die(
"Wrote %d bytes instead of %d at %lld", did,
size,
pos);
389 }
390#else
394 pdie(
"Seek to %lld", (
long long)
pos);
396 return;
397 if (did < 0)
398 pdie(
"Write %d bytes at %lld",
size, (
long long)
pos);
399 die(
"Wrote %d bytes instead of %d at %lld", did,
size, (
long long)
pos);
400 }
401#endif
408 else
411}
#define FSCHECK_IMMEDIATE_WRITE
#define new(TYPE, numElems)
Referenced by add_file(), alloc_rootdir_entry(), auto_rename(), check_backup_boot(), check_fat_state_bit(), clear_lfn_slots(), fs_flush(), lfn_add_slot(), lfn_fix_checksum(), lfn_get(), lfn_remove(), read_fat(), read_fsinfo(), reclaim_file(), rename_file(), set_fat(), update_free(), write_boot_label(), and write_volume_label().