Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 2006 23:51:22 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 108581 for review
Message-ID:  <200610272351.k9RNpMG4062718@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=108581

Change 108581 by marcel@marcel_cluster on 2006/10/27 23:50:59

	Fix efifs_readdir():
	o  The Read() function returns success at EOF, but returns a
	   size of 0.
	o  Determine d_namlen based on how many characters we copied.

Affected files ...

.. //depot/projects/ia64/sys/boot/efi/libefi/efifs.c#11 edit

Differences ...

==== //depot/projects/ia64/sys/boot/efi/libefi/efifs.c#11 (text+ko) ====

@@ -43,7 +43,7 @@
 
 union fileinfo {
 	EFI_FILE_INFO info;
-	char bytes[sizeof(EFI_FILE_INFO) + 510];
+	char bytes[sizeof(EFI_FILE_INFO) + 508];
 };
 
 static EFI_GUID sfs_guid = SIMPLE_FILE_SYSTEM_PROTOCOL;
@@ -299,6 +299,8 @@
 	status = file->Read(file, &sz, &fi);
 	if (EFI_ERROR(status))
 		return (status_to_errno(status));
+	if (sz == 0)
+		return (ENOENT);
 
 	d->d_fileno = 0;
 	d->d_reclen = sizeof(*d);
@@ -306,10 +308,10 @@
 		d->d_type = DT_DIR;
 	else
 		d->d_type = DT_REG;
-	d->d_namlen = (fi.info.Size - sizeof(EFI_FILE_INFO)) / sizeof(CHAR16);
-	for (i = 0; i < d->d_namlen; i++)
+	for (i = 0; fi.info.FileName[i] != 0; i++)
 		d->d_name[i] = fi.info.FileName[i];
 	d->d_name[i] = 0;
+	d->d_namlen = i;
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610272351.k9RNpMG4062718>