public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 9/9] Phoenix-RTOS: Adjust network-related headers to new kernel API.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (4 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 4/9] Phoenix-RTOS: Provide __progname symbol for user-space apps Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 6/9] Phoenix-RTOS: Implement daemon() function Jakub Sejdak
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/include/arpa/inet.h    |  1 +
 newlib/libc/sys/phoenix/include/net/if.h       | 58 +-------------------------
 newlib/libc/sys/phoenix/include/netinet/in.h   | 40 ++----------------
 newlib/libc/sys/phoenix/include/netinet6/in6.h | 23 +---------
 newlib/libc/sys/phoenix/net/inet_aton.c        |  1 +
 newlib/libc/sys/phoenix/socket.c               |  1 +
 newlib/libc/sys/phoenix/sockopt.c              |  6 ++-
 newlib/libc/sys/phoenix/sys/socket.h           |  7 ++++
 8 files changed, 20 insertions(+), 117 deletions(-)

diff --git a/newlib/libc/sys/phoenix/include/arpa/inet.h b/newlib/libc/sys/phoenix/include/arpa/inet.h
index aca1920..8b76fc0 100644
--- a/newlib/libc/sys/phoenix/include/arpa/inet.h
+++ b/newlib/libc/sys/phoenix/include/arpa/inet.h
@@ -26,6 +26,7 @@
 #define	_ARPA_INET_H
 
 #include <netinet/in.h>
+#include <phoenix/socket.h>
 #include <stdint.h>
 
 #define	INET_ADDRSTRLEN		16
diff --git a/newlib/libc/sys/phoenix/include/net/if.h b/newlib/libc/sys/phoenix/include/net/if.h
index ad089f3..516af21 100644
--- a/newlib/libc/sys/phoenix/include/net/if.h
+++ b/newlib/libc/sys/phoenix/include/net/if.h
@@ -37,6 +37,7 @@
 #ifndef _NET_IF_H
 #define	_NET_IF_H
 
+#include <phoenix/iface.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/time.h>
@@ -106,24 +107,6 @@ struct if_data {
 	struct timeval ifi_lastchange;		/* Time of last administrative change */
 };
 
-#define	IFF_UP				0x1			/* Interface is up */
-#define	IFF_BROADCAST		0x2			/* Broadcast address valid */
-#define	IFF_DEBUG			0x4			/* Turn on debugging */
-#define	IFF_LOOPBACK		0x8			/* Is a loopback net */
-#define	IFF_POINTOPOINT		0x10		/* Interface is point-to-point link */
-#define	IFF_NOTRAILERS		0x20		/* Avoid use of trailers */
-#define	IFF_RUNNING			0x40		/* Resources allocated */
-#define	IFF_NOARP			0x80		/* No address resolution protocol */
-#define	IFF_PROMISC			0x100		/* Receive all packets */
-#define	IFF_ALLMULTI		0x200		/* Receive all multicast packets */
-#define	IFF_OACTIVE			0x400		/* Transmission in progress */
-#define	IFF_SIMPLEX			0x800		/* Can't hear own transmissions */
-#define	IFF_LINK0			0x1000		/* Per link layer defined bit */
-#define	IFF_LINK1			0x2000		/* Per link layer defined bit */
-#define	IFF_LINK2			0x4000		/* Per link layer defined bit */
-#define	IFF_ALTPHYS			IFF_LINK2	/* Use alternate physical connection */
-#define	IFF_MULTICAST		0x8000		/* Supports multicast */
-
 /*
  * The following flag(s) ought to go in if_flags, but we cannot change
  * struct ifnet because of binary compatibility, so we store them in
@@ -191,45 +174,6 @@ struct if_announcemsghdr {
 #define	IFAN_ARRIVAL		0		/* Interface arrival */
 #define	IFAN_DEPARTURE		1		/* Interface departure */
 
