1
0
mirror of https://github.com/simh/simh.git synced 2026-05-03 22:48:35 +00:00

SCP: Avoid seeking on attached sequential devices on non seekable files

As reported on #982
This commit is contained in:
Mark Pizzolato
2020-12-14 18:48:14 -08:00
parent c32b3ab054
commit 852c0bc1bc
5 changed files with 52 additions and 13 deletions

View File

@@ -44,6 +44,7 @@
sim_fwrite - endian independent write (formerly fxwrite)
sim_fseek - conditionally extended (>32b) seek (
sim_fseeko - extended seek (>32b if available)
sim_can_seek - test for seekable (regular file)
sim_fsize - get file size
sim_fsize_name - get file size of named file
sim_fsize_ex - get file size as a t_offset
@@ -235,6 +236,16 @@ uint32 sim_fsize (FILE *fp)
return (uint32)(sim_fsize_ex (fp));
}
t_bool sim_can_seek (FILE *fp)
{
struct stat statb;
if ((0 != fstat (fileno (fp), &statb)) ||
(0 == (statb.st_mode & S_IFREG)))
return FALSE;
return TRUE;
}
/* OS-dependent routines */
/* Optimized file open */