diff options
author | H. Peter Anvin <hpa@zytor.com> | 2011-05-01 18:30:01 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2011-05-01 18:30:01 -0700 |
commit | 275abcfb66c764bbc7b0d07ec9b63e6fda63ec3a (patch) | |
tree | cf5aed4cc0735ba156404c3de4523b507df6f216 /core/fs | |
parent | 6ed325a3c881565cc2473d1fbfa69d806b4b7bbf (diff) | |
download | syslinux-275abcfb66c764bbc7b0d07ec9b63e6fda63ec3a.tar.gz |
pxe: push the open flags down into individual methods
Push the open flags down to the individual system methods.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core/fs')
-rw-r--r-- | core/fs/pxe/ftp.c | 5 | ||||
-rw-r--r-- | core/fs/pxe/http.c | 5 | ||||
-rw-r--r-- | core/fs/pxe/pxe.c | 18 | ||||
-rw-r--r-- | core/fs/pxe/pxe.h | 9 | ||||
-rw-r--r-- | core/fs/pxe/tftp.c | 4 |
5 files changed, 27 insertions, 14 deletions
diff --git a/core/fs/pxe/ftp.c b/core/fs/pxe/ftp.c index 4efcedb6..93255a1f 100644 --- a/core/fs/pxe/ftp.c +++ b/core/fs/pxe/ftp.c @@ -168,7 +168,8 @@ static void ftp_close_file(struct inode *inode) ftp_free(inode); } -void ftp_open(struct url_info *url, struct inode *inode, const char **redir) +void ftp_open(struct url_info *url, int flags, struct inode *inode, + const char **redir) { struct pxe_pvt_inode *socket = PVT(inode); struct pxe_pvt_inode *ctlsock; @@ -179,6 +180,8 @@ void ftp_open(struct url_info *url, struct inode *inode, const char **redir) err_t err; (void)redir; /* FTP does not redirect */ + (void)flags; + inode->size = 0; if (!url->port) diff --git a/core/fs/pxe/http.c b/core/fs/pxe/http.c index fef87b0a..6f159f6f 100644 --- a/core/fs/pxe/http.c +++ b/core/fs/pxe/http.c @@ -145,7 +145,8 @@ void http_bake_cookies(void) http_do_bake_cookies(cookie_buf); } -void http_open(struct url_info *url, struct inode *inode, const char **redir) +void http_open(struct url_info *url, int flags, struct inode *inode, + const char **redir) { struct pxe_pvt_inode *socket = PVT(inode); int header_bytes; @@ -172,6 +173,8 @@ void http_open(struct url_info *url, struct inode *inode, const char **redir) int status; int pos; + (void)flags; + if (!header_buf) return; /* http is broken... */ diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index b7ec0506..60f5d581 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -4,6 +4,7 @@ #include <core.h> #include <fs.h> #include <minmax.h> +#include <fcntl.h> #include <sys/cpu.h> #include <lwip/api.h> #include <lwip/dns.h> @@ -32,13 +33,15 @@ __lowmem char packet_buf[PKTBUF_SIZE] __aligned(16); static struct url_scheme { const char *name; - void (*open)(struct url_info *url, struct inode *inode, const char **redir); + void (*open)(struct url_info *, int, struct inode *, const char **); + int ok_flags; } url_schemes[] = { - { "tftp", tftp_open }, - { "http", http_open }, - { "ftp", ftp_open }, - { NULL, NULL }, + { "tftp", tftp_open, 0 }, + { "http", http_open, O_DIRECTORY }, + { "ftp", ftp_open, 0 }, + { NULL, NULL, 0 }, }; +#define OK_FLAGS_MASK (O_DIRECTORY|O_WRONLY) /* * Allocate a local UDP port structure and assign it a local port number. @@ -321,8 +324,6 @@ static void __pxe_searchdir(const char *filename, int flags, struct file *file) int redirect_count = 0; bool found_scheme = false; - (void)flags; - inode = file->inode = NULL; while (filename) { @@ -352,7 +353,8 @@ static void __pxe_searchdir(const char *filename, int flags, struct file *file) found_scheme = false; for (us = url_schemes; us->name; us++) { if (!strcmp(us->name, url.scheme)) { - us->open(&url, inode, &filename); + if (((flags ^ us->ok_flags) & OK_FLAGS_MASK) == 0) + us->open(&url, flags, inode, &filename); found_scheme = true; break; } diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h index c8d35d0b..c0847906 100644 --- a/core/fs/pxe/pxe.h +++ b/core/fs/pxe/pxe.h @@ -219,18 +219,21 @@ void pxe_idle_init(void); void pxe_idle_cleanup(void); /* tftp.c */ -void tftp_open(struct url_info *url, struct inode *inode, const char **redir); +void tftp_open(struct url_info *url, int flags, struct inode *inode, + const char **redir); /* gpxeurl.c */ void gpxe_open(struct inode *inode, const char *url); #define GPXE 0 /* http.c */ -void http_open(struct url_info *url, struct inode *inode, const char **redir); +void http_open(struct url_info *url, int flags, struct inode *inode, + const char **redir); void http_bake_cookies(void); /* ftp.c */ -void ftp_open(struct url_info *url, struct inode *inode, const char **redir); +void ftp_open(struct url_info *url, int flags, struct inode *inode, + const char **redir); /* tcp.c */ void tcp_close_file(struct inode *inode); diff --git a/core/fs/pxe/tftp.c b/core/fs/pxe/tftp.c index 5aafd8eb..b203a8f1 100644 --- a/core/fs/pxe/tftp.c +++ b/core/fs/pxe/tftp.c @@ -209,7 +209,8 @@ static void tftp_get_packet(struct inode *inode) * @out: the lenght of this file, stores in file->file_len * */ -void tftp_open(struct url_info *url, struct inode *inode, const char **redir) +void tftp_open(struct url_info *url, int flags, struct inode *inode, + const char **redir) { struct pxe_pvt_inode *socket = PVT(inode); char *buf; @@ -234,6 +235,7 @@ void tftp_open(struct url_info *url, struct inode *inode, const char **redir) struct ip_addr addr; (void)redir; /* TFTP does not redirect */ + (void)flags; if (url->type != URL_OLD_TFTP) { /* |