+
+void print_message_file(char *filename)
+{
+ char *msg = NULL;
+ char *p, *endp;
+ char *defdev = boot.dev;
+ int defpart = boot.part;
+ char msgpath[1024];
+ int opened = 0;
+ int result = 0;
+ int n;
+ struct boot_file_t file;
+ struct boot_fspec_t msgfile;
+
+ defdev = cfg_get_strg(0, "device");
+ if (!defdev)
+ defdev = boot.dev;
+ p = cfg_get_strg(0, "partition");
+ if (p) {
+ n = simple_strtol(p, &endp, 10);
+ if (endp != p && *endp == 0)
+ defpart = n;
+ }
+
+ strncpy(msgpath, filename, sizeof(msgpath));
+ if (!parse_device_path(msgpath, defdev, defpart, "/etc/yaboot.msg", &msgfile)) {
+ prom_printf("%s: Unable to parse\n", msgpath);
+ goto done;
+ }
+
+ result = open_file(&msgfile, &file);
+ if (result != FILE_ERR_OK) {
+ prom_printf("%s:%d,", msgfile.dev, msgfile.part);
+ prom_perror(result, msgfile.file);
+ goto done;
+ } else
+ opened = 1;
+
+ msg = malloc(2001);
+ if (!msg)
+ goto done;
+ else
+ memset(msg, 0, 2001);
+
+ if (file.fs->read(&file, 2000, msg) <= 0)
+ goto done;
+ else
+ prom_printf("%s", msg);
+
+done:
+ if (opened)
+ file.fs->close(&file);
+ if (msg)
+ free(msg);
+}
+