diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fs/chdir.c | 3 | ||||
-rw-r--r-- | core/fs/fs.c | 13 | ||||
-rw-r--r-- | core/fs/pxe/pxe.c | 10 | ||||
-rw-r--r-- | core/fs/readdir.c | 3 | ||||
-rw-r--r-- | core/include/fs.h | 6 |
5 files changed, 20 insertions, 15 deletions
diff --git a/core/fs/chdir.c b/core/fs/chdir.c index 9e8dfd2e..0df0286b 100644 --- a/core/fs/chdir.c +++ b/core/fs/chdir.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdbool.h> #include <string.h> +#include <fcntl.h> #include "fs.h" #include "cache.h" @@ -79,7 +80,7 @@ int chdir(const char *src) return this_fs->fs_ops->chdir(this_fs, src); /* Otherwise it is a "conventional filesystem" */ - rv = searchdir(src); + rv = searchdir(src, O_RDONLY|O_DIRECTORY); if (rv < 0) return rv; diff --git a/core/fs/fs.c b/core/fs/fs.c index 54099860..81dafe9d 100644 --- a/core/fs/fs.c +++ b/core/fs/fs.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdbool.h> #include <string.h> +#include <fcntl.h> #include <dprintf.h> #include "fs.h" #include "cache.h" @@ -186,7 +187,7 @@ void pm_searchdir(com32sys_t *regs) char *name = MK_PTR(regs->ds, regs->edi.w[0]); int rv; - rv = searchdir(name); + rv = searchdir(name, O_RDONLY); if (rv < 0) { regs->esi.w[0] = 0; regs->eax.l = 0; @@ -198,7 +199,7 @@ void pm_searchdir(com32sys_t *regs) } } -int searchdir(const char *name) +int searchdir(const char *name, int flags) { struct inode *inode = NULL; struct inode *parent = NULL; @@ -213,7 +214,7 @@ int searchdir(const char *name) /* if we have ->searchdir method, call it */ if (file->fs->fs_ops->searchdir) { - file->fs->fs_ops->searchdir(name, file); + file->fs->fs_ops->searchdir(name, flags, file); if (file->inode) return file_to_handle(file); @@ -343,14 +344,14 @@ err_no_close: return -1; } -int open_file(const char *name, struct com32_filedata *filedata) +int open_file(const char *name, int flags, struct com32_filedata *filedata) { int rv; struct file *file; char mangled_name[FILENAME_MAX]; mangle_name(mangled_name, name); - rv = searchdir(mangled_name); + rv = searchdir(mangled_name, flags); if (rv < 0) return rv; @@ -377,7 +378,7 @@ void pm_open_file(com32sys_t *regs) char mangled_name[FILENAME_MAX]; mangle_name(mangled_name, name); - rv = searchdir(mangled_name); + rv = searchdir(mangled_name, O_RDONLY); if (rv < 0) { regs->eflags.l |= EFLAGS_CF; } else { diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index 3242a9f5..b7ec0506 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -295,20 +295,20 @@ static void url_set_ip(struct url_info *url) * @out: the lenght of this file, stores in file->file_len * */ -static void __pxe_searchdir(const char *filename, struct file *file); +static void __pxe_searchdir(const char *filename, int flags, struct file *file); extern uint16_t PXERetry; -static void pxe_searchdir(const char *filename, struct file *file) +static void pxe_searchdir(const char *filename, int flags, struct file *file) { int i = PXERetry; do { dprintf("PXE: file = %p, retries left = %d: ", file, i); - __pxe_searchdir(filename, file); + __pxe_searchdir(filename, flags, file); dprintf("%s\n", file->inode ? "ok" : "failed"); } while (!file->inode && i--); } -static void __pxe_searchdir(const char *filename, struct file *file) +static void __pxe_searchdir(const char *filename, int flags, struct file *file) { struct fs_info *fs = file->fs; struct inode *inode; @@ -321,6 +321,8 @@ static void __pxe_searchdir(const char *filename, struct file *file) int redirect_count = 0; bool found_scheme = false; + (void)flags; + inode = file->inode = NULL; while (filename) { diff --git a/core/fs/readdir.c b/core/fs/readdir.c index d071affd..a437011d 100644 --- a/core/fs/readdir.c +++ b/core/fs/readdir.c @@ -1,3 +1,4 @@ +#include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/dirent.h> @@ -12,7 +13,7 @@ DIR *opendir(const char *path) int rv; struct file *file; - rv = searchdir(path); + rv = searchdir(path, O_RDONLY|O_DIRECTORY); if (rv < 0) return NULL; diff --git a/core/include/fs.h b/core/include/fs.h index 4301481e..0691caa5 100644 --- a/core/include/fs.h +++ b/core/include/fs.h @@ -52,7 +52,7 @@ struct fs_ops { enum fs_flags fs_flags; int (*fs_init)(struct fs_info *); - void (*searchdir)(const char *, struct file *); + void (*searchdir)(const char *, int, struct file *); uint32_t (*getfssec)(struct file *, char *, int, bool *); void (*close_file)(struct file *); void (*mangle_name)(char *, const char *); @@ -179,10 +179,10 @@ static inline struct file *handle_to_file(uint16_t handle) void pm_mangle_name(com32sys_t *); void pm_searchdir(com32sys_t *); void mangle_name(char *, const char *); -int searchdir(const char *name); +int searchdir(const char *name, int flags); void _close_file(struct file *); size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors); -int open_file(const char *name, struct com32_filedata *filedata); +int open_file(const char *name, int flags, struct com32_filedata *filedata); void pm_open_file(com32sys_t *); void close_file(uint16_t handle); void pm_close_file(com32sys_t *); |