aboutsummaryrefslogtreecommitdiff
path: root/stand/libsa/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/libsa/open.c')
-rw-r--r--stand/libsa/open.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/stand/libsa/open.c b/stand/libsa/open.c
index ccee4aa5c07b..91848aca7dbe 100644
--- a/stand/libsa/open.c
+++ b/stand/libsa/open.c
@@ -138,6 +138,8 @@ open(const char *fname, int mode)
struct fs_ops *fs;
struct open_file *f;
int fd, i, error, besterror;
+ bool is_dir;
+ size_t n;
const char *file;
TSENTER();
@@ -154,31 +156,42 @@ open(const char *fname, int mode)
f->f_devdata = NULL;
file = NULL;
+ if (exclusive_file_system == NULL ||
+ (exclusive_file_system->fs_flags & FS_OPS_NO_DEVOPEN) == 0) {
+ error = devopen(f, fname, &file);
+ if (error ||
+ (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL))
+ goto err;
+
+ /* see if we opened a raw device; otherwise, 'file' is the file name. */
+ if (file == NULL || *file == '\0') {
+ f->f_flags |= F_RAW;
+ f->f_rabuf = NULL;
+ TSEXIT();
+ return (fd);
+ }
+ } else
+ file = fname;
+
if (exclusive_file_system != NULL) {
+ /* loader is forcing the filesystem to be used */
fs = exclusive_file_system;
- error = (fs->fo_open)(fname, f);
+ error = (fs->fo_open)(file, f);
if (error == 0)
goto ok;
goto err;
}
- error = devopen(f, fname, &file);
- if (error ||
- (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL))
- goto err;
-
- /* see if we opened a raw device; otherwise, 'file' is the file name. */
- if (file == NULL || *file == '\0') {
- f->f_flags |= F_RAW;
- f->f_rabuf = NULL;
- TSEXIT();
- return (fd);
- }
-
/* pass file name to the different filesystem open routines */
besterror = ENOENT;
+ n = strlen(file);
+ is_dir = (n > 0 && file[n - 1] == '/');
for (i = 0; file_system[i] != NULL; i++) {
fs = file_system[i];
+ if (is_dir && is_tftp()) {
+ error = EOPNOTSUPP;
+ goto err;
+ }
error = (fs->fo_open)(file, f);
if (error == 0)
goto ok;