-/*
- * Interface request structure used for socket
- * ioctl's.  All interface ioctl's must have parameter
- * definitions which begin with ifr_name.  The
- * remainder may be interface specific.
- */
-struct ifreq {
-	char ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
-	union {
-		struct sockaddr ifru_addr;
-		struct sockaddr ifru_dstaddr;
-		struct sockaddr ifru_broadaddr;
-		struct sockaddr ifru_netmask;
-		short ifru_flags[2];
-		short ifru_index;
-		int	ifru_metric;
-		int	ifru_mtu;
-		int	ifru_phys;
-		int	ifru_media;
-		caddr_t	ifru_data;
-		int	ifru_cap[2];
-	} ifr_ifru;
-
-#define	ifr_addr		ifr_ifru.ifru_addr			/* Address */
-#define	ifr_dstaddr		ifr_ifru.ifru_dstaddr		/* Other end of p-to-p link */
-#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr		/* Broadcast address */
-#define	ifr_netmask		ifr_ifru.ifru_netmask		/* Interface net mask	*/
-#define	ifr_flags		ifr_ifru.ifru_flags[0]		/* Flags */
-#define	ifr_prevflags	ifr_ifru.ifru_flags[1]		/* Flags */
-#define	ifr_metric		ifr_ifru.ifru_metric		/* Metric */
-#define	ifr_mtu			ifr_ifru.ifru_mtu			/* Mtu */
-#define ifr_phys		ifr_ifru.ifru_phys			/* Physical wire */
-#define ifr_media		ifr_ifru.ifru_media			/* Physical media */
-#define	ifr_data		ifr_ifru.ifru_data			/* For use by interface */
-#define	ifr_reqcap		ifr_ifru.ifru_cap[0]		/* Requested capabilities */
-#define	ifr_curcap		ifr_ifru.ifru_cap[1]		/* Current capabilities */
-#define	ifr_index		ifr_ifru.ifru_index			/* Interface index */
-};
-
 struct ifaliasreq {
 	char ifra_name[IFNAMSIZ];	/* if name, e.g. "en0" */
 	struct sockaddr ifra_addr;
diff --git a/newlib/libc/sys/phoenix/include/netinet/in.h b/newlib/libc/sys/phoenix/include/netinet/in.h
index 18fabfe..9db5f61 100644
--- a/newlib/libc/sys/phoenix/include/netinet/in.h
+++ b/newlib/libc/sys/phoenix/include/netinet/in.h
@@ -40,8 +40,8 @@
 #define _NETINET_IN_H
 
 #include <machine/endian.h>
-#include <netinet6/in6.h>
-#include <sys/socket.h>
+#include <phoenix/netinet.h>
+#include <sys/types.h>
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define htons(a)	(a)
@@ -72,35 +72,9 @@ static uint16_t ntohs(uint16_t netshort)
 }
 #endif
 
-/* Protocols common to RFC 1700, POSIX, and X/Open. */
-#define	IPPROTO_IP			0						/* Dummy for IP */
-#define	IPPROTO_ICMP		1						/* Control message protocol */
-#define	IPPROTO_TCP			6						/* TCP */
-#define	IPPROTO_UDP			17						/* User datagram protocol */
-
-#define	INADDR_ANY			(u_int32_t) 0x00000000
-#define	INADDR_BROADCAST	(u_int32_t) 0xffffffff	/* Must be masked */
-
-typedef	uint32_t			in_addr_t;
-typedef	uint16_t			in_port_t;
-
-/* Internet address (a structure for historical reasons). */
-struct in_addr {
-	in_addr_t s_addr;
-};
-
-/* Socket address, internet style. */
-struct sockaddr_in {
-	uint8_t sin_len;
-	sa_family_t sin_family;
-	in_port_t sin_port;
-	struct in_addr sin_addr;
-	char sin_zero[8];
-};
-
 #if __POSIX_VISIBLE >= 200112
-#define	IPPROTO_RAW			255		/* Raw IP packet */
-#define	INET_ADDRSTRLEN		16
+#define	IPPROTO_RAW				255			/* Raw IP packet */
+#define	INET_ADDRSTRLEN			16
 #endif
 
 /*
@@ -282,12 +256,6 @@ struct sockaddr_in {
 #define	IP_DEFAULT_MULTICAST_LOOP	1		/* Normally hear sends if a member  */
 #define	IP_MAX_MEMBERSHIPS			20		/* Per socket */
 
-/* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */
-struct ip_mreq {
-	struct in_addr imr_multiaddr;			/* IP multicast address of group */
-	struct in_addr imr_interface;			/* Local IP address of interface */
-};
-
 /* Argument for IP_PORTRANGE - which range to search when port is unspecified at bind() or connect() */
 #define	IP_PORTRANGE_DEFAULT		0		/* Default range */
 #define	IP_PORTRANGE_HIGH			1		/* "high" - request firewall bypass */
diff --git a/newlib/libc/sys/phoenix/include/netinet6/in6.h b/newlib/libc/sys/phoenix/include/netinet6/in6.h
index 1ebbc1d..956723b 100644
--- a/newlib/libc/sys/phoenix/include/netinet6/in6.h
+++ b/newlib/libc/sys/phoenix/include/netinet6/in6.h
@@ -70,6 +70,7 @@
 #ifndef _NETINET6_IN6_H
 #define _NETINET6_IN6_H
 
+#include <phoenix/netinet6.h>
 #include <sys/types.h>
 
 /*
@@ -114,33 +115,11 @@
 #define	IPV6PORT_RESERVEDMIN	600
 #define	IPV6PORT_RESERVEDMAX	(IPV6PORT_RESERVED-1)
 
-/* IPv6 address */
-struct in6_addr {
-	union {
-		uint8_t __u6_addr8[16];
-		uint16_t __u6_addr16[8];
-		uint32_t __u6_addr32[4];
-	} __u6_addr;		/* 128-bit IP6 address */
-};
-
-#define s6_addr					__u6_addr.__u6_addr8
-
-#define INET6_ADDRSTRLEN		46
-
 /* Socket address for IPv6 */
 #ifndef _XOPEN_SOURCE
 #define SIN6_LEN
 #endif
 
