From 50bfb9acf98d5f4c0c5948cc28285e990b40b659 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 8 Apr 2012 23:10:42 +0200 Subject: Replace fragile manual »make dist« system with one based on »git archive«. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Makeconf (lndist): Remove target. (dist-hook, dist.tar): New targets. * Makefile (dist): Rewrite this target's as well as accompanying rules. (%-lndist, cp-linked-files, $(lf-inst)): Remove targets. (%.bz2, %.gz, %/dist-hook): New targets. (DISTFILES): Set. * doc/Makefile (DISTFILES): Set. * doc/Makefile (lndist, lndist-info-targets): Remove targets. * include/Makefile (lndist): Remove target. * libthreads/Makefile (lndist, lndist-i386-files, lndist-map-file): Remove targets. * pfinet/Makefile (lndist, lndist-linux-src-net-core-files) (lndist-linux-src-net-ethernet-files, lndist-linux-src-net-ipv4-files) (lndist-linux-src-net-ipv6-files, lndist-linux-src-asm-files) (lndist-linux-src-include-linux-files, lndist-linux-src-include-net-files) (lndist-linux-src-include-asm-files, lndist-glue-include-linux-files) (lndist-glue-include-asm-files): Remove targets. * auth/Makefile (LCLHDRS): Don't set. * boot/Makefile (LCLHDRS, DIST_FILES): Likewise. * bsdfsck/Makefile (LCLHDRS): Likewise. * config/Makefile (DIST_FILES): Likewise. * console-client/Makefile (LCLHDRS): Likewise. * console/Makefile (LCLHDRS, DIST_FILES): Likewise. * doc/Makefile (DIST_FILES): Likewise. * exec/Makefile (LCLHDRS, DIST_FILES): Likewise. * ext2fs/Makefile (LCLHDRS): Likewise. * fatfs/Makefile (LCLHDRS): Likewise. * ftpfs/Makefile (LCLHDRS): Likewise. * hostmux/Makefile (LCLHDRS): Likewise. * hurd/Makefile (DIST_FILES): Likewise. * include/Makefile (LCLHDRS): Likewise. * isofs/Makefile (LCLHDRS, DIST_FILES): Likewise. * libcons/Makefile (LCLHDRS): Likewise. * libdirmgt/Makefile (LCLHDRS): Likewise. * libdiskfs/Makefile (LCLHDRS): Likewise. * libfshelp/Makefile (LCLHDRS): Likewise. * libftpconn/Makefile (LCLHDRS): Likewise. * libihash/Makefile (LCLHDRS): Likewise. * libiohelp/Makefile (LCLHDRS): Likewise. * libnetfs/Makefile (LCLHDRS): Likewise. * libpager/Makefile (LCLHDRS): Likewise. * libpipe/Makefile (LCLHDRS): Likewise. * libports/Makefile (LCLHDRS): Likewise. * libps/Makefile (LCLHDRS): Likewise. * libshouldbeinlibc/Makefile (LCLHDRS): Likewise. * libstore/Makefile (LCLHDRS, DIST_FILES): Likewise. * libthreads/Makefile (LCLHDRS): Likewise. * libtreefs/Makefile (LCLHDRS): Likewise. * libtrivfs/Makefile (LCLHDRS): Likewise. * mach-defpager/Makefile (LCLHDRS): Likewise. * nfs/Makefile (LCLHDRS): Likewise. * nfsd/Makefile (LCLHDRS): Likewise. * pfinet/Makefile (LCLHDRS): Likewise. * pflocal/Makefile (LCLHDRS): Likewise. * proc/Makefile (LCLHDRS, DIST_FILES): Likewise. * release/Makefile (DIST_FILES): Likewise. * storeio/Makefile (LCLHDRS): Likewise. * sutils/Makefile (LCLHDRS): Likewise. * term/Makefile (LCLHDRS, DIST_FILES): Likewise. * tmpfs/Makefile (LCLHDRS): Likewise. * ufs-fsck/Makefile (LCLHDRS): Likewise. * ufs/Makefile (LCLHDRS): Likewise. * usermux/Makefile (LCLHDRS): Likewise. * utils/Makefile (LCLHDRS): Likewise. --- libpipe/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libpipe') diff --git a/libpipe/Makefile b/libpipe/Makefile index b64166a6..a7625d6c 100644 --- a/libpipe/Makefile +++ b/libpipe/Makefile @@ -1,6 +1,6 @@ # Makefile for libpipe # -# Copyright (C) 1995, 1996 Free Software Foundation, Inc. +# Copyright (C) 1995, 1996, 2012 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -23,7 +23,6 @@ libname = libpipe installhdrs = pipe.h pq.h SRCS = pq.c dgram.c pipe.c stream.c seqpack.c addr.c pq-funcs.c pipe-funcs.c -LCLHDRS = pipe.h pq.h OBJS = $(SRCS:.c=.o) HURDLIBS=threads ports -- cgit v1.2.3 From 980e2112cf7a987df40b3157a417ad0e3a831476 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 27 Apr 2012 15:32:39 +0200 Subject: Add MSG_PEEK support to pflocal * libpipe/pq.h (packet_peek): Declare new function. * libpipe/pq.c (packet_read): Move code to new `packet_fetch' function, call it with `remove' set to 1. (packet_fetch): New function with code from `packet_read', but do not remove data if `remove' is 0. (packet_peek): New function, calls `packet_fetch' with `remove' set to 0. * libpipe/dgram.c (dgram_read): When MSG_PEEK is in *flags, do not dequeue and only peek data. * libpipe/seqpack.c (seqpack_read): Likewise. * libpipe/stream.c (stream_read): Likewise. * pflocal/socket.c (S_socket_recv): Pass MSG_PEEK flag to libpipe. --- libpipe/dgram.c | 12 ++++++++++-- libpipe/pq.c | 37 ++++++++++++++++++++++++++++++------- libpipe/pq.h | 7 +++++++ libpipe/seqpack.c | 13 +++++++++++-- libpipe/stream.c | 13 +++++++++++-- pflocal/socket.c | 2 +- 6 files changed, 70 insertions(+), 14 deletions(-) (limited to 'libpipe') diff --git a/libpipe/dgram.c b/libpipe/dgram.c index 3f3b2ab6..30695f1e 100644 --- a/libpipe/dgram.c +++ b/libpipe/dgram.c @@ -40,8 +40,16 @@ static error_t dgram_read (struct packet *packet, int *dequeue, unsigned *flags, char **data, size_t *data_len, size_t amount) { - *dequeue = 1; - return packet_read (packet, data, data_len, amount); + if (flags && *flags & MSG_PEEK) + { + *dequeue = 0; + return packet_peek (packet, data, data_len, amount); + } + else + { + *dequeue = 1; + return packet_read (packet, data, data_len, amount); + } } struct pipe_class _dgram_pipe_class = diff --git a/libpipe/pq.c b/libpipe/pq.c index afdda051..102f3ee3 100644 --- a/libpipe/pq.c +++ b/libpipe/pq.c @@ -349,13 +349,13 @@ packet_write (struct packet *packet, return 0; } -/* Removes up to AMOUNT bytes from the beginning of the data in PACKET, and +/* Remove or peek up to AMOUNT bytes from the beginning of the data in PACKET, and puts it into *DATA, and the amount read into DATA_LEN. If more than the original *DATA_LEN bytes are available, new memory is vm_allocated, and the address and length of this array put into DATA and DATA_LEN. */ -error_t -packet_read (struct packet *packet, - char **data, size_t *data_len, size_t amount) +static error_t +packet_fetch (struct packet *packet, + char **data, size_t *data_len, size_t amount, int remove) { char *start = packet->buf_start; char *end = packet->buf_end; @@ -367,7 +367,7 @@ packet_read (struct packet *packet, { char *buf = packet->buf; - if (packet->buf_vm_alloced && amount >= vm_page_size) + if (remove && packet->buf_vm_alloced && amount >= vm_page_size) /* We can return memory from BUF directly without copying. */ { if (buf + vm_page_size <= start) @@ -414,7 +414,7 @@ packet_read (struct packet *packet, bcopy (start, *data, amount); start += amount; - if (start - buf > 2 * PACKET_SIZE_LARGE) + if (remove && start - buf > 2 * PACKET_SIZE_LARGE) /* Get rid of unused space at the beginning of the buffer -- we know it's vm_alloced because of the size, and this will allow the buffer to just slide through memory. Because we wait for @@ -430,10 +430,33 @@ packet_read (struct packet *packet, packet->buf_len -= dealloc; } - packet->buf_start = start; + if (remove) + packet->buf_start = start; } } *data_len = amount; return 0; } + +/* Removes up to AMOUNT bytes from the beginning of the data in PACKET, and + puts it into *DATA, and the amount read into DATA_LEN. If more than the + original *DATA_LEN bytes are available, new memory is vm_allocated, and + the address and length of this array put into DATA and DATA_LEN. */ +error_t +packet_read (struct packet *packet, + char **data, size_t *data_len, size_t amount) +{ + return packet_fetch (packet, data, data_len, amount, 1); +} + +/* Peek up to AMOUNT bytes from the beginning of the data in PACKET, and + puts it into *DATA, and the amount read into DATA_LEN. If more than the + original *DATA_LEN bytes are available, new memory is vm_allocated, and + the address and length of this array put into DATA and DATA_LEN. */ +error_t +packet_peek (struct packet *packet, + char **data, size_t *data_len, size_t amount) +{ + return packet_fetch (packet, data, data_len, amount, 0); +} diff --git a/libpipe/pq.h b/libpipe/pq.h index 0fffe254..4e500b6c 100644 --- a/libpipe/pq.h +++ b/libpipe/pq.h @@ -98,6 +98,13 @@ error_t packet_write (struct packet *packet, error_t packet_read (struct packet *packet, char **data, size_t *data_len, size_t amount); +/* Peek up to AMOUNT bytes from the beginning of the data in PACKET, and + puts it into *DATA, and the amount read into DATA_LEN. If more than the + original *DATA_LEN bytes are available, new memory is vm_allocated, and + the address and length of this array put into DATA and DATA_LEN. */ +error_t packet_peek (struct packet *packet, + char **data, size_t *data_len, size_t amount); + /* Returns any ports in PACKET in PORTS and NUM_PORTS, and removes them from PACKET. */ error_t packet_read_ports (struct packet *packet, diff --git a/libpipe/seqpack.c b/libpipe/seqpack.c index 44a15a03..041abb74 100644 --- a/libpipe/seqpack.c +++ b/libpipe/seqpack.c @@ -43,8 +43,17 @@ static error_t seqpack_read (struct packet *packet, int *dequeue, unsigned *flags, char **data, size_t *data_len, size_t amount) { - error_t err = packet_read (packet, data, data_len, amount); - *dequeue = (packet_readable (packet) == 0); + error_t err; + if (flags && *flags & MSG_PEEK) + { + err = packet_peek (packet, data, data_len, amount); + *dequeue = 0; + } + else + { + err = packet_read (packet, data, data_len, amount); + *dequeue = (packet_readable (packet) == 0); + } return err; } diff --git a/libpipe/stream.c b/libpipe/stream.c index 8eb90435..671907e7 100644 --- a/libpipe/stream.c +++ b/libpipe/stream.c @@ -56,8 +56,17 @@ static error_t stream_read (struct packet *packet, int *dequeue, unsigned *flags, char **data, size_t *data_len, size_t amount) { - error_t err = packet_read (packet, data, data_len, amount); - *dequeue = (packet_readable (packet) == 0); + error_t err; + if (flags && *flags & MSG_PEEK) + { + err = packet_peek (packet, data, data_len, amount); + *dequeue = 0; + } + else + { + err = packet_read (packet, data, data_len, amount); + *dequeue = (packet_readable (packet) == 0); + } return err; } diff --git a/pflocal/socket.c b/pflocal/socket.c index 2684a723..a0e5b1da 100644 --- a/pflocal/socket.c +++ b/pflocal/socket.c @@ -372,7 +372,7 @@ S_socket_recv (struct sock_user *user, return EINVAL; /* XXX */ /* Fill in the pipe FLAGS from any corresponding ones in IN_FLAGS. */ - flags = 0; + flags = in_flags & MSG_PEEK; err = sock_acquire_read_pipe (user->sock, &pipe); if (err == EPIPE) -- cgit v1.2.3