Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144324066
D10947.id28900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10947.id28900.diff
View Options
Index: head/sys/boot/common/dev_net.c
===================================================================
--- head/sys/boot/common/dev_net.c
+++ head/sys/boot/common/dev_net.c
@@ -97,6 +97,14 @@
net_cleanup
};
+static struct uri_scheme {
+ const char *scheme;
+ int proto;
+} uri_schemes[] = {
+ { "tftp:/", NET_TFTP },
+ { "nfs:/", NET_NFS },
+};
+
static int
net_init(void)
{
@@ -334,11 +342,8 @@
return (EIO);
}
exit:
- netproto = NET_TFTP;
- if ((rootaddr = net_parse_rootpath()) != INADDR_NONE) {
- netproto = NET_NFS;
+ if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
rootip.s_addr = rootaddr;
- }
#ifdef NETIF_DEBUG
if (debug) {
@@ -387,14 +392,51 @@
uint32_t
net_parse_rootpath()
{
- n_long addr = INADDR_NONE;
- char *ptr;
+ n_long addr = htonl(INADDR_NONE);
+ size_t i;
+ char ip[FNAME_SIZE];
+ char *ptr, *val;
+
+ netproto = NET_NONE;
+
+ for (i = 0; i < nitems(uri_schemes); i++) {
+ if (strncmp(rootpath, uri_schemes[i].scheme,
+ strlen(uri_schemes[i].scheme)) != 0)
+ continue;
+ netproto = uri_schemes[i].proto;
+ break;
+ }
ptr = rootpath;
- (void)strsep(&ptr, ":");
- if (ptr != NULL) {
- addr = inet_addr(rootpath);
- bcopy(ptr, rootpath, strlen(ptr) + 1);
+ /* Fallback for compatibility mode */
+ if (netproto == NET_NONE) {
+ netproto = NET_NFS;
+ (void)strsep(&ptr, ":");
+ if (ptr != NULL) {
+ addr = inet_addr(rootpath);
+ bcopy(ptr, rootpath, strlen(ptr) + 1);
+ }
+ } else {
+ ptr += strlen(uri_schemes[i].scheme);
+ if (*ptr == '/') {
+ /* we are in the form <scheme>://, we do expect an ip */
+ ptr++;
+ /*
+ * XXX when http will be there we will need to check for
+ * a port, but right now we do not need it yet
+ */
+ val = strchr(ptr, '/');
+ if (val != NULL) {
+ snprintf(ip, sizeof(ip), "%.*s",
+ (int)((uintptr_t)val - (uintptr_t)ptr), ptr);
+ printf("%s\n", ip);
+ addr = inet_addr(ip);
+ bcopy(val, rootpath, strlen(val) + 1);
+ }
+ } else {
+ ptr--;
+ bcopy(ptr, rootpath, strlen(ptr) + 1);
+ }
}
return (addr);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 8, 8:38 PM (15 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28495728
Default Alt Text
D10947.id28900.diff (2 KB)
Attached To
Mode
D10947: Support URI scheme for root-path in netbooting
Attached
Detach File
Event Timeline
Log In to Comment