- Move the code to try to open a single chunk file and prompt for the
associated floppy if needed into a static split_openfile() function. - Use this function in splitfs_open() to open the first chunk rather than using open() directly. This allows the first chunk to be located on a different disk than the actual foo.split file.
This commit is contained in:
parent
4b609f5564
commit
7d45c61f20
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124572
@ -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);
|
||||
@ -77,6 +78,28 @@ split_file_destroy(struct split_file *sf)
|
||||
free(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)
|
||||
{
|
||||
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user