[Yaffs] [Yaffs-archive] maybe I found a bug?

guo@unication.com.cn guo@unication.com.cn
Thu, 4 Dec 2003 14:28:49 +0800


This is a multi-part message in MIME format.

------=_NextPart_000_0058_01C3BA72.EF1F2660
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: base64

dGhpcyBlbWFpbCBpcyBhIGNvcHkgb2YgbXkgbGFzdCBvbmUsIHRoZSBwcm9ncmFtIGlzIGF0dGFj
aGVkLg==

------=_NextPart_000_0058_01C3BA72.EF1F2660
Content-Type: application/octet-stream;
	name="test-yaffs.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="test-yaffs.c"

// very Simple program to test YAFFS=0A=
// by Russell Greece, guo@unication.com.cn=0A=
// 2003-12-04=0A=
=0A=
// bind a unix domain socket, delete PATH it without closed=0A=
// loop for  make a normal file, rename it=0A=
// and then, error occured=0A=
// I found the inode numbers of socket and new file are identical=0A=
=0A=
// Why I do this test:=0A=
// I choosed YAFFS in my new system, qt/Embedded and Qtopia cannot=0A=
//   run successful often.=0A=
// So my friend Timmy Lee(timmy@unication.com.cn) and I debug it,=0A=
//   at last, we found this point =0A=
// I need help. pleeeeeeease...=0A=
=0A=
#include <stdio.h>=0A=
#include <unistd.h>=0A=
#include <sys/types.h>=0A=
#include <sys/socket.h>=0A=
#include <sys/ioctl.h>=0A=
#include <sys/file.h>=0A=
#include <sys/time.h>=0A=
#include <sys/stat.h>=0A=
#include <fcntl.h>=0A=
#include <netinet/in.h>=0A=
#include <sys/un.h>=0A=
#include <netdb.h>=0A=
#include <errno.h>=0A=
#include <stdlib.h>=0A=
 =0A=
=0A=
// Get inode of specified PATH=0A=
static long long FileINode(const char *FileName)=0A=
{=0A=
	struct stat Stat;=0A=
	if (stat(FileName, &Stat) < 0) {=0A=
		return -1;=0A=
	}=0A=
	return Stat.st_ino;=0A=
}=0A=
=0A=
#define UNLINK_FILE_NAME "/mnt/yaffs/russell_unlinked"=0A=
=0A=
// create a socket PATH(unix domain), rm the PATH, keep fd openning=0A=
static void BindSocket(void)=0A=
{=0A=
	int error;=0A=
	int s =3D socket( PF_LOCAL, SOCK_STREAM, 0 );=0A=
	struct sockaddr_un a;=0A=
=0A=
	memset( &a, 0, sizeof(a) );=0A=
	a.sun_family =3D PF_LOCAL;=0A=
	strncpy( a.sun_path, UNLINK_FILE_NAME, sizeof(a.sun_path) - 1 );=0A=
	error =3D bind( s, (struct sockaddr*)&a, SUN_LEN(&a) );=0A=
	if (error < 0) {=0A=
		perror("bind:");=0A=
	}=0A=
	printf ("inode of %s is %lld\n", UNLINK_FILE_NAME, =
FileINode(UNLINK_FILE_NAME));=0A=
	unlink (UNLINK_FILE_NAME);=0A=
}=0A=
=0A=
=0A=
// create a file FileName."new", write it, and rename it to FileName=0A=
static int TestCount =3D 0;=0A=
static void TestFile(const char *FileName)=0A=
{=0A=
	int fd;=0A=
	int i;=0A=
	char TmpFileName[strlen(FileName) + 1 + 4];=0A=
=0A=
	TestCount ++;=0A=
	sprintf(TmpFileName, "%s.new", FileName);=0A=
	fd =3D open(TmpFileName, O_CREAT|O_WRONLY, 0666);=0A=
	if (fd < 0) {=0A=
		perror("open new");=0A=
		printf("Test count is %d\n", TestCount);=0A=
		printf ("inode of %s is %lld\n", TmpFileName, FileINode(TmpFileName));=0A=
		exit(1);=0A=
	}=0A=
	for (i =3D 0; i < 10; i++) {=0A=
		char Buffer[100];=0A=
		sprintf(Buffer, "this is line %d\n", i + 1);=0A=
		write(fd, Buffer, strlen(Buffer));=0A=
	}=0A=
	close (fd);=0A=
	rename(TmpFileName, FileName);=0A=
}=0A=
=0A=
// you know that=0A=
int main(void)=0A=
{=0A=
	BindSocket();=0A=
	=0A=
	for (;;) {=0A=
		TestFile("/mnt/yaffs/russell_normal");=0A=
	}=0A=
	return 0;=0A=
=0A=
}=0A=

------=_NextPart_000_0058_01C3BA72.EF1F2660--


---------------------------------------------------------------------------------------
This mailing list is hosted by Toby Churchill open software (www.toby-churchill.org).
If mailing list membership is no longer wanted you can remove yourself from the list by 
sending an email to yaffs-request@toby-churchill.org with the text "unsubscribe" 
(without the quotes) as the subject.