-struct sockaddr_in6 {
-	uint8_t sin6_family;		/* AF_INET6 (sa_family_t) */
-	uint16_t sin6_port;			/* Transport layer port # (in_port_t) */
-	uint32_t sin6_flowinfo;		/* IP6 flow information */
-	struct in6_addr sin6_addr;	/* IP6 address */
-	uint32_t sin6_scope_id;		/* scope zone index */
-};
-
-
 /* Definition of some useful macros to handle IP6 addresses */
 #define IN6ADDR_ANY_INIT \
 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
diff --git a/newlib/libc/sys/phoenix/net/inet_aton.c b/newlib/libc/sys/phoenix/net/inet_aton.c
index f595e87..9013bca 100644
--- a/newlib/libc/sys/phoenix/net/inet_aton.c
+++ b/newlib/libc/sys/phoenix/net/inet_aton.c
@@ -60,6 +60,7 @@
 #include <arpa/inet.h>
 #include <ctype.h>
 #include <errno.h>
+#include <netinet/in.h>
 #include <stdlib.h>
 
 int inet_aton(const char *cp, struct in_addr *inp)
diff --git a/newlib/libc/sys/phoenix/socket.c b/newlib/libc/sys/phoenix/socket.c
index 213345f..39e4ab2 100644
--- a/newlib/libc/sys/phoenix/socket.c
+++ b/newlib/libc/sys/phoenix/socket.c
@@ -25,6 +25,7 @@
 #include "syscall.h"
 
 #include <errno.h>
+#include <phoenix/socket_args.h>
 #include <sys/socket.h>
 
 int socket(int domain, int type, int protocol)
diff --git a/newlib/libc/sys/phoenix/sockopt.c b/newlib/libc/sys/phoenix/sockopt.c
index a0acca8..6486e7b 100644
--- a/newlib/libc/sys/phoenix/sockopt.c
+++ b/newlib/libc/sys/phoenix/sockopt.c
@@ -25,6 +25,8 @@
 #include "syscall.h"
 
 #include <errno.h>
+#include <phoenix/socket_args.h>
+#include <phoenix/sockios.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 
@@ -41,7 +43,7 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 
 int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
 {
-	struct setsockopt_args args;
+	struct sockopt_args args;
 	args.level = level;
 	args.optname = optname;
 	args.optval = optval;
@@ -59,7 +61,7 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl
 
 int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 {
-	struct setsockopt_args args;
+	struct sockopt_args args;
 	args.level = level;
 	args.optname = optname;
 	args.optval = (void *) optval;
diff --git a/newlib/libc/sys/phoenix/sys/socket.h b/newlib/libc/sys/phoenix/sys/socket.h
index 670dfa1..78776f5 100644
--- a/newlib/libc/sys/phoenix/sys/socket.h
+++ b/newlib/libc/sys/phoenix/sys/socket.h
@@ -25,7 +25,10 @@
 #ifndef _SYS_SOCKET_H
 #define	_SYS_SOCKET_H
 
+#include <phoenix/netinet.h>
+#include <phoenix/netinet6.h>
 #include <phoenix/socket.h>
+#include <phoenix/sockios.h>
 #include <sys/types.h>
 
 #define	_SS_MAXSIZE		128U
@@ -41,6 +44,10 @@ struct sockaddr_storage {
 	char __ss_pad2[_SS_PAD2SIZE];
 };
 
+#define HAVE_STRUCT_SOCKADDR_STORAGE
+#define HAVE_STRUCT_IN6_ADDR
+#define HAVE_STRUCT_SOCKADDR_IN6
+
 int socket(int domain, int type, int protocol);
 int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
 int listen(int sockfd, int backlog);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/9] Phoenix-RTOS: Provide __progname symbol for user-space apps.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (3 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 5/9] Phoenix-RTOS: Add checking EOF in getmntent() Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 9/9] Phoenix-RTOS: Adjust network-related headers to new kernel API Jakub Sejdak
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/machine/arm/crt0.S | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/sys/phoenix/machine/arm/crt0.S b/newlib/libc/sys/phoenix/machine/arm/crt0.S
index 7c48691..0ab7da6 100644
--- a/newlib/libc/sys/phoenix/machine/arm/crt0.S
+++ b/newlib/libc/sys/phoenix/machine/arm/crt0.S
@@ -28,6 +28,7 @@
 	.global		main
 	.global		exit
 	.global		environ
+	.global		__progname
 
 	.align	4
 
@@ -36,7 +37,10 @@ _start:
 	pop		{lr}
 	ldmfd	sp,	{r0-r2}
 	ldr		r3,	=environ
+	ldr		r4, =__progname
+	ldr		r5,	[r1]
 	str		r2,	[r3]
