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:
11
sim_fio.c
11
sim_fio.c
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user