Wrap open_config() the same way that open() wraps open_file(). The
only user of open_config() requires access to a file descriptor so it
makes sense to return a file descriptor.
The file handle implementation is a historic piece of code and this
patch tries to hide it as they will likely be removed at a future
point in time. Furthermore, the file handle code is very core-specific
and should not be exposed to any callers of open_config().
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
-include $(topdir)/version.mk
OPTFLAGS =
-INCLUDES = -I./include -I$(com32)/include
+INCLUDES = -I./include -I$(com32)/include -I$(com32)/lib
# This is very similar to cp437; technically it's for Norway and Denmark,
# but it's unlikely the characters that are different will be used in
+#include <sys/file.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <dprintf.h>
#include "core.h"
+#include "dev.h"
#include "fs.h"
#include "cache.h"
free_file(file);
}
+extern const struct input_dev __file_dev;
+
/*
* Find and open the configuration file
*/
-int open_config(struct com32_filedata *filedata)
+int open_config(void)
{
- return this_fs->fs_ops->open_config(filedata);
+ int fd, handle;
+ struct file_info *fp;
+
+ fd = opendev(&__file_dev, NULL, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ fp = &__file_info[fd];
+
+ handle = this_fs->fs_ops->open_config(&fp->i.fd);
+ if (handle < 0) {
+ close(fd);
+ errno = ENOENT;
+ return -1;
+ }
+
+ fp->i.offset = 0;
+ fp->i.nbytes = 0;
+
+ return fd;
}
void pm_mangle_name(com32sys_t *regs)