+	str		r5,	[r4]
 
 	/* Align stack. */
 	bic		sp,	#0x00000007
@@ -44,4 +48,7 @@ _start:
 	blx		lr
 	ldr		lr,	=exit
 	blx		lr
-	
\ No newline at end of file
+
+	.section	.data
+__progname:
+	.word		0
\ No newline at end of file
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/9] Phoenix-RTOS: Add <netpacket/packet.h> header and import <net/if_arp.h> header from FreeBSD.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 8/9] Phoenix-RTOS: Add dummy implementation of fdatasync() syscall Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 3/9] Phoenix-RTOS: Fix warning with pointer treated as integer Jakub Sejdak
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/include/net/if_arp.h       | 121 +++++++++++++++++++++
 newlib/libc/sys/phoenix/include/netpacket/packet.h |  63 +++++++++++
 2 files changed, 184 insertions(+)
 create mode 100644 newlib/libc/sys/phoenix/include/net/if_arp.h
 create mode 100644 newlib/libc/sys/phoenix/include/netpacket/packet.h

diff --git a/newlib/libc/sys/phoenix/include/net/if_arp.h b/newlib/libc/sys/phoenix/include/net/if_arp.h
new file mode 100644
index 0000000..bdcacbc
--- /dev/null
+++ b/newlib/libc/sys/phoenix/include/net/if_arp.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)if_arp.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/net/if_arp.h,v 1.16 2001/10/14 20:17:52 fjoe Exp $
+ */
+
+#ifndef _NET_IF_ARP_H_
+#define	_NET_IF_ARP_H_
+
+/*
+ * Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description.  ARP packets are variable
+ * in size; the arphdr structure defines the fixed-length portion.
+ * Protocol type values are the same as those for 10 Mb/s Ethernet.
+ * It is followed by the variable-sized fields ar_sha, arp_spa,
+ * arp_tha and arp_tpa in that order, according to the lengths
+ * specified.  Field names used correspond to RFC 826.
+ */
+struct	arphdr {
+	u_short	ar_hrd;		/* format of hardware address */
+#define ARPHRD_ETHER 	1	/* ethernet hardware format */
+#define ARPHRD_IEEE802	6	/* token-ring hardware format */
+#define ARPHRD_ARCNET	7	/* arcnet hardware format */
+#define ARPHRD_FRELAY 	15	/* frame relay hardware format */
+	u_short	ar_pro;		/* format of protocol address */
+	u_char	ar_hln;		/* length of hardware address */
+	u_char	ar_pln;		/* length of protocol address */
+	u_short	ar_op;		/* one of: */
+#define	ARPOP_REQUEST	1	/* request to resolve address */
+#define	ARPOP_REPLY	2	/* response to previous request */
+#define	ARPOP_REVREQUEST 3	/* request protocol address given hardware */
+#define	ARPOP_REVREPLY	4	/* response giving protocol address */
+#define ARPOP_INVREQUEST 8 	/* request to identify peer */
+#define ARPOP_INVREPLY	9	/* response identifying peer */
+/*
+ * The remaining fields are variable in size,
+ * according to the sizes above.
+ */
+#ifdef COMMENT_ONLY
+	u_char	ar_sha[];	/* sender hardware address */
+	u_char	ar_spa[];	/* sender protocol address */
+	u_char	ar_tha[];	/* target hardware address */
+	u_char	ar_tpa[];	/* target protocol address */
+#endif
+};
+
+#define ar_sha(ap)	(((caddr_t)((ap)+1)) +   0)
+#define ar_spa(ap)	(((caddr_t)((ap)+1)) +   (ap)->ar_hln)
+#define ar_tha(ap)	(((caddr_t)((ap)+1)) +   (ap)->ar_hln + (ap)->ar_pln)
+#define ar_tpa(ap)	(((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln)
+
+#define arphdr_len2(ar_hln, ar_pln)					\
+	(sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln))
+#define arphdr_len(ap)	(arphdr_len2((ap)->ar_hln, (ap)->ar_pln))
+
+/*
+ * ARP ioctl request
+ */
+struct arpreq {
+	struct	sockaddr arp_pa;		/* protocol address */
+	struct	sockaddr arp_ha;		/* hardware address */
+	int	arp_flags;			/* flags */
+};
+/*  arp_flags and at_flags field values */
+#define	ATF_INUSE	0x01	/* entry in use */
+#define ATF_COM		0x02	/* completed entry (enaddr valid) */
+#define	ATF_PERM	0x04	/* permanent entry */
+#define	ATF_PUBL	0x08	/* publish entry (respond for other host) */
+#define	ATF_USETRAILERS	0x10	/* has requested trailers */
+
+#ifdef _KERNEL
+/*
+ * Structure shared between the ethernet driver modules and
+ * the address resolution code.  For example, each ec_softc or il_softc
+ * begins with this structure.
+ */
+struct	arpcom {
+	/*
+	 * The ifnet struct _must_ be at the head of this structure.
+	 */
+	struct 	ifnet ac_if;		/* network-visible interface */
+	u_char	ac_enaddr[6];		/* ethernet hardware address */
+	int	ac_multicnt;		/* length of ac_multiaddrs list */
+	void	*ac_netgraph;		/* ng_ether(4) netgraph node info */
+};
+
+extern u_char	etherbroadcastaddr[6];
+#endif
+
+#endif /* !_NET_IF_ARP_H_ */
diff --git a/newlib/libc/sys/phoenix/include/netpacket/packet.h b/newlib/libc/sys/phoenix/include/netpacket/packet.h
new file mode 100644
index 0000000..28be5ac
--- /dev/null
+++ b/newlib/libc/sys/phoenix/include/netpacket/packet.h
@@ -0,0 +1,63 @@
+/* Copyright (c) 2016 Phoenix Systems
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.*/
+
+#ifndef NETPACKET_PACKET_H
+#define NETPACKET_PACKET_H
+
+struct sockaddr_ll {
+	unsigned short int sll_family;
+	unsigned short int sll_protocol;
+	int sll_ifindex;
+	unsigned short int sll_hatype;
+	unsigned char sll_pkttype;
+	unsigned char sll_halen;
+	unsigned char sll_addr[8];
+  };
+
+#define PACKET_ADD_MEMBERSHIP		1
+#define PACKET_DROP_MEMBERSHIP		2
+#define	PACKET_RECV_OUTPUT			3
+#define	PACKET_RX_RING				5
+#define	PACKET_STATISTICS			6
+
+#define PACKET_HOST					0
+#define PACKET_BROADCAST			1
+#define PACKET_MULTICAST			2
+#define PACKET_OTHERHOST			3
+#define PACKET_OUTGOING				4
+#define PACKET_LOOPBACK				5
+#define PACKET_FASTROUTE			6
+
+struct packet_mreq {
+	int mr_ifindex;
+	unsigned short int mr_type;
+	unsigned short int mr_alen;
+	unsigned char mr_address[8];
+};
+
+#define PACKET_MR_MULTICAST			0
+#define PACKET_MR_PROMISC			1
+#define PACKET_MR_ALLMULTI			2
+
+#endif
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/9] Add dummy implementation of getentropy(), if_nametoindex() and if_indextoname() functions.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (6 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 6/9] Phoenix-RTOS: Implement daemon() function Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-27 11:24 ` [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Corinna Vinschen
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/Makefile.am       |  6 ++++
 newlib/libc/sys/phoenix/Makefile.in       | 41 ++++++++++++++++++-------
 newlib/libc/sys/phoenix/getentropy.c      | 48 +++++++++++++++++++++++++++++
 newlib/libc/sys/phoenix/net/nametoindex.c | 50 +++++++++++++++++++++++++++++++
 4 files changed, 134 insertions(+), 11 deletions(-)
 create mode 100644 newlib/libc/sys/phoenix/getentropy.c
 create mode 100644 newlib/libc/sys/phoenix/net/nametoindex.c

diff --git a/newlib/libc/sys/phoenix/Makefile.am b/newlib/libc/sys/phoenix/Makefile.am
index e57a334..e83be53 100644
--- a/newlib/libc/sys/phoenix/Makefile.am
+++ b/newlib/libc/sys/phoenix/Makefile.am
@@ -31,6 +31,7 @@ SOURCES = \
 	net/inet_ntoa.c \
 	net/inet_ntop.c \
 	net/inet_pton.c \
+	net/nametoindex.c \
 	net/network.c \
 	alarm.c \
 	chmod.c \
@@ -42,6 +43,7 @@ SOURCES = \
 	fcntl.c \
 	fork.c \
 	fs.c \
+	getentropy.c \
 	getmntent.c \
 	getpagesize.c \
 	groups.c \
@@ -130,4 +132,8 @@ install-data-local:
 	$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet6; \
 	for i in $(srcdir)/include/netinet6/*.h; do \
 	  $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet6/`basename $$i`; \
+	done; \
+	$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netpacket; \
+	for i in $(srcdir)/include/netpacket/*.h; do \
+	  $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netpacket/`basename $$i`; \
 	done;
diff --git a/newlib/libc/sys/phoenix/Makefile.in b/newlib/libc/sys/phoenix/Makefile.in
index bcd6388..18e76fa 100644
--- a/newlib/libc/sys/phoenix/Makefile.in
+++ b/newlib/libc/sys/phoenix/Makefile.in
@@ -81,17 +81,18 @@ am__objects_1 = lib_a-domainname.$(OBJEXT) \
 	lib_a-inet_net_pton.$(OBJEXT) lib_a-inet_netof.$(OBJEXT) \
 	lib_a-inet_network.$(OBJEXT) lib_a-inet_ntoa.$(OBJEXT) \
 	lib_a-inet_ntop.$(OBJEXT) lib_a-inet_pton.$(OBJEXT) \
-	lib_a-network.$(OBJEXT) lib_a-alarm.$(OBJEXT) \
-	lib_a-chmod.$(OBJEXT) lib_a-chown.$(OBJEXT) \
-	lib_a-clocks.$(OBJEXT) lib_a-dup.$(OBJEXT) \
-	lib_a-endmntent.$(OBJEXT) lib_a-exec.$(OBJEXT) \
-	lib_a-fcntl.$(OBJEXT) lib_a-fork.$(OBJEXT) lib_a-fs.$(OBJEXT) \
-	lib_a-getmntent.$(OBJEXT) lib_a-getpagesize.$(OBJEXT) \
-	lib_a-groups.$(OBJEXT) lib_a-ids.$(OBJEXT) lib_a-io.$(OBJEXT) \
-	lib_a-ioctl.$(OBJEXT) lib_a-mmap.$(OBJEXT) \
-	lib_a-mount.$(OBJEXT) lib_a-nanosleep.$(OBJEXT) \
-	lib_a-phoenix.$(OBJEXT) lib_a-pid.$(OBJEXT) \
-	lib_a-pipe.$(OBJEXT) lib_a-poll.$(OBJEXT) \
+	lib_a-nametoindex.$(OBJEXT) lib_a-network.$(OBJEXT) \
+	lib_a-alarm.$(OBJEXT) lib_a-chmod.$(OBJEXT) \
+	lib_a-chown.$(OBJEXT) lib_a-clocks.$(OBJEXT) \
+	lib_a-dup.$(OBJEXT) lib_a-endmntent.$(OBJEXT) \
+	lib_a-exec.$(OBJEXT) lib_a-fcntl.$(OBJEXT) \
+	lib_a-fork.$(OBJEXT) lib_a-fs.$(OBJEXT) \
+	lib_a-getentropy.$(OBJEXT) lib_a-getmntent.$(OBJEXT) \
+	lib_a-getpagesize.$(OBJEXT) lib_a-groups.$(OBJEXT) \
+	lib_a-ids.$(OBJEXT) lib_a-io.$(OBJEXT) lib_a-ioctl.$(OBJEXT) \
+	lib_a-mmap.$(OBJEXT) lib_a-mount.$(OBJEXT) \
+	lib_a-nanosleep.$(OBJEXT) lib_a-phoenix.$(OBJEXT) \
+	lib_a-pid.$(OBJEXT) lib_a-pipe.$(OBJEXT) lib_a-poll.$(OBJEXT) \
 	lib_a-realpath.$(OBJEXT) lib_a-reboot.$(OBJEXT) \
 	lib_a-resource.$(OBJEXT) lib_a-sbrk.$(OBJEXT) \
 	lib_a-sched.$(OBJEXT) lib_a-select.$(OBJEXT) \
@@ -266,6 +267,7 @@ SOURCES = \
 	net/inet_ntoa.c \
 	net/inet_ntop.c \
 	net/inet_pton.c \
+	net/nametoindex.c \
 	net/network.c \
 	alarm.c \
 	chmod.c \
@@ -277,6 +279,7 @@ SOURCES = \
 	fcntl.c \
 	fork.c \
 	fs.c \
+	getentropy.c \
 	getmntent.c \
 	getpagesize.c \
 	groups.c \
@@ -506,6 +509,12 @@ lib_a-inet_pton.o: net/inet_pton.c
 lib_a-inet_pton.obj: net/inet_pton.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-inet_pton.obj `if test -f 'net/inet_pton.c'; then $(CYGPATH_W) 'net/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/net/inet_pton.c'; fi`
 
+lib_a-nametoindex.o: net/nametoindex.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nametoindex.o `test -f 'net/nametoindex.c' || echo '$(srcdir)/'`net/nametoindex.c
+
+lib_a-nametoindex.obj: net/nametoindex.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nametoindex.obj `if test -f 'net/nametoindex.c'; then $(CYGPATH_W) 'net/nametoindex.c'; else $(CYGPATH_W) '$(srcdir)/net/nametoindex.c'; fi`
+
 lib_a-network.o: net/network.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-network.o `test -f 'net/network.c' || echo '$(srcdir)/'`net/network.c
 
@@ -572,6 +581,12 @@ lib_a-fs.o: fs.c
 lib_a-fs.obj: fs.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fs.obj `if test -f 'fs.c'; then $(CYGPATH_W) 'fs.c'; else $(CYGPATH_W) '$(srcdir)/fs.c'; fi`
 
+lib_a-getentropy.o: getentropy.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getentropy.o `test -f 'getentropy.c' || echo '$(srcdir)/'`getentropy.c
+
+lib_a-getentropy.obj: getentropy.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getentropy.obj `if test -f 'getentropy.c'; then $(CYGPATH_W) 'getentropy.c'; else $(CYGPATH_W) '$(srcdir)/getentropy.c'; fi`
+
 lib_a-getmntent.o: getmntent.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getmntent.o `test -f 'getmntent.c' || echo '$(srcdir)/'`getmntent.c
 
@@ -1087,6 +1102,10 @@ install-data-local:
 	$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet6; \
 	for i in $(srcdir)/include/netinet6/*.h; do \
 	  $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet6/`basename $$i`; \
+	done; \
+	$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netpacket; \
+	for i in $(srcdir)/include/netpacket/*.h; do \
+	  $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netpacket/`basename $$i`; \
 	done;
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/newlib/libc/sys/phoenix/getentropy.c b/newlib/libc/sys/phoenix/getentropy.c
new file mode 100644
index 0000000..097fb90
--- /dev/null
+++ b/newlib/libc/sys/phoenix/getentropy.c
@@ -0,0 +1,48 @@
+/* Copyright (c) 2016 Phoenix Systems
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.*/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define DEV_RANDOM      "/dev/random"
+#define MAX_ENTROPY     256
+
+int getentropy(void *buf, size_t buflen)
+{
+	if (buflen > MAX_ENTROPY) {
+		errno = -EIO;
+		return -1;
+	}
+
+    int ret = -1;
+	int fd = open(DEV_RANDOM, O_RDONLY);
+	if (fd >= 0) {
+		ret = read(fd, buf, buflen);
+		close(fd);
+	}
+
+    return (ret > 0) ? 0 : -1;
+}
diff --git a/newlib/libc/sys/phoenix/net/nametoindex.c b/newlib/libc/sys/phoenix/net/nametoindex.c
new file mode 100644
index 0000000..b11b10f
--- /dev/null
+++ b/newlib/libc/sys/phoenix/net/nametoindex.c
@@ -0,0 +1,50 @@
+/* Copyright (c) 2016 Phoenix Systems
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.*/
+
+#include "syscall.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+unsigned int if_nametoindex(const char *ifname)
+{
+	if (strcmp(ifname, "eth0") != 0) {
+		errno = EINVAL;
+		return 0;
+	}
+
+	return 1;
+}
+
+char *if_indextoname(unsigned int ifindex, char *ifname)
+{
+	if (ifindex != 1) {
+		errno = ENXIO;
+		return NULL;
+	}
+
+	strcpy(ifname, "eth0");
+	return ifname;
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/9] Phoenix-RTOS: Add checking EOF in getmntent().
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (2 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 3/9] Phoenix-RTOS: Fix warning with pointer treated as integer Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 4/9] Phoenix-RTOS: Provide __progname symbol for user-space apps Jakub Sejdak
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/getmntent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libc/sys/phoenix/getmntent.c b/newlib/libc/sys/phoenix/getmntent.c
index 74d00b1..e61d245 100644
--- a/newlib/libc/sys/phoenix/getmntent.c
+++ b/newlib/libc/sys/phoenix/getmntent.c
@@ -47,7 +47,7 @@ struct mntent *getmntent_r(FILE *fp, struct mntent *result, char *buffer, int bu
 
 	buff_ptr = buffer;
 
-	if (getline(&line, &size, fp) == -1) {
+	if (getline(&line, &size, fp) == -1 || feof(fp)) {
 		free(line);
 		return NULL;
 	}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 8/9] Phoenix-RTOS: Add dummy implementation of fdatasync() syscall.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 2/9] Phoenix-RTOS: Add <netpacket/packet.h> header and import <net/if_arp.h> header from FreeBSD Jakub Sejdak
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/sync.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/newlib/libc/sys/phoenix/sync.c b/newlib/libc/sys/phoenix/sync.c
index de478c9..6f72640 100644
--- a/newlib/libc/sys/phoenix/sync.c
+++ b/newlib/libc/sys/phoenix/sync.c
@@ -43,3 +43,8 @@ int fsync(int fd)
 
 	return ret;
 }
+
+int fdatasync(int fd)
+{
+	return fsync(fd);
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/9] Phoenix-RTOS: Fix warning with pointer treated as integer.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 8/9] Phoenix-RTOS: Add dummy implementation of fdatasync() syscall Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 2/9] Phoenix-RTOS: Add <netpacket/packet.h> header and import <net/if_arp.h> header from FreeBSD Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 5/9] Phoenix-RTOS: Add checking EOF in getmntent() Jakub Sejdak
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/groups.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libc/sys/phoenix/groups.c b/newlib/libc/sys/phoenix/groups.c
index 11cc079..b231475 100644
--- a/newlib/libc/sys/phoenix/groups.c
+++ b/newlib/libc/sys/phoenix/groups.c
@@ -96,5 +96,5 @@ int setpgrp(pid_t pid, pid_t pgid)
 {
 	/* TODO: implement. */
 	errno = ENOSYS;
-	return NULL;
+	return -1;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/9] Phoenix-RTOS: Implement daemon() function.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (5 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 9/9] Phoenix-RTOS: Adjust network-related headers to new kernel API Jakub Sejdak
@ 2016-06-24 12:15 ` Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 7/9] Add dummy implementation of getentropy(), if_nametoindex() and if_indextoname() functions Jakub Sejdak
  2016-06-27 11:24 ` [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Corinna Vinschen
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/fork.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/newlib/libc/sys/phoenix/fork.c b/newlib/libc/sys/phoenix/fork.c
index 696ce08..7e8d591 100644
--- a/newlib/libc/sys/phoenix/fork.c
+++ b/newlib/libc/sys/phoenix/fork.c
@@ -25,7 +25,10 @@
 #include "syscall.h"
 
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 pid_t fork()
 {
@@ -42,3 +45,26 @@ pid_t vfork()
 {
 	return fork();
 }
+
+int daemon(int nochdir, int noclose)
+{
+	switch(fork()) {
+	case -1:
+		return -1;
+	case 0:
+		break;
+	default:
+		exit(0);
+	}
+
+	if (setsid() == -1)
+		return -1;
+
+	if (nochdir == 0)
+		chdir("/");
+
+	if (noclose == 0)
+		freopen("/dev/null", "a+", stdout);
+
+	return 0;
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h>.
@ 2016-06-24 12:15 Jakub Sejdak
  2016-06-24 12:15 ` [PATCH 8/9] Phoenix-RTOS: Add dummy implementation of fdatasync() syscall Jakub Sejdak
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Jakub Sejdak @ 2016-06-24 12:15 UTC (permalink / raw)
  To: newlib; +Cc: Kuba Sejdak

