diff --git a/BasiliskII/src/Unix/Darwin/lowmem.c b/BasiliskII/src/Unix/Darwin/lowmem.c index 2874b229..8db1f74e 100644 --- a/BasiliskII/src/Unix/Darwin/lowmem.c +++ b/BasiliskII/src/Unix/Darwin/lowmem.c @@ -30,6 +30,7 @@ #include #include #include +#include static const char progname[] = "lowmem"; static const char *filename; @@ -134,6 +135,7 @@ main(int argc, const char *argv[]) struct mach_header_64 *machhead64; #endif struct fat_header *fathead; + struct stat f; if (argc != 2) { (void)fprintf(stderr, "Usage: %s executable\n", progname); @@ -142,6 +144,13 @@ main(int argc, const char *argv[]) filename = argv[1]; + if (stat(filename, &f)) { + (void)fprintf(stderr, "%s: could not stat %s: %s\n", + progname, filename, strerror(errno)); + exit(1); + } + file_size = f.st_size; + fd = open(filename, O_RDWR, 0); if (fd == -1) { (void)fprintf(stderr, "%s: could not open %s: %s\n", @@ -149,17 +158,6 @@ main(int argc, const char *argv[]) exit(1); } - file_size = lseek(fd, 0, SEEK_END); - if (file_size == -1) { - // for some mysterious reason, this sometimes fails... - file_size = 0x1000; -#if 0 - (void)fprintf(stderr, "%s: could not get size of %s: %s\n", - progname, filename, strerror(errno)); - exit(1); -#endif - } - /* * Size does not really matter, it will be rounded-up to a multiple * of the page size automatically.