ipl: Add fileio_close() function to close file handles

The "list directory" function uses file handles to open the directories.
Since there is a limited number of file handles available, add the fileio_close() function to
free them up after usage.

Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/ipl/bootloader.h b/ipl/bootloader.h
index 8871d87..af4733f 100644
--- a/ipl/bootloader.h
+++ b/ipl/bootloader.h
@@ -45,6 +45,7 @@
 
 /* fileio.c */
 int fileio_open(describe_t describef, read_t readf);
+void fileio_close(unsigned int fd);
 int seekread(int fd, char *buf, unsigned nbytes, __u64 devaddr);
 void describe(int fd, int *bufalign, int *blocksize);
 
diff --git a/ipl/fileio.c b/ipl/fileio.c
index 7b31a69..29dddfd 100644
--- a/ipl/fileio.c
+++ b/ipl/fileio.c
@@ -41,9 +41,23 @@
 	}
     }
 
+    if (Debug)
+	printf("assigning fd # %d\n", d);
+
     return d;
 }
 
+void fileio_close(unsigned int fd)
+{
+    if (fd > MAX_FD)
+	return;
+
+    if (Debug)
+	printf("closing fd # %d\n", fd);
+
+    memset(&fileio[fd], 0, sizeof(fileio[0]));
+}
+
 int seekread(int fd, char *buf, unsigned nbytes, __u64 devaddr)
 {
     int r = -1;