From: Kuba Sejdak <jakub.sejdak@phoesys.com>

---
 newlib/libc/sys/phoenix/sys/unistd.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/newlib/libc/sys/phoenix/sys/unistd.h b/newlib/libc/sys/phoenix/sys/unistd.h
index 6e17144..bdf5bd5 100644
--- a/newlib/libc/sys/phoenix/sys/unistd.h
+++ b/newlib/libc/sys/phoenix/sys/unistd.h
@@ -31,6 +31,7 @@
 #define __need_size_t
 #define __need_ptrdiff_t
 #include <stddef.h>
+#include <sys/select.h>
 
 extern char **environ;
 
@@ -46,6 +47,7 @@ int close(int fd);
 int _close(int fd);
 char *ctermid(char *s);
 char *cuserid(char *string);
+int daemon(int nochdir, int noclose);
 int dup(int oldfd);
 int dup2(int olffd, int newfd);
 int execl(const char *path, const char *arg, ...);
@@ -59,6 +61,7 @@ int execvpe(const char *file, char *const argv[], char *const envp[]);
 int fchdir(int fd);
 int fchmod(int fd, mode_t mode);
 int fchown(int fd, uid_t owner, gid_t group);
+int fdatasync(int fd);
 pid_t fork();
 long fpathconf(int fd, int name);
 int fsync(int fd);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h>.
  2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
                   ` (7 preceding siblings ...)
  2016-06-24 12:15 ` [PATCH 7/9] Add dummy implementation of getentropy(), if_nametoindex() and if_indextoname() functions Jakub Sejdak
