summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2004-01-15 18:38:15 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2004-01-15 18:38:15 +0000
commit7d45c61f20aadb71ac1d58ee8b2d43e04283876a (patch)
tree7cbebe0c5068fe4e39a0da7150e7bc04a006dcc3
parent4b609f5564497b946430b7c67c67786f7409f9c9 (diff)
Notes
-rw-r--r--lib/libstand/splitfs.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/lib/libstand/splitfs.c b/lib/libstand/splitfs.c
index 153f05443484..87924640ff50 100644
--- a/lib/libstand/splitfs.c
+++ b/lib/libstand/splitfs.c
@@ -44,6 +44,7 @@ struct split_file
off_t file_pos; /* Offset from the beginning of the slice */
};
+static int split_openfile(struct split_file *sf);
static int splitfs_open(const char *path, struct open_file *f);
static int splitfs_close(struct open_file *f);
static int splitfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
@@ -78,6 +79,28 @@ split_file_destroy(struct split_file *sf)
}
static int
+split_openfile(struct split_file *sf)
+{
+ int i;
+
+ for (i = 0;; i++) {
+ sf->curfd = open(sf->filesv[sf->curfile], O_RDONLY);
+ if (sf->curfd >= 0)
+ break;
+ if ((sf->curfd == -1) && (errno != ENOENT))
+ return (errno);
+ if (i == NTRIES)
+ return (EIO);
+ printf("\nInsert disk labelled %s and press any key...",
+ sf->descsv[sf->curfile]);
+ getchar();
+ putchar('\n');
+ }
+ sf->file_pos = 0;
+ return (0);
+}
+
+static int
splitfs_open(const char *fname, struct open_file *f)
{
char *buf, *confname, *cp;
@@ -139,7 +162,12 @@ splitfs_open(const char *fname, struct open_file *f)
free(buf);
close(conffd);
- if ((sf->filesc == 0) || ((sf->curfd = open(sf->filesv[0], O_RDONLY)) == -1)) {
+ if (sf->filesc == 0) {
+ split_file_destroy(sf);
+ return(ENOENT);
+ }
+ errno = split_openfile(sf);
+ if (errno != 0) {
split_file_destroy(sf);
return(ENOENT);
}
@@ -190,18 +218,9 @@ splitfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
return (errno);
sf->curfile++;
- for (i = 0;; i++) {
- sf->curfd = open(sf->filesv[sf->curfile], O_RDONLY);
- if (sf->curfd >= 0)
- break;
- if ((sf->curfd == -1) && (errno != ENOENT))
+ errno = split_openfile(sf);
+ if (errno)
return (errno);
- if (i == NTRIES)
- return (EIO);
- printf("\nInsert disk labelled %s and press any key...", sf->descsv[sf->curfile]);
- getchar();putchar('\n');
- }
- sf->file_pos = 0;
}
} while (totread < size);