[5758] in Athena Bugs

home help back first fref pref prev next nref lref last post

A bug with AFS on the PMAX

daemon@ATHENA.MIT.EDU (geoff@ATHENA.MIT.EDU)
Fri Aug 17 18:52:46 1990

From: geoff@ATHENA.MIT.EDU
To: bugs@ATHENA.MIT.EDU
Cc: geoff@ATHENA.MIT.EDU
Date: Fri, 17 Aug 90 18:52:21 EDT

Program with which you had the problem: test program supplied below.

Name of person who discovered the bug:
Their MIT phone number:
Their MIT address:
Their Athena Login ID:geoff
Name of consultant reporting bug:
------------------------------------------------------------------------
A brief synopsis of the problem: seeking to end of file by using a 3rd
argument of "2" (relative to EOF) to lseek or fseek on a file accessed
via AFS on a PMAX is equivalent to using a 3rd argument of "0"
(relative to start of file).
------------------------------------------------------------------------
Please describe the problem in detail (mention any necessary files or
commands that may be involved, on which machine the bug happened, and what
the program did that was wrong): running the test program and then
catting temp.line will produce this output normally:

first line of text
second line

but when run on an AFS file system on a PMAX (e.g. hodge), produces
this output:

second line
f text
------------------------------------------------------------------------
Repeat by (please enter a set of commands which will allow us to 
repeat the bug):

rlogin hodge
cd /tmp
/afs/sipb/user/geoff/decmipsbin/afs; cat temp.line
cd /afs/sipb/user/$USER	# or some other AFS-mounted directory
/afs/sipb/user/geoff/decmipsbin/afs; cat temp.line
# note the differences in output
------------------------------------------------------------------------
Fix (if you know what it is): sorry.

--- test program follows ---

/*
 * demo AFS bug: lseek(f,o,2)==lseek(f,o,0) /Geoff Collyer
 *	run this program, then "cat temp.line" and note the garble.
 */

#include <stdio.h>

#define TEMPFILE "temp.line"	/* in current dir. to ease use */
#define LINE1 "first line of text\n"
#define LINE2 "second line\n"
#define STRLEN(s) (sizeof(s) - 1)

#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_END 2
#endif

/* imports */
extern long lseek();

main()
{
	register int fd;

	fd = creat(TEMPFILE, 0666);
	if (fd < 0) {
		perror(TEMPFILE);
		exit(1);
	} else
		(void) close(fd);
	fd = open(TEMPFILE, 2);		/* read/write */
	if (fd < 0) {
		perror(TEMPFILE);
		exit(1);
	}
	if (write(fd, LINE1, STRLEN(LINE1)) != STRLEN(LINE1) ||
	    lseek(fd, 0L, SEEK_END) < 0 ||	/* no-op, in theory */
	    write(fd, LINE2, STRLEN(LINE2)) != STRLEN(LINE2) ||
	    close(fd) < 0)
		fprintf(stderr, "error writing %s\n", TEMPFILE);
	exit(0);
}

home help back first fref pref prev next nref lref last post