@ 2016-06-27 11:24 ` Corinna Vinschen
  8 siblings, 0 replies; 10+ messages in thread
From: Corinna Vinschen @ 2016-06-27 11:24 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

On Jun 24 14:14, Jakub Sejdak wrote:
> From: Kuba Sejdak <jakub.sejdak@phoesys.com>

All patches applied.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-27 11:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 12:15 [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Jakub Sejdak
2016-06-24 12:15 ` [PATCH 8/9] Phoenix-RTOS: Add dummy implementation of fdatasync() syscall Jakub Sejdak
2016-06-24 12:15 ` [PATCH 2/9] Phoenix-RTOS: Add <netpacket/packet.h> header and import <net/if_arp.h> header from FreeBSD Jakub Sejdak
2016-06-24 12:15 ` [PATCH 3/9] Phoenix-RTOS: Fix warning with pointer treated as integer Jakub Sejdak
2016-06-24 12:15 ` [PATCH 5/9] Phoenix-RTOS: Add checking EOF in getmntent() Jakub Sejdak
2016-06-24 12:15 ` [PATCH 4/9] Phoenix-RTOS: Provide __progname symbol for user-space apps Jakub Sejdak
2016-06-24 12:15 ` [PATCH 9/9] Phoenix-RTOS: Adjust network-related headers to new kernel API Jakub Sejdak
2016-06-24 12:15 ` [PATCH 6/9] Phoenix-RTOS: Implement daemon() function Jakub Sejdak
2016-06-24 12:15 ` [PATCH 7/9] Add dummy implementation of getentropy(), if_nametoindex() and if_indextoname() functions Jakub Sejdak
2016-06-27 11:24 ` [PATCH 1/9] Phoenix-RTOS: Provide daemon() and fdatasync() syscalls in <sys/unistd.h> Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).