[syslinux:lwip] pxe, http: support readdir (ls) over http
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Mon May 2 23:39:02 PDT 2011
Commit-ID: b3c87d5a304e7f846191bd2fbe55834b82439fa8
Gitweb: http://syslinux.zytor.com/commit/b3c87d5a304e7f846191bd2fbe55834b82439fa8
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 2 May 2011 23:36:41 -0700
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 2 May 2011 23:38:23 -0700
pxe, http: support readdir (ls) over http
Use a heuristic http index parser (which is assumed to work with most
webserver-generated indicies) to support ls over http.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
NEWS | 3 ++-
com32/lib/Makefile | 1 +
core/fs/pxe/http.c | 8 +++++++-
core/fs/pxe/pxe.c | 18 ++++++++++++++++--
core/fs/pxe/pxe.h | 4 ++++
5 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index 3474c80..4fa140f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,8 @@ to all derivatives.
Changes in 4.10:
* PXELINUX: An entirely new network implementation based on
the lwIP embedded TCP/IP stack. As a result, plain PXELINUX
- can now support HTTP and FTP without gPXE/iPXE.
+ can now support HTTP and FTP without gPXE/iPXE. ls/readdir
+ functionality is supported over http with an indexing webserver.
* Rename the "ipappend" option to "sysappend" ("ipappend" is
still accepted as an alias) and make it available for all
derivatives. Add additional strings derived from the system
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 20002ac..7f1c499 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -133,6 +133,7 @@ LIBCOREOBJS = \
memcpy.o mempcpy.o memset.o memcmp.o memmove.o \
strlen.o stpcpy.o strcpy.o strcmp.o strlcpy.o strlcat.o \
strchr.o strncmp.o strncpy.o \
+ ctypes.o strtoul.o strntoumax.o \
\
asprintf.o snprintf.o sprintf.o vsnprintf.o \
\
diff --git a/core/fs/pxe/http.c b/core/fs/pxe/http.c
index 3f2bb15..1fd87aa 100644
--- a/core/fs/pxe/http.c
+++ b/core/fs/pxe/http.c
@@ -145,6 +145,12 @@ void http_bake_cookies(void)
http_do_bake_cookies(cookie_buf);
}
+static const struct pxe_conn_ops http_conn_ops = {
+ .fill_buffer = tcp_fill_buffer,
+ .close = tcp_close_file,
+ .readdir = http_readdir,
+};
+
void http_open(struct url_info *url, int flags, struct inode *inode,
const char **redir)
{
@@ -179,7 +185,7 @@ void http_open(struct url_info *url, int flags, struct inode *inode,
return; /* http is broken... */
/* This is a straightforward TCP connection after headers */
- socket->ops = &tcp_conn_ops;
+ socket->ops = &http_conn_ops;
/* Reset all of the variables */
inode->size = content_length = -1;
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index f54e595..acefac9 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -367,10 +367,12 @@ static void __pxe_searchdir(const char *filename, int flags, struct file *file)
#endif
}
- if (inode->size)
+ if (inode->size) {
file->inode = inode;
- else
+ file->inode->mode = (flags & O_DIRECTORY) ? DT_DIR : DT_REG;
+ } else {
free_socket(inode);
+ }
return;
}
@@ -1091,6 +1093,17 @@ cant_free:
return;
}
+static int pxe_readdir(struct file *file, struct dirent *dirent)
+{
+ struct inode *inode = file->inode;
+ struct pxe_pvt_inode *socket = PVT(inode);
+
+ if (socket->ops->readdir)
+ return socket->ops->readdir(inode, dirent);
+ else
+ return -1; /* No such operation */
+}
+
const struct fs_ops pxe_fs_ops = {
.fs_name = "pxe",
.fs_flags = FS_NODEV,
@@ -1102,4 +1115,5 @@ const struct fs_ops pxe_fs_ops = {
.close_file = pxe_close_file,
.mangle_name = pxe_mangle_name,
.load_config = pxe_load_config,
+ .readdir = pxe_readdir,
};
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 6c84d8b..4c7e8e6 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -111,6 +111,7 @@ struct netbuf;
struct pxe_conn_ops {
void (*fill_buffer)(struct inode *inode);
void (*close)(struct inode *inode);
+ int (*readdir)(struct inode *inode, struct dirent *dirent);
};
struct pxe_pvt_inode {
@@ -222,6 +223,9 @@ void http_open(struct url_info *url, int flags, struct inode *inode,
const char **redir);
void http_bake_cookies(void);
+/* http_readdir.c */
+int http_readdir(struct inode *inode, struct dirent *dirent);
+
/* ftp.c */
void ftp_open(struct url_info *url, int flags, struct inode *inode,
const char **redir);
More information about the Syslinux-commits
mailing list