From: Martin Str|mberg Message-Id: <200001161111.MAA17304@father.ludd.luth.se> Subject: Re: _lleek To: djgpp-workers AT delorie DOT com Date: Sun, 16 Jan 100 12:11:32 +0100 (MET) Cc: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii) In-Reply-To: from Eli Zaretskii at "Jan 16, 0 10:49:39 am" X-Mailer: ELM [version 2.4ME+ PL15 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: dj-admin AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk According to Eli Zaretskii: > > On Thu, 13 Jan 100, Martin Stromberg wrote: > > > The problem is that the INT21 call registers used for offset (input > > and output) is totally only 32 bits, so we have this mapping: > > register contents -> offset > > 0 0 > > . . > > . . > > . . > > 2^32-2 2^32-2 > > 2^32-1 -1 (failure) > > > > So my tests showed calling lseek(fd, -2, SEEK_SET) would result in the > > file growing to maxsize (as if lseek(fd, 2^32-2 , SEEK_SET) was > > called). Please try this and verify my findings, if possible. > > Unfortunately, I don't have any access to a system with FAT32 volumes > (FAT32 considerably slows down disk I/O, so I routinely refuse > Windows's suggestion to convert). > > So, if I understand correctly, you are suggesting to implement lseek > of -2 as lseek of -3 followed by lseek of +1, is that right? Eeeh... I don't understand what that would give us. Consider this program: #include #include #include #include #include int main(int argc, char *argv[]) { char ch; char new_ch; int fd; long long ret; if( argc != 2 || sscanf(argv[1], "%c", &new_ch) != 1 ) { fprintf(stderr, "%s: run like this '%s '.\n", argv[0], argv[0] ); exit(1); } fd = open("g:/ggg.grr", O_RDWR|O_CREAT, S_IWUSR); if( 0 <= fd ) { printf("fd = %d.\n", fd); lseek(fd, -3, SEEK_SET); ret = read(fd, &ch, 1); printf("1: ret = %lld, ch = %d.\n", ret, ch); ret = write(fd, &new_ch, 1); printf("1: ret = %lld.\n", ret); } return(0); } After running this, I'll have a file g:/ggg.grr that is 2^32-3 big! Substitute -3 with any big value in [2^31, 2^32-3] and you'll get a big file (I've tried a couple different ones). If you use -2 instead of -3, the program behavs erratically. Every two runs it will create a file of max size and the other runs it will create a file of size 2! Glass, Satyagraha, MartinS