From 70ad90095b7b4ae26266878a48b0abae9717010b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 23 Jul 2009 08:57:02 +0100 Subject: fs-front: cope with a missing fs-backend Obviously save\restore is not going to work if fs-backend is missing, but at least the stubdom will be able to work correctly in all the other cases. Signed-off-by: Stefano Stabellini --- extras/mini-os/fs-front.c | 49 ++++++++++++++++++++++++++++++++++++++++++----- extras/mini-os/main.c | 5 ----- 2 files changed, 44 insertions(+), 10 deletions(-) (limited to 'extras/mini-os') diff --git a/extras/mini-os/fs-front.c b/extras/mini-os/fs-front.c index b22266dd23..7c4d68df5a 100644 --- a/extras/mini-os/fs-front.c +++ b/extras/mini-os/fs-front.c @@ -193,6 +193,9 @@ int fs_open(struct fs_import *import, char *file) struct fsif_request *req; int fd; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -234,6 +237,9 @@ int fs_close(struct fs_import *import, int fd) struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -274,6 +280,9 @@ ssize_t fs_read(struct fs_import *import, int fd, void *buf, ssize_t ret; int i; + if (!import) + return -1; + BUG_ON(len > PAGE_SIZE * FSIF_NR_READ_GNTS); /* Prepare request for the backend */ @@ -345,6 +354,9 @@ ssize_t fs_write(struct fs_import *import, int fd, void *buf, ssize_t ret, to_copy; int i; + if (!import) + return -1; + BUG_ON(len > PAGE_SIZE * FSIF_NR_WRITE_GNTS); /* Prepare request for the backend */ @@ -413,6 +425,9 @@ int fs_stat(struct fs_import *import, struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -455,6 +470,9 @@ int fs_truncate(struct fs_import *import, struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -495,6 +513,9 @@ int fs_remove(struct fs_import *import, char *file) struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -543,6 +564,9 @@ int fs_rename(struct fs_import *import, char old_header[] = "old: "; char new_header[] = "new: "; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -594,6 +618,9 @@ int fs_create(struct fs_import *import, char *name, struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -641,6 +668,9 @@ char** fs_list(struct fs_import *import, char *name, char **files, *current_file; int i; + if (!import) + return NULL; + DEBUG("Different masks: NR_FILES=(%llx, %d), ERROR=(%llx, %d), HAS_MORE(%llx, %d)\n", NR_FILES_MASK, NR_FILES_SHIFT, ERROR_MASK, ERROR_SHIFT, HAS_MORE_FLAG, HAS_MORE_SHIFT); @@ -696,6 +726,9 @@ int fs_chmod(struct fs_import *import, int fd, int32_t mode) struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -736,6 +769,9 @@ int64_t fs_space(struct fs_import *import, char *location) struct fsif_request *req; int64_t ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -777,6 +813,9 @@ int fs_sync(struct fs_import *import, int fd) struct fsif_request *req; int ret; + if (!import) + return -1; + /* Prepare request for the backend */ back_req_id = reserve_fsif_request(import); DEBUG("Backend request id=%d\n", back_req_id); @@ -1231,20 +1270,20 @@ void init_fs_frontend(void) { struct minios_list_head *entry; struct fs_import *import = NULL; - printk("Initing FS fronend(s).\n"); + printk("Initing FS frontend(s).\n"); - //exports = probe_exports(); add_export(&exports, 0); minios_list_for_each(entry, &exports) { import = minios_list_entry(entry, struct fs_import, list); printk("FS export [dom=%d, id=%d] found\n", import->dom_id, import->export_id); - init_fs_import(import); + if (init_fs_import(import) != 0) { + fs_import = import; + break; + } } - fs_import = import; - if (!fs_import) printk("No FS import\n"); } diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c index 204cf85f8a..ebdab33921 100644 --- a/extras/mini-os/main.c +++ b/extras/mini-os/main.c @@ -69,11 +69,6 @@ static void call_main(void *p) #endif #ifdef CONFIG_QEMU - if (!fs_import) { - printk("No FS backend found, is it running?\n"); - do_exit(); - } - /* Fetch argc, argv from XenStore */ domid = xenbus_read_integer("target"); if (domid == -1) { -- cgit v1.2.3