ssize_t (*write)(struct file_info *, const void *, size_t);
int (*close)(struct file_info *);
int (*open)(struct file_info *);
+ const struct output_dev *fallback; /* Fallback option for certain consoles */
};
/* File structure */
fp->iop = idev;
}
- if (odev) {
+ while (odev) {
if (odev->open && (e = odev->open(fp))) {
+ if (e == EAGAIN) {
+ if (odev->fallback) {
+ odev = odev->fallback;
+ continue;
+ } else {
+ e = EIO;
+ }
+ }
errno = e;
goto puke;
}
fp->oop = odev;
+ break;
}
return fd;
#include <com32.h>
#include <minmax.h>
#include <colortbl.h>
+#include <console.h>
#include <klibc/compiler.h>
#include "ansi.h"
#include "file.h"
} else {
/* Switch mode */
if (__vesacon_init())
- return EIO;
+ return EAGAIN;
/* Initial state */
__ansi_init(&ti);
.write = __vesacon_write,
.close = __vesacon_close,
.open = __vesacon_open,
+ .fallback = &dev_ansicon_w,
};
#include <string.h>
#include <com32.h>
#include <minmax.h>
+#include <console.h>
#include "file.h"
extern int __vesacon_open(void);
.write = __vesaserial_write,
.close = __vesacon_close,
.open = __vesacon_open,
+ .fallback = &dev_ansiserial_w,
};