Compare commits
No commits in common. "78928b7eb46f9762bacabc9c5c0616d290267223" and "dafd2fecf770223fe720e52191b86538269955e9" have entirely different histories.
78928b7eb4
...
dafd2fecf7
|
@ -128,7 +128,7 @@ namespace BAN
|
||||||
bool operator!=(RefPtr other) const { return m_pointer != other.m_pointer; }
|
bool operator!=(RefPtr other) const { return m_pointer != other.m_pointer; }
|
||||||
|
|
||||||
bool empty() const { return m_pointer == nullptr; }
|
bool empty() const { return m_pointer == nullptr; }
|
||||||
explicit operator bool() const { return m_pointer; }
|
operator bool() const { return m_pointer; }
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace BAN
|
||||||
|
|
||||||
bool valid() const { return m_link && m_link->valid(); }
|
bool valid() const { return m_link && m_link->valid(); }
|
||||||
|
|
||||||
explicit operator bool() const { return valid(); }
|
operator bool() const { return valid(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WeakPtr(const RefPtr<WeakLink<T>>& link)
|
WeakPtr(const RefPtr<WeakLink<T>>& link)
|
||||||
|
|
|
@ -105,7 +105,6 @@ namespace Kernel
|
||||||
BAN::ErrorOr<void> listen(int backlog);
|
BAN::ErrorOr<void> listen(int backlog);
|
||||||
BAN::ErrorOr<size_t> sendto(BAN::ConstByteSpan message, const sockaddr* address, socklen_t address_len);
|
BAN::ErrorOr<size_t> sendto(BAN::ConstByteSpan message, const sockaddr* address, socklen_t address_len);
|
||||||
BAN::ErrorOr<size_t> recvfrom(BAN::ByteSpan buffer, sockaddr* address, socklen_t* address_len);
|
BAN::ErrorOr<size_t> recvfrom(BAN::ByteSpan buffer, sockaddr* address, socklen_t* address_len);
|
||||||
BAN::ErrorOr<void> getsockname(sockaddr* address, socklen_t* address_len);
|
|
||||||
|
|
||||||
// General API
|
// General API
|
||||||
BAN::ErrorOr<size_t> read(off_t, BAN::ByteSpan buffer);
|
BAN::ErrorOr<size_t> read(off_t, BAN::ByteSpan buffer);
|
||||||
|
@ -140,8 +139,7 @@ namespace Kernel
|
||||||
virtual BAN::ErrorOr<void> listen_impl(int) { return BAN::Error::from_errno(ENOTSUP); }
|
virtual BAN::ErrorOr<void> listen_impl(int) { return BAN::Error::from_errno(ENOTSUP); }
|
||||||
virtual BAN::ErrorOr<void> bind_impl(const sockaddr*, socklen_t) { return BAN::Error::from_errno(ENOTSUP); }
|
virtual BAN::ErrorOr<void> bind_impl(const sockaddr*, socklen_t) { return BAN::Error::from_errno(ENOTSUP); }
|
||||||
virtual BAN::ErrorOr<size_t> sendto_impl(BAN::ConstByteSpan, const sockaddr*, socklen_t) { return BAN::Error::from_errno(ENOTSUP); }
|
virtual BAN::ErrorOr<size_t> sendto_impl(BAN::ConstByteSpan, const sockaddr*, socklen_t) { return BAN::Error::from_errno(ENOTSUP); }
|
||||||
virtual BAN::ErrorOr<size_t> recvfrom_impl(BAN::ByteSpan, sockaddr*, socklen_t*) { return BAN::Error::from_errno(ENOTSUP); }
|
virtual BAN::ErrorOr<size_t> recvfrom_impl(BAN::ByteSpan, sockaddr*, socklen_t*) { return BAN::Error::from_errno(ENOTSUP); }
|
||||||
virtual BAN::ErrorOr<void> getsockname_impl(sockaddr*, socklen_t*) { return BAN::Error::from_errno(ENOTSUP); }
|
|
||||||
|
|
||||||
// General API
|
// General API
|
||||||
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) { return BAN::Error::from_errno(ENOTSUP); }
|
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) { return BAN::Error::from_errno(ENOTSUP); }
|
||||||
|
|
|
@ -47,7 +47,6 @@ namespace Kernel
|
||||||
virtual void unbind_socket(BAN::RefPtr<NetworkSocket>, uint16_t port) override;
|
virtual void unbind_socket(BAN::RefPtr<NetworkSocket>, uint16_t port) override;
|
||||||
virtual BAN::ErrorOr<void> bind_socket_to_unused(BAN::RefPtr<NetworkSocket>, const sockaddr* send_address, socklen_t send_address_len) override;
|
virtual BAN::ErrorOr<void> bind_socket_to_unused(BAN::RefPtr<NetworkSocket>, const sockaddr* send_address, socklen_t send_address_len) override;
|
||||||
virtual BAN::ErrorOr<void> bind_socket_to_address(BAN::RefPtr<NetworkSocket>, const sockaddr* address, socklen_t address_len) override;
|
virtual BAN::ErrorOr<void> bind_socket_to_address(BAN::RefPtr<NetworkSocket>, const sockaddr* address, socklen_t address_len) override;
|
||||||
virtual BAN::ErrorOr<void> get_socket_address(BAN::RefPtr<NetworkSocket>, sockaddr* address, socklen_t* address_len) override;
|
|
||||||
|
|
||||||
virtual BAN::ErrorOr<size_t> sendto(NetworkSocket&, BAN::ConstByteSpan, const sockaddr*, socklen_t) override;
|
virtual BAN::ErrorOr<size_t> sendto(NetworkSocket&, BAN::ConstByteSpan, const sockaddr*, socklen_t) override;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace Kernel
|
||||||
virtual void unbind_socket(BAN::RefPtr<NetworkSocket>, uint16_t port) = 0;
|
virtual void unbind_socket(BAN::RefPtr<NetworkSocket>, uint16_t port) = 0;
|
||||||
virtual BAN::ErrorOr<void> bind_socket_to_unused(BAN::RefPtr<NetworkSocket>, const sockaddr* send_address, socklen_t send_address_len) = 0;
|
virtual BAN::ErrorOr<void> bind_socket_to_unused(BAN::RefPtr<NetworkSocket>, const sockaddr* send_address, socklen_t send_address_len) = 0;
|
||||||
virtual BAN::ErrorOr<void> bind_socket_to_address(BAN::RefPtr<NetworkSocket>, const sockaddr* address, socklen_t address_len) = 0;
|
virtual BAN::ErrorOr<void> bind_socket_to_address(BAN::RefPtr<NetworkSocket>, const sockaddr* address, socklen_t address_len) = 0;
|
||||||
virtual BAN::ErrorOr<void> get_socket_address(BAN::RefPtr<NetworkSocket>, sockaddr* address, socklen_t* address_len) = 0;
|
|
||||||
|
|
||||||
virtual BAN::ErrorOr<size_t> sendto(NetworkSocket&, BAN::ConstByteSpan, const sockaddr*, socklen_t) = 0;
|
virtual BAN::ErrorOr<size_t> sendto(NetworkSocket&, BAN::ConstByteSpan, const sockaddr*, socklen_t) = 0;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace Kernel
|
||||||
NetworkSocket(NetworkLayer&, ino_t, const TmpInodeInfo&);
|
NetworkSocket(NetworkLayer&, ino_t, const TmpInodeInfo&);
|
||||||
|
|
||||||
virtual BAN::ErrorOr<long> ioctl_impl(int request, void* arg) override;
|
virtual BAN::ErrorOr<long> ioctl_impl(int request, void* arg) override;
|
||||||
virtual BAN::ErrorOr<void> getsockname_impl(sockaddr*, socklen_t*) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NetworkLayer& m_network_layer;
|
NetworkLayer& m_network_layer;
|
||||||
|
|
|
@ -119,10 +119,6 @@ namespace Kernel
|
||||||
BAN::ErrorOr<long> sys_chown(const char*, uid_t, gid_t);
|
BAN::ErrorOr<long> sys_chown(const char*, uid_t, gid_t);
|
||||||
|
|
||||||
BAN::ErrorOr<long> sys_socket(int domain, int type, int protocol);
|
BAN::ErrorOr<long> sys_socket(int domain, int type, int protocol);
|
||||||
BAN::ErrorOr<long> sys_getsockname(int socket, sockaddr* address, socklen_t* address_len);
|
|
||||||
BAN::ErrorOr<long> sys_getsockopt(int socket, int level, int option_name, void* option_value, socklen_t* option_len);
|
|
||||||
BAN::ErrorOr<long> sys_setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len);
|
|
||||||
|
|
||||||
BAN::ErrorOr<long> sys_accept(int socket, sockaddr* address, socklen_t* address_len);
|
BAN::ErrorOr<long> sys_accept(int socket, sockaddr* address, socklen_t* address_len);
|
||||||
BAN::ErrorOr<long> sys_bind(int socket, const sockaddr* address, socklen_t address_len);
|
BAN::ErrorOr<long> sys_bind(int socket, const sockaddr* address, socklen_t address_len);
|
||||||
BAN::ErrorOr<long> sys_connect(int socket, const sockaddr* address, socklen_t address_len);
|
BAN::ErrorOr<long> sys_connect(int socket, const sockaddr* address, socklen_t address_len);
|
||||||
|
|
|
@ -164,14 +164,6 @@ namespace Kernel
|
||||||
return recvfrom_impl(buffer, address, address_len);
|
return recvfrom_impl(buffer, address, address_len);
|
||||||
};
|
};
|
||||||
|
|
||||||
BAN::ErrorOr<void> Inode::getsockname(sockaddr* address, socklen_t* address_len)
|
|
||||||
{
|
|
||||||
LockGuard _(m_mutex);
|
|
||||||
if (!mode().ifsock())
|
|
||||||
return BAN::Error::from_errno(ENOTSOCK);
|
|
||||||
return getsockname_impl(address, address_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<size_t> Inode::read(off_t offset, BAN::ByteSpan buffer)
|
BAN::ErrorOr<size_t> Inode::read(off_t offset, BAN::ByteSpan buffer)
|
||||||
{
|
{
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mutex);
|
||||||
|
|
|
@ -139,28 +139,6 @@ namespace Kernel
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> IPv4Layer::get_socket_address(BAN::RefPtr<NetworkSocket> socket, sockaddr* address, socklen_t* address_len)
|
|
||||||
{
|
|
||||||
if (*address_len < (socklen_t)sizeof(sockaddr_in))
|
|
||||||
return BAN::Error::from_errno(ENOBUFS);
|
|
||||||
|
|
||||||
sockaddr_in* in_addr = reinterpret_cast<sockaddr_in*>(address);
|
|
||||||
|
|
||||||
SpinLockGuard _(m_bound_socket_lock);
|
|
||||||
for (auto& [bound_port, bound_socket] : m_bound_sockets)
|
|
||||||
{
|
|
||||||
if (socket != bound_socket.lock())
|
|
||||||
continue;
|
|
||||||
// FIXME: sockets should have bound address
|
|
||||||
in_addr->sin_family = AF_INET;
|
|
||||||
in_addr->sin_port = bound_port;
|
|
||||||
in_addr->sin_addr.s_addr = INADDR_ANY;
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<size_t> IPv4Layer::sendto(NetworkSocket& socket, BAN::ConstByteSpan buffer, const sockaddr* address, socklen_t address_len)
|
BAN::ErrorOr<size_t> IPv4Layer::sendto(NetworkSocket& socket, BAN::ConstByteSpan buffer, const sockaddr* address, socklen_t address_len)
|
||||||
{
|
{
|
||||||
if (address->sa_family != AF_INET)
|
if (address->sa_family != AF_INET)
|
||||||
|
|
|
@ -100,10 +100,4 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> NetworkSocket::getsockname_impl(sockaddr* address, socklen_t* address_len)
|
|
||||||
{
|
|
||||||
TRY(m_network_layer.get_socket_address(this, address, address_len));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,8 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<int> OpenFileDescriptorSet::socket(int domain, int type, int protocol)
|
BAN::ErrorOr<int> OpenFileDescriptorSet::socket(int domain, int type, int protocol)
|
||||||
{
|
{
|
||||||
bool valid_protocol = true;
|
if (protocol != 0)
|
||||||
|
return BAN::Error::from_errno(EPROTONOSUPPORT);
|
||||||
|
|
||||||
SocketDomain sock_domain;
|
SocketDomain sock_domain;
|
||||||
switch (domain)
|
switch (domain)
|
||||||
|
@ -108,7 +109,6 @@ namespace Kernel
|
||||||
break;
|
break;
|
||||||
case AF_UNIX:
|
case AF_UNIX:
|
||||||
sock_domain = SocketDomain::UNIX;
|
sock_domain = SocketDomain::UNIX;
|
||||||
valid_protocol = false;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return BAN::Error::from_errno(EPROTOTYPE);
|
return BAN::Error::from_errno(EPROTOTYPE);
|
||||||
|
@ -119,25 +119,17 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
case SOCK_STREAM:
|
case SOCK_STREAM:
|
||||||
sock_type = SocketType::STREAM;
|
sock_type = SocketType::STREAM;
|
||||||
if (protocol != IPPROTO_TCP)
|
|
||||||
valid_protocol = false;
|
|
||||||
break;
|
break;
|
||||||
case SOCK_DGRAM:
|
case SOCK_DGRAM:
|
||||||
sock_type = SocketType::DGRAM;
|
sock_type = SocketType::DGRAM;
|
||||||
if (protocol != IPPROTO_UDP)
|
|
||||||
valid_protocol = false;
|
|
||||||
break;
|
break;
|
||||||
case SOCK_SEQPACKET:
|
case SOCK_SEQPACKET:
|
||||||
sock_type = SocketType::SEQPACKET;
|
sock_type = SocketType::SEQPACKET;
|
||||||
valid_protocol = false;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return BAN::Error::from_errno(EPROTOTYPE);
|
return BAN::Error::from_errno(EPROTOTYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocol && !valid_protocol)
|
|
||||||
return BAN::Error::from_errno(EPROTONOSUPPORT);
|
|
||||||
|
|
||||||
auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid()));
|
auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid()));
|
||||||
|
|
||||||
int fd = TRY(get_free_fd());
|
int fd = TRY(get_free_fd());
|
||||||
|
|
|
@ -911,56 +911,6 @@ namespace Kernel
|
||||||
return TRY(m_open_file_descriptors.socket(domain, type, protocol));
|
return TRY(m_open_file_descriptors.socket(domain, type, protocol));
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_getsockname(int socket, sockaddr* address, socklen_t* address_len)
|
|
||||||
{
|
|
||||||
LockGuard _(m_process_lock);
|
|
||||||
TRY(validate_pointer_access(address_len, sizeof(address_len)));
|
|
||||||
TRY(validate_pointer_access(address, *address_len));
|
|
||||||
|
|
||||||
auto inode = TRY(m_open_file_descriptors.inode_of(socket));
|
|
||||||
if (!inode->mode().ifsock())
|
|
||||||
return BAN::Error::from_errno(ENOTSOCK);
|
|
||||||
|
|
||||||
TRY(inode->getsockname(address, address_len));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_getsockopt(int socket, int level, int option_name, void* option_value, socklen_t* option_len)
|
|
||||||
{
|
|
||||||
LockGuard _(m_process_lock);
|
|
||||||
TRY(validate_pointer_access(option_len, sizeof(option_len)));
|
|
||||||
TRY(validate_pointer_access(option_value, *option_len));
|
|
||||||
|
|
||||||
auto inode = TRY(m_open_file_descriptors.inode_of(socket));
|
|
||||||
if (!inode->mode().ifsock())
|
|
||||||
return BAN::Error::from_errno(ENOTSOCK);
|
|
||||||
|
|
||||||
// Because all networking is synchronous, there can not be errors to report
|
|
||||||
if (level == SOL_SOCKET && option_name == SO_ERROR)
|
|
||||||
{
|
|
||||||
if (*option_len)
|
|
||||||
*reinterpret_cast<uint8_t*>(option_value) = 0;
|
|
||||||
*option_len = BAN::Math::min<socklen_t>(*option_len, sizeof(int));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dprintln("SYS_GETSOCKOPT {}, {}, {}, {}, {}", socket, level, option_name, option_value, option_len);
|
|
||||||
return BAN::Error::from_errno(ENOTSUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len)
|
|
||||||
{
|
|
||||||
LockGuard _(m_process_lock);
|
|
||||||
TRY(validate_pointer_access(option_value, option_len));
|
|
||||||
|
|
||||||
auto inode = TRY(m_open_file_descriptors.inode_of(socket));
|
|
||||||
if (!inode->mode().ifsock())
|
|
||||||
return BAN::Error::from_errno(ENOTSOCK);
|
|
||||||
|
|
||||||
dprintln("SYS_GETSOCKOPT {}, {}, {}, {}, {}", socket, level, option_name, option_value, option_len);
|
|
||||||
return BAN::Error::from_errno(ENOTSUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_accept(int socket, sockaddr* address, socklen_t* address_len)
|
BAN::ErrorOr<long> Process::sys_accept(int socket, sockaddr* address, socklen_t* address_len)
|
||||||
{
|
{
|
||||||
if (address && !address_len)
|
if (address && !address_len)
|
||||||
|
|
|
@ -361,7 +361,7 @@ namespace Kernel
|
||||||
|
|
||||||
bool TTY::is_initialized()
|
bool TTY::is_initialized()
|
||||||
{
|
{
|
||||||
return !!s_tty;
|
return s_tty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ set(LIBC_SOURCES
|
||||||
fcntl.cpp
|
fcntl.cpp
|
||||||
grp.cpp
|
grp.cpp
|
||||||
malloc.cpp
|
malloc.cpp
|
||||||
netdb.cpp
|
|
||||||
printf_impl.cpp
|
printf_impl.cpp
|
||||||
pwd.cpp
|
pwd.cpp
|
||||||
scanf_impl.cpp
|
scanf_impl.cpp
|
||||||
|
|
|
@ -61,7 +61,6 @@ __BEGIN_DECLS
|
||||||
#define NAME_MAX 255
|
#define NAME_MAX 255
|
||||||
#define PATH_MAX 256
|
#define PATH_MAX 256
|
||||||
#define LOGIN_NAME_MAX 256
|
#define LOGIN_NAME_MAX 256
|
||||||
#define HOST_NAME_MAX 255
|
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ void endservent(void);
|
||||||
void freeaddrinfo(struct addrinfo* ai);
|
void freeaddrinfo(struct addrinfo* ai);
|
||||||
const char* gai_strerror(int ecode);
|
const char* gai_strerror(int ecode);
|
||||||
int getaddrinfo(const char* __restrict nodename, const char* __restrict servname, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res);
|
int getaddrinfo(const char* __restrict nodename, const char* __restrict servname, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res);
|
||||||
struct hostent* gethostbyname(const char* name);
|
|
||||||
struct hostent* gethostent(void);
|
struct hostent* gethostent(void);
|
||||||
int getnameinfo(const struct sockaddr* __restrict sa, socklen_t salen, char* __restrict node, socklen_t nodelen, char* __restrict service, socklen_t servicelen, int flags);
|
int getnameinfo(const struct sockaddr* __restrict sa, socklen_t salen, char* __restrict node, socklen_t nodelen, char* __restrict service, socklen_t servicelen, int flags);
|
||||||
struct netent* getnetbyaddr(uint32_t net, int type);
|
struct netent* getnetbyaddr(uint32_t net, int type);
|
||||||
|
|
|
@ -78,9 +78,6 @@ __BEGIN_DECLS
|
||||||
O(SYS_SMO_DELETE, smo_delete) \
|
O(SYS_SMO_DELETE, smo_delete) \
|
||||||
O(SYS_SMO_MAP, smo_map) \
|
O(SYS_SMO_MAP, smo_map) \
|
||||||
O(SYS_ISATTY, isatty) \
|
O(SYS_ISATTY, isatty) \
|
||||||
O(SYS_GETSOCKNAME, getsockname) \
|
|
||||||
O(SYS_GETSOCKOPT, getsockopt) \
|
|
||||||
O(SYS_SETSOCKOPT, setsockopt) \
|
|
||||||
|
|
||||||
enum Syscall
|
enum Syscall
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
#include <BAN/Bitcast.h>
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
struct hostent* gethostbyname(const char* name)
|
|
||||||
{
|
|
||||||
static char name_buffer[HOST_NAME_MAX + 1];
|
|
||||||
static in_addr_t addr_buffer;
|
|
||||||
static in_addr_t* addr_ptrs[2];
|
|
||||||
static struct hostent hostent;
|
|
||||||
|
|
||||||
if (strlen(name) > HOST_NAME_MAX)
|
|
||||||
return nullptr;
|
|
||||||
strcpy(name_buffer, name);
|
|
||||||
hostent.h_name = name_buffer;
|
|
||||||
|
|
||||||
hostent.h_aliases = nullptr;
|
|
||||||
|
|
||||||
hostent.h_addrtype = AF_INET;
|
|
||||||
hostent.h_length = sizeof(in_addr_t);
|
|
||||||
|
|
||||||
addr_ptrs[0] = &addr_buffer;
|
|
||||||
addr_ptrs[1] = nullptr;
|
|
||||||
hostent.h_addr_list = reinterpret_cast<char**>(addr_ptrs);
|
|
||||||
|
|
||||||
int socket = -1;
|
|
||||||
|
|
||||||
if (in_addr_t ipv4 = inet_addr(name); ipv4 != (in_addr_t)(-1))
|
|
||||||
addr_buffer = ipv4;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int socket = ::socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
|
||||||
if (socket == -1)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
sockaddr_un addr;
|
|
||||||
addr.sun_family = AF_UNIX;
|
|
||||||
strcpy(addr.sun_path, "/tmp/resolver.sock");
|
|
||||||
if (connect(socket, (sockaddr*)&addr, sizeof(addr)) == -1)
|
|
||||||
goto error_close_socket;
|
|
||||||
|
|
||||||
if (send(socket, name, strlen(name), 0) == -1)
|
|
||||||
goto error_close_socket;
|
|
||||||
|
|
||||||
sockaddr_storage storage;
|
|
||||||
if (recv(socket, &storage, sizeof(storage), 0) == -1)
|
|
||||||
goto error_close_socket;
|
|
||||||
|
|
||||||
close(socket);
|
|
||||||
|
|
||||||
if (storage.ss_family != AF_INET)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
addr_buffer = *reinterpret_cast<in_addr_t*>(storage.ss_storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return &hostent;
|
|
||||||
|
|
||||||
error_close_socket:
|
|
||||||
close(socket);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
|
@ -1,6 +1,3 @@
|
||||||
#include <BAN/Assert.h>
|
|
||||||
#include <BAN/Debug.h>
|
|
||||||
|
|
||||||
#include <bits/printf.h>
|
#include <bits/printf.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -606,11 +603,7 @@ int remove(const char* path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
int rename(const char* old, const char* _new)
|
int rename(const char*, const char*);
|
||||||
{
|
|
||||||
dwarnln("rename({}, {})", old, _new);
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void rewind(FILE* file)
|
void rewind(FILE* file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,18 +62,3 @@ int socket(int domain, int type, int protocol)
|
||||||
{
|
{
|
||||||
return syscall(SYS_SOCKET, domain, type, protocol);
|
return syscall(SYS_SOCKET, domain, type, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getsockname(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len)
|
|
||||||
{
|
|
||||||
return syscall(SYS_GETSOCKNAME, socket, address, address_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getsockopt(int socket, int level, int option_name, void* __restrict option_value, socklen_t* __restrict option_len)
|
|
||||||
{
|
|
||||||
return syscall(SYS_GETSOCKOPT, socket, level, option_name, option_value, option_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len)
|
|
||||||
{
|
|
||||||
return syscall(SYS_SETSOCKOPT, socket, level, option_name, option_value, option_len);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#include <BAN/Assert.h>
|
|
||||||
#include <BAN/Debug.h>
|
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -78,9 +75,3 @@ struct tm* localtime(const time_t* timer)
|
||||||
// FIXME: support timezones
|
// FIXME: support timezones
|
||||||
return gmtime(timer);
|
return gmtime(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t strftime(char* __restrict s, size_t maxsize, const char* __restrict format, const struct tm* __restrict timeptr)
|
|
||||||
{
|
|
||||||
dwarnln("strftime({}, {}, {}, {})", s, maxsize, format, timeptr);
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
curl-*
|
|
|
@ -1,58 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ -z $BANAN_ARCH ]; then
|
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $BANAN_SYSROOT ]; then
|
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $BANAN_TOOLCHAIN_PREFIX ]; then
|
|
||||||
echo "You must set the BANAN_TOOLCHAIN_PREFIX environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
CURL_VERSION="curl-8.8.0"
|
|
||||||
CURL_TAR="$CURL_VERSION.tar.gz"
|
|
||||||
CURL_URL="https://curl.se/download/$CURL_TAR"
|
|
||||||
|
|
||||||
cd $(dirname $(realpath $0))
|
|
||||||
|
|
||||||
if [ ! -d $CURL_VERSION ]; then
|
|
||||||
if [ ! -f $CURL_TAR ]; then
|
|
||||||
wget $CURL_URL
|
|
||||||
fi
|
|
||||||
tar xf $CURL_TAR
|
|
||||||
|
|
||||||
for patch in ./patches/*; do
|
|
||||||
patch -ruN -d $CURL_VERSION < "$patch"
|
|
||||||
done
|
|
||||||
|
|
||||||
grep -qxF doom ../installed || echo curl >> ../installed
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $CURL_VERSION
|
|
||||||
|
|
||||||
export PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH"
|
|
||||||
|
|
||||||
if [ ! -d "build-${BANAN_ARCH}" ]; then
|
|
||||||
mkdir -p "build-${BANAN_ARCH}"
|
|
||||||
cd "build-${BANAN_ARCH}"
|
|
||||||
|
|
||||||
../configure \
|
|
||||||
--host=x86_64-banan_os \
|
|
||||||
--prefix=$BANAN_SYSROOT/usr \
|
|
||||||
--without-ssl \
|
|
||||||
--disable-threaded-resolver \
|
|
||||||
--disable-ipv6 \
|
|
||||||
--disable-docs
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "build-${BANAN_ARCH}"
|
|
||||||
|
|
||||||
make && make install
|
|
|
@ -1,12 +0,0 @@
|
||||||
diff -ruN curl-8.8.0/config.sub curl-patched/config.sub
|
|
||||||
--- curl-8.8.0/config.sub 2023-03-13 00:39:42.000000000 +0200
|
|
||||||
+++ curl-patched/config.sub 2024-06-17 21:16:00.348556957 +0300
|
|
||||||
@@ -1754,7 +1754,7 @@
|
|
||||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
|
||||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
|
||||||
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
|
|
||||||
- | fiwix* )
|
|
||||||
+ | fiwix* | banan_os* )
|
|
||||||
;;
|
|
||||||
# This one is extra strict with allowed versions
|
|
||||||
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add support for banan-os
|
||||||
|
|
||||||
---
|
---
|
||||||
doomgeneric/Makefile.banan_os | 57 +++++++++++
|
doomgeneric/Makefile.banan_os | 57 +++++++++++
|
||||||
doomgeneric/doomgeneric_banan_os.cpp | 138 +++++++++++++++++++++++++++
|
doomgeneric/doomgeneric_banan_os.cpp | 144 +++++++++++++++++++++++++++
|
||||||
2 files changed, 200 insertions(+)
|
2 files changed, 200 insertions(+)
|
||||||
create mode 100644 doomgeneric/Makefile.banan_os
|
create mode 100644 doomgeneric/Makefile.banan_os
|
||||||
create mode 100644 doomgeneric/doomgeneric_banan_os.cpp
|
create mode 100644 doomgeneric/doomgeneric_banan_os.cpp
|
||||||
|
@ -79,7 +79,7 @@ new file mode 100644
|
||||||
index 0000000..9161771
|
index 0000000..9161771
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/doomgeneric/doomgeneric_banan_os.cpp
|
+++ b/doomgeneric/doomgeneric_banan_os.cpp
|
||||||
@@ -0,0 +1,138 @@
|
@@ -0,0 +1,144 @@
|
||||||
+extern "C"
|
+extern "C"
|
||||||
+{
|
+{
|
||||||
+#include "doomgeneric.h"
|
+#include "doomgeneric.h"
|
||||||
|
@ -217,6 +217,12 @@ index 0000000..9161771
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
+int rename(const char* oldp, const char* newp)
|
||||||
|
+{
|
||||||
|
+ fprintf(stderr, "rename(\"%s\", \"%s\")\n", oldp, newp);
|
||||||
|
+ exit(1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
+}
|
+}
|
||||||
--
|
--
|
||||||
2.45.2
|
2.45.2
|
||||||
|
|
Loading…
Reference in New Issue